13.2 IoCompletion Routine Required Functionality

On entry, an IoCompletion routine is called with DeviceObject, Irp, and Context pointers, as shown by the declaration. The Dispatch routine that called IoSetCompletionRoutine can pass a Context pointer to whatever driver-determined context it set up for the IoCompletion routine to use in processing the given IRP. Note that such a context area cannot be pageable because the IoCompletion routine can be called at IRQL DISPATCH_LEVEL.

When it is called, an IoCompletion routine is responsible for doing whatever additional IRP processing the driver writer chooses and any necessary cleanup operations for the request, as determined by how the Dispatch routine set up the request.

    Consider the following implementation guidelines for IoCompletion routines 

If any still-higher-level driver has set its IoCompletion routine in the original IRP, that driver’s IoCompletion routine is not called until all lower-level drivers have called IoCompleteRequest with the original IRP.