Restoring Functionality with the Last Known Good Configuration
It's happened to me, and I'm sure it's happened to you, as well. You pop in a CD to install a driver for a snazzy new piece of hardware and blam, the system comes to a grinding halt and the bugcheck screen appears. After a few minutes, the system restarts and you watch as blam, the system crashes again.
It doesn't take a diagnostic genius to figure out that the driver you just installed made some change in the deep recesses of the machine that is giving Mr. Computer indigestion. The problem now becomes restoring the system back to functionality.
The obvious first step is to keep the bad driver from loading. Drivers are loaded by Registry entries in a top-level key in the System hive called a control set. If you could just use a copy of the old control set that doesn't have the entry for the new driver, life would be good. This is the philosophy behind the Last Known Good Configuration option in the Safe Mode menu.
Structure of Control Sets
Launch the Registry Editor and expand the tree under the HKLM | System hive to a key called Current Control Set. This control set holds four high-level keys that have the parameters for controlling services and drivers. These keys are as follows:
This key contains the parameters that the operating system kernel needs to boot the system. This includes settings for software classes, device classes, load sequencing for device drivers, and security settings. Control also contains parameters used by the Configuration Manager so it can access the Registry. This leads to a Catch-22 situation. The Configuration Manager needs parameters in the Control key to tell it how to read transaction tracking logs. If an update to the Control key is in the transaction tracking log, the system could fail to start. For this reason, the system stores a complete backup of the System hive in a file called System.alt.
This key stores the results of Plug-and-Play enumeration. When you open the Device Management console and see the list of devices and their associated parameters and resources, you are looking at a graphical representation of the Enum key contents.
This key is like a miniature control set that sets special parameters for Docked or Undocked conditions. Hardware profiles are rarely needed thanks to Plug-and-Play, but if you define profiles, the special configuration settings associated with that profile are saved here. If multiple hardware profiles exist, then Ntldr presents a selection menu right after the standard boot menu.
This key contains the operating parameters for all services and drivers.
You'll notice that there are three control set keys: the Current Control Set and Control Set 1 and Control Set 2. Highlight the Select key, which sits outside the control sets. This key has three values:
This points to the control set that was used to boot the machine. This entry points at Control Set 1.
This points to the control set that will be used during the next normal boot. This entry also points at Control Set 1.
If this entry has a value, it's because a control set has been marked as Failed following the selection of a new default control set. The normal entry is 0, meaning that no control sets have been marked as failed.
This entry points at the control set that last successfully booted the machine. This entry points at Control Set 2.
Recovering the Last Known Good Configuration
With this information in mind, Procedure 21.7 shows the sequence of events when a machine boots and the user selects the Last Known Good Configuration option.
Procedure 21.7 Booting with the Last Known Good Configuration
The machine POSTs then loads the boot sector image. This image loads the NT bootstrap loader, Ntldr.
One of Ntldr's duties is to check HKLM | System | Select to find the identity of the Default control set. It passes the number of this control set to the NT kernel driver, Ntoskrnl.
If the user interrupts the standard boot process by pressing F8 at the boot menu, Ntldr displays the Advanced Options Menu. One of the options is Last Known Good Configuration.
Highlight the Last Known Good Configuration option and press Enter. The system returns to the boot menu with a red message across the bottom of the screen saying Last Known Good Configuration. At this point, two things happen in the Select key. The original Default control set, which was Control Set 1, is now marked as Failed. Also, the LastKnownGood control set, Control Set 2, is set as Default.
Select the standard boot menu item, which should say Microsoft Windows Server 2003, and press Enter. NTLDR starts loading drivers then displays the Hardware Profile/Configuration Recovery Menu.
The Recovery Menu is a combination of the hardware profile selection menu and a control set selection window. This window is a holdover from classic NT. No action should be taken.
Press Enter to continue or let the counter do it for you. The Windows Executive loads, shifts to graphics mode, then initializes the system based on the contents of the Default control set, which at this time is Control Set 2. In other words, Control Set 2 becomes the Current control set.
If the system boots successfully, defined as all services starting, all drivers loading, and a user logging on successfully at the console, then a value of 1 is set in the ReportBootOK value under the Winlogon key in HKLM | Software | Microsoft | Windows NT | CurrentVersion.
A ReportBootOK of 1 indicates that the current control set successfully booted the system. The contents of the current control set, which is now Control Set 2, is copied to a new control set, Control Set 3, which becomes the LastKnownGood control set.
After this procedure, the resulting control set assignments in the Select key would be the following:
As you can see, this game of musical control sets only resolves a blue screen problem if it is caused by an entry in a control set subkey. If the problem is caused by an entry in some other hive, such as Software, the system will continue to be unstable.