VS2010编译驱动设置
2010-04-28 16:00
323 查看
How to configure Visual Studio 2010 for compiling drivers
一. Setup Visual Studio 2010
二. Setup DDK (WDK)
三. Add to VS pathes to DDK include files, libs and bins.
四. Create new empty "Win32 project" and add source file (i.e. HelloWorld.c).
五. Configure project properties (All Configurations)
5.1. C/C++ - General - Debug Information Format = Program Database (/Zi)
5.2. C/C++ - Preprocessor - Preprocessor Definitions = _X86_ [add also DBG for Debug config]
【WIN32;_DEBUG;_X86_;i386;STD_CALL;CONDITION_HANDLING;WIN32_LEAN_AND_MEAN;NT_UP;SRVDBG;DBG;_IDWBUILD;_WIN32_WINNT=0x0400;%(PreprocessorDefinitions)】
5.3. C/C++ - Code Generation - Enable C++ Exceptions = No
5.4. C/C++ - Code Generation - Basic Runtime Checks = Default
5.5. C/C++ - Code Generation - Buffer Security Check = No (/GS-)
5.6. C/C++ - Advanced - Calling Convention = __stdcall (/Gz)
5.7. C/C++ - Advanced - Compile As = Compile as C Code (/TC) [if you are going to use plain C]
5.8. Linker - General - Output File = $(OutDir)/$(ProjectName).sys
5.9. Linker - General - Enable Incremental Linking = Default
5.10. Linker - Input - Additional Dependencies = ntoskrnl.lib hal.lib $(NOINHERIT) [add here needed libs here e.g. ntoskrnl.lib hal.lib]
【不知道上面是不是笔误,应该为:ntoskrnl.lib;hal.lib;%(AdditionalDependencies)】
5.11. Linker - Input - Ignore All Default Libraries = Yes (/NODEFAULTLIB)
5.12. Linker - Manifest File - Generate Manifest = No
5.13. Linker - System - SubSystem = Native (/SUBSYSTEM:NATIVE)
5.14. Linker - System - Driver = Driver (/DRIVER)
5.15. Linker - Advanced - Entry Point = DriverEntry
5.16. Linker - Advanced - Base Address = 0x10000
5.17. Linker - Advanced - Randomized Base Address = Disable (/DYNAMICBASE:NO)
【这个也是错误的:应该置空】
5.18. Linker - Advanced - Data Execution Prevention (DEP) = Disable (/NXCOMPAT:NO)
【这个也是错误的:应该置空】
六. Config VC++ Directories
6.1 Open Open up property manager by clicking on Menu View->Property Manager.
6.2 Expand the project node and then the Configuration|Platform nodes, you will see "Microsoft.cpp.<Platform>.users" file for each Configuration|Platform. These are the files for the global settings, similar to the old tools/Options/VC++ Directories.
6.3 Multi-Select "Microsoft.cpp.<Platform>.users", right click and bring up the property page window
6.4 In the property page window, click on "VC++ Directories" (for example) in the left pane, add new paths for the directories such as "Include Directories". separated by semicolons
(eg:Include Directories config As:
$(ddkroot)/INC
$(ddkroot)/INC/WNET
$(ddkroot)/INC/DDK/WNET
Library Directories config As:
$(ddkroot)/LIB/WNET/I386
)
6.5 Make sure to save the settings before shutting down Visual Studio.
6.6 Re-launch Visual Studio and the new settings will be in effect.
6.7 Note: If you would like to only change the settings for one project, you can right click on the project and bring up the property page. Change the settings for “VC++ Directories”, these settings will be persisted to the project file.
七. OK. Have done. Now you can test it with simple code, e.g.:
#include "ntddk.h"
NTSTATUS
DriverEntry(PDRIVER_OBJECT DriverObject,PUNICODE_STRING RegistryPath)
{
return STATUS_UNSUCCESSFUL;
}
一. Setup Visual Studio 2010
二. Setup DDK (WDK)
三. Add to VS pathes to DDK include files, libs and bins.
四. Create new empty "Win32 project" and add source file (i.e. HelloWorld.c).
五. Configure project properties (All Configurations)
5.1. C/C++ - General - Debug Information Format = Program Database (/Zi)
5.2. C/C++ - Preprocessor - Preprocessor Definitions = _X86_ [add also DBG for Debug config]
【WIN32;_DEBUG;_X86_;i386;STD_CALL;CONDITION_HANDLING;WIN32_LEAN_AND_MEAN;NT_UP;SRVDBG;DBG;_IDWBUILD;_WIN32_WINNT=0x0400;%(PreprocessorDefinitions)】
5.3. C/C++ - Code Generation - Enable C++ Exceptions = No
5.4. C/C++ - Code Generation - Basic Runtime Checks = Default
5.5. C/C++ - Code Generation - Buffer Security Check = No (/GS-)
5.6. C/C++ - Advanced - Calling Convention = __stdcall (/Gz)
5.7. C/C++ - Advanced - Compile As = Compile as C Code (/TC) [if you are going to use plain C]
5.8. Linker - General - Output File = $(OutDir)/$(ProjectName).sys
5.9. Linker - General - Enable Incremental Linking = Default
5.10. Linker - Input - Additional Dependencies = ntoskrnl.lib hal.lib $(NOINHERIT) [add here needed libs here e.g. ntoskrnl.lib hal.lib]
【不知道上面是不是笔误,应该为:ntoskrnl.lib;hal.lib;%(AdditionalDependencies)】
5.11. Linker - Input - Ignore All Default Libraries = Yes (/NODEFAULTLIB)
5.12. Linker - Manifest File - Generate Manifest = No
5.13. Linker - System - SubSystem = Native (/SUBSYSTEM:NATIVE)
5.14. Linker - System - Driver = Driver (/DRIVER)
5.15. Linker - Advanced - Entry Point = DriverEntry
5.16. Linker - Advanced - Base Address = 0x10000
5.17. Linker - Advanced - Randomized Base Address = Disable (/DYNAMICBASE:NO)
【这个也是错误的:应该置空】
5.18. Linker - Advanced - Data Execution Prevention (DEP) = Disable (/NXCOMPAT:NO)
【这个也是错误的:应该置空】
六. Config VC++ Directories
6.1 Open Open up property manager by clicking on Menu View->Property Manager.
6.2 Expand the project node and then the Configuration|Platform nodes, you will see "Microsoft.cpp.<Platform>.users" file for each Configuration|Platform. These are the files for the global settings, similar to the old tools/Options/VC++ Directories.
6.3 Multi-Select "Microsoft.cpp.<Platform>.users", right click and bring up the property page window
6.4 In the property page window, click on "VC++ Directories" (for example) in the left pane, add new paths for the directories such as "Include Directories". separated by semicolons
(eg:Include Directories config As:
$(ddkroot)/INC
$(ddkroot)/INC/WNET
$(ddkroot)/INC/DDK/WNET
Library Directories config As:
$(ddkroot)/LIB/WNET/I386
)
6.5 Make sure to save the settings before shutting down Visual Studio.
6.6 Re-launch Visual Studio and the new settings will be in effect.
6.7 Note: If you would like to only change the settings for one project, you can right click on the project and bring up the property page. Change the settings for “VC++ Directories”, these settings will be persisted to the project file.
七. OK. Have done. Now you can test it with simple code, e.g.:
#include "ntddk.h"
NTSTATUS
DriverEntry(PDRIVER_OBJECT DriverObject,PUNICODE_STRING RegistryPath)
{
return STATUS_UNSUCCESSFUL;
}
相关文章推荐
- VS2010下写驱动和MFC,设置及编译问题
- VS2010 编译驱动设置
- 在VS2010中集成QT + Qt4.8.2编译MYSQL驱动
- VS2012 ddk驱动编译与虚拟机联机调试设置
- VS2012 ddk驱动编译与虚拟机联机调试设置 .
- VS2005编译DDK驱动的选项设置
- 设置编译内核lib驱动及应用层dll的source文件 推荐
- vs2010编译参数设置
- VS2010中编译openssl的步骤和使用设置
- VS2010 MFC中 静态编译设置方法
- VS2010中编译openssl的步骤和使用设置
- VS2010中编译openssl的步骤和使用设置
- OJ 调试技巧:VS2010 中 通过设置编译参数定义宏,无需修改源文件重定向标准输入输出
- VS2010编译Mongodb C++驱动
- vs2010 下 当前项目调试编译失败时,设置不启动上一次成功的实例
- VS2010 减小编译大小的设置
- OJ 调试技巧:VS2010 中 通过设置编译参数定义宏,无需修改源文件重定向标准输入输出
- 设置编译内核lib驱动及应用层dll的source文件
- VS2005编译DDK驱动的所有项目设置
- 【MATLAB】matlabR2010a与vs2010联合编译设置