Windows driver development and windows driver development

Source: Internet
Author: User

Windows driver development and windows driver development

In the previous article "Windows driver development-4", we have completed hardware preparation. However, we do not have specific data operations, such as receiving read/write operations.

Before performing such operations in WDF, you must perform device I/O control to ensure data integrity.

We know that WDF development follows the "Footsteps" of IRPs ".

I/O Request Delivery Mechanic

I/O request type

UMDF delivery Mechanic

KMDF delivery Mechanic

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

From the table, we can see that WDF uses the Queue mechanism during device I/O control.

Therefore, we need 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 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) Set callback events

Set the member variable value 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) create a queue
WdfIoQueueCreate

NTSTATUS WdfIoQueueCreate(  [in]            WDFDEVICE              Device,  [in]            PWDF_IO_QUEUE_CONFIG   Config,  [in, optional]  PWDF_OBJECT_ATTRIBUTES QueueAttributes,  [out, optional] WDFQUEUE               *Queue);


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.