阅读:1073回复:4
a BSOD of KERNEL_STACK_INPAGE_ERROR?
Hi all,
I have a BSOD problem of KERNEL_STACK_INPAGE_ERROR, which may be trigered by the following codes: NTSTATUS NTAPI HookCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PLARGE_INTEGER MaximumSize, IN ULONG SectionPageProtection, IN ULONG AllocationAttributes, IN HANDLE FileHandle) { ...... ntstatus = ObReferenceObjectByHandle(FileHandle, SYNCHRONIZE|FILE_READ_DATA, 0, KernelMode, &pFileObject, NULL); if(!NT_SUCCESS(ntstatus)) { goto HOOKEND; } ntStatus = ObOpenObjectByPointer(pFileObject, OBJ_KERNEL_HANDLE, NULL, SYNCHRONIZE|FILE_READ_DATA, *IoFileObjectType, KernelMode, &hFileHandle); if(!NT_SUCCESS(ntStatus)) { goto HOOKEND; } ntStatus = ZwQueryInformationFile(hFileHandle, &IoStatus, &StandardFileInfo, sizeof(FILE_STANDARD_INFORMATION), FileStandardInformation); if(ntStatus != STATUS_SUCCESS) { ZwClose(hFileHandle); goto HOOKEND; } nFileLen=StandardFileInfo.EndOfFile.LowPart; if ((nFileLen==0)||(nFileLen==0xFFFFFFFF)) { ZwClose(hFileHandle); goto HOOKEND; } if(nFileLen <= ReadFileLen) { pbData=(PCHAR)ExAllocatePool(NonPagedPool, nFileLen+1); ntemLen=nFileLen+1; } else { pbData=(PCHAR)ExAllocatePool(NonPagedPool, ReadFileLen+1); ntemLen=ReadFileLen+1; } if (pbData==NULL) { //zz KdPrint(("ProcessCheckSum: ExAllocatePool failed!\n")); ZwClose(hFileHandle); goto HOOKEND; } RtlZeroMemory(pbData,ntemLen); if(nFileLen <= ReadFileLen) { ntStatus=ZwReadFile(hFileHandle, NULL, NULL, NULL, &IoStatus, (PVOID)pbData, nFileLen, NULL, NULL); if(ntStatus != STATUS_SUCCESS) { //zz KdPrint(("ProcessCheckSum: ZwReadFile %s Failed\n", pFile)); ZwClose(hFileHandle); ExFreePool(pbData); return FALSE; } // calculate the crc valure CheckSum(CheckSumImage,pbData,nFileLen); } else { for(i = 0;i<nFileLen/ReadFileLen;i++) { ntStatus=ZwReadFile(hFileHandle, NULL, NULL, NULL, &IoStatus, (PVOID)pbData, ReadFileLen, NULL, NULL); if(ntStatus != STATUS_SUCCESS) { //zz KdPrint(("ProcessCheckSum: ZwReadFile %s Failed\n", pFile)); ZwClose(hFileHandle); ExFreePool(pbData); return FALSE; } CheckSum(CheckSumImage,pbData,ReadFileLen); RtlZeroMemory(pbData,ReadFileLen); } ntStatus=ZwReadFile(hFileHandle, NULL, NULL, NULL, &IoStatus, (PVOID)pbData, nFileLen-ReadFileLen*(nFileLen/ReadFileLen), NULL, NULL); if(ntStatus != STATUS_SUCCESS) { //zz KdPrint(("ProcessCheckSum: ZwReadFile %s Failed\n", pFile)); ZwClose(hFileHandle); ExFreePool(pbData); goto HOOKEND; } CheckSum(CheckSumImage,pbData,nFileLen-ReadFileLen*(nFileLen/ReadFileLen)); } ZwClose(hFileHandle); ExFreePool(pbData); ...... } Can anyone tell me where i am wrong, thank you! |
|
最新喜欢:naijie... |
沙发#
发布于:2007-01-18 23:12
Seems the discussion on OSR's mailing list is not enough to let you drop this hook. :)
How about the solution provided in Daniel's reply? |
|
板凳#
发布于:2007-01-19 00:22
考虑把FileObject放IoWorkQueue处理,唉~
|
|
|
地板#
发布于:2007-01-22 10:13
请问为什么要放到Ioworkqueue里面进行处理,出于什么样的考虑?
|
|
地下室#
发布于:2007-01-22 11:49
>>Seems the discussion on OSR's mailing list is not enough to let you drop this hook. :)
>>How about the solution provided in Daniel's reply? I have not found a perfect way to terminate the process, hehe, so i insist on my way temporarily. |
|