Previous Next

IoDetachDevice

The IoDetachDevice routine releases an attachment between the caller’s device object and a lower driver’s device object.

VOID 
  IoDetachDevice(
    IN OUT PDEVICE_OBJECT  TargetDevice
    );

Parameters

TargetDevice
Pointer to the lower driver’s device object. The caller previously called IoAttachDevice or IoAttachDeviceToDeviceStack successfully to get this pointer.

Return Value

None

Headers

Declared in wdm.h and ntddk.h. Include wdm.h or ntddk.h.

Comments

IoDetachDevice decrements the reference count of the TargetDevice object. If the reference count goes to zero and the lower driver has been marked for an unload operation, the lower driver is unloaded.

Callers of IoDetachDevice must be running at IRQL = PASSIVE_LEVEL.

See Also

IoAttachDevice, IoAttachDeviceToDeviceStack