调试驱动程序安装错误
使用SetupAPI安装驱动程序时,如果出现问题,往往比较难以调试。MSDN介绍了如何让SetupAPI输出更多信息到记录文件,和如何理解记录文件的信息。
Setting SetupAPI Logging Levels
[This is preliminary documentation and subject to change.]
You can control the amount of information that is written to the SetupAPI log, either for all Setup applications or for individual Setup applications.
To change the level of information written to the SetupAPI log for all Setup applications, create (or modify) the following registry value:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\LogLevel
By setting this value (using the values listed in the tables below) you can choose the level of errors that are logged, modify the verbosity of logging, or turn off logging. You can also log information to a debugger as well as to the log file.
To specify logging levels for individual Setup applications, create a registry entry under the following key:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Setup\AppLogLevels
Under this key, create a value name representing the application's executable file name, and assign the desired logging level to that name (using the values listed in the tables below), such as service.exe=LoggingLevel.
The logging level is a DWORD value. If this value is not specified or is zero, SetupAPI uses a default behavior, as indicated in the tables below.
The DWORD value is made up of three parts, formatted as 0xSSSSDDGG. The low eight bits, represented by the mask 0x000000FF, set the logging level for general Setup operations. The next-higher eight bits, represented by the mask 0x0000FF00, set the logging level for device installation operations. The highest bits are special flags.
The following tables contain the general logging levels, device installation logging levels, and special logging flags for Windows 2000 and later.
General Logging Levels |
Meaning |
0x00000000 |
Use default settings (currently 0x20). |
0x00000001 |
Off (no Setup logging). |
0x00000010 |
Log errors. |
0x00000020 |
Log errors and warnings. |
0x00000030 |
Log errors, warnings and other information. |
0x00000040 |
Log errors, warnings and other information in verbose mode. |
0x00000050 |
Log errors, warnings and other information in verbose mode, plus time-stamped entries. |
0x00000060 |
Log errors, warnings and other information in verbose mode, plus time entries. Additionally, all entries are time-stamped. |
0x00000070 |
Log errors, warnings and other information in verbose mode, plus time messages. All entries are time-stamped. Additional messages that can slow down the system, such as cache hits, are included. |
0x000000FF |
Specifies the most verbose logging available. |
Device Logging Levels |
Meaning |
0x00000000 |
Use default settings (currently 0x3000). |
0x00000100 |
Off (no Setup logging). |
0x00001000 |
Log errors. |
0x00002000 |
Log errors and warnings. |
0x00003000 |
Log errors, warnings and other information. |
0x00004000 |
Log errors, warnings and other information in verbose mode. |
0x00005000 |
Log errors, warnings and other information in verbose mode, plus time-stamped entries. |
0x00006000 |
Log errors, warnings and other information in verbose mode, plus time entries. Additionally, all entries are time-stamped. |
0x00007000 |
Log errors, warnings and other information in verbose mode, plus time messages. All entries are time-stamped. Additional messages that can slow down the system, such as cache hits, are included. |
0x0000FF00 |
Specifies the most verbose logging available. |
Special Flags |
Meaning |
0x08000000 |
(Windows XP and later) Add a time stamp to all log entries. |
0x20000000 |
(Windows XP and later) Don't flush logging information to disk after each entry is written. (Logging is faster, but information could be lost if the system crashes.) |
0x40000000 |
Write log entries chronologically instead of grouping entries. |
0x80000000 |
Send the output to the debugger as well as to the log file. |
For example, SetupAPI interprets some sample LoggingFlags values as follows:
- 0x00000000 means default logging.
- 0x0000FFFF means verbose logging.
- 0x8000FF00 means log verbose device installation information to both the log file and the debugger.
To modify the default SetupAPI logging levels during a clean installation, edit the registry during the period between text-mode Setup and GUI-mode Setup. The following steps describe the procedure. These steps assume that you are installing to D:\Winnt and have a working build of the same version of Windows on another partition. Change the SetupAPI logging levels as follows:
- Start the installation of the clean build you are testing.
- Stop the setup process during the first boot after text-mode Setup (that is, before GUI-mode Setup).
- Boot into the working build by selecting it from the boot menu, and log on as Administrator.
- Find the registry hives (files) in D:\Winnt\System32\config. In this case, you need to modify the registry hive in Software.sav.
- On Windows 2000, run Regedt32, select the "HKEY_LOCAL_MACHINE on Local Machine" window, and select the HKEY_LOCAL_MACHINE key. Then click on the Registry menu and select Load Hive.
On Windows XP and later, run RegEdit. Highlight HKEY_LOCAL_MACHINE, click on the File menu and select Load Hive.
- Browse the files and select D:\Winnt\System32\config\software.sav. When prompted for key name, enter "_sw.sav "
- Open the _sw.sav key under HKEY_LOCAL_MACHINE and highlight the following key:
HKEY_LOCAL_MACHINE\_sw.sav\Microsoft\Windows\CurrentVersion\Setup
On Windows 2000, click on the Security menu, select Permissions, and grant full control to Administrator.
On Windows XP and later, click on the Edit menu, select Permissions, and grant full control to Administrator.
- On Windows 2000, add the necessary registry values under this key using clicking on Edit and selecting Add Value.
On Windows XP and later, click on Edit and select New DWORD Value.
Enter the value. For example, add "0xFFFF" to enable full verbose logging.
- Select HKEY_LOCAL_MACHINE\_sw.sav, and unload the hive (using the Registry menu on Windows 2000, or the File menu on Windows XP and later)The _sw.sav key should disappear.
- Copy D:\Winnt\System32\config\software.sav to D:\Winnt\System32\config\software.
- Reboot and continue into Setup.
- To verify this change, press SHIFT+F10 in GUI-mode Setup, then run regedit.exe and check the logging level.
Interpreting a Sample SetupAPI Log File
[This is preliminary documentation and subject to change.]
The sample logs below illustrate the information that is contained in a SetupAPI log file.
In general, all parts of an installation appear together in the log file. An installation section in the log starts with an entry of the format [year/month/day time process-id.instance description] where instance is a number that ensures that two sections instantiated at the same time for the same process are unique.
This topic includes:
Sample Windows 2000 SetupAPI Log File
In the following sample Windows 2000 log file, the indented sections are explanatory annotations. The sample log was generated with LogLevel=0xFFFF for verbose output:
[1999/10/15 15:14:25 376.1560 Driver Install]
SetupAPI lists the hardware and compatible IDs of the device being
installed. The first ID listed is the most exact match. Lines without a time
stamp provide context for time-stamped entries.
Searching for hardware ID(s): acpi\pnp0200,*pnp0200
Enumerating files E:\WINNT\inf\*.inf
@ 15:14:25.637 : Opened PNF of "E:\WINNT\inf\1394.inf".
PNFs are preprocessed INF files.
:
Searching other INFs...
:
@ 15:14:26.688 : Opened PNF of "E:\WINNT\inf\machine.inf".
Setup found a match here, so it logs the INF in which it found
the match, what hardware ID it matched on, descriptive information,
and the install section.
@ 15:14:26.698 : Found *PNP0200 in E:\WINNT\inf\machine.inf; Device:
Direct memory access controller; Driver: Direct memory access
controller; Provider: Microsoft; Mfg: (Standard system devices);
Section: NO_DRV_X
@ 15:14:26.698 : Decorated section name: NO_DRV_X
:
Setup searches other INFs.
:
@ 15:14:31.575 : Opened PNF of "E:\WINNT\inf\wordpad.inf".
Setup has finished searching INFs. Next, it loads class
co-installers and class installers that are registered for
this device's setup class.
Loading co-installer modules for Direct memory access controller.
@ 15:14:31.615 : Verifying file: E:\WINNT\System32\SysSetup.Dll using
key: SysSetup.Dll in catalog: -.
@ 15:14:31.695 : Obtained module "E:\WINNT\System32\SysSetup.Dll"
procedure "CriticalDeviceCoInstaller" for use.
:
Setup performs various device installation operations
before it sends a DIF_INSTALLDEVICEFILES request.
:
@ 15:14:32.026 : Device install function: DIF_INSTALLDEVICEFILES.
Setup logs each device installation function code.
Co-installers are numbered in the order that they are loaded.
@ 15:14:32.026 : Executing co-installer 1 of 1.
@ 15:14:32.036 : Completed co-installer 1 of 1.
In this example, there is no class installer for the
device's setup class. You can tell this because there is
no entry for "Executing class-installer."
@ 15:14:32.046 : Completed class-installer.
Now Setup calls the default handler for this DIF request.
If "Executing default installer" is listed before the class
installer completes, that means the class installer called
the default handler function directly.
@ 15:14:32.046 : Executing default installer.
@ 15:14:32.056 : Install Device: Begin.
Setup lists the devnode here.
@ 15:14:32.066 : Doing copy-only install of ACPI\PNP0200\4&12BA42B2&0.
Setup lists the INF and decorated INF section being used.
@ 15:14:32.136 : Installing section NO_DRV_X from e:\winnt\inf\machine.inf.
@ 15:14:32.146 : Install Device: Queuing files from INF(s).
@ 15:14:32.156 : Install Device: Queuing co-installer files from
INF(s).
Processing co-installer registration section NO_DRV_X.CoInstallers.
@ 15:14:32.236 : Verifying file: E:\WINNT\INF\certclas.inf using key:
certclas.inf in catalog: -.
@ 15:14:32.346 : Co-Installers Registered.
@ 15:14:32.356 : Installing section NO_DRV_X.Interfaces from
e:\winnt\inf\machine.inf.
@ 15:14:32.366 : Interfaces installed.
@ 15:14:32.376 : Device install finished successfully
(ACPI\PNP0200\4&12BA42B2&0).
@ 15:14:32.386 : Install Device: End.
@ 15:14:32.396 : Completed default installer.
The installation pass for copying files has finished successfully.
Now carry on with the rest of the installation operations for this
device.
@ 15:14:32.457 : Verifying file: e:\winnt\inf\machine.inf using key:
machine.inf in catalog: -.
@ 15:14:32.497 : Verifying file: e:\winnt\inf\layout.inf using key:
layout.inf in catalog: -.
@ 15:14:32.557 : Pruning Files: Verifying catalogs/infs.
@ 15:14:32.567 : Pruning Files: Verifying catalogs/infs completed.
:
Setup performs various other device installation
functions before sending DIF_INSTALLDEVICE.
:
@ 15:14:33.498 : Device install function: DIF_INSTALLDEVICE.
@ 15:14:33.498 : Executing co-installer 1 of 1.
@ 15:14:33.518 : Completed co-installer 1 of 1.
@ 15:14:33.528 : Completed class-installer.
@ 15:14:33.538 : Executing default installer.
@ 15:14:33.538 : Install Device: Begin.
@ 15:14:33.548 : Doing full install of ACPI\PNP0200\4&12BA42B2&0.
@ 15:14:33.628 : Install Device: Changing registry settings specified
by INF(s).
@ 15:14:33.638 : Install Device: Writing driver specific registry
settings.
@ 15:14:33.668 : Install Device: Installing required Windows services.
@ 15:14:33.678 : Install Device: Writing drive descriptive registry
settings.
@ 15:14:33.708 : Install Device: Restarting device.
@ 15:14:33.768 : Install Device: Restarting device completed.
@ 15:14:33.788 : Device install finished successfully
(ACPI\PNP0200\4&12BA42B2&0).
@ 15:14:33.798 : Install Device: End.
@ 15:14:33.798 : Completed default installer.
@ 15:14:33.808 : Executing co-installer (Post Processing).
@ 15:14:33.838 : Completed co-installer 1 (Post Processing).
:
Setup performs various device installation functions
after sending DIF_INSTALLDEVICE.
:
Sample Windows XP SetupAPI Log File
For Windows XP, each log entry includes a message identifier consisting of a letter or dash (-) followed by a number. The following table describes the format for message identifiers.
Message ID |
Message Type |
#Ennn |
Error message. |
#Wnnn |
Warning message. |
#Innn |
Informational message. |
#Tnnn |
Timing message. |
#Vnnn |
Verbose message. |
#-nnn |
Status message. |
Following are a couple of segments from a Windows XP error log:
[2001/02/27 20:14:30 1148.173]
#-198 Command line processed: C:\WINDOWS\system32\mmc.exe "C:\WINDOWS\system32\devmgmt.msc"
#-147 Loading class installer module for "Communications Port".
@ 20:14:33.381 #V132 File "C:\WINDOWS\INF\certclas.inf" (key "certclas.inf") is signed in catalog "C:\WINDOWS\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\NT5INF.CAT".
@ 20:14:33.810 #V132 File "C:\WINDOWS\System32\MsPorts.Dll" (key "MsPorts.Dll") is signed in catalog "C:\WINDOWS\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\NT5.CAT".
@ 20:14:33.873 #V146 Using exported function "PortsClassInstaller" in module "C:\WINDOWS\System32\MsPorts.Dll".
@ 20:14:33.873 #V166 Device install function: DIF_UPDATEDRIVER_UI.
@ 20:14:33.873 #T152 Executing class installer.
@ 20:14:33.873 #V153 Completed class installer.
@ 20:14:33.889 #V155 Executing default installer.
@ 20:14:33.889 #V156 Completed default installer.
@ 20:14:36.302 #I060 Set selected driver.
#-019 Searching for hardware ID(s): *pnp0501
@ 20:14:36.318 #V017 Enumerating files "C:\WINDOWS\inf".
(following #V lines are logged only if driver bits of log level >= 0x7000)
@ 20:14:36.556 #V392 Using INF cache "C:\WINDOWS\inf\INFCACHE.1".
@ 20:14:36.731 #V073 Cache: Excluding INF "accessor.inf".
@ 20:14:36.731 #V073 Cache: Excluding INF "agtinst.inf".
:
:
@ 20:14:37.318 #T075 Enumerating files: Directory pass completed.
@ 20:14:37.398 #V005 Opened the PNF file of "C:\WINDOWS\inf\msports.inf" (Languge = 0409).
@ 20:14:37.413 #I022 Found "*PNP0501" in C:\WINDOWS\inf\msports.inf; Device: "Communications Port"; Driver: "Communications Port"; Provider: "Microsoft"; Mfg: "(Standard port types)"; Section name: "ComPort".
(rank of 0 is absolute best match)
@ 20:14:37.413 #I023 Actual install section: [ComPort.NT]. Rank: 0x00001000. Effective driver date: 02/14/2001.
@ 20:14:37.413 #I022 Found "*PNP0501" in C:\WINDOWS\inf\msports.inf; Device: "Communications Port"; Driver: "Communications Port"; Provider: "Microsoft"; Mfg: "(Standard port types)"; Section name: "ComPort".
@ 20:14:37.413 #I023 Actual install section: [ComPort.NT]. Rank: 0x00000000. Effective driver date: 02/14/2001.
@ 20:14:37.413 #T076 Enumerating files: Cache pass completed.
@ 20:15:01.383 #V166 Device install function: DIF_SELECTBESTCOMPATDRV.
@ 20:15:01.383 #T152 Executing class installer.
@ 20:15:01.383 #V153 Completed class installer.
@ 20:15:01.399 #V155 Executing default installer.
@ 20:15:01.399 #I063 Selected driver installs from section [ComPort] in "c:\windows\inf\msports.inf".
@ 20:15:01.526 #I320 Class GUID of device remains {4D36E978-E325-11CE-BFC1-08002BE10318}.
@ 20:15:01.526 #I060 Set selected driver.
@ 20:15:01.526 #I058 Selected best compatible driver.
@ 20:15:01.526 #V156 Completed default installer.
@ 20:15:02.447 #V166 Device install function: DIF_ALLOW_INSTALL.
@ 20:15:02.447 #T152 Executing class installer.
@ 20:15:02.447 #V153 Completed class installer.
@ 20:15:02.447 #V155 Executing default installer.
@ 20:15:02.447 #V156 Completed default installer.
@ 20:15:02.463 #V166 Device install function: DIF_INSTALLDEVICEFILES.
@ 20:15:02.463 #T152 Executing class installer.
@ 20:15:02.463 #V153 Completed class installer.
@ 20:15:02.463 #V155 Executing default installer.
@ 20:15:02.463 #T200 Install Device: Begin.
@ 20:15:02.478 #V124 Doing copy-only install of "ROOT\*PNP0501\PNPBIOS_17".
@ 20:15:02.478 #V005 Opened the PNF file of "c:\windows\inf\msports.inf" (Languge = 0409).
@ 20:15:02.478 #V005 Opened the PNF file of "c:\windows\inf\layout.inf" (Languge = 0409).
@ 20:15:02.494 #V011 Installing section [ComPort.NT] from "c:\windows\inf\msports.inf".
@ 20:15:02.494 #T203 Install Device: Queuing files from INF(s).
@ 20:15:02.510 #V005 Opened the PNF file of "C:\WINDOWS\INF\drvindex.inf" (Languge = 0409).
@ 20:15:02.590 #V094 Queued copy from section [ComPort.NT.Copy] in "c:\windows\inf\msports.inf": "serial.sys" to "serial.sys" with flags 0x80000024, target directory is "C:\WINDOWS\System32\DRIVERS".
@ 20:15:02.590 #V096 Source in section [sourcedisksfiles] in "c:\windows\inf\layout.inf"; Media=1 Description="Windows XP Professional CD-ROM" Tag="\win51ip.b2" Path="\i386". Driver cache will be used.
@ 20:15:02.605 #V132 File "C:\WINDOWS\INF\certclas.inf" (key "certclas.inf") is signed in catalog "C:\WINDOWS\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\NT5INF.CAT".
@ 20:15:02.605 #V005 Opened the PNF file of "C:\WINDOWS\INF\certclas.inf" (Languge = 0409).
@ 20:15:02.685 #V094 Queued copy from section [ComPort.NT.Copy] in "c:\windows\inf\msports.inf": "serenum.sys" to "serenum.sys" with flags 0x80000024, target directory is "C:\WINDOWS\System32\DRIVERS".
@ 20:15:02.685 #V096 Source in section [sourcedisksfiles] in "c:\windows\inf\layout.inf"; Media=1 Description="Windows XP Professional CD-ROM" Tag="\win51ip.b2" Path="\i386". Driver cache will be used.
@ 20:15:02.685 #T204 Install Device: Queuing coinstaller files from INF(s).
@ 20:15:02.685 #V005 Opened the PNF file of "c:\windows\inf\msports.inf" (Languge = 0409).
@ 20:15:02.701 #V005 Opened the PNF file of "c:\windows\inf\layout.inf" (Languge = 0409).
#-046 Processing Coinstaller registration section [ComPort.NT.CoInstallers].
@ 20:15:02.701 #V056 Coinstallers registered.
@ 20:15:02.717 #V011 Installing section [ComPort.NT.Interfaces] from "c:\windows\inf\msports.inf".
@ 20:15:02.732 #V054 Interfaces installed.
@ 20:15:02.732 #V121 Device install of "ROOT\*PNP0501\PNPBIOS_17" finished successfully.
@ 20:15:02.732 #T201 Install Device: End.
@ 20:15:02.748 #V156 Completed default installer.
@ 20:15:02.748 #T185 Pruning Files: Verifying catalogs/infs.
@ 20:15:02.764 #V132 File "c:\windows\inf\msports.inf" (key "msports.inf") is signed in catalog "C:\WINDOWS\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\NT5INF.CAT".
@ 20:15:02.812 #V132 File "c:\windows\inf\layout.inf" (key "layout.inf") is signed in catalog "C:\WINDOWS\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\NT5INF.CAT".
@ 20:15:02.812 #T186 Pruning Files: Verifying catalogs/infs completed.
@ 20:15:02.859 #V132 File "C:\WINDOWS\System32\DRIVERS\serial.sys" (key "serial.sys") is signed in catalog "C:\WINDOWS\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\NT5.CAT".
@ 20:15:02.875 #V191 File "C:\WINDOWS\System32\DRIVERS\serial.sys" pruned from copy.
@ 20:15:02.875 #V132 File "C:\WINDOWS\System32\DRIVERS\serenum.sys" (key "serenum.sys") is signed in catalog "C:\WINDOWS\System32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\NT5.CAT".
@ 20:15:02.875 #V191 File "C:\WINDOWS\System32\DRIVERS\serenum.sys" pruned from copy.
@ 20:15:02.875 #V166 Device install function: DIF_REGISTER_COINSTALLERS.
@ 20:15:02.923 #T152 Executing class installer.
@ 20:15:02.939 #V153 Completed class installer.
@ 20:15:02.939 #V155 Executing default installer.
@ 20:15:02.939 #V005 Opened the PNF file of "c:\windows\inf\msports.inf" (Languge = 0409).
@ 20:15:02.939 #I056 Coinstallers registered.
@ 20:15:02.955 #V156 Completed default installer.
@ 20:15:02.955 #V166 Device install function: DIF_INSTALLINTERFACES.
@ 20:15:02.955 #T152 Executing class installer.
@ 20:15:02.955 #V153 Completed class installer.
@ 20:15:02.955 #V155 Executing default installer.
@ 20:15:02.971 #V005 Opened the PNF file of "c:\windows\inf\msports.inf" (Languge = 0409).
@ 20:15:02.971 #V011 Installing section [ComPort.NT.Interfaces] from "c:\windows\inf\msports.inf".
@ 20:15:02.986 #I054 Interfaces installed.
@ 20:15:02.986 #V156 Completed default installer.
@ 20:15:02.986 #V166 Device install function: DIF_INSTALLDEVICE.
@ 20:15:03.002 #T152 Executing class installer.
@ 20:15:03.002 #V005 Opened the PNF file of "c:\windows\inf\msports.inf" (Languge = 0409).
@ 20:15:03.018 #T200 Install Device: Begin.
@ 20:15:03.018 #I123 Doing full install of "ROOT\*PNP0501\PNPBIOS_17".
@ 20:15:03.018 #V005 Opened the PNF file of "c:\windows\inf\msports.inf" (Languge = 0409).
@ 20:15:03.018 #T211 Install Device: Changing registry settings as specified by the INF(s).
@ 20:15:03.034 #T212 Install Device: Writing driver specific registry settings.
@ 20:15:03.050 #T213 Install Device: Installing required Windows services.
#-035 Processing service Add/Delete section [ComPort.NT.Services].
@ 20:15:03.320 #V282 Add Service: Modified existing service "Serial".
@ 20:15:03.653 #V282 Add Service: Modified existing service "Serenum".
@ 20:15:03.669 #T214 Install Device: Writing drive descriptive registry settings.
@ 20:15:03.669 #T216 Install Device: Restarting device.
@ 20:15:06.399 #T217 Install Device: Restarting device completed.
@ 20:15:06.399 #W114 Device "ROOT\*PNP0501\PNPBIOS_17" required reboot: Device has problem: 0x0c: CM_PROB_NORMAL_CONFLICT.
@ 20:15:06.399 #T222 Install Device: Calling RunOnce/GrpConv items.
@ 20:15:06.415 #I138 Executing RunOnce to process 5 RunOnce entries.
@ 20:15:07.241 #I121 Device install of "ROOT\*PNP0501\PNPBIOS_17" finished successfully.
@ 20:15:07.272 #T201 Install Device: End.
@ 20:15:07.336 #V153 Completed class installer.
@ 20:15:07.368 #V166 Device install function: DIF_NEWDEVICEWIZARD_FINISHINSTALL.
@ 20:15:07.368 #T152 Executing class installer.
@ 20:15:07.495 #V153 Completed class installer.
@ 20:15:07.495 #V155 Executing default installer.
@ 20:15:07.495 #V156 Completed default installer.
@ 20:15:42.100 #V166 Device install function: DIF_DESTROYPRIVATEDATA.
@ 20:15:42.100 #T152 Executing class installer.
@ 20:15:42.100 #V153 Completed class installer.
@ 20:15:42.116 #V155 Executing default installer.
@ 20:15:42.116 #V156 Completed default installer.