Driver development environment settings in Windows XP (DDK + vc6.0)

Source: Internet
Author: User
Generally, the driver debugging is completed in cmd with DDK. I have skipped this part for the moment. The following describes how to configure VC ++ 6.0 to develop a device driver in the Visual Studio 6.0 integrated environment.

On Windows, the development environment provided by Windows DDK is based on the command line, which is inconvenient to operate. Visual Studio 6.0 provides a friendly and easy-to-use integrated environment, it makes us feel more powerful.
So can we use the Integrated Environment of Visual Studio to develop drivers? The answer is yes. By setting the Visual Studio integrated environment, you can create your own driver development integrated environment.

1,

First, install VC ++ 6.0. I installed the English version. The Chinese version should also work, but I did not try it.

Second, install winxp ddk. Note that there cannot be spaces in the installation directory, for example, D: \ Program Files,

I directly installed it on the d disk. After installation, set the environment variable ddkroot as the installation directory D: \ winddk \ 2505.

2. Create a directory. As the Development Directory, I used the project file pci9052demo IN THE <PCI Device Development Guide> to test the file on the E disk. Therefore, the working directory is E: \ pci9052demo

3. Create a batch processing file named makedrvr. bat in the working 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 % F: % wdmworkshop % free-CEF
: Exit

Explanation:

1% is ddk_dir, which is the installation directory of DDK.

2% is driver_drive, which is the drive letter of your working directory. Here is E:

3% is driver_dir, which is the path of your working directory. Here is E: \ pci9052demo.

4% indicates the compilation mode, checked indicates the debugging mode, and free indicates the release mode. Here is the problem, which will be discussed later.

The batch processing first checks the passed parameters, then calls the setenv command of DDK to set the environment variable, then changes the directory to the drive and directory where the source program is located, and finally calls build, -B ensures that all error messages are displayed.-W ensures that warnings are output on the screen. These errors and warnings are displayed 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. you can delete and add Win32 checked and Win32 free according to cant's windows WDM device driver development guide.

5. Change the settings in project> Settings of VC.

Modify the two configurations
========================================================== ==================================
Free
========================================================== ==================================
Build command line:
E: \ pci9052demo \Makedrvr%Ddkroot% E: e: \ pci9052demo free
 
Rebuild all opinions:
-Nmake/

Output Filename:
Pci9052demo. sys

Browse info file name:
Objfre \ i386 \ pci9052demo. BSC

========================================================== ==================================
Checked
========================================================== ==================================
Build command line:
E: \ pci9052demo \Makedrvr%Ddkroot% E: e: \ pci9052demo checked
 
Rebuild all opinions:
-Nmake/

Output Filename:
Pci9052demo. sys

Browse info file name:
Objfre \ i386 \ pci9052demo. BSC

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

After the settings are complete, the following error occurs during compilation:

Usage: setenv <directory> [fre | chk] [64] [Hal]
Example: setenv D: \ DDK chk set checked Environment
Example: setenv D: \ DDK set free environment (default)
Example: setenv D: \ DDK fre 64 sets 64 bit free environment
Example: setenv D: \ DDK Hal sets free Hal Environment
Example: setenv D: \ DDK fre Hal same
'Build 'is neither an internal or external command nor a program that can be run.
Or batch files.

Pci9052demo. sys-0 error (s), 0 warning (s)

What is the problem? The key lies in that the compiling mode of xp ddk is no longer free and checked, but FRE And chk above, and fre 64, Hal, and fre Hal are also added.

Solution: Change the compilation mode set in project-> Settings of VC to FRE And chk, and the output will be normal,

-------------------- Configuration: pci9052demo-Win32 fre --------------------
Build: object root set to :=> objfre
Build: adding/y to copycmd so xcopy ops won't hang.
Build:/I switch ignored
Build: Compile and link for i386
Build: loading D: \ winddk \ 2505 \ build. dat...
Build: computing include file dependencies:
Build: e: \ pci9052demo \ sources. Unexpected in directory with dirs File
Build: Ignoring E: \ pci9052demo \ sources.
Build: pci9052demo found in dirs., is not a subdirectory of E: \ pci9052demo
Build: Examining E: \ pci9052demo directory tree for files to compile.
E: \ pci9052demo
Build: Linking e: \ pci9052demo directory
Build: Done

Pci9052demo. sys-0 error (s), 0 warning (s)

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.