Bewerken

Delen via


WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE function (wdfiotarget.h)

[Applies to KMDF only]

The WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE function initializes a driver's WDF_IO_TARGET_OPEN_PARAMS structure so that the driver can open a remote I/O target by specifying a Windows Driver Model (WDM) device object.

Syntax

void WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE(
  [out] PWDF_IO_TARGET_OPEN_PARAMS Params,
  [in]  PDEVICE_OBJECT             DeviceObject
);

Parameters

[out] Params

A pointer to a driver-allocated WDF_IO_TARGET_OPEN_PARAMS structure that the function initializes.

[in] DeviceObject

A pointer to a DEVICE_OBJECT structure, which is used as the value for the DeviceObject member of the WDF_IO_TARGET_OPEN_PARAMS structure.

Return value

None

Remarks

The WDF_IO_TARGET_OPEN_PARAMS structure is used as input to the WdfIoTargetOpen method.

The WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE function initializes the Size, Type, and TargetDeviceObject members of the specified WDF_IO_TARGET_OPEN_PARAMS structure.

Typically, a driver sets the TargetFileObject member of the WDF_IO_TARGET_OPEN_PARAMS structure after the driver has called WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE.

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

Examples

The following code example creates an I/O target object and opens the target by specifying a DEVICE_OBJECT structure. The sample driver obtains the DEVICE_OBJECT structure by calling NdisMGetDeviceProperty (not shown).

WDF_IO_TARGET_OPEN_PARAMS  openParams;
NTSTATUS  ntStatus;

ntStatus = WdfIoTargetCreate(
                             Adapter->WdfDevice,
                             WDF_NO_OBJECT_ATTRIBUTES,
                             &Adapter->IoTarget
                             );
if (!NT_SUCCESS(ntStatus)) {
    DEBUGP(MP_ERROR, ("WdfIoTargetCreate failed 0x%x\n", ntStatus));
    break;
}

WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE(
                                               &openParams,
                                               Adapter->NextDeviceObject
                                               );

ntStatus = WdfIoTargetOpen(Adapter->IoTarget,
                           &openParams);
if (!NT_SUCCESS(ntStatus)) {
    DEBUGP(MP_ERROR, ("WdfIoTargetOpen failed 0x%x\n", ntStatus));
    break;
}

Requirements

Requirement Value
Target Platform Universal
Minimum KMDF version 1.0
Header wdfiotarget.h (include Wdf.h)
IRQL Any level

See also

WDF_IO_TARGET_OPEN_PARAMS

WDF_IO_TARGET_OPEN_PARAMS_INIT_CREATE_BY_NAME

WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME

WdfIoTargetOpen