Windows驱动程序开发

一、工具的获得

有以下两种方式:

1、下载安装WDK for visual studio。

2、下载完整WEDK包,该包包含了visual studio开发环境、SDK和WDK 

本人的安装方式是在宿主机上以第一种方式安装,在一个虚拟机上以第二种方式安装;

二、Building debug virtual machine environment 

If you follow the instructions of the microsoft doc, you will probably setup the kdnet on bridge network. Then you will fail in a large probability. Because your NIC might not be supported by microsoft, you can hardly connect your debbuger and target virtual machine. So, the correct approach is to create a virtual machine with a intenal virtual network and setup the kdnet on this internal virtual network.

关于调试器的环境,微软的指南是一个大坑。最好的方法是建立一个只有内部虚拟网络的虚拟机作为目标机。

在两台主机的防火墙->高级设置中->入站规则 中设置允许ICMP v4入站。

在虚目标机上禁止“强制驱动程序签名”,这需要进入高级系统启动菜单。但是在虚拟机上,只有一种办法可行:即在登录界面点击电源开关,然后按住SHIFT点击“重启”。

三、按照指南构建驱动程序,排除两个错误

1、Spectre-mitigated libraries are required for this project.

提示需要防止spectre攻击库生成代码。解决这个错误有两种办法,一是下载spectre版各种库和构件,另一种是在本项目禁止使用防止spectre攻击代码生成。

2、Inf2Cat,signability test failed

点击进去后看到错误细节是:

riverVer set to a date in the future (postdated DriverVer not allowed)

如果是用集成环境编译,则可以在项目inf2Cat属性页选择 Use Local Time解决。

如果利用命令行编译,则需要修改driver.inf文件,把DriverVer变量设成 mm/dd/yyyy格式的一个不早于当天的日期。

//这应该算是wdk的一个bug, 一直未得到修正。

四、EWDK命令行编译驱动程序

1、复制一个vcxproj 和inf文件到.c源程序目录;

2、msbuild /t:clean /t:build .\MyprojectFile

发布了36 篇原创文章 · 获赞 0 · 访问量 9131

猜你喜欢

转载自blog.csdn.net/eliuxiaoming1/article/details/104766088