首页
社区
课程
招聘
[求助]请教各位驱动大牛问题一个
发表于: 2012-4-30 11:19 5979

[求助]请教各位驱动大牛问题一个

2012-4-30 11:19
5979
驱动下怎么获取Mutant句柄名?
如图 在XT里面看到的 稍有不解

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

上传的附件:
收藏
免费 1
支持
分享
最新回复 (4)
雪    币: 601
活跃值: (256)
能力值: ( LV11,RANK:190 )
在线值:
发帖
回帖
粉丝
2
ObQueryNameString查不到么
2012-4-30 12:24
0
雪    币: 130
活跃值: (1005)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
何为总是问完问题才想到出呢
为何总是自己想出才有回答呢
NtQueryObject (ObjectNameInformation);
解决了还是谢谢LS
2012-4-30 12:57
0
雪    币: 213
活跃值: (1190)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
4
楼主用的是什么工具啊
2012-4-30 12:59
0
雪    币: 343
活跃值: (40)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
5
贴上一段,仅在XP Professional SP2上测试通过。
typedef struct _OBJECT_DIRECTORY_INFORMATION {
	UNICODE_STRING Name;
	UNICODE_STRING TypeName;
} OBJECT_DIRECTORY_INFORMATION, *POBJECT_DIRECTORY_INFORMATION;

typedef NTSTATUS (*ZwQueryDirectoryObject)(HANDLE DirectoryHandle, PVOID Buffer, ULONG Length, BOOLEAN ReturnSingleEntry, BOOLEAN RestartScan, PULONG Context, PULONG ReturnLength);

VOID PrintBaseNamedObjects()
{
	// 获取ZwQueryDirectoryObject函数地址
	UNICODE_STRING ustrQueryFunc;
	RtlInitUnicodeString(&ustrQueryFunc, L"ZwQueryDirectoryObject");
	ZwQueryDirectoryObject pfnQuery = (ZwQueryDirectoryObject)MmGetSystemRoutineAddress(&ustrQueryFunc);
	if(pfnQuery != NULL)
	{
		// 打开"\BaseNameObjects"对象目录
		UNICODE_STRING ustrBaseNamedObjects;
		RtlInitUnicodeString(&ustrBaseNamedObjects, L"\\BaseNamedObjects");
		OBJECT_ATTRIBUTES oa;
		InitializeObjectAttributes(&oa, &ustrBaseNamedObjects, OBJ_CASE_INSENSITIVE, NULL, NULL);
		HANDLE hDirectory;
		NTSTATUS status = ZwOpenDirectoryObject(&hDirectory, DIRECTORY_QUERY, &oa);
		if(NT_SUCCESS(status))
		{
			POBJECT_DIRECTORY_INFORMATION pBuffer = NULL;
			ULONG ulLength = 0x400;
			ULONG ulContext = 0;	// Search的上下文
			// 循环获取"\BaseNameObjects"对象目录下信息
			do 
			{
				if(pBuffer != NULL)
				{
					ExFreePool(pBuffer);
					pBuffer = NULL;
					ulLength *= 2;	// 成倍增加
				}
				pBuffer = (POBJECT_DIRECTORY_INFORMATION)ExAllocatePool(NonPagedPool, ulLength);
				if(pBuffer != NULL)
				{
					status = pfnQuery(hDirectory, pBuffer, ulLength, FALSE, TRUE, &ulContext, NULL);
				}
				else
				{
					status = STATUS_BUFFER_TOO_SMALL;
				}
			} while (STATUS_MORE_ENTRIES == status || STATUS_BUFFER_TOO_SMALL == status);

			if(NT_SUCCESS(status))
			{
				POBJECT_DIRECTORY_INFORMATION pInfo = pBuffer;
				// 循环处理每个OBJECT_DIRECTORY_INFORMATION
				while(pInfo != NULL && pInfo->Name.Length != 0 && pInfo->TypeName.Length != 0)
				{
					KdPrint(("Name: %ws, TypeName: %ws.\n", pInfo->Name.Buffer, pInfo->TypeName.Buffer));
					++pInfo;
				}
			}

			if(pBuffer != NULL)
			{
				ExFreePool(pBuffer);
				pBuffer = NULL;
			}
			ZwClose(hDirectory);
		}
		else
		{
			KdPrint(("ZwOpenDirectoryObject Failed!\n"));
		}
	}
	else
	{
		KdPrint(("MmGetSystemRoutineAddress Failed!\n"));
	}
}
2012-4-30 13:57
0
游客
登录 | 注册 方可回帖
返回
//