阅读:1436回复:1
ZwReadFile老是黑屏?
cTempName 中是“\\??\\c:\\abc\\abc.exe”这样的文件名
RtlInitAnsiString( &fileNameAnsiString, cTempName); RtlAnsiStringToUnicodeString( &fileNameUnicodeString, &fileNameAnsiString, TRUE ); InitializeObjectAttributes( &objectAttributes, &fileNameUnicodeString, OBJ_CASE_INSENSITIVE, NULL, NULL ); ntStatus = ZwCreateFile( &hFileHandle, FILE_READ_DATA, &objectAttributes, &Io_StatusBlock, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ, FILE_OPEN, FILE_NON_DIRECTORY_FILE, NULL, 0 ); if( !NT_SUCCESS( ntStatus ) ) { RtlFreeUnicodeString(&fileNameUnicodeString); return FALSE; } ntStatus = ZwQueryInformationFile( hFileHandle, &Io_StatusBlock, &File_Infomation, sizeof(FILE_STANDARD_INFORMATION), FileStandardInformation ); if( !NT_SUCCESS( ntStatus ) ) { ZwClose (hFileHandle); RtlFreeUnicodeString(&fileNameUnicodeString); return FALSE; } llFileSize = File_Infomation.EndOfFile.QuadPart; pBaseAddress = ExAllocatePool(NonPagedPool, (ULONG)llFileSize); if (!pBaseAddress) { ZwClose (hFileHandle); RtlFreeUnicodeString(&fileNameUnicodeString); return FALSE; } liByteOffSet.QuadPart =0; ntStatus = ZwReadFile( hFileHandle, NULL, NULL, NULL, &Io_StatusBlock, pBaseAddress, (ULONG)llFileSize, &liByteOffSet, NULL ); if( !NT_SUCCESS( ntStatus ) ) { ExFreePool(pBaseAddress); ZwClose (hFileHandle); RtlFreeUnicodeString(&fileNameUnicodeString); return FALSE; } ExFreePool(pBaseAddress); ZwClose (hFileHandle); RtlFreeUnicodeString(&fileNameUnicodeString); ZwCreateFile和ZwQueryInformationFile都执行正确,ZwReadFile执行时肯定会黑屏,但是黑屏的时机不定。如何解决呢? |
|
沙发#
发布于:2008-12-04 16:03
我也碰到这问题,呵呵
|
|
|