Windows biometric framework sample umdf driver: This device cannot start. (Code 10)

橙三吉。 提交于 2019-12-07 23:40:29

All started when I was able to install my Biometric Driver but it showed a "Yellow Exclamation Mark" and a generic message "This device cannot start. (Code 10)"

The biometric sample project does not include an example how to sign properly EngineAdapter.dll with Visual Studio I found this resource (page 33-34) where shows How to Sign The EngineAdapter on project properties Build Events -> Post Build Event:

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

Next This first video tutorial shows an example of debugging umdf driver using a tool from the WDK wdfverifier.exe I couldn't attach the debugger to my driver process because the process is not present. But I could debug at startup before the process crashes.

To debug with wdfverifier.exe I took the following steps:

Settings Tab: Check the option "Automatically Launch user-mode debugger when requested", specify 15 seconds in the input "Host Process will wait"

Preferences Tab: Check "Use WinDbg", then

Disable/Enable my device on Device Manager

WinDbg launches and I can check if my driver module was loaded with the next command:

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!

Now I can set break points but before that I had to specify to WinDbg where are the symbol file (*.pdb) and source code of the driver with the next commands (the paths may be different if you build the package project, I am building the WudfBioUsbSample with a reference to EngineAdapter Project):

.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

Next I could set a break point:

//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

The method CreateUsbIoTargets is where the errors show up. These errors are fixed by JinZhuXing in this github issue

After fixing the driver code and debugging that the method CreateUsbIoTargets runs Ok

Still showed me The Yellow Exclamation Mark but this time the error was in the EngineAdapter.dll. The next error shows in EventViewer: Application and Services Logs > Microsoft\Windows\Biometrics

The module's "Engine Adapter" initialization routine failed with error: 0x80004001

The EngineAdapter project methods were returning E_NOTIMPL I just changed this to return S_OK instead for all methods. And the biometric unit was successfully created.

Also debugging of the Engine Plugin is done with Visual Studio. Here are the steps I followed:

Use wdfverifier.exe to attach WinDbg to the process of my umdf driver and set a break point to OnGetAttributes method (this method is called when I start/restart the Windows Biometric Service)This breakpoint will make the service to wait before it calls the EngineAdapter Plugin code.

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

Restart or start Windows Biometric Service (WbioSrvc on Task Manager->Services Tab)

Copy The Process ID (PID)

Run Visual Studio as Administrator, Open WBDIsample project

Use Menu Debug -> Attach to Process...

Enter the following values:

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.

Set Breakpoints on WbioQueryEngineInterface, EngineAdapterAttach, EngineAdapterDetach a sample implementation is on msdn

run the command g (Go) on WinDbg

g

After this you can debug the code of the plugin on Visual Studio.

What is left is to implement the code for the Biometric Driver and The necessary plugins for your device

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!