title | description | keywords | ms.date | ||
---|---|---|---|---|---|
Initializing a General I/O Target in UMDF |
Initializing a General I/O Target in UMDF |
|
04/20/2017 |
[!includeUMDF 1 Deprecation]
The steps that your driver uses to initialize a general I/O target depend on whether the I/O target is local or remote.
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:
-
Call the QueryInterface method of the device's IWDFDevice interface to retrieve a pointer to the IWDFFileHandleTargetFactory interface.
-
Obtain a Win32 handle to a file, named pipe, or socket by calling the Win32 CreateFile, CreateNamedPipe, or socket function.
-
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.
Before your driver can use a remote I/O target, it must create a remote target object and open the target, as follows:
-
Call IWDFDevice2::CreateRemoteTarget to create a remote target object.
-
Call either IWDFRemoteTarget::OpenFileByName (for files) or IWDFRemoteTarget::OpenRemoteInterface (for device interfaces) to open the target for I/O operations.