The PnP Manager uses this IRP to direct drivers to remove a device's software representation (device objects, and so forth). The PnP Manager sends this IRP when a device has been removed in an orderly fashion (for example, initiated by a user in the Unplug or Eject Hardware program), by surprise (a user pulls the device from its slot without prior warning), or when the user requests to update drivers.
On Windows 2000 and later systems, the PnP Manager sends this IRP when the Device Manager disables the device. On Windows 98/Me, the Pnp Manager sends stop IRPs instead. See Stopping a Device for details.
The PnP Manager does the following before sending this IRP to the drivers for a device:
The top driver in a device stack handles a remove IRP and passes it to the next lower driver. The parent bus driver for a device is the last driver to perform its remove-device operations. A driver handles remove IRPs in its DispatchPnP routine.
Before a driver returns success for an IRP_MN_REMOVE_DEVICE request, it must ensure that all resources for the device have been released. This IRP could be the last call before the driver is unloaded.
Removing one device can create the need to remove a series of other devices. The PnP Manager coordinates the removal of the additional device objects from the top level down to the root-device level.
This section describes:
Removing a Device in a Function Driver