IoRegisterShutdownNotification function (wdm.h)
The IoRegisterShutdownNotification routine registers the driver to receive an IRP_MJ_SHUTDOWN IRP when the system is shut down.
NTSTATUS IoRegisterShutdownNotification( [in] PDEVICE_OBJECT DeviceObject );
Pointer to the device object of the device for which the driver requests shutdown notification. The system passes this pointer to the driver's DispatchShutdown routine.
IoRegisterShutdownNotification returns STATUS_SUCCESS on success, or the appropriate NTSTATUS error code on failure.
The IoRegisterShutdownNotification routine registers the driver to receive an IRP_MJ_SHUTDOWN IRP for the specified device when the system shuts down. The driver receives one such IRP for each device it registers to receive notification for. Drivers handle IRP_MJ_SHUTDOWN IRPs within their DispatchShutdown routines.
If the driver ceases to require shutdown notification for the device, use IoUnregisterShutdownNotification to remove the driver from the shutdown notification queue.
Only one driver in a device stack should register to receive shutdown notification.
The system sends the driver the IRP_MJ_SHUTDOWN request before it flushes the file systems. Some drivers, such as drivers for mass storage devices, can require shutdown notification after the system flushes the file systems. To receive shutdown notification for a device after the file systems are flushed, use the IoRegisterLastChanceShutdownNotification routine instead.
The registered DispatchShutdown routine is called before the power manager sends an IRP_MN_SET_POWER request for PowerSystemShutdown. The DispatchShutdown routine is not called for transitions to any other power states.
A driver writer can make no assumptions about the order in which the driver's DispatchShutdown routine will be called in relation to other such routines or to other shutdown activities.
A PnP driver might register a shutdown routine to perform certain tasks before system shutdown starts, such as locking down code.
|Minimum supported client||Available in Windows 2000 and later versions of Windows. Not available in Microsoft Windows 98/Me.|
|Header||wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)|
|DDI compliance rules||HwStorPortProhibitedDDIs(storport), IrqlIoPassive5(wdm), PowerIrpDDis(wdm)|
Submit and view feedback for