Initializing a General I/O Target
The framework initializes a driver's local I/O target for a device when the driver calls WdfDeviceCreate. To retrieve a handle to a device's local I/O target, the driver calls WdfDeviceGetIoTarget.
Most drivers send requests only to their local I/O target.
To initialize a remote I/O target for a device, the driver must:
Call WdfIoTargetCreate to create an I/O target object.
Call WdfIoTargetOpen to open an I/O target so that the driver can send requests to it.
When the driver calls WdfIoTargetOpen, it typically identifies the remote I/O target by supplying a Unicode string that represents an object name. This name can identify a device, file, or device interface. The framework sends I/O requests to the top of the driver stack that supports the object name.
Rarely, a driver might identify a remote I/O target by supplying a pointer to a Windows Driver Model (WDM) DEVICE_OBJECT structure. This pointer identifies a different driver within the calling driver's stack. Framework-based drivers rarely use this technique because they rarely have access to other drivers' DEVICE_OBJECT structures.
The following example shows how the Ndisedge sample driver uses the above technique to create and open a remote I/O target:
status = WdfIoTargetCreate(Adapter->WdfDevice,
WDF_NO_OBJECT_ATTRIBUTES,
&Adapter->IoTarget);
if (!NT_SUCCESS(status)) {
DEBUGP(MP_ERROR, ("WdfIoTargetCreate failed 0x%x\n",
status));
return status;
}
WDF_IO_TARGET_OPEN_PARAMS_INIT_CREATE_BY_NAME(&openParams,
&fileName,
STANDARD_RIGHTS_ALL
);
status = WdfIoTargetOpen(Adapter->IoTarget,
&openParams);
if (!NT_SUCCESS(status)) {
DEBUGP(MP_ERROR, ("WdfIoTargetOpen failed 0x%x\n", status));
return status;
}