The
Another way to monitor registry activity during the logon, logoff, boot, or shutdown process is to use the Process Monitor log boot feature, which you can enable by selecting Log Boot on the Options menu. The next time you boot the system, the Process Monitor device driver logs registry activity from early in the boot to %SystemRoot%\Procmon.pml. It will continue logging to that file until disk space runs out, the system shuts down, or you run Process Monitor. A log file storing a registry trace of startup, logon, logoff, and shutdown on a Windows system will typically be between 50 and 150 MB in size.
Registry Internals
In this section, you’ll find out how the configuration manager—the executive subsystem that implements the registry—organizes the registry’s on-disk files. We’ll examine how the configuration manager manages the registry as applications and other operating system components read and change registry keys and values. We’ll also discuss the mechanisms by which the configuration manager tries to ensure that the registry is always in a recoverable state, even if the system crashes while the registry is being modified.
Hives
On disk, the registry isn’t simply one large file but rather a set of discrete files called hives. Each hive contains a registry tree, which has a key that serves as the root or starting point of the tree. Subkeys and their values reside beneath the root. You might think that the root keys displayed by the Registry Editor correlate to the root keys in the hives, but such is not the case. Table 4-5 lists registry hives and their on-disk file names. The path names of all hives except for user profiles are coded into the configuration manager. As the configuration manager loads hives, including system profiles, it notes each hive’s path in the values under the HKLM\SYSTEM\CurrentControlSet\Control\Hivelist subkey, removing the path if the hive is unloaded. It creates the root keys, linking these hives together to build the registry structure you’re familiar with and that the Registry Editor displays.
You’ll notice that some of the hives listed in Table 4-5 are volatile and don’t have associated files. The system creates and manages these hives entirely in memory; the hives are therefore temporary. The system creates volatile hives every time it boots. An example of a volatile hive is the HKLM\HARDWARE hive, which stores information about physical devices and the devices’ assigned resources. Resource assignment and hardware detection occur every time the system boots, so not storing this data on disk is logical.
Hive Registry Path
Hive File Path
HKEY_LOCAL_MACHINE\BCD00000000
\Boot\BCD
HKEY_LOCAL_MACHINE\COMPONENTS
%SystemRoot%\System32\Config\Components
HKEY_LOCAL_MACHINE\SYSTEM
%SystemRoot%\System32\Config\System
HKEY_LOCAL_MACHINE\SAM
%SystemRoot%\System32\Config\Sam
HKEY_LOCAL_MACHINE\SECURITY
%SystemRoot%\System32\Config\Security
HKEY_LOCAL_MACHINE\SOFTWARE
%SystemRoot%\System32\Config\Software
HKEY_LOCAL_MACHINE\HARDWARE
Volatile hive
HKEY_USERS\
%SystemRoot%\ServiceProfiles\LocalService\Ntuser.dat
HKEY_USERS\
%SystemRoot%\ServiceProfiles\NetworkService\NtUser.dat
HKEY_USERS\
\Users\
HKEY_USERS\
\Users\
HKEY_USERS\.DEFAULT
%SystemRoot%\System32\Config\Default
EXPERIMENT: Manually Loading and Unloading Hives
Regedit has the ability to load hives that you can access through its File menu. This capability can be useful in troubleshooting scenarios where you want to view or edit a hive from an unbootable system or a backup medium. In this experiment, you’ll use Regedit to load a version of the HKLM\SYSTEM hive that Windows Setup creates during the install process.
Hives can be loaded only underneath HKLM or HKU, so open Regedit, select HKLM, and choose Load Hive from the Regedit File menu.
Navigate to the %SystemRoot%\System32\Config\RegBack directory in the Load Hive dialog box, select System and open it. When prompted, type Test as the name of the key under which it will load.
Open the newly created HKLM\Test key, and explore the contents of the hive.