WdfIoTargetOpen method

[Applies to KMDF and UMDF]

The WdfIoTargetOpen method opens a remote I/O target so the driver can send I/O requests to it.

Syntax


NTSTATUS WdfIoTargetOpen(
  [in]  WDFIOTARGET IoTarget,
  [in]  PWDF_IO_TARGET_OPEN_PARAMS OpenParams
);

Parameters

IoTarget [in]

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

OpenParams [in]

A pointer to a caller-allocated WDF_IO_TARGET_OPEN_PARAMS structure.

Return value

WdfIoTargetOpen returns STATUS_SUCCESS if the operation succeeds. Otherwise, this method might return one of the following values:

Return codeDescription
STATUS_INVALID_DEVICE_STATE

The specified I/O target is already open.

STATUS_INSUFFICIENT_RESOURCES

Available system resources were insufficient to complete the operation.

STATUS_INFO_LENGTH_MISMATCH

The size of the WDF_IO_TARGET_OPEN_PARAMS structure that OpenParams specified was incorrect.

STATUS_NO_SUCH_DEVICE

The TargetFileObject member of the caller's WDF_IO_TARGET_OPEN_PARAMS structure specified an invalid file object.

STATUS_INVALID_PARAMETER

An invalid parameter was detected.

 

This method also might return other NTSTATUS values.

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

Remarks

Drivers can open remote I/O targets by supplying a Unicode string that represents an object name or by supplying a pointer to a Windows Driver Model (WDM) DEVICE_OBJECT structure. (Framework-based drivers typically do not have pointers to other drivers' DEVICE_OBJECT structures.)

If you want your driver to use its local I/O target, the driver must call WdfDeviceGetIoTarget instead of WdfIoTargetOpen.

If a call to WdfIoTargetOpen fails, the driver should call WdfObjectDelete to delete the I/O target object.

For more information about WdfIoTargetOpen, see Initializing a General I/O Target.

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

Examples

The following example creates an I/O target object, initializes a WDF_IO_TARGET_OPEN_PARAMS structure, and opens a remote I/O target by specifying a device's symbolic link name.


WDF_OBJECT_ATTRIBUTES  ioTargetAttrib;
WDFIOTARGET  ioTarget;
WDF_IO_TARGET_OPEN_PARAMS  openParams;

WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(
                                        &ioTargetAttrib,
                                        TARGET_DEVICE_INFO
                                        );
status = WdfIoTargetCreate(
                           device,
                           &ioTargetAttrib,
                           &ioTarget
                           );
if (!NT_SUCCESS(status)) {
    return status;
}
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME(
                                            &openParams,
                                            SymbolicLink,
                                            STANDARD_RIGHTS_ALL
                                            );
status = WdfIoTargetOpen(
                         ioTarget,
                         &openParams
                         );
if (!NT_SUCCESS(status)) {
    WdfObjectDelete(ioTarget);
    return status;
}

Requirements

Minimum KMDF version

1.0

Minimum UMDF version

2.0

Header

Wdfiotarget.h (include Wdf.h)

Library

Wdf01000.sys (KMDF);
WUDFx02000.dll (UMDF)

IRQL

PASSIVE_LEVEL

DDI compliance rules

DriverCreate, KmdfIrql, KmdfIrql2

See also

DEVICE_OBJECT
WDF_IO_TARGET_OPEN_PARAMS
WdfDeviceGetIoTarget
WdfIoTargetClose
WdfIoTargetCreate
WdfIoTargetOpen
WdfObjectDelete

 

 

Send comments about this topic to Microsoft

표시:
© 2014 Microsoft