Stopping a Device to Disable It (Windows 98/Me)
On Windows 98/Me, the PnP manager issues stop IRPs when Device Manager disables the device. (Windows 2000 and later versions of Windows issue remove IRPs in this situation).
The PnP manager sends the stop IRPs in the following sequence:
The PnP manager issues an IRP_MN_QUERY_STOP_DEVICE to ask whether the drivers for a device can stop the device.
If all the drivers in the device stack return STATUS_SUCCESS, the drivers have put the device into a state (stop-pending) from which the device can be quickly stopped.
The PnP manager queries as many device stacks as necessary to disable the device.
If the IRP_MN_QUERY_STOP_DEVICE succeeds, the PnP manager issues an IRP_MN_STOP_DEVICE to stop the device.
The PnP manager sends the stop IRP only if the previous query-stop IRP for the device completed successfully. In response to the stop IRP, drivers release the device's hardware resources (such as its I/O ports) and fail any IRPs that require access to the device.
If the IRP_MN_QUERY_STOP_DEVICE fails, the PnP manager sends an IRP_MN_CANCEL_STOP_DEVICE to cancel the query.
In response to an IRP_MN_CANCEL_STOP_DEVICE, the drivers for a device return the device to the started state and resume processing I/O requests for the device.
The PnP manager cancels the query-stop for a device stack if one driver in the stack failed the request. When the PnP manager cancels the query-stop on just one device stack, it sends the IRP_MN_CANCEL_STOP_DEVICE request because any drivers attached above the driver that failed the query have the device in the stop-pending state. When the IRP_MN_CANCEL_STOP_DEVICE succeeds, drivers have returned the device to the started state.
When a device is being disabled, its drivers cannot queue incoming IRPs because there is no guarantee when the device might be reenabled. Consequently, data might be lost.
Build date: 11/16/2013