在 VS 2008 内开发驱动程序的 “解决方案” 的编译链接选项的设置
I’ll give you what I found, but all I can say is don’t do it.
There are always problems linking one version of the CRT against a version of a compiler that it wasn’t written for.
Create a win32 DLL project.
C/C++ settings for VC2008
-
General
Additional Include Directories:
C:\WINDDK\2600\inc\wxp
C:\WINDDK\2600\inc\ddk\wxp
C:\WINDDK\2600\inc\ddk\wdm\wxp
C:\WINDDK\2600\inc\crt
Debug Information Format : Program Database (/Zi) -
Optimization
Enable Intrinsic Functions: Yes (/Oi) … To avoid the memcmp compile error. -
Preprocessor
Preprocessor Definitions:
_X86_=1
i386=1
_WIN32_WINNT=0×0501
WINVER=0×0501
WIN32_LEAN_AND_MEAN=1 … dont know if this does much for a device driver
Ignore Standard Include Path:Yes (/X) -
Code Generation
Enable C++ Exceptions:No … no exception handling in the kernel!
Buffer Security Check:No (/GS-) … linker error if set to Yes
Basic runtime Checks: Default -
Advanced
Calling Convention:__stdcall (/Gz) -
Language
Enable Run-Time Type Info:No (/GR-) … linker error if set to Yes
Linker settings for VC2008
-
Input
Additional Dependencies:int64.lib ntoskrnl.lib hal.lib … etc.
Ignore All Default Libraries:Yes (/NODEFAULTLIB) -
Manifest File
Generate Manifest:No -
System
SubSystem:Native (/SUBSYSTEM:NATIVE)
Driver:Driver (/DRIVER) -
Advanced
Base address:0×10000
Entry Point:DriverEntry
Target Machine:MachineX86 (/MACHINE:X86)
Randomized Base Address:Default
Data Execution Prevention (DEP) : default -
General
Additional Library Directories:C:\WINDDK\2600\lib\wxp\i386
Enable Incremental linking: No (/INCREMENTAL:NO)
Output file: $(OutDir)\$(ProjectName).sys -
Command line
add there /safeseh:no option
You change the paths to your paths obviously, but this is what the original poster said worked.
相关连接:
http://alter.org.ua/en/docs/nt_kernel/vc6_to_vc8/
http://alter.org.ua/en/docs/nt_kernel/vc6_proj/
VS2008 头文件和库文件目录的设置, 在编译驱动时, 将 WDK 相关的头文件和库文件如下图所示在搜索顺序中置顶(由于 WDK(DDK) 头文件与 SDK 头文件并不完全兼容, 不能混用, 因此在不再编译驱动时, 将其置底, 在这一点上, MS 做的比 GCC 要差, WinGW 就能够混用):


或者, 在 “我的电脑” -> “属性” -> “高级” -> “环境变量” 内添加一条: 变量名=BASEDIR 变量值=D:\WinDDK\7600.16385.1, 然后用 quicksys 创建工程, 然后用 VS 2008 打开编译.

Exported-2010-02-28
例子工程
hellosys
附录: VC6 的驱动编译环境设置


一些资源:
How to Get the WDK
Windows Driver Kit Version 7.1.0
修改版的 QuickSys 在这里 QuickSYS
DDKWizard homepage
windows 2000 NTDDK
windows XP DDK(支持 VC 6)
修改后的山寨版 ntifs.h 和 原始山寨版 ntifs.h
old sfilter
sfilter 流程浅析 以及配套代码 sfilter better — crypfile
romfs-15
filedisk-17

近期评论