Guidelines for Writing PnP Notification Callback Routines
The PnP manager calls notification callback routines at IRQL = PASSIVE_LEVEL.
To ensure smooth operation of the PnP subsystem, a PnP notification callback routine must follow these guidelines:
A notification callback routine must not block.
A notification callback routine must not call, or cause a call to, synchronous routines that generate PnP events or any routine that blocks waiting for device installation or removal.
Calling such routines during a notification callback can cause a system deadlock.
A notification callback routine should return success for any events it does not explicitly fail.
When a driver registers for notification on an event category, the PnP manager notifies the driver of all events in that category, present and future. If a driver returns an error status for events it does not handle, the driver risks failing a new query event by mistake.
A driver correctly returns an error status when, for example, the driver fails a query notification to veto the event being proposed.
A notification callback routine should be paged code.