WdfIoTargetWdmGetTargetFileObject function

[Applies to KMDF only]

The WdfIoTargetWdmGetTargetFileObject method returns a pointer to the Windows Driver Model (WDM) file object that is associated with a specified remote I/O target.


PFILE_OBJECT WdfIoTargetWdmGetTargetFileObject(



A handle to a remote I/O target object. This handle was obtained from a previous call to WdfIoTargetCreate.

Return Value

WdfIoTargetWdmGetTargetFileObject returns a pointer to a WDM FILE_OBJECT structure.

A bug check occurs if the driver supplies an invalid object handle.


The pointer that the WdfIoTargetWdmGetTargetFileObject method returns is valid until the driver calls WdfIoTargetClose or WdfIoTargetCloseForQueryRemove, or until the remote I/O target object is deleted. If the driver provides an EvtCleanupCallback function for the remote I/O target object, and if the object is deleted before the remote I/O target is closed, the pointer is valid until the EvtCleanupCallback function returns.

If the driver attempts to access the WDM device object after it has been removed, the driver can cause the system to crash. The toastmon sample demonstrates how the driver can provide an EvtIoTargetQueryRemove callback function so that it is notified if the I/O target is removed.

For more information about WdfIoTargetWdmGetTargetFileObject, see Obtaining Information About a General I/O Target.

For more information about I/O targets, see Using I/O Targets.


The following code example obtains a pointer to the WDM file object that is associated with a remote I/O target.

PFILE_OBJECT pfileObject;

pfileObject = WdfIoTargetWdmGetTargetFileObject(IoTarget);


Target Platform Universal
Minimum KMDF version 1.0
Header wdfiotarget.h (include Wdf.h)
Library Wdf01000.sys (see Framework Library Versioning.)
DDI compliance rules DriverCreate, KmdfIrql, KmdfIrql2

See Also





Send comments about this topic to Microsoft