Bewerken

Delen via


IRP_MN_REMOVE_DEVICE

All PnP drivers must handle this IRP.

Value

0x02

Major Code

IRP_MJ_PNP

When Sent

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 driver(s).

On Windows 2000 and later systems, the PnP manager also sends this IRP if one of the drivers in the device stack fails an IRP_MN_START_DEVICE request for the device.

For an orderly device removal, the PnP manager sends an IRP_MN_QUERY_REMOVE_DEVICE prior to the remove IRP. In this case, the device is in the remove-pending state when the remove IRP arrives. For a surprise device removal on Microsoft Windows 2000 or later, the PnP manager sends an IRP_MN_SURPRISE_REMOVAL prior to the remove IRP. In this case, the device is in the surprise-removed state when the remove IRP arrives. Drivers can also receive a remove IRP before a device is started. In this case, the device is in the non-started state when the IRP arrives.

The PnP manager sends this IRP at IRQL PASSIVE_LEVEL in the context of a system thread.

Input Parameters

None

Output Parameters

None

I/O Status Block

A driver must set Irp->IoStatus.Status to STATUS_SUCCESS. Drivers must not fail this IRP.

Operation

This IRP is handled first by the driver at the top of the device stack and then by each lower driver in the stack.

In response to this IRP, drivers perform such tasks as powering down the device, removing the device's software representation (device objects, and so forth), and releasing any resources for the device.

For more information about handling this IRP, see Handling an IRP_MN_REMOVE_DEVICE Request. For general information about supporting device removal, see Removing a Device.

Sending This IRP

Reserved for system use. Drivers must not send this IRP.

If a bus driver detects that one (or more) of its child devices (child PDOs) has been physically removed from the computer, the bus driver calls IoInvalidateDeviceRelations to report the change to the PnP manager. The PnP manager then sends remove IRPs for any devices that have disappeared.

Requirements

Header

Wdm.h (include Wdm.h, Ntddk.h, or Ntifs.h)

See also

IoInvalidateDeviceRelations

IoRegisterPlugPlayNotification

IRP_MN_CANCEL_REMOVE_DEVICE

IRP_MN_QUERY_REMOVE_DEVICE

IRP_MN_SURPRISE_REMOVAL