On Windows, the development environment provided by Windows DDK is based on the command line, it is extremely inconvenient to operate, I believe that the driver development of the friend must be disgusted. Visual Studio 6.0, on the other hand, provides us with a very friendly and easy-to-use integration environment that gives us a sense of the menace.
So, can you use Visual Studio's integrated environment to develop drivers? After many explorations and combined with my own development-driven experience, the author has worked out a set of practical methods to create its own driving development integration environment through simple setup of Visual Studio integrated environment.
The following author of some experience dedicated to share with you, if there is improper, welcome correction.
0. System requirements are installed
DDK
Visual c++6.0 (all tools selected at installation)
1. Transformation of Ddk\bin\setenv.bat
Comment out the relevant statements that require MSTOOLS (add call vc_dir\vc98\bin\vcvars32. bat if you want to develop the driver in the command-line environment) so that you can use the VC tools at the command line , you don't have to call Vcvars32.bat if you only want to develop in the IDE environment, because the path information for the relevant tools can be set in the VC environment.)
2. Create a directory driverenv (random directory name), as your development-driven stronghold
3. Create a batch file Makedrvr.bat under this directory, which reads 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
%
CD%3
Build-b-W%5%6%7%8%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 process first checks the passed parameters and then invokes the DDK setenv command to set the environment variable, and then changes the directory to the source program
In the drive and directory, and the last call to Build,-b guaranteed to display complete error messages,-W guarantees the output warning on the screen, which can be seen in the Output window of the VC IDE.
4. Create a blank project
Select the new menu item for the file, select the makefile of the project bar, and then enter the path to next, and Visual Studio offers two configurations Win32 Debug and Win32 release.
5. Modify these two configurations
Choose project's Settings menu item Win32 Debug:
Fill in the Makedrvr ddk_dir source_drive source_dir checked [build options] in the Build Command line column
Fill in the Rebuild All options column-nmake/a
Fill in the Output file column with the same file name as the targetname in the sources file
In the Browse info file Name column, fill in the obj\i386\checked\ (the same file name as TargetName, see below). bsc
Win32 Release:
In the build Command line, fill in the Makedrvr ddk_dir source_drive source_dir free [build options]
Fill in the Rebuild All options column-nmake/a
Fill in the Output file column with the same file name as the targetname in the sources file
In the Browse info file Name column, fill in the obj\i386\free\ (the same file name as TargetName). BSc
Note: Ddk_dir can generally be written as%basedir%,build options generally-cef that is enough
6. Add source file to project
Can be new, or can be added, this is the same as ordinary Win32 development.
7. Add a resource file
Select the Resource menu item for the Insert
8. Put the file makefile into the source program directory, its content is always
#
# don't EDIT this FILE!!! Edit. \sources. If you are want to add a new source
# file to this component. This file merely indirects to the real make file
# That's shared by 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//This is the name of the driver. sys file to be generated
Targetpath=obj//.sys directory where the file resides, (due to DDK bugs) the checked and free directories should be created manually in the obj directory as the final repository for. Sys
Targettype=driver//driver type, generally unchanged
includes=$ (BASEDIR) \inc//ddk include file path, generally unchanged
Sources=ramdrive.cpp ramdrive.rc//source file (not header file), resource file
Browser_info = 1//If you want to browse the information, you must have the bank;
10. Because makedrvr.bat in the driverenv directory, so should add the directory to VC executable files inside
Select the Options menu item for Tools, then choose Directories page, directories the show in the For column executable files, and then add it.
Now that the environment is set up, you can press F7 to build your driver.