Microsoft KB Archive/179254

{|
 * width="100%"|

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

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):

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.

Keywords : _IK

Issue type : kbinfo

Technology : kbAudDeveloper kbWinDDKSearch kbWin32sSearch kbWin32DDKSearch kbWin32DDKNT400 kbWin32DDKNTSearch