Table of contents
Collapse the table of content
Expand the table of content

Initializing a General I/O Target in UMDF

Last Updated: 4/22/2017

[This topic applies to UMDF 1.x.]

The steps that your driver uses to initialize a general I/O target depend on whether the I/O target is local or remote.

Initializing a local I/O target

Local I/O targets include a device's default I/O target and file-handle-based I/O targets.

The framework initializes a driver's default I/O target for a device when the driver calls the IWDFDriver::CreateDevice method. To retrieve the IWDFIoTarget interface that enables the driver to access the device's default I/O target, the driver calls the IWDFDevice::GetDefaultIoTarget method.

Most drivers send requests only to their default I/O target.

If a UMDF driver must send I/O requests to a handle-based interface, such as a network socket interface, the driver must create a file-handle-based I/O target object. To create a file-handle-based I/O target object, the driver must do the following:

  1. Call the QueryInterface method of the device's IWDFDevice interface to retrieve a pointer to the IWDFFileHandleTargetFactory interface.

  2. Obtain a Win32 handle to a file, named pipe, or socket by calling the Win32 CreateFile, CreateNamedPipe, or socket function.

  3. Call the IWDFFileHandleTargetFactory::CreateFileHandleTarget method to create a file-handle-based I/O target object for the file, pipe, or socket.

For a code example that shows how to retrieve the IWDFFileHandleTargetFactory interface, obtain a Win32 handle, and create a file-handle-based I/O target object, see the code example at IWDFFileHandleTargetFactory::CreateFileHandleTarget.

After the driver creates the file-handle-based I/O target, the driver can send I/O requests to the I/O target.

Initializing a Remote I/O Target

Before your driver can use a remote I/O target, it must create a remote target object and open the target, as follows:

  1. Call IWDFDevice2::CreateRemoteTarget to create a remote target object.

  2. Call either IWDFRemoteTarget::OpenFileByName (for files) or IWDFRemoteTarget::OpenRemoteInterface (for device interfaces) to open the target for I/O operations.

© 2017 Microsoft