IoGetRelatedDeviceObject function

Given a file object, the IoGetRelatedDeviceObject routine returns a pointer to the corresponding device object.

Syntax

PDEVICE_OBJECT IoGetRelatedDeviceObject(
  _In_ PFILE_OBJECT FileObject
);

Parameters

FileObject

Pointer to the file object.

Return Value

IoGetRelatedDeviceObject returns a pointer to the device object.

Remarks

When called on a file object that represents the underlying storage device, IoGetRelatedDeviceObject returns the highest-level device object in the storage device stack. To obtain the highest-level device object in the file system driver stack, drivers must call IoGetRelatedDeviceObject on a file object that represents the file system's driver stack, and the file system must currently be mounted. (Otherwise, the storage device stack is traversed instead of the file system stack.)

To ensure that the file system is mounted on the storage device, the driver must have specified an appropriate access mask, such as FILE_READ_DATA or FILE_WRITE_ATTRIBUTES, when opening the file or device represented by the file object. Specifying FILE_READ_ATTRIBUTES does not cause the file system to be mounted.

The caller must be running at IRQL <= DISPATCH_LEVEL. Usually, callers of this routine are running at IRQL = PASSIVE_LEVEL.

Requirements

   
Windows version Available starting with Windows 2000.
Target Platform Universal
Header wdm.h (include Wdm.h, Ntddk.h, Ntifs.h)
Library NtosKrnl.lib
DLL NtosKrnl.exe
IRQL "<= DISPATCH_LEVEL (see Remarks section)"

See Also

IoGetDeviceObjectPointer

Send comments about this topic to Microsoft