c++ - Windows 生物识别框架示例 umdf 驱动程序 : This device cannot start.(代码 10)

标签 c++ wdk umdf wbf wbdi

我正在尝试运行 Windows biometric driver sample我对驱动程序开发很天真

我已经更改了 inx 文件中的硬件 ID,并重建了驱动程序项目,并在我的 Windows 10 Pro 版本 1803 上安装了生成的驱动程序。

我使用的是 Fingerprint Morpho Device 1300 E3

驱动安装成功,但出现一个错误:

此设备无法启动。 (代码 10) 指定的请求不是目标设备的有效操作。

我查看了文件 C:\Windows\INF\setupapi.dev.log

它显示下一个警告:

     sig:                     {_VERIFY_FILE_SIGNATURE} 10:13:03.130
     sig:                          Key      = wudfbiousbsample.inf
     sig:                          FilePath = C:\WINDOWS\System32\DriverStore\Temp\{ee9ffca3-751f-0b4e-a7ac-dce2543d995e}\wudfbiousbsample.inf
     sig:                          Catalog  = C:\WINDOWS\System32\DriverStore\Temp\{ee9ffca3-751f-0b4e-a7ac-dce2543d995e}\biometrics.cat
!    sig:                          Verifying file against specific (valid) catalog failed.
!    sig:                          Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
!!!  dvi:                     Device not started: Device has problem: 0x0a (CM_PROB_FAILED_START), problem status: 0xc0000450.

但我在本地计算机上的受信任的根证书颁发机构和受信任的发布者上安装了 TestCertificate

我还检查了事件查看器: 应用程序和服务日志 > Microsoft\Windows\CodeIntegrity 应用程序和服务日志 > Microsoft\Windows\Biometrics

我尝试使用 wdfverifier.exe 进行调试 following some videos from msdn但是这个过程没有开始所以我无法调试:(

我确认 Visual Studio 没有对 EngineAdapter.dll 插件文件进行签名,因此我禁用了驱动程序签名并按照 this paper 手动进行了签名。 .但是我得到了相同的错误代码 10 :(

我还想知道错误代码 10 是否是预期的行为,因为 EngineAdapter.dll 的代码未实现。

更新:我正在 Windows 10 专业版 1709 虚拟机 VMWare 上进行测试,但我遇到了其他错误:

此设备无法正常工作,因为 Windows 无法加载此设备所需的驱动程序。 (代码 31)

!!!  dvi:                     Device not started: Device has problem: 0x1f (CM_PROB_FAILED_ADD), problem status: 0xc0000001.

同样的警告:

     sig:           {_VERIFY_FILE_SIGNATURE} 17:19:01.646
     sig:                Key      = wudfbiousbsample.inf
     sig:                FilePath = C:\Windows\System32\DriverStore\Temp\{85323f79-3f5f-f84c-a52b-639b6ae57db1}\wudfbiousbsample.inf
     sig:                Catalog  = C:\Windows\System32\DriverStore\Temp\{85323f79-3f5f-f84c-a52b-639b6ae57db1}\biometrics.cat
!    sig:                Verifying file against specific (valid) catalog failed.
!    sig:                Error 0x800b0109: A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider.
     sig:           {_VERIFY_FILE_SIGNATURE exit(0x800b0109)} 17:19:01.661
     sig:           {_VERIFY_FILE_SIGNATURE} 17:19:01.676
     sig:                Key      = wudfbiousbsample.inf
     sig:                FilePath = C:\Windows\System32\DriverStore\Temp\{85323f79-3f5f-f84c-a52b-639b6ae57db1}\wudfbiousbsample.inf
     sig:                Catalog  = C:\Windows\System32\DriverStore\Temp\{85323f79-3f5f-f84c-a52b-639b6ae57db1}\biometrics.cat
     sig:                Success: File is signed in Authenticode(tm) catalog.
     sig:                Error 0xe0000241: The INF was signed with an Authenticode(tm) catalog from a trusted publisher.
     sig:           {_VERIFY_FILE_SIGNATURE exit(0xe0000241)} 17:19:01.708
     sto:      {DRIVERSTORE IMPORT VALIDATE: exit(0x00000000)} 17:19:01.739

完整的日志文件在这里 setupapi.dev.log

我认为驱动程序不会加载,因为有关证书的警告或错误可能在其他地方。

如果有人能给我一个小建议让我继续。我现在卡住了:(

非常感谢。

最佳答案

当我能够安装我的生物识别驱动程序时,一切都开始了,但它显示了一个“黄色感叹号”和一条通用消息“该设备无法启动。(代码 10)”

生物识别示例项目不包括如何使用我发现的 Visual Studio 正确签署 EngineAdapter.dll 的示例 this resource (page 33-34)其中显示如何在项目属性构建事件 -> 构建事件后签署 EngineAdapter:

Command Line: signtool sign /v /ac "Path_to_cross_certificate_DigiCert Assured ID Root CA.crt" /tr http://timestamp.digicert.com /td sha256 /fd sha256 /f "path_to_my_certificate_file.pfx" /p mypassword "$(Platform)\$(ConfigurationName)\EngineAdapter.dll"
Use In Build: Yes

下一页 This first video tutorial显示了使用 WDK wdfverifier.exe 中的工具调试 umdf 驱动程序的示例 我无法将调试器附加到我的驱动程序进程,因为该进程不存在。但我可以在进程崩溃之前在启动时进行调试。

要使用 wdfverifier.exe 进行调试,我采取了以下步骤:

设置选项卡: 勾选“Automatically Launch user-mode debugger when requested”选项,在输入“Host Process will wait”中指定 15 秒

首选项选项卡: 选中“使用 WinDbg”,然后

在设备管理器中禁用/启用我的设备

WinDbg 启动,我可以检查我的驱动程序模块是否加载了下一个命令:

lm m *bio*
//the module is not loaded, use g commant to continue
g
//again see if the module was loaded
lm m *bio*
//module shows up, great!

现在我可以设置断点了,但在此之前我必须向 WinDbg 指定符号文件 (*.pdb) 和驱动程序源代码的位置以及下一个命令(如果构建 package 项目,我正在构建 WudfBioUsbSample 并引用 EngineAdapter 项目):

.symfix
.srcpath+ C:\Users\myuser\Documents\Windows-driver-samples\biometrics\driver    
.sympath+ C:\Users\myuser\Documents\Windows-driver-samples\biometrics\driver\x64\Debug

.reload /f

接下来我可以设置一个断点:

//x command is used to search if the method exist
x WudfBioUsbSample!CBiometricDriver::*
x WudfBioUsbSample!CBiometricDevice::*
x WudfBioUsbSample!CBiometricDevice::OnGetAttributes
//examples of breakpoints
bp WudfBioUsbSample!CBiometricDriver::OnDeviceAdd
bp WudfBioUsbSample!CBiometricDevice::OnGetAttributes
bp WudfBioUsbSample!CBiometricDevice::CreateUsbIoTargets

CreateUsbIoTargets 方法是出现错误的地方。这些错误由 JinZhuXing 在 this github issue 中修复

修复驱动代码并调试CreateUsbIoTargets方法运行正常

仍然向我显示黄色感叹号,但这次错误出在 EngineAdapter.dll 中。事件查看器中显示下一个错误:应用程序和服务日志 > Microsoft\Windows\Biometrics

模块的“引擎适配器”初始化例程失败,出现错误:0x80004001

EngineAdapter 项目方法正在返回 E_NOTIMPL 我只是将其更改为返回 S_OK 而不是所有方法。生物识别单元创建成功。

此外,引擎插件的调试是使用 Visual Studio 完成的。以下是我遵循的步骤:

使用 wdfverifier.exe 将 WinDbg 附加到我的 umdf 驱动程序的进程,并为 OnGetAttributes 方法设置断点(当我启动/重新启动 Windows 生物识别服务时调用此方法)此断点将使服务在它之前等待调用 EngineAdapter 插件代码。

x WudfBioUsbSample!CBiometricDevice::OnGetAttributes
bp WudfBioUsbSample!CBiometricDevice::OnGetAttributes
g

重新启动或启动 Windows 生物识别服务(WbioSrvc 在任务管理器 -> 服务选项卡上)

复制进程 ID (PID)

以管理员身份运行 Visual Studio,打开 WBDIsample 项目

使用菜单 Debug -> Attach to Process...

输入以下值:

Connection Type: Windows User Mode Debugger
Connection Target: Localhost

Check "Show processes from all users" 

Filter by Process ID 
Select the process and Click Attach button.

WbioQueryEngineInterface、EngineAdapterAttach、EngineAdapterDetach 上设置断点 一个sample implementation is on msdn

在 WinDbg 上运行命令 g (Go)

g

之后您可以在 Visual Studio 上调试插件的代码。

剩下的就是实现生物识别驱动程序的代码和设备所需的插件

关于c++ - Windows 生物识别框架示例 umdf 驱动程序 : This device cannot start.(代码 10),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54758289/

相关文章:

c++ - 从网络摄像头预览捕获图像的最佳 DirectShow 方式? SampleGrabber 已弃用

c++ - 在 Visual C++ 中全局覆盖 malloc

windows - WDK 10 - 无法以安装了 SDK7 的 Windows 7 为目标

c++ - Windows 生物识别服务在调用 WinBioCaptureSample 时循环运行 SensorAdapterStartCapture

c++ - 设备无法启动。 (代码 10)umdf 驱动程序开发错误

c++ - HKEY 句柄为 NULL,在调试期间它写入未使用的<无法读取内存>

c++ - 无法设置顶点着色器中的输入位置

尝试在 win 10 中打开设备时,c++ CreateFile() 返回 1(无效函数)

c - 如何保护注册表不使用 deleteservice?

driver - 通过 Visual Studio 构建 Windows 驱动程序时出现 GUID 错误