`
yexin218
  • 浏览: 958124 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
社区版块
存档分类
最新评论

WDK+Visual Studio 2008配置编译驱动

阅读更多

Introduction 

As it is known, Microsoft officially doesn't support integration of DDK with Visual Studio (any version). So we can use the Visual Studio editor (or any other text editor) for developing the source codes of a driver, but for compiling we should use the DDK build utility. Of course it is not very convenient because we must always switch between editor and console window, but the worst thing is that the developer must spend a lot of time to find lines with errors in the editor.

Background 

There are several ways to compile drivers with Visual Studio. You can find most of them in the nice Mark Roddy article, Windows Driver Build Methods and Tools .

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

  1. Setup Visual Studio 2008.

  2. Setup DDK (WDK).

  3. Add to VS paths DDK include files, libs and bins.

  4. Create new empty "Win32 project" and add source file (i.e. HelloWorld.c ).

  5. Configure project properties (All Configurations):

    1. C\C++ - General - Debug Information Format = Program Database (/Zi )
    2. C\C++ - Preprocessor - Preprocessor Definitions = _X86_ [add also DBG for Debug config]
    3. C\C++ - Code Generation - Enable C++ Exceptions = No
    4. C\C++ - Code Generation - Basic Runtime Checks = Default
    5. C\C++ - Code Generation - Buffer Security Check = No (/GS -)
    6. C\C++ - Advanced - Calling Convention = __stdcall (/Gz )
    7. C\C++ - Advanced - Compile As = Compile as C Code (/TC) [if you are going to use plain C]
    8. Linker - General - Output File = $(OutDir)\$(ProjectName).sys
    9. Linker - General - Enable Incremental Linking = Default
    10. Linker - Input - Additional Dependencies = ntoskrnl.lib hal.lib $(NOINHERIT) [add needed libs here e.g. ntoskrnl.lib hal.lib ]
    11. Linker - Input - Ignore All Default Libraries = Yes (/NODEFAULTLIB )
    12. Linker - Manifest File - Generate Manifest = No
    13. Linker - System - SubSystem = Native (/SUBSYSTEM:NATIVE )
    14. Linker - System - Driver = Driver (/DRIVER )
    15. Linker - Advanced - Entry Point = DriverEntry
    16. Linker - Advanced - Base Address = 0x10000
    17. Linker - Advanced - Randomized Base Address = Disable (/DYNAMICBASE:NO )
    18. Linker - Advanced - Data Execution Prevention (DEP) = Disable (/NXCOMPAT:NO )
  6. OK. Done. Now you can test it with simple code, e.g.:

  7. #include "ntddk.h"
    
    NTSTATUS
    DriverEntry(PDRIVER_OBJECT DriverObject,PUNICODE_STRING
    RegistryPath)
    {
    return STATUS_UNSUCCESSFUL;
    }

    About the Author

    Andrey Sergienko
  8. From:  http://www.codeproject.com/KB/winsdk/vs2008_and_drivers.aspx

找到一个中文版的:

 

1、现在要让Visual Studio 2008 能够编译驱动 程序,步骤如下:

(1) 打开VS2008 ,单 击工具 ——>选项 ;在选项的列表栏选择项目和解决方案 ——>C++目录 ;在左侧的显示以下内容的项目 中 先选择包含文件 ,并在下面新建D:\WinDDK \6001.18002\inc\api和D:\WinDDK\6001.18002\inc\ddk两个路径(注意:D:\请替换成你WDK的安装目录 );然后再在显示以下内容的项目 中选择库文件,在下面添加D:\WinDDK\6001.18002\lib \wxp\i386(注意:D:\请替换成你WDK的安装目录 )。

(2) 接下来是每次创建项目都需要做的。先创建一个项目,在项目生成后点击项 目 ——>(项目名)属性 ,点击配置管理器 ,并在配置管理器 中 新建一个名为Free的配置(新建时从Release复制配置);之后在属性页的右侧选择配置属性 ——>C/C++ ——>高级 ,调用约定改为 __stdcall(/Gz);再在属性页的右侧选择配置属性 ——>链接器 ,在常规 中把输出文件 改 为$(OutDir)\$(ProjectName).sys,在清单 文件 中把启用用户账户控制(UAC) 改为 否(这就是VS2008 中新增加的特性),在优化 中将链接时间代码生成 改 为默认值,在高级 中将随机地址 改为默认值(这也是VS2008 中 新增加的特性),最后在命令行 中输入:

ntoskrnl.lib
/base:"0x10000"
/entry:"DriverEntry"
/subsystem:native
/nologo
/stack:0x400000,0x1000
/incremental:no
/nodefaultlib

 

原文来自: http://flyxxtt.blogbus.com/logs/42680411.html

分享到:

相关推荐

    VS2008编译驱动程序的配置方法

    编译驱动程序的常用方法有两种,一种是通过WDK/DDK的COMMAND环境进行编译,另外一种是通过...通过Visual Studio编译驱动程序需要对其进行相关配置,本文以VS2008和WDK7600为例,讲解了实现编译驱动程序的配置方法。

    FindWDK:CMake模块,用于使用Windows开发工具包(WDK)构建驱动程序

    Visual Studio 2015及更高版本 CMake 3.0及更高版本 用法 将FindWDK添加到模块搜索路径,然后调用find_package : list ( APPEND CMAKE_MODULE_PATH "<path>" ) find_package (WDK REQUIRED ) FindWDK将搜索已...

    虚拟鼠标驱动程序源代码

    本资源包含 虚拟鼠标驱动程序源代码 及 最新...安装SDK成功后,可在Visual Studio 2017下成功编译(Visual Studio 2012,Visual Studio 2015也可以)。 编译成功后,请将Driver.inf 及 Driver.sys拷贝到虚拟机下调试。

    虚拟驱动程序源代码

    本资源包含 虚拟鼠标 及 键盘驱动程序源代码 及...安装SDK成功后,可在Visual Studio 2017下成功编译(Visual Studio 2012,Visual Studio 2015也可以)。 编译成功后,请将Driver.inf 及 Driver.sys拷贝到虚拟机下调试。

    CharSample_VS2019_Win7(32).rar

    安装 wdksetup.exe 时必须将安装 WDK Visual Studio 扩展。 必须完成此操作,才能使 WDK VS 集成正常工作 Win7虚拟机必须安装.NET运行环境(dotNetFx40_Full_setup.exe)和vc运行时库(vc_redist.x86_2019.exe)。 程序...

    《Windows内核安全与驱动开发》随书光盘iso镜像版

    source目录下的fir.sln文件为工程的解决方案文件,读者可以使用Visual Studio 2005开发工具打开fir.sln文件,fir.sln内的部分工程可以直接在IDE环境中编译,部分工程需要读者使用WDK的build命令进行编译。...

    Windows内核安全与驱动开发_随书光盘

    source目录下的fir.sln文件为工程的解决方案文件,读者可以使用Visual Studio 2005开发工具打开fir.sln文件,fir.sln内的部分工程可以直接在IDE环境中编译,部分工程需要读者使用WDK的build命令进行编译。...

    用于驱动程序手动映射的UEFIbootkit_C_下载

    \n例如:umap test.sys\n编译\n和项目都可以使用标准 Visual Studio 编译(使用 WDK for mapper)。请记住,任何更改都必须在其相应的 bootkit 资源中更新。也可以只替换为自己的驱动程序(确保撤消 bootkit 挂钩)...

    ZFSin:Windows端口上的OpenZFS

    主机(运行Visual Studio和内核调试器) 目标(运行编译的内核模块) VM映像随Visual Studio 2017一起提供,我们使用它来编译驱动程序。 建议将VM放在静态IP上,因为它们可以在所有崩溃时更改IP,并且您必须再次...

    dokanx:Windows用户模式文件系统框架

    Visual Studio 2013解决方案文件与makefile和ddkbuild一起提供,因此您可以更轻松地进行构建。 所有Dokan库dll代码均已在C ++中重新编译 对驱动程序使用预编译的头文件,从而使构建速度更快。 Usermode文件系统...

    umap:UEFI引导程序包,用于驱动程序手动映射

    ap Windows UEFI引导程序包,可在不使用UEFI...mapper和umap项目都可以使用标准Visual Studio(带有WDK的mapper )进行编译。 请记住,对mapper任何更改都必须在其相应的bootkit资源中进行更新。 也可以用自己的驱动程

    Windows x64内核模块-HelloWorld

    Windows内核安全与驱动开发书的第一个示例程序,在新版本开发环境中调试通过,使用Visual Studio 2017加上WDK 1803环境编译。在调试过程中,由于x64驱动程序禁止使用嵌入汇编,采用Shellcode方式进行软件中断调用,...

    NetDriver:可以发送和接收HTTP请求的内核模式TDI客户端

    NetDriver 可以发送和接收HTTP请求的内核模式TDI客户端使用Visual Studio 2013编译要编译驱动程序,请安装WDK 8.1

    HID类USB设备读写测试程序

    针对HID类USB设备的读写测试程序。...然后就会弹出对话框。 可执行程序在Release文件夹中。里面我放了WDK中微软提供的usbview.... 本程序在Visual Studio 2005.NET中编译,如果没有该版本的话建议自己构建一下环境。

    KernelModeMonitor:内核模式驱动程序和用户模式应用程序通信项目

    模拟Microsoft的WinObj工具模块:列出加载的模块(.dll和.sys文件) 驱动程序对象:列出目录对象内的所有驱动程序VS版本使用Visual Studio 2013 Ultimate和WDK(Windows驱动程序工具包)版本8.1编译项目。...

    基于virtualBox,python,windows platform sdk等编写的安卓模拟器+源代码+文档说明

    Visual Studio 2010 with service pack 1. Windows Driver Development Kit (WDK) V7.1 Python 2.7.x Git VirtualBox 其中需求的许多库,Minw QT CURL OpenSSL已经附带 ### 1.3 下载源码 ### 1.4 编译源码 ...

    Vanguard:官方Vanguard反作弊源代码

    先锋队官方Vanguard反作弊源... 使用Visual Studio 2019和WDK,您应该能够毫无问题地构建它。 确切的说明留给读者练习。PS不起作用? 确保已安装并正在运行vgk.sys。 如果您已经是VALORANT播放器,则会自动为您设置。

    xmake:on基于Lua的跨平台构建实用程序

    它可以像Make / Ninja这样直接编译项目,也可以像CMake / Meson这样生成项目文件,并且它还具有内置的程序包管理系统来帮助用户解决C / C ++依赖库的集成使用。 如果您想了解更多信息,请参阅: , 和 ,也欢迎加入...

Global site tag (gtag.js) - Google Analytics