Reprinted Please note: Panshi software-http://panshisoft.cn/dirchanger.htm
Vc6 is just an IDE that can easily call compilers, connectors, header files, library files. If the editing and compilation drivers can be integrated, this can improve development efficiency.
For common Win32 applications, vc6 has been supported by default, but there is no set engineering wizard for the driver. In fact, the driver is also a sys, which is written in C language. Therefore, it is theoretically correct to compile it, but it is a little troublesome in actual operations.
The following describes how to compile the SYS driver on various platforms (including 64-bit platforms)
First, let's look at the 32-bit version driver compilation method. First, you have to prepare some necessary compilation tools:
1. Install vc6
2. Install DDK? This problem is actually very simple, but many people do not understand it. Of course, the better the DDK is to be installed, the more platforms the new supports. For example, you cannot compile 64-bit sys for 2000ddk, because it does not contain 64-bit libraries and compilers, we chose the latest one, 2003ddk (wdk is also supported). Many supported platforms, including amd64, IA64, 2000, XP, 2003 ).
Now, our system has installed the most powerful development tool vc6, the latest DDK, and compiling the drivers for each platform in VC is okay!
Assume that our DDK is installed in C:/2003ddk.
Directory, then I will find a lot of examples of the driver (select all when installing), we choose C:/2003ddk/src/WDM/USB/bulkusb
As an example of our experiment.
Step 1:
Open VC and create a Win32 Application
Project, and then select an empty project
(I use the English version of VC. I suggest you replace it with the English version), which means creating an empty Win32 project.
The project name is bulkusb. Click Finish.
Step 2:
Change C:/2003ddk/src/WDM/USB/bulkusb/sys
(Here is the driver code, and the other EXE is the user program, regardless of it) all the files in the copy to the bulkusb project directory. Then, set. H,. C,. RC
Import it to the corresponding directory in VC.
Step 3:
Then, set the project options and compile the code into sys.
. To compile, we need DDK, so we need to go to the tool-> options-> directories of VC first.
Set some paths for VC call (set the basic principle: make sure all the following paths are at the top!
).
Set the include path:
C:/2003ddk/INC
C:/2003ddk/INC/CRT
C:/2003ddk/INC/wnet
C:/2003ddk/INC/DDK/wnet
C:/2003ddk/INC/DDK/WDM/wnet
In this order. Do you have the wnet directory here? This is the latest header file of 2003. In fact, you can select the wxp or w2k directory, but the header file in wnet is the most comprehensive, because the system keeps improving, some new APIs are only defined in the new header file. Of course, it is best to select the corresponding header file to compile the driver of the corresponding system, but I have tried to use the driver compiled by wnet in 2000, because we generally do not use the newly added APIs ..
Set the Lib path:
C:/2003ddk/lib
C:/2003ddk/lib/CRT/i386
C:/2003ddk/lib/wnet/i386
// The wnet principle is the same as above
Set executable file:
C:/2003ddk/bin/x86
// The Compiler's example contains the directory cl.exeand link.exe. We need to compile the 32-bit driver, so add the file to it and put it in the first item.
.
In general, as long as you set the include, Lib, and compiler, it is okay to compile any files. You can also try to install the latest 2003sdk and compile the Win32 application to 64-bit.
Step 4:
Start to enter the Project Settings, first set C/C ++
In preprocesser Definitions
Enter the following string:
Input in release:
_ X86 _ = 1, i386 = 1, std_call, Win32 = 100, _ win32_winnt = 0x0501, winver = 0x0501, ndebug
Debug input:
_ X86 _ = 1, i386 = 1, std_call, Win32 = 100, _ win32_winnt = 0x0501, winver = 0x0501, _ debug
In code generation
Calling convention in
Use _ stdcall,
(This is required by the driver)
Debug has a special compilation option/GZ
(Note that it is in upper case. Do not delete it in lower case !) Delete the chkesp file. Otherwise, the chkesp file cannot be connected.
Step 5:
Start setting Link
Page to change the output file name to the Sys extension,
In general
Object/library modules
, Fill in the Lib called by the driver:
Ntoskrnl. Lib Hal. Lib usbd. Lib wmilib. Lib
.
Then enter output
In entry-point symbol
:
Enter DriverEntry
The following figure shows options for the project.
ManualAdd
Copy the following link options:
/Machine: ix86/driver/subsystem: Native/section: init, D/ignore: 4198,4010, 4037,4039, 4065,4070, 4078,4087, 4089,4221
Delete the following options:
/Subsystem: Windows
/Machine
Indicates the target machine type,/driver
Represents the driver,/subsystem: Native
It also represents the driver.
OK. We can compile the 32-bit driver!
What if we want to compile a 64-bit driver? Note that there are two types of 64-bit: amd64 and IA64. You need to select your target platform. Currently, amd64 is the most popular platform.
In fact, compiling to 64-bit is also very simple. You just need to change the 32-bit configuration a little. Let's take compiling the amd64-bit driver as an example (you will copy the project Mappings of VC
Replace the 32-bit relase and debug copies with releaseamd64.
And debugamd64
And then modify it based on the copy ):
1. Modify two lib paths:
C:/2003ddk/lib/CRT/i386
Change to: C:/2003ddk/lib/CRT/amd64
C:/2003ddk/lib/wnet/i386
Change to: C:/2003ddk/lib/wnet/amd64
2. Modify the compiler path:
C:/2003ddk/bin/x86
Changed:
C:/2003ddk/bin/win64/x86/amd64
C:/2003ddk/bin/x86
// This sentence also exists
3. Modify C/C ++
Preprocesser definitions in
Is:
Releaseamd64 input:
_ Amd64 _, amd64, std_call, Win32 = 100, _ win32_winnt = 0x0501, winver = 0x0501, ndebug
Debugamd64 input:
_ Amd64 _, amd64, std_call, Win32 = 100, _ win32_winnt = 0x0501, winver = 0x0501, _ debug
4. link needs to be modified
Project Options on the page
Manually change:/machine: ix86
Changed to:/machine: amd64
5. In theory, the setting is OK here, but there is still a link error unresolved external symbol _ security_cookie. You only need to add bufferoverflowk. lib to the link Lib.
(Why is bufferoverflowk. Lib? Here: http://support.microsoft.com/kb/894573
. Download the modified engineering example:
.
Most of the above settings can be saved in the VC project file (*. DSP), in addition to the set include path, lib path and compiler path, these paths are global and will be left when other projects are opened, it will cause trouble to compile the application, and you need to change it back one by one, while the directory Switch
It was developed to quickly switch these paths.
Usage:
Main toolbar:
Set the path such as the compiler: (five types of configuration are available by default, vc6 is the default, 32 is the driver, 64 is the driver, 32 bit application, 64 bit Application)
Use these five configurations (very simple, just click the corresponding button ):
Additional features: (the XP button makes the compiled program have an XP style, so it's cool! After you click it, The vc6 dialog box will pop up. You must click "yes". If you do not click it, you do not need to click it. ^ _ ^)
Comparison of XP style: