Hi All,
I am developing mini-filter driver, which will be used to monitor write for path “\Device\Harddisk0\DR0” (which is MBR location),
Till now every thing is fine and i am able to detect required write call, but before denying, I wanted to verify that current write content with existing disk content, for that i am using FltReadFile with same file object. But i am getting BSOD.
I am currently in preWrite. So what is going wrong in this case???
code -
ntStatus = ObReferenceObjectByPointer(FltObjects->FileObject,GENERIC_READ,*IoFileObjectType,KernelMode);
if (STATUS_SUCCESS == ntStatus)
{
pBuff = FltAllocatePoolAlignedWithTag(FltObjects->Instance,NonPagedPool,1024,‘mbrm’);
if (NULL == pBuff)
__leave;
//
// read MBR from DISK
//
lgOffSet.QuadPart = ulBytesRead = 0;
ntStatus = FltReadFile(
FltObjects->Instance,
FltObjects->FileObject,
&lgOffSet,
sizeof(byBuff),
pBuff,
FLTFL_IO_OPERATION_NON_CACHED |
FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET,
&ulBytesRead,
NULL,
NULL);
if (STATUS_SUCCESS != ntStatus || sizeof(byBuff) != ulBytesRead)
{
FltFreePoolAlignedWithTag(FltObjects->Instance,pBuff,‘mbrm’);
__leave;
}
RtlCopyMemory(byBuff,pBuff,512);
FltFreePoolAlignedWithTag(FltObjects->Instance,pBuff,‘mbrm’);
ObDereferenceObject(FltObjects->FileObject);
}