Driver development-compile and forward

Source: Internet
Author: User

I have talked about the compiling environment and tools before. Here, I will talk about it in combination with this example:

DDK is divided into 98 DDK and 2000 DDK, which work similarly, but some drivers can only be used in 2000 DDK. Win98 is destined to be an operating system to be phased out, so I didn't pay too much attention when I was studying it. I used 2000 DDK, therefore, all of the following content is for 2000 DDK.

· Preparations
1. Make sure that you have installed visual c ++
2. Install DDK 2000
3. After the 2000 DDK is successfully installed,Start"->"Program"Should contain"Development Kits"->"Windows 2000 DDKProject.
(Be sure to install the VC before installing the DDK. This order must not be reversed !!)
4. Make sure that the ddkroot environment variable is set to the base Directory of Windows 2000 DDK. If not, go to the control panelSystem"Attribute"Advanced"Set this environment variable in the label environment variable editor.

· Compile necessary files
When compiling a WDM program, two files are required:
1,Makefile
(What is this? You may ask .) For younger programmers, you may not have seen this file. In fact, before the emergence of the vc ide, we must use makefile to determine which files in the project need to be re-compiled. The current ide has automatically completed this job.
The job we need to do is to provide such a file with the following content:

#
# Do not edit this file !!! Edit./sources. If you want to add a new source
# File to this component. This file merely indirects to the real make File
# That is shared by all the driver components of the Windows NT DDK
#

! Include $ (ntmakeenv)/makefile. Def

As it said, Do not edit this file. In fact, the makefile content required by each WDM program is the same, that is, we only need to simply copy a makefile to a new project.
2,Sources

Targetname = hellowdm // name of the compiled driver
Targettype = driver // The compilation type is driver compilation.
Drivertype = WDM // The driver type is WDM.
Targetpath = OBJ // The generated file is stored in the OBJ directory.

Required des = $ (basedir)/INC; // This is the header file to be introduced.
$ (Basedir)/INC/DDK ;/

Targetlibs = $ (basedir)/lib/*/free/usbd. Lib // This is the library file to be introduced.

Sources = hellowdm. cpp // This is the source code file

This file specifies that the target name of the driver is hellowdm. SYS. It is a WDM driver and the generated file is stored in the OBJ directory. It is worth noting that there cannot be spaces before and after "=", otherwise there will be errors during compilation.

· Start Compilation
Wahaha, Luo luochao mentioned a lot before, and now the focus is finally reached. The compilation process of WDM programs is special. It is not compiled by F7 in VC (although you can achieve this through settings ), instead, build a DDK utility. The following describes the specific steps:
1. Generation of "debug"
First, assume that your source code is stored in D:/hellowdm. Follow these steps:

Start> program> Development Kits> Windows 2000 DDK> checked Build Environment"

The screen will show: (the line with "enter" needs to be input by the reader)

New or updated msvc detected. Updating DDK environment ....

Setting environment for using Microsoft Visual C ++ tools.
Starting dirs creation... Completed.

D:/ntddk> Cd/hellowdm (Press ENTER)

D:/hellowdm> build (Press ENTER)

If the source code is correct, the generated hellowdm. sys will be stored in the objchk/i386 directory.

2. Generate "release"
Follow these steps:

Start> program> Development Kits> Windows 2000 DDK> Free Build Environment"

The subsequent steps are the same as those of the debug version. The difference is that the generated hellowdm. sys will be stored in the objfre/i386 directory.

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.