Initializing a General I/O Target in UMDF

Warning

UMDF 2 is the latest version of UMDF and supersedes UMDF 1. All new UMDF drivers should be written using UMDF 2. No new features are being added to UMDF 1 and there is limited support for UMDF 1 on newer versions of Windows 10. Universal Windows drivers must use UMDF 2.

The archived UMDF 1 samples can be found in the Windows 11, version 22H2 - May 2022 Driver Samples Update.

For more info, see Getting Started with UMDF.

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.