Windows debugging 10

Source: Internet
Author: User

Driver Structure

==============

The IO system controls and drives the execution of the driver. The driver has a series of functions which are called at different stages of Io request processing. The main points of the driver function are described as follows:

  • An initialization routine-when the IO manager loads the driver into the operating system, the IO manager executes a driver initialization function, which is typically calledDriverEntry.
  • An add-device routine (an add-device routine)-A plug-and-play driver will implement a device add function. when the device in charge of the driver is monitored, the PNP manager sends a notification to the driver through this function.
  • A series of allocation functions (a set of dispatch routines)-the allocation function is the main function provided by the device driver. for example, you can enable, disable, read, and write the functions supported by other devices. These devices can be file systems or networks.
  • A startup Io function (a start I/O routine)-the driver can useStart Io FunctionsTo initialize data transmission to another device. You can also initialize data transmission from another device to another device.Devices that rely on the IO manager to queue Device Requests. Io manager serializes IRPs to ensure that the driver processes only one IRP at a time. most drivers process multiple IRPs at the same time, but serialization is reasonable for some drivers, such as keyboard drivers.
  • An interrupt service routine (ISR)-When a device is interrupted, the kernel interrupt distributor transfers the control to this function. in the Windows Io model, the interrupt service function (ISR) runs at the device interrupt request level (dirql ), therefore, in order to avoid unnecessary obstacles to low-level interrupt processing, the fewer operations they perform, the better. an ISR processes the deferred Procedure Call (DPC) function that is rejected by the IRQL function to interrupt the remaining requests. (Only devices that rely on the Interrupt Drive have ISR and file system read drivers. For example, no ISR is available)
  • A dpc function (an interrupt-servicing DPC routine) for service interruption executes most of the work, which is related to the handling of device interruptions after ISR execution. DPC functions are executed at a lower IRQL (DPC/dispatch level) than ISR, that is, device level, to avoid unnecessary interruptions. a dpc function initializes the end of Io and starts the next Io operation in the queue of the device.

Although the following functions are not shown in, they can be found in many types of device drivers:

 

  • One or more end functions (one or more I/O completion routines)-a hierarchical driver may have Io completion functions, it is used to notify the device when a low-level driver finishes processing the IRP (I/O Request Packet. for example, the IO manager will call the IO completion function of the file system driver when a driver finishes converting data to a file. end function notification file system driver: the data conversion operation is successful, failed, or canceled. It also allows the file system driver to clean up.
  • A cancelling Io function (a cancel I/O routine)-if an IO operation is canceled, the driver can define one or more cancelling Io functions. when the driver receives an IRP that can be canceled, it will assign a cancellation function to the IRP. if a thread that processes Io exits before the end of the IO request, or cancels the operation (for example, through the windows cancelio function), the IO manager executes the cancel function in the IRP, if this IRP is assigned such a function. A canceling function is necessary to release any IRP that has acquired resources, regardless of the IO operation. It is just like an IRP in the canceled state.
  • An unload routine is written in the function to release any system resources that the driver is using so that the IO manager can remove them from the memory. any resources requested in the initialization function are usually released in the unmount function. therefore, when the system is running, a driver can be loaded and uninstalled successfully.
  • A system shutdown notification routine allows the driver to clean up before the system is shut down.
  • Error-logging routines-when an unexpected error occurs (for example, a disk is damaged ), the error handler of the driver records the error and notifies the IO manager. the IO manager writes this information to the error log.
Related Article

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.