Hello!
I’m developing a filter wich must in it’s IRP_MJ_CREATE handler to do some
postprocessing.
My code looks like that:
a) In the main hook routine:
case IRP_MJ_CREATE:
IoSetCompletionRoutine( Irp, CreateDone, (PVOID)Context, TRUE, TRUE,
TRUE );
b) In the completion routine:
NTSTATUS CreateDone ( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID
Context )
{
CREATE_REQUEST * CreateRequest = ( CREATE_REQUEST *) ExAllocatePool (
NonPagedPool, sizeof ( CREATE_REQUEST ));
CreateRequest -> Irp = Irp;
…
if( Irp -> PendingReturned )
IoMarkIrpPending ( Irp );
ExInitializeWorkItem ( &CreateRequest -> WorkItem, CreateDoneWork,
CreateRequest );
ExQueueWorkItem ( &pCreateRequest -> WorkItem, CriticalWorkQueue );
…
return STATUS_MORE_PROCESSING_REQUERED;
}
c) Work item routine:
VOID CreateDoneWork ( PVOID Request )
{
CREATE_REQUEST * CreateRequest = ( CREATE_REQUEST * ) Request;
… do some job …
IoCompleteRequest ( CreateRequest -> Irp, IO_NO_INCREMENT );
ExFreePool ( Request);
}
Above code does not work - it genereates page fault somewhere later.
What have I done wrong?