WDK版本为7600.16385.1,本例中WDK安装在C:\WinDDK上
一、驱动check版本,也即Debug版本的设置
1.使用 “开始菜单+Pause” 快捷键,或右键 我的电脑-->属性-->高级-->
环境变量-->Administrator的用户变量,设置:
WDKPATH=C:\WinDDK\7600.16385.1
2.用VS20128创建一个Win32控制台应用程序,勾选 Additional options: Empty project
3.将编写好的源代码文件导入项目,右键 项目名 选择 Add-->Existing Item
4.修改项目属性,右键 项目名 选择 Properties-->Configuration Properties
(1)
C/C++-->General:
Debug Information Format = C7 Compatible (/Z7)
Warning Level = Level 4 (/W4)
C/C++-->Preprocessor:
Preprocessor Definitions = WIN32=100;_X86_=1;WINVER=0x500;DEG=1
Ignore Standard Include Path = Yes(/X)
C/C++-->Code Generation:
Enable Minimal Rebuild = No
Basic Runtime Checks = Default
Runtime Library = Multi-threaded Debug (/MTd)
Security Check = No (/GS-)
C/C++-->Advanced:
Calling Convention = __stdcall (/Gz)
Compile As = Compile as C Code (/TC)
(2)
Linker-->General:
Output File = $(OutDir)$(TargetName).sys
Enable Incremental Linking = No (/INCREMENTAL:NO)
Additional Library Directories = $(WDKPATH)\lib\wxp\i386
Linker-->Input:
Additional Dependencies = ntoskrnl.lib;wdm.lib;fltlib.lib;fltMgr.lib
Ignore All Default Libraries = Yes (/NODEFAULTLIB)
Linker-->Manifest File:
Generate Manifest = No
Enable User Account Control (UAC) = No
Linker-->Debugging:
Generate Map File = Yes (/MAP)
Map File Name = $(TargetDir)$(TargetName).map
Linker-->System:
SubSystem = Native (/SUBSYSTEM:NATIVE)
Stack Reserve Size = 4194304
Stack Commit Size = 4096
Driver = Driver (/DRIVER)
Linker-->Advanced:
Entry Point = DriverEntry
Set Checksum = No
Base Address = 0x10000
Randomized Base Address = Yes (/DYNAMICBASE)
Data Execution Prevention (DEP) = Yes (/NXCOMPAT)
Target Machine = MachineX86 (/MACHINE:X86)
Linker-->Command Line:
设置该项可以避免以下错误提示:
LINK : warning LNK4078: multiple 'INIT' sections found with different attributes (E2000020)
LINK : error LNK2001: 无法解析的外部符号__load_config_used
5.右键单击项目,选择 Rebuild
二、驱动free版本,也即Release版本的设置
右键 项目名 选择 Properties-->Configuration Properties
(1)
C/C++-->General:
Additional Include Directories = $(WDKPATH)\inc\ddk;
$(WDKPATH)\inc\api;$(WDKPATH)\inc\crt
Debug Information Format = Program Database (/Zi)
Warning Level = Level 4 (/W4)
C/C++-->Preprocessor:
Preprocessor Definitions = WIN32=100;_X86_=1;WINVER=0x500;DEG=1
Ignore Standard Include Path = Yes(/X)
C/C++-->Code Generation:
Enable Minimal Rebuild = Yes (/Gm)
Basic Runtime Checks = Default
Runtime Library = Multi-threaded (/MT)
Security Check = No (/GS-)
Enable Function-Level Linking = Yes (/Gy)
C/C++-->Advanced:
Calling Convention = __stdcall (/Gz)
Compile As = Compile as C Code (/TC)
(2)
Linker-->General:
Output File = $(OutDir)$(TargetName).sys
Enable Incremental Linking = No (/INCREMENTAL:NO)
Additional Library Directories = $(WDKPATH)\lib\wxp\i386
Linker-->Input:
Additional Dependencies = ntoskrnl.lib wdm.lib fltlib.lib fltMgr.lib
Ignore All Default Libraries = Yes (/NODEFAULTLIB)
Linker-->Manifest File:
Generate Manifest = No
Enable User Account Control (UAC) = No (/MANIFESTUAC:NO)
Linker-->Debugging:
Generate Debug Info = No
Generate Map File = Yes (/MAP)
Map File Name = $(TargetDir)$(TargetName).map
Linker-->System:
SubSystem = Native (/SUBSYSTEM:NATIVE)
Stack Reserve Size = 4194304
Stack Commit Size = 4096
Driver = Driver (/DRIVER)
Linker-->Advanced:
Entry Point = DriverEntry
Set Checksum = Yes (/RELEASE)
Base Address = 0x10000
Randomized Base Address = Yes (/DYNAMICBASE)
Data Execution Prevention (DEP) = Yes (/NXCOMPAT)
Target Machine = MachineX86 (/MACHINE:X86)
Linker-->Command Line:
Additional options = /SECTION:INIT,D /IGNORE:4078 /safeseh:no
设置该项可以避免以下错误提示:
LINK : warning LNK4078: multiple 'INIT' sections found with different attributes (E2000020)
LINK : error LNK2001: 无法解析的外部符号__load_config_used