WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_FILE function

[Applies to UMDF only]

The WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_FILE function initializes a driver's WDF_IO_TARGET_OPEN_PARAMS structure so the driver can open an I/O target by specifying a filename.

Syntax


void WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_FILE(
  _Out_     PWDF_IO_TARGET_OPEN_PARAMS Params,
  _In_opt_  PCUNICODE_STRING FileName
);

Parameters

Params [out]

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

FileName [in, optional]

A value for the FileName member of the WDF_IO_TARGET_OPEN_PARAMS structure. Most drivers specify NULL here unless the lower target supports Device Namespace Access.

Return value

This function does not return a value.

Remarks

The WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_FILE function zeros the specified WDF_IO_TARGET_OPEN_PARAMS structure and sets its Size member. It also sets the structure's Type member to WdfIoTargetOpenLocalTargetByFile and sets the FileName member if the driver supplies a filename.

A driver can explicitly close the I/O target by calling WdfIoTargetClose. If the driver does not explicitly close the target, the framework closes the target automatically when the device is removed (an I/O target is by default parented to the device).

Examples

The following code example shows how a UMDF driver can open a local target with a file object as described in WDF_IO_TARGET_OPEN_TYPE:


WDF_OBJECT_ATTRIBUTES  ioTargetAttrib;
WDFIOTARGET  ioTarget;
WDF_IO_TARGET_OPEN_PARAMS  openParams;

//
// Create target
//
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&ioTargetAttrib, TARGET_DEVICE_INFO);
status = WdfIoTargetCreate(device, &ioTargetAttrib, &ioTarget);
if (!NT_SUCCESS(status)) {
    return status;
}

//
// Open target
//
WDF_IO_TARGET_OPEN_PARAMS_INIT_OPEN_BY_FILE(&openParams, NULL);
status = WdfIoTargetOpen(ioTarget, &openParams);
if (!NT_SUCCESS(status)) {
    WdfObjectDelete(ioTarget);
    return status;
}

//
// create a request
//


//
// Format the request for the above target
//


//
// Send request to above target
//


Requirements

Minimum support

Windows 8.1

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_TYPE

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft. All rights reserved.