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:

  1. A notification callback routine must not block.

  2. 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.

    For example, a driver must not call IoReportTargetDeviceChange in a notification callback routine. Call IoReportTargetDeviceChangeAsynchronous instead.

  3. 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.

  4. A notification callback routine should be paged code.

Send comments about this topic to Microsoft