Reusing IRPs

Under certain circumstances, drivers can reuse IRPs. The driver can allocate a pool of memory buffers that it uses to hold IRPs as they need to be created.

Drivers must not attempt to reuse IRPs issued by the I/O manager. In particular, drivers should not attempt to reuse IRPs created by the IoMakeAssociatedIrp, IoBuildSynchronousFsdRequest, IoBuildAsynchronousFsdRequest, or IoBuildDeviceIoControlRequest routines.

Drivers can safely reuse IRPs that they have created, as follows:

  1. If a driver allocates an IRP as raw memory (for example, by calling ExAllocatePoolWithTag), and then initializes it with IoInitializeIrp, then it can safely call IoInitializeIrp or IoReuseIrp to reinitialize the memory buffer.

  2. On Microsoft Windows 2000 and later operating systems, drivers that create an IRP with IoAllocateIrp can reuse the IRP by calling IoReuseIrp.

  3. If a driver allocates an IRP by calling IoAllocateIrp with the ChargeQuota parameter set to FALSE, then it can safely use IoInitializeIrp to reinitialize the IRP. Drivers that must work on Windows 98/Me can use this method as a work-around. Drivers designed strictly for Windows 2000 and later operating systems should use the previous method.