Microsoft KB Archive/180589

{|
 * width="100%"|

INFO: IoMarkIrpPending(Irp) vs. IoStatus.Status=STATUS_PENDING

 * }

Q180589

-

The information in this article applies to:


 * Microsoft Win32 Device Driver Kit (DDK) for Windows NT, version 4.0

-

SUMMARY
This article explains the difference between IoMarkIrpPending(Irp), IoStatus.Status=STATUS_PENDING, and return STATUS_PENDING.

MORE INFORMATION
To see exactly what IoMarkIrpPending does, look at the following definition in NTDDK.H:

  // VOID // IoMarkIrpPending(  //     IN OUT PIRP Irp   //     ) //   // Routine Description: //   // This routine marks the specified I/O Request Packet (IRP) to indicate // that an initial status of STATUS_PENDING was returned to the caller. // This is used so that I/O completion can determine whether or not to  // fully complete the I/O operation requested by the packet. //   // Arguments: //   //     Irp - Pointer to the I/O Request Packet to be marked pending. //   // Return Value: //   //     None. //   //--

#define IoMarkIrpPending( Irp ) ( \       IoGetCurrentIrpStackLocation( (Irp) )->Control |=       SL_PENDING_RETURNED )

There is never any reason to store STATUS_PENDING in Irp->IoStatus.Status because Irp->IoStatus.Status is filled in with the "final" status of the IRP just before calling IoCompleteRequest. None of the code paths look at Irp->IoStatus.Status until IoCompleteRequest is called. Therefore, there is no reason to set Irp->IoStatus.Status to any value before IoCompleteRequest is called. Conversely, STATUS_PENDING is never an appropriate value for Irp- >IoStatus.Status when IoCompleteRequest is called.

STATUS_PENDING is the proper return value from any dispatch routine that has not called IoCompleteRequest on the IRP or not passed the IRP to a lower-layer driver. This type of routine must also call IoMarkIrpPending for the IRP.

Keywords :

Issue type : kbinfo

Technology : kbAudDeveloper kbWinDDKSearch kbWin32sSearch kbWin32DDKSearch kbWin32DDKNT400 kbWin32DDKNTSearch