How to Develop a device driver in the integrated environment of Visual Studio 6.0

Source: Internet
Author: User
Author: yansm

Submitted by: eastvc released on: 2003-10-19 19:47:05
Source: http://www.china-pub.com

On Windows, the development environment provided by Windows DDK is based on the command line, which is inconvenient to operate. I believe that those who have developed the driver will be absolutely miserable. On the other hand, Visual Studio 6.0 provides us with a very friendly and easy-to-use integrated environment that makes us feel more powerful.
So can we use the Integrated Environment of Visual Studio to develop drivers? After many explorations and development-driven experience, I found a set of practical methods. Through simple settings of the Visual Studio integrated environment, you have created your own driver development and integration environment. I will share some of my experiences with you. If you have any mistakes, please correct me.

0. system requirements have been installed
DDK
Visual c ++ 6.0 (all tools are selected during installation)

1. Modify DDK \ bin \ setenv. bat
Comment out the statements that require mstools (if you want to develop a driver in the command line environment, you also need to add call vc_dir \ vc98 \ bin \ vcvars32. BAT ), this allows you to use VC-related tools in the command line. If you only want to develop in the IDE environment, you do not have to call vcvars32.bat, because the path information of related tools can be set in the VC environment .)

2. Create a directory driverenv (the directory name is random) as the base camp for your development driver

3. Create a batch file named makedrvr. BAT in this directory. The content is as follows:
@ Echo off
If "% 1" = "" Goto usage
If "% 3" = "" Goto usage
If not exist % 1 \ bin \ setenv. Bat goto usage
Call % 1 \ bin \ setenv % 1% 4
% 2

Cd % 3
Build-B-w % 5% 6% 7% 9

Goto exit

: Usage
Echo usage MakeDrvr DDK_dir Driver_Drive Driver_Dir free/checked [build_options]
Echo eg MakeDrvr % DDKROOT % C: % WDMBOOK % free-cef
: Exit
The batch processing first checks the passed parameters, then calls the setenv command of ddk to set the environment variable, and then changes the directory to the source program
In the drive and directory, and finally call build,-B ensures that the error message is displayed completely,-w ensures that a warning is output on the screen, you can see these errors and warnings in the output window of vc ide.

4. Create a blank Project
Select the new menu item of File, select the makefile in the project column, and enter the path to go down the next step. visual studio provides two types of configuration: win32 debug and win32 release.

5. Modify the two configurations.
Select the settings menu item win32 debug for the project:
Fill in MakeDrvr DDK_DIR SOURCE_DRIVE SOURCE_DIR checked [Build options] In the build Command Line column.
Enter-nmake/a in the Rebuild all options column.
Fill in the output file column with the same TARGETNAME as the sources file.
Fill in obj \ i386 \ checked \ In the Browse info file name column (for the same file name as TARGETNAME, see the following). bsc

Win32 release:
Enter MakeDrvr DDK_DIR SOURCE_DRIVE SOURCE_DIR free [Build options] In the build Command Line column.
Enter-nmake/a in the Rebuild all options column.
Fill in the output file column with the same TARGETNAME as the sources file.
In the Browse info file name field, enter obj \ i386 \ free \ (file name identical to TARGETNAME). bsc
Note: DDK_DIR can generally be written as % BASEDIR %, and build options is generally-cef, that is, enough

6. Add the source file to the Project
It can be created or added, which is the same as that of common win32 development.

7. Add a resource file
Select the insert resource menu item.

8. Put the makefile in the source program directory, and its content is always
#
# 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

9. Put the file sources into the source program directory. The content is
Targetname = ramdrive // The Name Of The driver. SYS file to be generated
Targetpath = OBJ // The upper directory of the directory where the. SYS file is located. (due to the DDK bug) You should manually create the checked and free directories under the OBJ directory to serve as the final directory of. sys.
Targettype = driver // type of the driver, which is generally unchanged
Supported des = $ (basedir) \ Inc // DDK contains the file path, which is generally unchanged
Sources = ramdrive. cpp ramdrive. RC // source file (not header file), resource file
Browser_info = 1 // if you want to browse information, you must have a row. Otherwise, you can

10. Because makedrvr. bat is in the driverenv directory, add the directory to executable files of VC.
Select the Options menu of tools, select the directories page, select executable files in the show directories for column, and then add.

Now, the environment has been set up. You can press F7 to build your driver.

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.