能力值:
( LV3,RANK:20 )
|
-
-
2 楼
貌似是用线程,设置超时时间
|
能力值:
( LV2,RANK:10 )
|
-
-
3 楼
调试的时候,始终是枚举某个句柄的时候不通过
如果用线程,还是没办法完成枚举操作
PS:在线程里面调用ZwQueryObject的时候,返回STATU_ACCESS_VIOLATION错误
|
能力值:
( LV3,RANK:20 )
|
-
-
4 楼
下面这段代码是“如何操作被占用文件三法”这篇文章中的,好好看看吧
DWORD WINAPI GetFileNameThread(PVOID lpParameter)
{
PNM_INFO NmInfo = lpParameter;
IO_STATUS_BLOCK IoStatus;
int r;
NtQueryInformationFile(NmInfo->hFile, &IoStatus, &NmInfo->Info,
sizeof(NM_INFO) - sizeof(HANDLE), FileNameInformation);
return 0;
}
void GetFileName(HANDLE hFile, PCHAR TheName)
{
HANDLE hThread;
PNM_INFO Info = HeapAlloc(hHeap, 0, sizeof(NM_INFO));
Info->hFile = hFile;
hThread = CreateThread(NULL, 0, GetFileNameThread, Info, 0, NULL);
if (WaitForSingleObject(hThread, INFINITE) == WAIT_TIMEOUT) TerminateThread(hThread, 0);
CloseHandle(hThread);
memset(TheName, 0, MAX_PATH);
WideCharToMultiByte(CP_ACP, 0, Info->Info.FileName, Info->Info.FileNameLength >> 1, TheName, MAX_PATH, NULL, NULL);
HeapFree(hHeap, 0, Info);
}
|