Device Removal

Device removal is tested by selecting the target device and clicking the Test Removal button. This test encompasses IRP_MN_QUERY_REMOVE_DEVICE, IRP_MN_CANCEL_REMOVE_DEVICE, and IRP_MN_REMOVE_DEVICE.

The testsattempts to install its upper-filter driver on the target device stack. This attempt results in a query-remove IRP. -If this query-remove IRP fails, you might need to restart the computer to get the filter driver onto the device stack. If the remove request is not vetoed, the device stack will be removed and restarted with the filter driver on the device stack.

The test, by using setup APIs, causes a query-remove IRP to be sent to the device stack. The filter driver fails this remove request, so a cancel-remove IRP is sent. The filter driver will assert that the cancel-remove was successful.

Next, the test application calls the appropriate class installer and any registered co-installers to disable or enable and remove or reenumerate the device (this tests the class and co-installers handling of DIF_PROPERTYCHANGE with DICS_DISABLE, DICS_ENABLE, and DICS_PROPCHANGE). When receiving IRP_MN_REMOVE_DEVICE, the filter driver will assert that the lower drivers completed it successfully.

The test again calls the class or co-installers (this time with DIF_REMOVE) and then reenumerates the device's parent to attempt to restart the device. This step essentially uninstalls the device as if you had used Device Manager.

Each of these steps involves a preliminary remove request. If that request is vetoed, the device will not be removed. You can choose to veto a remove request when appropriate, such as while streaming video on a USB camera or if the target device is in the boot or paging path. Remember that simply failing all remove requests is generally not good practice. Failing all remove requests will not guarantee that driver will never receive a remove because a remove IRP will still be issued after a surprise removal, or if anyone in the device stack fails a start IRP.

 

 

Send comments about this topic to Microsoft

Build date: 9/28/2012