IoGetAttachedDevice function

The IoGetAttachedDevice routine returns a pointer to the highest-level device object associated with the specified device.

Syntax

PDEVICE_OBJECT IoGetAttachedDevice(
  PDEVICE_OBJECT DeviceObject
);

Parameters

DeviceObject

A pointer to the device object for which the topmost attached device is to be returned.

Return Value

IoGetAttachedDevice returns the highest-level device attached to the specified device.

Remarks

If the device object specified by DeviceObject has no other device objects attached to it, DeviceObject and the returned pointer are equal.

IoGetAttachedDevice differs from IoGetAttachedDeviceReference in the following respects:

  • IoGetAttachedDevice does not increment the reference count on the device object. (Thus no matching call to ObDereferenceObject is required.)
  • Callers of IoGetAttachedDevice must ensure that no device objects are added to or removed from the stack while IoGetAttachedDevice is executing. Callers that cannot do this must use IoGetAttachedDeviceReference instead.

Requirements

   
Target Platform Universal
Header ntifs.h (include Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL <= DISPATCH_LEVEL

See Also

IoGetAttachedDeviceReference

ObDereferenceObject