Hi, all.
I think that, unusually, replies aren't written to my articles. ![]()
The reason might be lack of my ability to express in english.
Thus, I attached my source.... I cannot solve this problem by myself.
Any advices, even though a little thing, would be helpful.
This is Pre Callback of IRP_MJ_SET_INFORMATION.
The Purpose is that adding footer at the end of a file.
(I did shorten code for reading at ease)
FLT_PREOP_CALLBACK_STATUS
MiniFilterPreSetInformation(
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__deref_out_opt PVOID *CompletionContext
)
{
/*
pass over definitions of variables
*/
/*
Stream Context & Process Check
*/
try{
if ( iopb->Parameters.SetFileInfrmation.FileInformationClass == FileEndOfFileInformation ){
EndofFileInfo = (PFILE_END_OF_FILE_INFORMATION)iopb->Parameters.SetFileInformation.InfoBuffer;
if ( EndofFileInfo == NULL ){
leave;
}
nFileSizeWithoutHeader = EndofFileInfo->EndOfFile.LowPart;
FltSetCallbackDataDirty( Data );
ByteOffset.HighPart = 0;
ByteOffset.LowPart = nFileSizeWithoutHeader - 4096;
if ( ByteOffset.LowPart > 0 )
{
//
// I did only Read.
//
HeaderBuffer = FltAllocatePoolAlignedWithTag( FltObjects->Instance, NonPagedPool, 4096, MARKANY_HEADER_TAG );
RtlZeroMemory( HeaderBuffer, 4096 );
//
// After this FltReadFile Operation, the Minifilter wait permanently.
// OS is normal, but minifilter does not work, even not be unloaded.
//
status = FltReadFile( FltObjects->Instance,
FltObjects->FileObject,
&ByteOffset,
VolumeContext->SectorSize,
HeaderBuffer,
FLTFL_IO_OPERATION_DO_NOT_UPDATE_BYTE_OFFSET | FLTFL_IO_OPERATION_NON_CACHED,
&BytesRead,
NULL,
NULL);
//Never reach this step when debugging
if ( !NT_SUCCESS(status) ){
DbgPrint( "[MADSMF] |SetInformation | Fail to FltReadFile\n" );
leave;
}
ExFreePool(HeaderBuffer);
}
}
}
finally
{
}
return RetStatus;
}
Eventually, FltReadFile Function hangs, because of deadlock or other cause.
Can you find any inappropriate code??