Redigera

Dela via


Handling an IRP_MN_CANCEL_STOP_DEVICE Request (Windows 2000 and later)

An IRP_MN_CANCEL_STOP_DEVICE request must be handled first by the parent bus driver for a device and then by each next higher driver in the device stack. A driver handles stop IRPs in its DispatchPnP routine.

In response to an IRP_MN_CANCEL_STOP_DEVICE request, a driver must return the device to its started state and resume normal operation. Drivers must succeed a cancel-stop IRP.

A driver handles an IRP_MN_CANCEL_STOP_DEVICE request with a procedure such as the following:

  1. Postpone restarting the device until lower drivers have completed their restart operations. (See Postponing PnP IRP Processing Until Lower Drivers Finish.)

  2. After lower drivers finish, return the device to its started state.

    Exact operations depend on the device and the driver.

  3. Start IRPs in the IRP-holding queue.

    If the driver was holding requests while the device was in the stop-pending state, clear the HOLD_NEW_REQUESTS flag and start the IRPs in the IRP-holding queue. See Holding Incoming IRPs When A Device Is Paused for more information.

  4. Complete the IRP with IoCompleteRequest.

    • In a function or filter driver:

      The driver's IoCompletion routine returned STATUS_MORE_PROCESSING_REQUIRED, as described in Postponing PnP IRP Processing Until Lower Drivers Finish, so the driver's DispatchPnP routine must call IoCompleteRequest to resume I/O completion processing.

      The driver sets Irp->IoStatus.Status to STATUS_SUCCESS, calls IoCompleteRequest with a priority boost of IO_NO_INCREMENT, and returns STATUS_SUCCESS from its DispatchPnP routine.

      Drivers must not fail this operation. If a driver fails the restart IRP, the device is in an inconsistent state and will not operate properly.

    • In a parent bus driver:

      The driver sets Irp->IoStatus.Status to STATUS_SUCCESS and calls IoCompleteRequest specifying a priority boost of IO_NO_INCREMENT. The bus driver returns STATUS_SUCCESS from its DispatchPnP routine.

      A bus driver must not fail this operation. If a driver fails the restart IRP, the device is in an inconsistent state and will not operate properly.

A driver might receive a spurious cancel-stop request when the device is started and active. This can occur, for example, if the driver (or a driver higher in the device stack) failed an IRP_MN_QUERY_STOP_DEVICE request. When a device is started and active, drivers can safely succeed spurious cancel-stop requests for the device.