I/O Manager Routines


Windows Driver Kit: Kernel-Mode Driver Architecture
IoMarkIrpPending

The IoMarkIrpPending routine marks the specified IRP, indicating that a driver's dispatch routine subsequently returned STATUS_PENDING because further processing is required by other driver routines.

VOID 
  IoMarkIrpPending(
    IN OUT PIRP  Irp
    );

Parameters

Irp
Pointer to the IRP to be marked as pending.

Return Value

None

Comments

Unless an IRP's dispatch routine completes the IRP (by calling IoCompleteRequest) or passes the IRP on to lower drivers, it must call IoMarkIrpPending with the IRP. Otherwise, the I/O manager attempts to complete the IRP as soon as the dispatch routine returns control.

After calling IoMarkIrpPending, the dispatch routine must return STATUS_PENDING, even if some routine completes the IRP (by calling IoCompleteRequest) before the dispatch routine that called IoMarkIrpPending returns.

If a driver queues incoming IRPs, it should call IoMarkIrpPending before it queues each IRP. Otherwise, an IRP could be dequeued, completed by another driver routine, and freed by the system before the call to IoMarkIrpPending occurs, thereby causing a crash.

If a driver sets an IoCompletion routine for an IRP and then passes the IRP down to a lower driver, the IoCompletion routine should check the IRP->PendingReturned flag. If the flag is set, the IoCompletion routine must call IoMarkIrpPending with the IRP. (IoCompletion routines do not return STATUS_PENDING, however. For more information, see Implementing an IoCompletion Routine.)

Warning  Drivers that create the IRP and send it to another stack must not call IoMarkIrpPending in their completion routine. This call will corrupt the pool header of the next allocation because there is no stack location for those drivers.

A driver that passes down the IRP and then waits on an event should not mark the IRP pending. Instead, its IoCompletion routine should signal the event and return STATUS_MORE_PROCESSING_REQUIRED.

Requirements

IRQL: Any level

Headers: Declared in Wdm.h. Include Wdm.h, Ntddk.h, or Ntifs.h.

See Also

IoCompleteRequest, IoStartPacket, IRP


Send feedback on this topic
Built on November 19, 2009
Page view tracker