smmary of Guidelines for Pending IRPs
Driver writers must follow certain guidelines when handling IRPs for which STATUS_PENDING can be returned. Ignoring these guidelines may cause post-processing to occur twice, resulting in a system crash, or prevent post-processing from occurring, resulting in a system hang.
The following are the fundamental guidelines for returning STATUS_PENDING:
· If a driver returns STATUS_PENDING, it must first call the IoMarkIrpPending macro to mark the I/O stack location as pending.
· Conversely, if a driver calls IoMarkIrpPending, it must return STATUS_PENDING.
In addition:
· If a driver returns the same status as the next lower driver and sets an IoCompletion routine, the IoCompletion routine must call IoMarkIrpPending if the value of the Irp->PendingReturned field is TRUE.
If a driver completes an I/O request on a different thread from that on which it received the request, its dispatch routine or IoCompletion routine must call IoMarkIrpPending and its dispatch routine must return STATUS_PENDING.