Handling a System Set-Power IRP in a Filter Driver

All filter drivers and any function driver that does not own power policy for its device stack should simply pass the system set-power IRP to the next-lower driver, in the following steps:

  1. 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 first call PoStartNextPowerIrp, call IoCompleteRequest to complete the IRP, and then return the failure status.

  2. Call PoStartNextPowerIrp to start the next power IRP. (Windows Server 2003, Windows XP, and Windows 2000 only.)

  3. Set the IRP stack location (IoSkipCurrentIrpStackLocation or IoCopyCurrentIrpStackLocationToNext). The driver can set an IoCompletion routine in the IRP, but doing so is rarely necessary.

  4. 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.

  5. Call IoReleaseRemoveLock. However, if the driver set an IoCompletion routine for the IRP, make this call from the IoCompletion routine instead.

  6. Return STATUS_PENDING from its DispatchPower routine.