PnP Notification Overview
The PnP manager provides a mechanism for drivers and applications to be notified when certain events occur on a specific device or on the system in general. A driver can register for notification of the following categories of events:
When a driver registers for this category of events on a device interface, the PnP manager notifies the driver of the following events:
Indicates that a device interface of the specified class has been enabled. For example, a user added a new disk to the machine and the volume manager enabled a new volume (a device interface of the class "volume").
Indicates that a device interface of the specified class has been disabled.
See IoRegisterDeviceInterface and related routines for more information about device interfaces.
When a driver registers for this category of events on a device, the PnP manager notifies the driver when the following events occur on the device:
Indicates that the PnP manager is about to remove the drivers for the device. Several actions can cause this event, including: a user has requested to remove the specified device from the machine or a user has issued an update-driver request for the device. This notification requests the drivers for the device to either approve or veto the impending remove operation.
Indicates that the specified device has been removed from the machine or that a user is changing the driver(s) for the device.
Indicates that an impending remove operation on the specified device has been canceled.
- GUID_XXX (custom events)
Indicates that a custom event has occurred on the specified device.
A driver writer can define a custom event for a device. When the driver (or another related component) notifies the PnP manager that the custom event has occurred, the PnP manager notifies any components that registered for target device change notifications on the device.
Unlike registering for device interface changes, which can be considered a "passive" interest in the interface, registering for target device changes indicates an "active" interest in a device.
This category includes the following events:
Indicates that a user has requested to change the hardware profile of the machine. The PnP manager uses this notification to ask registered components whether it can change the hardware profile without disrupting system operation. Registered components typically succeed these query requests.
Indicates that the hardware profile of the machine has changed. If a driver maintains profile-specific settings, such a driver should refresh those settings after a hardware profile change.
Indicates that an impending hardware profile change has been canceled.
PnP notification works as follows for kernel-mode components:
A driver registers for notification on a category of events by calling IoRegisterPlugPlayNotification.
A PnP notification callback routine remains registered until the driver explicitly removes the registration.
The PnP manager calls the driver's callback routine when an event in the registered category occurs.
The driver removes the callback registration by calling IoUnregisterPlugPlayNotification.
Drivers must not generate a synchronous event or wait for an asynchronous event to occur during the processing of a close.
For further information about PnP notification, see the following sections: