【问题标题】:cannot install a driver无法安装驱动程序
【发布时间】:2022-01-07 09:48:12
【问题描述】:

我使用这个 tatourial (https://docs.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/writing-a-very-small-kmdf--driver) 构建了一个简单的驱动程序。 我试图安装我的驱动程序,但是当我运行 devcon 工具时,我得到了:

Device node created. Install is complete when drivers are installed...
Updating drivers for Root/MyFiestDriver from C:\Users\WDKRemoteUser\Downloads\drive-download-20220107T092709Z-001\MyFiestDriver.inf.
devcon.exe failed.

我检查了日志并收到以下错误消息:

     [Device Install (UpdateDriverForPlugAndPlayDevices) - Root/MyFirstDriver]
>>>  Section start 2022/01/07 12:36:43.703
      cmd: devcon.exe  install MyFirstDriver.inf Root/MyFirstDriver
     ndv: INF path: C:\Users\WDKRemoteUser\Downloads\drive-download-20220107T092709Z-001\MyFirstDriver.inf
     ndv: Install flags: 0x00000001
     ndv: {Update Device Driver - ROOT\SYSTEM\0001}
     ndv:      Search options: 0x00000080
     ndv:      Searching single INF 'C:\Users\WDKRemoteUser\Downloads\drive-download-20220107T092709Z-001\MyFirstDriver.inf'
     dvi:      {Build Driver List} 12:36:43.734
     dvi:           Searching for hardware ID(s):
     dvi:                root/MyFirstDriver
     dvi:      {Build Driver List - exit(0x00000000)} 12:36:43.812
!    ndv:      No matching drivers found in single INF
     dvi:      {DIF_SELECTBESTCOMPATDRV} 12:36:43.828
     dvi:           Default installer: Enter 12:36:43.828
     dvi:                {Select Best Driver}
!    dvi:                     Selecting driver failed(0xe0000228)
     dvi:                {Select Best Driver - exit(0xe0000228)}
!    dvi:           Default installer: failed
!    dvi:           Error 0xe0000228: There are no compatible drivers for this device.
     dvi:      {DIF_SELECTBESTCOMPATDRV - exit(0xe0000228)} 12:36:43.859
!    ndv:      Unable to select best compatible driver. Error = 0xe0000228
     ndv:      No drivers found for device.
     ndv: {Update Device Driver - exit(00000103)}
!    ndv: No better matching drivers found for device 'ROOT\SYSTEM\0001'.
     ndv: {Update Device Driver - ROOT\SYSTEM\0002}
     ndv:      Search options: 0x00000080
     ndv:      Searching single INF 'C:\Users\WDKRemoteUser\Downloads\drive-download-20220107T092709Z-001\MyFirstDriver.inf'
     dvi:      {Build Driver List} 12:36:43.906
     dvi:           Searching for hardware ID(s):
     dvi:                root/MyFirstDriver
     dvi:      {Build Driver List - exit(0x00000000)} 12:36:43.922
!    ndv:      No matching drivers found in single INF
     dvi:      {DIF_SELECTBESTCOMPATDRV} 12:36:43.922
     dvi:           Default installer: Enter 12:36:43.937
     dvi:                {Select Best Driver}
!    dvi:                     Selecting driver failed(0xe0000228)
     dvi:                {Select Best Driver - exit(0xe0000228)}
!    dvi:           Default installer: failed
!    dvi:           Error 0xe0000228: There are no compatible drivers for this device.
     dvi:      {DIF_SELECTBESTCOMPATDRV - exit(0xe0000228)} 12:36:43.953
!    ndv:      Unable to select best compatible driver. Error = 0xe0000228
     ndv:      No drivers found for device.
     ndv: {Update Device Driver - exit(00000103)}
!    ndv: No better matching drivers found for device 'ROOT\SYSTEM\0002'.
!    ndv: No devices were updated.
<<<  Section end 2022/01/07 12:36:44.062
<<<  [Exit status: FAILURE(0x00000103)]

我使用了 Visual Studio 为我生成的 inf 文件,但无法找到解决此问题的方法。

我使用的 inf 文件是这样的:

    ;
; MyFirstDriver.inf
;

[Version]
Signature="$WINDOWS NT$"
Class=System ; TODO: specify appropriate Class
ClassGuid={4d36e97d-e325-11ce-bfc1-08002be10318} ; TODO: specify appropriate ClassGuid
Provider=%ManufacturerName%
CatalogFile=MyFirstDriver.cat
DriverVer = 01/04/2022,10.43.33.93
PnpLockdown=1

[DestinationDirs]
DefaultDestDir = 12
MyFirstDriver_Device_CoInstaller_CopyFiles = 11

[SourceDisksNames]
1 = %DiskName%,,,""

[SourceDisksFiles]
MyFirstDriver.sys  = 1,,
;


;*****************************************
; Install Section
;*****************************************

[Manufacturer]
%ManufacturerName%=Standard,NTamd64

[Standard.NTamd64]
%MyFirstDriver.DeviceDesc%=MyFirstDriver_Device, Root\MyFirstDriver ; TODO: edit hw-id

[MyFirstDriver_Device.NT]
CopyFiles=Drivers_Dir

[Drivers_Dir]
MyFirstDriver.sys

;-------------- Service installation
[MyFirstDriver_Device.NT.Services]
AddService = MyFirstDriver,%SPSVCINST_ASSOCSERVICE%, MyFirstDriver_Service_Inst

; -------------- MyFirstDriver driver install sections
[MyFirstDriver_Service_Inst]
DisplayName    = %MyFirstDriver.SVCDESC%
ServiceType    = 1               ; SERVICE_KERNEL_DRIVER
StartType      = 3               ; SERVICE_DEMAND_START
ErrorControl   = 1               ; SERVICE_ERROR_NORMAL
ServiceBinary  = %12%\MyFirstDriver.sys

;
;--- MyFirstDriver_Device Coinstaller installation ------
;

[MyFirstDriver_Device.NT.CoInstallers]
AddReg=MyFirstDriver_Device_CoInstaller_AddReg
CopyFiles=MyFirstDriver_Device_CoInstaller_CopyFiles

[MyFirstDriver_Device_CoInstaller_AddReg]
;


[MyFirstDriver_Device_CoInstaller_CopyFiles]
;


[MyFirstDriver_Device.NT.Wdf]
KmdfService =  MyFirstDriver, MyFirstDriver_wdfsect
[MyFirstDriver_wdfsect]
KmdfLibraryVersion = 1.15

[Strings]
SPSVCINST_ASSOCSERVICE= 0x00000002
ManufacturerName="<Your manufacturer name>" ;TODO: Replace with your manufacturer name
DiskName = "MyFirstDriver Installation Disk"
MyFirstDriver.DeviceDesc = "MyFirstDriver Device"
MyFirstDriver.SVCDESC = "MyFirstDriver Service"

【问题讨论】:

    标签: windows driver inf


    【解决方案1】:

    我有同样的问题。 在您的情况下,您将“root/MyFirstDriver”传递给 devcon,但您已将 inx/inf 文件中的 id 定义为相似但不相同的字符串“root\MyFirstDriver”。我猜这就是你的 devcon 命令失败的原因。

    在我的情况下,字符串是相同的,但我仍然收到“在单个 INF 中找不到匹配的驱动程序”错误。最终我发现我使用的 Debug Win32 驱动程序无法正常工作。将示例项目切换到 x64 Release 版本为我解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多