How To Write Drivers

Table of contents:

How To Write Drivers
How To Write Drivers

Video: How To Write Drivers

Video: How To Write Drivers
Video: Developing Kernel Drivers with Modern C+ - Pavel Yosifovich 2024, April
Anonim

Unified work with all devices of a personal computer in Windows, as well as some other functions of the operating system are provided by a set of drivers. In order to write drivers, you need to be well versed in programming, the principles of the kernel and various Windows subsystems.

How to write drivers
How to write drivers

Necessary

Windows Driver Development Kit

Instructions

Step 1

Download the Windows Driver Development Kit (DDK) distribution from microsoft.com (available for MSDN subscribers) and install it on your computer. This package contains all the necessary tools for developing and building drivers (compiler, linker, header files, libraries), as well as comprehensive documentation.

Step 2

Study in detail all the available documentation on writing drivers for Windows. Use the reference information from the DDK and related MSDN topic (msdn.microsoft.com). You must fully understand all aspects of the Windows Driver Model (WDM) and grasp the basic architectural concepts. You must clearly understand the differences between user-mode and kernel-mode drivers, device drivers, and file system drivers. You need to know the specifics of different classes of drivers, their types (bus drivers, filters, functional drivers) and subtypes (display drivers, modems, network devices, parallel and serial ports, storage devices). Pay particular attention to the principles of Packet-Driven I / O with Reusable IRPs, memory management, exception handling, and the correct application of synchronization objects.

Step 3

Clearly define the functionality of the driver being developed. Based on this, determine what type and class it belongs to.

Step 4

Select a programming language. Traditionally, kernel-mode drivers are implemented in C. User-mode drivers are usually developed in C ++. There are several exceptions to these rules. For example, client minidrivers for audio and video streams, WDM audio drivers for kernel mode miniports, WIA drivers, and sometimes display drivers are written in C ++.

Step 5

Create a project that implements the driver stub. Explore the DDK directory with examples. Find the correct driver demo project. If you cannot find a suitable example, create the files yourself that contain the required source code and build script files. For example, when developing a kernel-mode driver, you need to implement the DriverEntry function, which contains the initialization code as well as some standard routines (such as AddDevice, StartIo, etc.).

Step 6

Implement the driver functionality. Add code to the functions created in the previous step. Add logic to handle I / O requests, etc.

Recommended: