Handling a System Query-Power IRP in a Filter or Function Driver
A filter or function driver (that is not the power policy owner for a device) should pass a system query-power IRP to the next-lower driver, in the following steps:
Call IoAcquireRemoveLock, passing the current IRP, to ensure that the driver does not receive a PnP IRP_MN_REMOVE_DEVICE request while handling the power IRP.
If IoAcquireRemoveLock returns a failure status, the driver should not continue processing the IRP. Instead, beginning with Windows Vista, the driver should call IoCompleteRequest to complete the IRP and return the failure status. In Windows Server 2003, Windows XP, and Windows 2000, the driver should call PoStartNextPowerIrp, call IoCompleteRequest to complete the IRP, and return the failure status.
Determine whether it should fail the query. For guidelines, see Failing a System Query-Power IRP in a Filter or Function Driver and complete processing as described in that section.
Call PoStartNextPowerIrp. (Windows Server 2003, Windows XP, and Windows 2000 only)
Set the IRP stack location (IoSkipCurrentIrpStackLocation or IoCopyCurrentIrpStackLocationToNext). The driver can set an IoCompletion routine in the IRP, but doing so is rarely necessary.
Call IoCallDriver (in Windows 7 and Windows Vista) or PoCallDriver (in Windows Server 2003, Windows XP, and Windows 2000) to pass the IRP to the next-lower driver.
Call IoReleaseRemoveLock. However, if the driver set an IoCompletion routine for the IRP, make this call from the IoCompletion routine instead.
Return STATUS_PENDING from its DispatchPower routine.