hi-
I have a volume upper filter driver that was working great. it kept
stats about the number of reads/writes sent to the volume(disk), and other
information like the byte offset and the size of the request. I just
took the toaster filter sample (from the XPDDK) and modified it to suit my needs.
Now, I wanted to add a completion routine that could inspect data
after a read request has been completed. The routine is as follows:
NTSTATUS
StatFilterReadCompRoutine(PDEVICE_OBJECT DeviceObject, PIRP pIrp,
PVOID Context) {
PKEVENT event = (PKEVENT)Context;
if(pIrp->PendingReturned) {
IoMarkIrpPending(pIrp);
}
KeSetEvent(event, 0, FALSE);
return STATUS_MORE_PROCESSING_REQUIRED;
}
This routine is set in StatFilterRead(…) like follows:
NTSTATUS
StatFilterRead( IN PDEVICE_OBJECT DeviceObject, IN PIRP pIrp )
{
…
/* set the completion routine */
IoSetCompletionRoutine(pIrp, StatFilterReadCompRoutine,
&(deviceExtension->eventdude), TRUE, TRUE, TRUE);
/* initialize the event */
KeInitializeEvent(&(deviceExtension->event),
NotificationEvent, FALSE);
/* IoCopy because we set the completion routine */
IoCopyCurrentIrpStackLocationToNext(pIrp);
status = IoCallDriver(deviceExtension->NextLowerDriver, pIrp);
KeWaitForSingleObject(&(deviceExtension->eventdude), Executive,
KernelMode, FALSE, NULL);
pIrp->IoStatus.Status = status; // FIXME: is this right?
if( NT_SUCCESS(status) ) {
/* inspect the contents of the read request */
}
IoCompleteRequest(pIrp, IO_NO_INCREMENT);
return status;
}
As you can see, the two functions do anything currently. I just
wanted to get the completion routine stuff to work and get control
back the the read dispatch routine. However, the system hangs during
boot. The only changes to the code are the completion routine stuff.
Nothing in the driver is in paged memory. I have been reading online
and in rajeev’s book about using IopCompleteRequest if the request was
sent in synchronous mode. Is this the problem? There is also mention
in the book that if a paging request is being satisfied then the
driver must not issue any APCs. This is my current guess as to why
the system cannot get past boot. If this is correct, does anyone know
the solution? Sorry for the long email.
Thanks,
-Nick Kidd