Bewerken

Delen via


WDF_IO_TARGET_OPEN_PARAMS_INIT_CREATE_BY_NAME function (wdfiotarget.h)

[Applies to KMDF and UMDF]

The WDF_IO_TARGET_OPEN_PARAMS_INIT_CREATE_BY_NAME function initializes a driver's WDF_IO_TARGET_OPEN_PARAMS structure so the driver can open an I/O target by specifying the name of the device, file, or device interface. If the supplied name does not exist, the operating system will try to create it.

Syntax

void WDF_IO_TARGET_OPEN_PARAMS_INIT_CREATE_BY_NAME(
  [out] PWDF_IO_TARGET_OPEN_PARAMS Params,
  [in]  PCUNICODE_STRING           TargetDeviceName,
  [in]  ACCESS_MASK                DesiredAccess
);

Parameters

[out] Params

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

[in] TargetDeviceName

A value for the TargetDeviceName member of the WDF_IO_TARGET_OPEN_PARAMS structure.

[in] DesiredAccess

A value for the DesiredAccess member of the WDF_IO_TARGET_OPEN_PARAMS structure.

Return value

None

Remarks

If TargetDeviceName specifies the name of a file that already exists, the system replaces the existing file. If the file does not exist, the system creates it.

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

KMDF The WDF_IO_TARGET_OPEN_PARAMS_INIT_CREATE_BY_NAME function initializes the Size, Type, TargetDeviceName, DesiredAccess, and CreateOptions members of the specified WDF_IO_TARGET_OPEN_PARAMS structure.

UMDF The WDF_IO_TARGET_OPEN_PARAMS_INIT_CREATE_BY_NAME function initializes the Size, Type, DesiredAccess, and TargetDeviceName members of the specified WDF_IO_TARGET_OPEN_PARAMS structure. It sets the ShareAccess member to zero. It also sets the FileAttributes member to FILE_ATTRIBUTE_NORMAL.

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 a target by specifying a file name.

UNICODE_STRING  fileName;

RtlInitUnicodeString(
                     &fileName, 
                     (PCWSTR)PROTOCOL_INTERFACE_NAME
                     );

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;
}

Requirements

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

See also

WDF_IO_TARGET_OPEN_PARAMS

WDF_IO_TARGET_OPEN_PARAMS_INIT_EXISTING_DEVICE

WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_NAME

WdfIoTargetOpen