Article ID: 298504 - View products that this article applies to.
This article was previously published under Q298504
This article describes how a function or a filter driver for a device can report if the device can tolerate surprise removal. Even if the bus driver indicates that the device can tolerate surprise removal, NDIS always clears the SurpriseRemoval field.
In Microsoft Windows 2000, you can avoid the Unsafe Removal dialog box. To do this, stop the device by selecting clicking Unplug/Eject icon in the task bar notification area. Then, unplug the hardware. However, if you have a device that can be surprise-removed, this process is unnecessary. Instead, drivers for hot plug-in/unplug devices that do not maintain a persistent state should inform the operating systems that they can tolerate a surprise removal by setting the SurpriseRemovalOK field in the DeviceCapabilities structure to TRUE in response to the IRP_MN_QUERY_CAPABILITIES Plug and Play IRP.
According to the Plug and Play rule, drivers should set the SurpriseRemovalOK field in the IRP_MN_QUERY_CAPABILITIES IRP before the drivers pass the IRP to the lower drivers in the device stack. Because the Windows 2000 USB hub driver incorrectly resets this field to FALSE, Windows 2000 drivers for USB devices must set the SurpriseRemovalOK field on the way up. This behavior is demonstrated in the following code example. This code example is adapted for the toaster function driver sample in the DDK (Src\General\Toaster\Func\Toaster.c).
Additionally, some devices that do not use persistent storage are not as safe to surprise remove. For example, you may surprise remove a PCMCIA card. Sometimes, hardware limitations may cause this removal to cause the PCI bus to fail. Therefore, the PCMCIA bus driver sets the SurpiseRemovalOK field to FALSE for all PCMCIA cards.
NDIS miniport drivers cannot avoid the surprise removal dialog box by using the code example in this section because the following conditions are true:
Article ID: 298504 - Last Review: August 22, 2005 - Revision: 4.1