visual-studio 如何使用 Visual Studio 构建驱动程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1037343/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:41:56  来源:igfitidea点击:

how can i build a driver using visual studio?

visual-studiodriverwdk

提问by

does anyone have an article how to do this ?

有没有人有一篇文章如何做到这一点?

回答by 0xC0000022L

Since you gave no exact version of Visual Studio, let me give you the options I am aware of.

由于您没有提供确切版本的 Visual Studio,让我为您提供我所知道的选项。

Visual Studio 2012, 2013 and 2015

Visual Studio 2012、2013 和 2015

Respective contemporary DDK/WDK versions:WDKs 8, 8.1 and 10 (as of this writing).

相应的当代 DDK/WDK 版本:WDK8、8.1 和 10(截至撰写本文时)。

With the WDK for Windows 8, the WDK team at Microsoft finally offers full integration with Visual Studio again directly from Microsoft.

借助适用于 Windows 8 的 WDK,Microsoft 的 WDK 团队终于再次直接从 Microsoft 提供了与 Visual Studio 的完全集成。

However, while Visual Studio 2017 exists in minor version 15.4 already by the time of this update, the WDK still requiresVisual Studio 2015.

但是,虽然在此更新时 Visual Studio 2017 已经存在于次要版本 15.4 中,但 WDK 仍然需要Visual Studio 2015。

Visual Studio 2002 through 2010

Visual Studio 2002 到 2010

Respective contemporary DDK/WDK versions:DDKs for Windows XP/2003 Server, WDKs for Windows Vista and Windows 7 with their respective service pack levels and the respective server versions.

相应的当代 DDK/WDK 版本:适用于 Windows XP/2003 Server 的 DDK、适用于 Windows Vista 和 Windows 7 的WDK及其各自的服务包级别和各自的服务器版本。

Those versions were notofficially supported by Microsoft to build drivers. The only worse choice to compile a driver would be a complete third-party toolchain (other than Intel's C compiler which was sanctioned by MS, IIRC).

Microsoft并未正式支持这些版本来构建驱动程序。编译驱动程序的唯一更糟糕的选择是完整的第三方工具链(除了由 MS、IIRC 批准的英特尔 C 编译器)。

It was considered very bad form to use the Visual Studio compilers during that period, and Microsoft explicitly recommended against it. However, C++ in kernel mode was also once frowned upon and now MS provides C++ frameworks for kernel mode. The times they are changin' ... ;)

在那个时期使用 Visual Studio 编译器被认为是非常糟糕的形式,微软明确建议不要使用它。但是,内核模式下的 C++ 也曾被人嫌弃,现在 MS 为内核模式提供了 C++ 框架。他们正在改变的时代...... ;)

Anyway, workarounds exist in the form of ddkbuild.batand ddkbuild.cmdwhich use the DDK toolchain, but effectively allow you to integrate the resulting invocation from your "make" project inside Visual Studio. DDKWizardis a project creation wizard for both of those scripts. DDKWizard does notsupport Visual Studio 2010! The links to the two scripts provide a good documentation and DDKWizard also comes with a decent documentation.

无论如何,在变通的形式存在,ddkbuild.bat并且ddkbuild.cmd其使用DDK工具链,可有效地让你得到的调用从Visual Studio中的“作”项目整合。DDKWizard是这两个脚本的项目创建向导。DDKWizard并没有支持Visual Studio 2010中!这两个脚本的链接提供了一个很好的文档,DDKWizard 也提供了一个不错的文档。

To my knowledge ddkbuild.cmdis originally based on ddkbuild.batand the HollisTech version can also trace its heritage back to that version from OSR.

据我所知,HollisTech 版本ddkbuild.cmd最初是基于ddkbuild.batOSR 的,而且它的传统也可以追溯到那个版本。

VisualDDKcombined with VirtualKDemerged later than the aforementioned, but is to be considered a far superior, more sophisticated solution. But your mileage may vary. In either case the integration into Visual Studio is far more complete in the latter solution.

VisualDDK联合VirtualKD晚于前述的出现,但被认为远远优于,更复杂的解决方案。但是您的里程可能会有所不同。在任何一种情况下,在后一种解决方案中,与 Visual Studio 的集成都更加完整。

Visual Studio 6

视觉工作室 6

Respective contemporary DDK/WDK versions:DDKs for Windows NT 4 and Windows 2000.

相应的当代 DDK/WDK 版本:适用于 Windows NT 4 和 Windows 2000 的 DDK。

