Synchronization of the IRP of the Windows Driver Development technology detailed

Source: Internet
Author: User

    • Synchronous asynchronous operation of the application on the device:

Most of the IRP is initiated by the application's Win32 API function. These Win32 APIs natively support both synchronous and asynchronous operations. For example, ReadFile, WriteFile, and DeviceIoControl, and so on, have both asynchronous and synchronous modes of operation. Synchronous operation of DeviceIoControl:

when synchronizing, the DeviceIoControl internal calls the WaitForSingleObject function to wait for an event. This event is not triggered until the end of the IRP. If you disassemble the IoCompleteRequest kernel function, you will find that the event is set inside the iocompleterequest. DeviceIoControl will temporarily go to sleep until the IRP ends .

For asynchronous operations, the process is:

in the case of an asynchronous operation, when DeviceIoControl is called, an IRP is generated internally, and the IRP is passed to the driver's internal dispatch function. At this point, however, DeviceIoControl does not wait for the IRP to end, but returns directly. When an IRP is terminated over a period of time, the operating system starts an IRP-related event. This event notifies the application that an IRP request has been executed .

Synchronous Operating Devices :

The function declarations of CreateFile are as follows:

1 HANDLE WINAPI CreateFile (2 _in_ lpctstr lpFileName,3 _in_ DWORD dwdesiredaccess,4 _in_ DWORD dwShareMode,5 _in_opt_ lpsecurity_attributes lpsecurityattributes,6 _in_ DWORD dwcreationdisposition,7  _in_ DWORD dwflagsandattributes,8 _in_opt_ HANDLE hTemplateFile9);

The sixth parameter in CreateFile dwFlagsAndAttributes is the key to synchronous asynchronous operations. If file_flag_overlapped is not set in this parameter, subsequent operations on the device are synchronous operations, otherwise all operations are asynchronous operations .

Asynchronous Operation device mode one :

First look at the structure of the overlapped:

The last parameter, hevent, is used to notify the application when the operation is complete.

Synchronization of the IRP of the Windows Driver Development technology detailed

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.