"Code 10" errors with WPD drivers

Published 01 November 07 09:48 PM | hvdevice 

While building your drivers for HealthVault Conection Center you may come across the "Code 10" error and the device manager gives you a status of "This device cannot start. (Code 10)"  This is due to your driver not being able to start, or it may have crashed..  So below are some of the steps that you can take to help debug your driver.

The first thing to check is whether the driver even loads correctly as a DLL.  A simple way to do this is to run the Depends.exe tool (comes with Visual Studio) on the PC that has the problem.

If Depends.exe flags anything (e.g. can’t find the debug VC CRT, or some helper DLL) you should be able to identify and therefore fix the problem.  There are two common problems of this type:
- Missing CRTs.
    o   Whether DEBUG or Retail, the correct version of the VC runtime redist needs to be installed on the machine.  NOTE: Connection Center will install VC runtime for VC 2005 SP1.
- Missing I/O or device library file
    o   Make sure the device INF copies the I/O library or device library file to the correct location.  If your driver does not explicitly load library from a known directory but instead relies on the system to find and load the DLL, remember that the EXE you’re running under (WUDFHOST.EXE) has a working directory of %WINDIR%\System32, not the subdirectory where your driver is (%windir%\System32\drivers\umdf\Hdi).  Therefore, your INF may need to specify a different target location in the CopyFiles section for that file.

If Depends.exe loads the DLL fine, but you still have a code 10, then your driver is likely loading but failing to start.  The best thing to do there is to debug the driver when it is loaded/started.  Follow these steps to debug the driver start:

- WUDF has a registry entry that helps with debugging.  This entry causes the WUDF service to wait while a debugger is attached for a specified amount of time.
  (See http://msdn2.microsoft.com/en-us/library/aa510985.aspx)
- Set the registry value at
  "HKLM\Software\Microsoft\Windows NT\CurrentVersion\WUDF\Services\{193a1820-d9ac-4997-8c55-be817523f6aa}\HostProcessDbgBreakOnStart"
  to 0x00030000.
- Disable your WPD device in device manager
- Open your driver project in Visual Studio 2005 and open the source file 'device.cpp'.
- Set a break point in the function CDevice::OnPrepareHardware( ).
- Enable your WPD driver from device manager.
- In Visual Studio 2005 open the ‘Attach To Process’ dialog.  (Debug->Attach to process…).
- Check the boxes labeled ‘Show processes from all users’ and ‘Show processes in all sessions’.
- The process to attach to is called 'WUDFHOST.EXE'. Your WPD Driver is hosted in this process.  (If there is more than one WUDFHOST.EXE listed,
   it means you have more than one WPD driver running.  Go to Device Manager and DIsable the other WPD devices.)
- Hit F5 in Visual Studio 2005 and it will hit your Breakpoint in 'device.cpp'
- Walk through your driver start-up code.  Note that you must not return an error from CDevice::OnPrepareHardware( ).
  Returning an error tells PnP that your driver has a critical error and cannot load.  If your device is not available at load time,
  that is fine - you should still return success (you will just not have any data yet).

Comments

# University Update - Microsoft Windows - "Code 10" errors with WPD drivers said on November 1, 2007 6:46 PM:

PingBack from http://www.universityupdate.com/Technology/Microsoft_Windows/5413909.aspx

Anonymous comments are disabled

Search

This Blog

Syndication

Page view tracker