Prior to the Windows XP DDK (now DDK is called WDK) the compiler was not included in the DDK, so you had to have the compiler toolchain installed. This would be the case for NT 4.0 and Windows 2000.

在 Windows XP DDK(现在 DDK 称为 WDK)之前,编译器不包含在 DDK 中,因此您必须安装编译器工具链。NT 4.0 和 Windows 2000 就是这种情况。

回答by 0xC0000022L

Download and install VisualDDKand you'll be able to create driver projects and debug drivers directly from Visual Studio.

下载并安装VisualDDK,您将能够直接从 Visual Studio 创建驱动程序项目和调试驱动程序。

回答by Christopher

The ddkbuild from OSR-Online is a nice alternative ddkbuild download link.

OSR-Online 的 ddkbuild 是一个不错的替代ddkbuild 下载链接

回答by jolyon

create a makefile project and use the following as the build command:

创建一个 makefile 项目并使用以下命令作为构建命令:

pushd .  
call C:\WinDDK00.16385.1\bin\setenv.bat C:\WinDDK00.16385.1\ chk x86 WXP no_oacr   
popd  
build -cgwiz  

(obviously tweak the arguments to setenv to suit)

(显然调整 setenv 的参数以适应)

回答by Mourad Karim

To build my driver i used VisualDDK in visual studio 2008. In the beginning i start debugging using my computer and virtualBox machine but when i launch the debugging process in visual studio, my virtual machine did not show me the external ip address(normally should show me 192.168.1.102 and 10.0.1.15 in DDKLauncherMonitor but it show me only 10.0.1.15 ).

为了构建我的驱动程序,我在 Visual Studio 2008 中使用了 VisualDDK。一开始我使用我的计算机和 virtualBox 机器开始调试,但是当我在 Visual Studio 中启动调试过程时,我的虚拟机没有向我显示外部 IP 地址(通常应该显示我 192.168.1.102 和 10.0.1.15 在 DDKLauncherMonitor 但它只显示我 10.0.1.15 )。

I stopped using virtual machine and i decide to use real computer. In the second computer i launched DDKLauncherMonitor. And i start debugging from my first computer. I received Udp package in my second machine and also the driver.sys. But when i tried to load the driver from visual studio(First computer) nothing work. Plus this, in the second machine tell me "Windows required digitally signed driver".

我停止使用虚拟机,我决定使用真正的计算机。在第二台计算机上,我启动了 DDKLauncherMonitor。我从我的第一台计算机开始调试。我在我的第二台机器上收到了 Udp 包,还有 driver.sys。但是当我尝试从 Visual Studio(第一台计算机)加载驱动程序时,没有任何效果。另外,在第二台机器上告诉我“Windows 需要数字签名的驱动程序”。

There is same one meet this kind of problem and he/she can help.

有同样的人遇到这种问题,他/她可以提供帮助。

回答by CrazyChris

If you want to use DDK buildand WDK use ddkbuild.bat, it is pretty good (I think most of it works still) that should have you going. Alternatively check out ddkbuild.cmdfrom OSR.

如果您想使用 DDKbuild和 WDK use ddkbuild.bat,那么您应该去使用它是非常好的(我认为其中大部分仍然有效)。或者ddkbuild.cmd从 OSR签出。

回答by Sergey Podobry

In VS create a makefile project. Add your sources, headers, makefile and sourcefile. Open project properties->Configuration properties->NMake->Build Command Line and write:

在 VS 中创建一个 makefile 项目。添加您的源、头文件、makefile 和源文件。打开项目属性->配置属性->NMake->Build Command Line并写入:

call $(WINDDK)\bin\setenv.bat $(WINDDK) fre wnet
cd /d $(ProjectDir)
build.exe -I

Now you can build from VS. The advantage of the makefile project: it provides you with as many configurations as you need (w2k, wxp, wnet, wlh and etc) and you can build from the DDK command line.

现在您可以从 VS 构建。makefile 项目的优点:它为您提供了您需要的任意数量的配置(w2k、wxp、wnet、wlh 等)并且您可以从 DDK 命令行构建。

P.S. fre wnet- is a sample configuration, use what is required for your project. It is good to have both freand chkconfigurations. WINDDK - environment variable with a path to the DDK root.

PS fre wnet- 是一个示例配置,使用您的项目所需的配置。拥有frechk配置都很好。WINDDK - 带有 DDK 根路径的环境变量。