问题描述
我正在尝试在最新的Visual Studio上编译一个hello world驱动程序
似乎他们在最新版本中对Visual Studio进行了一些很棒的更改,因为我在VS 2017中没有这个问题,我无法编译一个简单的hello world驱动程序,您几乎可以在其中找到任何教程,因为我收到此错误:
Device driver does not install on any devices,use primitive driver if this is intended
https://github.com/MicrosoftDocs/windows-driver-docs/issues/2067
但是答案没有用,并且对于INF文件提到的更改没有帮助,这是我的INF文件,它是VS 2019上的默认INF:
;
; HelloWorld.inf
;
[Version]
Signature="$WINDOWS NT$"
Class=System
ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318}
Provider=%ManufacturerName%
DriverVer=
CatalogFile=HelloWorld.cat
PnpLockDown=1
[DestinationDirs]
DefaultDestDir = 12
[SourcedisksNames]
1 = %diskName%,""
[SourcedisksFiles]
[Manufacturer]
%ManufacturerName%=Standard,NT$ARCH$
[Standard.NT$ARCH$]
[Strings]
ManufacturerName="<Your manufacturer name>" ;Todo: Replace with your manufacturer name
ClassName=""
diskName="HelloWorld Source disk"
我应该如何更改?
Windows内核编程手册中的简单示例(从2019年开始)将不再编译,因为提供的所有INF文件都是无效的。.
解决方法
要解决该问题,只需从Visual Studio中删除Y
文件,然后重新编译即可。
这是由Windows 10 1903中新的“原始驱动程序”概念引起的。目的是显式地建模与设备实际上不相关的驱动程序。有关详细信息,请参见Microsoft Documentation on Primitive Drivers。
您的inf不包含任何有关迁移说明的部分,但其中包含Manufacturer
部分,原始驱动程序不允许该部分。删除它,验证可能会成功。