Windows Driver Development-5

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.