標籤:
?
Mark offers some third party utilities. That‘s good, but I will show a more handy way (IMHO): how to configure and use Visual Studio for compiling drivers.?
Have Fun
- Setup Visual Studio 2008.
- Setup DDK (WDK).
- Add to VS paths DDK include files, libs and bins.
- Create new empty "Win32 project" and add source file (i.e.?HelloWorld.c).
- Configure project properties (All Configurations):
- C\C++ - General - Debug Information Format = Program Database (/Zi)
- C\C++ - Preprocessor - Preprocessor Definitions = _X86_ [add also DBG for Debug config]
- C\C++ - Code Generation - Enable C++ Exceptions = No
- C\C++ - Code Generation - Basic Runtime Checks = Default
- C\C++ - Code Generation - Buffer Security Check = No?(/GS-)
- C\C++ - Advanced - Calling Convention = __stdcall (/Gz)
- C\C++ - Advanced - Compile As = Compile as C Code (/TC) [if you are going to use plain C]
- Linker - General - Output File =?$(OutDir)\$(ProjectName).sys
- Linker - General - Enable Incremental Linking = Default
- Linker - Input - Additional Dependencies =?ntoskrnl.lib hal.lib $(NOINHERIT)?[add needed libs here e.g.?ntoskrnl.lib hal.lib]
- Linker - Input - Ignore All Default Libraries = Yes (/NODEFAULTLIB)
- Linker - Manifest File - Generate Manifest = No
- Linker - System - SubSystem = Native (/SUBSYSTEM:NATIVE)
- Linker - System - Driver = Driver (/DRIVER)
- Linker - Advanced - Entry Point = DriverEntry
- Linker - Advanced - Base Address = 0x10000
- Linker - Advanced - Randomized Base Address = Disable (/DYNAMICBASE:NO)
(應該為預設值)
- Linker - Advanced - Data Execution Prevention?(DEP) = Disable (/NXCOMPAT:NO)
(應該為預設值)
?
- OK. Done. Now you can test it with simple code, e.g.:
Hide???Copy Code
#include"ntddk.h"
?
NTSTATUS
DriverEntry(PDRIVER_OBJECT DriverObject,PUNICODE_STRING
RegistryPath)
{
return STATUS_UNSUCCESSFUL;
}
VS2008+Windows DDK 7的環境配置