/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
如果是在程序中使用了 __try __except 链接的时候会报错 unresolved external symbol __except_handler4
所以在这里还要加上/GS- 参数 此参数可以参考帖子
http://topic.csdn.net/u/20111225/19/4d34fffb-f57c-4183-a07d-7169f661fb04.html
最终写成:
/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
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
在引用一些函数的时候 比如KeLowerIrql还应该把相应的库hal.lib 加入其中
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
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
当然也不是一成不变的这样设置 比如在WDM驱动中用到ObReferenceObjectByName的时候就应该
加上ntoskrnl.lib 因为ObReferenceObjectByName是ntoskrnl.exe的导出函数 所以最终变成
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