Getting Started with Windows drivers (i)

Source: Internet
Author: User

This blog is the foundation of Windows Driver development. Reprint marked Source: http://blog.csdn.net/ikerpeng/article/details/38776407


A simple Windows driver typically includes: header file (decision NT,WDM; definition macros ... ), the Ingress function (equivalent to main), creates a device routine (equivalent to the implementation of a function), a driver offload, and a default dispatch.


Knowledge Points:


1. Two kinds of drivers: NT and WDM: the former does not support Plug and Play; the header files are: NTDDK.h, WDM.h;


2.DriverEntry is the entrance to the function, including two parameters: Pdriverobject (The drive object passed by the I/O manager), Pregistrypath (pointing to the driver's responsible registry);


3. Device extension Structure: Responsible for supplementing the definition of equipment related information;


4. Load the program into the Init memory area with #pragma initcode, andthe INIT flag indicates that the program can be unloaded after it has been successfully loaded ;


5. Add extern "C "to ensure that C + + writing will not be error;"


6. The driver registers some callback functions for the operating system to call (all inside the Pdriverobject ) and tells the operating system by the way of pointers;


7. CreateDevice (pdriverobject) is a helper function that assists DriverEntry in creating a device object;

Constructs a Unicode string storage device object name;

IoCreateDevice create a Device object;

Fill in the extension structure of the equipment;

Create Symbolic links; ()

A successful creation is returned, and the deletion is unsuccessful.


8. Unloading the driver when the driver is unloaded: The address of the first device object is stored in the DeviceObject domain, and the Nextdevice field in each Device object records the address of the next device object, thus forming a list of: #pragma pagedcode:

The device object is obtained by the driving object;

Remove symbolic links for device objects;

Traverse the device object and delete it.


9. The default dispatch specifies the creation of the device object, the shutdown and read-write operations, and the status of the IRP.


Bibliography:

A detailed description of the Windows driver Development technology


Getting Started with Windows drivers (i)

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.