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

Last reviewed: February 6, 1998
Article ID: 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          : NTDDKKMode
Version           : WINNT:4.0
Platform          : winnt
Issue type        : kbinfo


================================================================================


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.