INFO: Why Is My deviceObject->currentIrp == NULL in My ISR?

Last reviewed: January 15, 1998
Article ID: Q179254
The information in this article applies to:
  • Microsoft Win32 Device Driver Kit (DDK) for Windows NT, version 4.0

SUMMARY

This article explains why it is possible for deviceObject->currentIrp == NULL in an ISR.

MORE INFORMATION

The only routines in the system that change deviceObject->currentIrp are IoStartPacket and IoStartNextPacket.

Following code demonstrates approximately what these routines do (ignoring details of cancels, spinlocks, the Key argument, and so on):

   IoStartPacket(dvcObj, Irp)
   {
      if (dvcObj->DeviceQueue.Busy) {
         insert IRP on device queue
      } else {
         dvcObj->DeviceQueue.Busy = TRUE;
         dvcObj->CurrentIrp = Irp;
         call StartIo routine (dvcObj, newIrp);
      }
   }

   IoStartNextPacket(dvcObj)
   {
      dvcObj->CurrentIrp = NULL;
      remove IRP from head of queue, store addr in newIrp
      if (queue was empty) {
         dvcObj->DeviceQueue.Busy = FALSE;
      } else {
         dvcObj->CurrentIrp = newIrp;
         call StartIo routine (dvcObj, newIrp);
      }
   }

If you don't use IoStart[Next]Packet, this field will always be NULL unless you change it yourself. There is probably no real reason to change it because if you aren't using IoStart[Next]Packet, it's probably because you support more than one "current" IRP. Therefore, having a single pointer to "the current IRP" is unnecessary.

If you are using IoStart[Next]Packet and you find that this field is NULL in your ISR, it means that you have already called IoStartNextPacket before the ISR was invoked and IoStartNextPacket did not find any more IRPs on the DeviceQueue. Along with clearing the DeviceQueue->Busy bit, IoStartNextPacket NULLs the CurrentIrp pointer when the device queue is empty.

These are the only two things in the system that manipulate the dvcObj- >DeviceQueue.Busy or dvcObj->CurrentIrp.

Keywords          : NTDDKKMode kbcode
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: January 15, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.