Developing Drivers with the Windows Driver Foundation (Pro Developer)

The following are suggestions for troubleshooting driver installation, along with some common errors and possible solutions. Before investigating a device installation problem, you should have the following items:

How to Use WinDbg to Debug Installation Errors

Device installation sometimes fails because of problems in the driver's loading and startup code. For UMDF drivers, these errors usually occur in the IDriverEntry::OnDeviceAdd method. For KMDF drivers, these errors usually occur in the DriverEntry or EvtDriverDeviceAdd routine.

To debug such errors, set breakpoints in the misbehaving routines and then use WinDbg to determine why they are failing.

Chapter 22, "How to Debug WDF Drivers," provides information about driver debugging and WinDbg.

Driver Installation Error Logs

Each component that is involved in installation and setup records information in a log file. You can check these log files for information that pertains to WDF and your driver.

All versions of Windows that support WDF have the following setup log files:

You can control the amount of information for each event in the SetupAPI log by setting a registry value. It is sometimes useful to increase the logging level for all installation applications. Errors that occur while installing your driver could actually have been caused by an installation error for another driver elsewhere in the device stack. To help catch such errors, increase the logging level.

 Tip  See "Troubleshooting Device Installation" in the WDK for more information about SetupAPI logging-online at http://go.microsoft.com/fwlink/?LinkId=79370.

Tip 

The SetupAPI and Setup action logs are a cumulative record of all installations and can be quite large. If you have a reproducible error, rename the existing log files and then reinstall the driver. The system will create new SetupAPI and Setup action logs that contain only the data associated with your driver.

Common WDF Installation Errors

A number of errors can occur during installation. Most are generic issues such as a mismatch between the files specified in the INF and the files actually in the package. This section discusses some common WDF installation errors and possible solutions.

 Tip  See "Guidelines for Using SetupAPI" in the WDK for a general discussion of driver installation errors-online at http://go.microsoft.com/fwlink/?LinkId=79371.

Fatal Error During Installation

Several problems can cause this error. Some common causes of this error include the following conditions:

PnP Manager Error Codes

If the PnP manager encounters an error, it returns an error code to indicate the nature of the problem. Device Manager has an entry for the device, but it is marked by a yellow exclamation point to indicate a failed installation. To view the error codes, open the device's Properties dialog box in Device Manager. This section briefly discusses two commonly encountered error codes for WDF drivers.

 Tip  See "Device Manager Error Messages" in the WDK for a complete list of PnP manager error codes-online at http://go.microsoft.com/fwlink/?LinkId=80068.

Error Code 37

This error can indicate a problem either with the co-installer or in the driver's DriverEntry routine. If either problem caused the error, the Setup action log probably contains one of the following messages:

Final status: error(0) The operation completed successfully. GetLatestInstalledVersion install version major 0x1, minor 0x1 is less than or equal to latest major 0x1, minor 0x1, asking for post processing WdfCoinstaller: DIF_INSTALLDEVICE: Post-Processing

The most likely cause of this error is a problem in the driver's DriverEntry routine. Set a breakpoint in this routine and use WinDbg to determine the problem.

Error Code 31

This error is always caused by a problem in the driver. This error is often generated when the EvtDriverDeviceAdd or IDriverEntry::OnDeviceAdd callback returns a status other than STATUS_SUCCESS.

Other Installation Errors

Most of the other causes of errors during installation should be evident from the entries in the Setup action log. The following are some typical examples:

Категории