I have found a lot of information on the Internet. I believe there are many guys who prefer vc6.0 like me. Isn't the latest wdk really usable? Yes !!!
Before you start, you must clarify one thing. You can use wdk + notepad alone to develop a driver, which is irrelevant to the VC compiler consumption, it is used as a super notepad, which saves you the trouble of maintaining makefile by yourself and has various other conveniences of IDE.
1. After vc6 and dwk are installed, the sequence is irrelevant.
Find the wdk program directory from the Start Menu, go to "Windows XP checked build environment", and enter the command "build". Then, wdk will compile itself, which takes about 1 minute.
2. Set the include/lib/Executable Directory for vc6.
Set it to the various directories of the platform you want to compile. Make sure that ntddk. H is found for include, lib corresponds to include, and executable must be sure to find cl.exe.
For example, on the XP platform:
Include:
C: \ winddk \ 7600.16385.1 \ Inc \ DDK
C: \ winddk \ 7600.16385.1 \ Inc \ API
C: \ winddk \ 7600.16385.1 \ Inc \ CRT
The LIB Connection Library contains the following parts:
C: \ winddk \ 7600.16385.1 \ Lib \ wxp \ i386
C: \ winddk \ 7600.16385.1 \ Lib \ win7 \ i386
The execution file contains:
C: \ winddk \ 7600.16385.1 \ bin
C: \ winddk \ 7600.16385.1 \ bin \ x86
C: \ winddk \ 7600.16385.1 \ bin \ x86 \ x86
For the original paths of the VC, we recommend that you delete both include and Lib, while executable sets the top of your newly added paths. The sequence cannot be wrong. Its remaining suggestions are reserved. Although the driver does not use ml.exe‑link.exe in the bindirectory of vcss, the Code prompts and other functions of VC need to be completed by some programs in the bin directory. Therefore, at least the original bin directory of VC must be retained, but it must be after the DDK ).
3. Create an empty project, exe or DLL, and then directly modify the project properties:
There are a lot of places to change. It is better to record the text of each option. Clear the option text box under C/C ++ and link and fill in the text below.
C/C ++ options:
/Nologo/GZ/MLD/W3/wx/z7/OD/d Win32 = 100/D _ x86 _ = 1/D winver = 0x500/d dbg = 1
/FO "mydriver_check/"/FD "mydriver_check/"/FD/C
If the _ Try _ temporary t link is used in the program, the unresolved external symbol _ effect_handler4 error is returned.
Therefore, add the/GS-parameter here for reference.
Http://topic.csdn.net/u/20111225/19/4d34fffb-f57c-4183-a07d-7169f661fb04.html
Written:
/Nologo/GZ/MLD/W3/wx/z7/OD/d Win32 = 100/D _ x86 _ = 1/D winver = 0x500/d dbg = 1
/FO "mydriver_check/"/FD "mydriver_check/"/FD/GS-/C
Link options:
The NT driver is
Ntoskrnl. lib/nologo/base: "0x10000"/Stack: 0x400000,0x1000/entry: "DriverEntry"
/Subsystem: console/Incremental: No/PDB: "mydriver_check/helloddk. PDB "/map:" mydriver_check/helloddk. map "/debug/machine: i386/nodefaultlib/out:" mydriver_check/helloddk. sys"
/Subsystem: Native/driver/section: init, D/release/ignore: 4078
When referencing some functions, for example, kelowerirql should also add the corresponding library Hal. lib to it.
Ntoskrnl. Lib Hal. lib/nologo/base: "0x10000"/Stack: 0x400000,0x1000/entry: "DriverEntry"
/Subsystem: console/Incremental: No/PDB: "mydriver_check/helloddk. PDB "/map:" mydriver_check/helloddk. map "/debug/machine: i386/nodefaultlib/out:" mydriver_check/helloddk. sys"
/Subsystem: Native/driver/section: init, D/release/ignore: 4078
The WDM driver is
WDM. lib/nologo/base: "0x10000"/Stack: 0x400000,0x1000/entry: "DriverEntry"/subsystem: Console
/Incremental: No/PDB: "sys_check/hellowdm. PDB"/debug/machine: i386/nodefaultlib
/Out: "sys_check/hellowdm. sys"/subsystem: Native/driver/section: init, D/release/ignore: 4078
Of course, this setting is not static. For example, when obreferenceobjectbyname is used in the WDM driver
When ntoskrnl. Lib is added, because obreferenceobjectbynameis the ntoskrnl.exe export function, it will eventually become
WDM. Lib ntoskrnl. lib/nologo/base: "0x10000"/Stack: 0x400000,0x1000/entry: "DriverEntry"/subsystem: Console
/Incremental: No/PDB: "sys_check/hellowdm. PDB"/debug/machine: i386/nodefaultlib
/Out: "sys_check/hellowdm. sys"/subsystem: Native/driver/section: init, D/release/ignore: 4078
4. Save the configuration. Now create a c file for this empty project and copy the following content:
# Include <ntddk. h>
Ntstatus DriverEntry (
In pdriver_object driverobject,
In punicode_string registrypath
)
{
Ntstatus status = status_unsuccessful;
Return status;
}
After compilation, the configuration is successful !!!