Hello everyone!
Well, i have yet another doubt.
I wanted to know if the following sequence (method) to read a file on
receiving Pre-Write is correct.
Assuming that i get ONLY non-cached writes including Paging Writes, and NO
cached writes.
PreWriteCallback()
{
if( request is paging write or TopLevelIrp != NULL ) {
// Since almost all paging requests have TopLevelIrp != NULL
// allocate and queue a generic work item to read the file.
workitem = FltAllocateGenericWorkItem();
context = event;
FltQueueGenericWorkItem( workitem,…,context);
KeWaitForSingleObject( event );
}
else{
Read the file;
}
return PREOP_SUCCESS_WITH_CALLBACK;
}
WorkerThread( context )
{
Read the file;
event = context;
KeSetEvent( event );
FreeGenericWorkItem;
}