In the previous article "Windows Driver Development-4" We have completed the hardware preparation. However, we do not have specific data operations, such as receiving read and write operations.
The IO control of the device is required prior to such operations in WDF, and the integrity of the data is maintained.
We know that the development of WDF is mainly followed by the "Footsteps" of IRPs.
I/O Request Delivery mechanism |
I/O request type |
UMDF delivery mechanism |
KMDF delivery mechanism |
read |
queue |
queue |
write |
queue |
queue |
device I/O control |
queue |
queue |
internal device I/O control |
queue |
queue |
create |
queue |
queue or callback |
close |
callback |
callback |
Cleanup |
Callback |
Callback |
As you can see from the table, WDF is a mechanism for using queue (queue) when making device I/O control.
So, we're going to provide queue support when adding devices.
Wdf_object_attributes_init_context_type (&ioqueueconfig, wdfioqueuedispatchparallel); Ioqueueconfig.evtiodevicecontrol = Evtiodevicecontrol; Status = Wdfioqueuecreate (device, &ioqueueconfig, wdf_no_object_attributes, wdf_no_handle);
(1) Initialize the queue configuration
Wdf_io_queue_config_init_default_queue
VOID wdf_io_queue_config_init_default_queue ( _out_ pwdf_io_queue_config CONFIG, _in_ Wdf_io_ Queue_dispatch_type Dispatchtype);
(2) Setting callback events
Sets the value of a member variable in the WDF_IO_QUEUE_CONFIG structure.
typedef struct _WDF_IO_QUEUE_CONFIG {ULONG Size; Wdf_io_queue_dispatch_type Dispatchtype; Wdf_tri_state powermanaged; BOOLEAN allowzerolengthrequests; BOOLEAN Defaultqueue; Pfn_wdf_io_queue_io_default Evtiodefault; Pfn_wdf_io_queue_io_read Evtioread; Pfn_wdf_io_queue_io_write Evtiowrite; Pfn_wdf_io_queue_io_device_control Evtiodevicecontrol; Pfn_wdf_io_queue_io_internal_device_control Evtiointernaldevicecontrol; Pfn_wdf_io_queue_io_stop Evtiostop; Pfn_wdf_io_queue_io_resume Evtioresume; Pfn_wdf_io_queue_io_canceled_on_queue Evtiocanceledonqueue; Union {struct {ULONG numberofpresentedrequests; } Parallel; } Settings; Wdfdriver Driver;} Wdf_io_queue_config, *pwdf_io_quEue_config;
(3) Set up a queue
Wdfioqueuecreate
NTSTATUS wdfioqueuecreate ( [in] wdfdevice Device, [in] pwdf_io_queue_config CONFIG, [in, optional] Pwdf_object_attributes queueattributes, [out, optional] wdfqueue *queue);
Windows Driver Development-5