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



The information in this article applies to:

  • Microsoft Win32 Device Driver Kit (DDK) for Windows NT 4.0
  • Microsoft Win32 Device Driver Kit (DDK) for Windows 2000 1.0

This article was previously published under Q179254

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[ByKey].

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

Sample Code

   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.

Modification Type:MinorLast Reviewed:5/24/2004
Keywords:kbcode kbinfo KB179254