IoDeleteDevice

VOID
    IoDeleteDevice(

        IN PDEVICE_OBJECT  DeviceObject
        );

IoDeleteDevice removes a device object from the system, for example, when the driver that created it is being unloaded.

Parameters

DeviceObject
Points to the driver’s device object to be released.

Comments

This routine must be called when a driver that created the device object is being unloaded or when the DriverEntry routine encounters a fatal initialization error, such as being unable to properly initialize a physical device. This routine also is called when a driver reconfigures its devices dynamically. For example, a disk driver called to repartition a disk would call IoDeleteDevice to tear down the device objects representing partitions to be replaced.

A driver must release certain resources for which the driver supplied storage in its device extension before it calls IoDeleteDevice. For example, if the driver stores the pointer to its interrupt object(s) in the device extension, it must call IoDisconnectInterrupt before IoDeleteDevice.

When IoDeleteDevice is called, there cannot be any outstanding references to the device being deleted nor any attached devices. If there are, a system erorr occurs.

Callers of IoDeleteDevice must be running at IRQL PASSIVE_LEVEL.

See Also

IoCreateDevice, IoDisconnectInterrupt