Tuesday, April 15, 2008

Five Stages of Mastering the Windows Registry

1. Fear of the new language
Mastering the registry, means learning a new language with its own syntax. At first there seems to be no pattern just strange words and hexadecimal numbers. For example, HKEY_Local_Machine Dword 0x00004B.

Activities in this first stage are confined to tentatively changing a few values from zero to one.

2. Wonderment Power Skill

After a while you begin to crack the code, HKEY_Current_User means the personal settings of the account logged on. It hits you that a String Value is text and DWORD is a number.

As you advance from changing existing values to adding new values you realize that the words are not case sensitive and the mixed case is just to make 'Values' easier to read.

3. Complacency - I can do anything
Now you reach the stage where a little knowledge is dangerous, you discover export and realize that you can import settings quickly by double clicking .reg files. Because you are having such fun you start taking risks, you cannot imagine anything can go wrong.

4. Panic - slip on a banana skin
Complacency will inevitably lead to disaster. Just as surely as children playing with knives get cut, or those playing with matches get burnt, so those messing with the registry will get: Machine will not boot Stop 0x0000051 error.

Stop messages like the above cause the heart to beat faster, you realize that you have gone too far and deleted or overwritten a vital section. At this stage it is either do or die. Either you vow never to touch Regedit again, and rebuild the machine from scratch, or you stay calm and rise to the next skill level.

5. Respect for registry editingKnowledge, power, and respect go hand in hand. In times of crisis you remember good practices, firstly you try F8, and Last Known Good. If that does not work then there is safe mode.

Once safe mode gets you in then you have a variety of tactics. Best is probably to restore the registry from the system state backup you made just before your Regedit session. You did backup didn't you?

If that does not work then boot into a parallel installation (if you have one). If there is no time for a parallel installation try and get a command console session started. Either run winnt32 / cmdcons in advance of your Regedit changes, or put a bootable OS CD in the caddy, and select Restore from the menu.

The .sav files could be your salvation I once used a parallel installation to find the original %SystemRoot%\System32\config folder and renamed software.sav and so got the machine to restart. Once the machine started I was able to import a .reg file that I can cunningly exported before trying a risky experiment.

In this final stage, you always have an eye on safety. Make those backups, assemble those tools, export the registry section regularly.

registry

Hives
The Registry is split into a number of logical sections, or "hives".[3] Hives are generally named by their Windows API definitions, which all begin "HKEY". They are abbreviated to a three- or four-letter short name starting with "HK" (e.g. HKCU and HKLM).

The HKEY_LOCAL_MACHINE and HKEY_CURRENT_USER nodes have a similar structure to each other; applications typically look up their settings by first checking for them in "HKEY_CURRENT_USER\Software\Vendor's name\Application's name\Version\Setting name", and if the setting is not found look instead in the same location under the HKEY_LOCAL_MACHINE key. When writing settings back, the reverse approach is used — HKEY_LOCAL_MACHINE is written first, but if that cannot be written to (which is usually the case if the logged-in user is not an administrator), the setting is stored in HKEY_CURRENT_USER instead.


HKEY_CLASSES_ROOT (HKCR)
Abbreviated HKCR, HKEY_CLASSES_ROOT stores information about registered applications, such as file associations and OLE Object Class IDs tying them to the applications used to handle these items. On Windows 2000 and above, HKCR is a compilation of HKCU\Software\Classes and HKLM\Software\Classes. If a given value exists in both of the subkeys above, the one in HKCU\Software\Classes is used.[4]


HKEY_CURRENT_USER (HKCU)
Abbreviated HKCU, HKEY_CURRENT_USER stores settings that are specific to the currently logged-in user. The HKCU key is a link to the subkey of HKEY_USERS that corresponds to the user; the same information is reflected in both locations. On Windows-NT based systems, each user's settings are stored in their own files called NTUSER.DAT and USRCLASS.DAT inside their own Documents and Settings subfolder (or the Users subfolder in Windows Vista).


HKEY_LOCAL_MACHINE (HKLM)
Abbreviated HKLM, HKEY_LOCAL_MACHINE stores settings that are general to all users on the computer. On NT-based versions of Windows, HKLM contains four subkeys, SAM, SECURITY, SOFTWARE and SYSTEM, that are found within their respective files located in the %SystemRoot%\System32\Config folder. A fifth subkey, HARDWARE, is volatile and is created dynamically, and as such is not stored in a file. Information about system hardware drivers and services are located under the SYSTEM subkey, while the SOFTWARE subkey contains software and Windows settings.


HKEY_USERS (HKU)
Abbreviated HKU, HKEY_USERS contains subkeys corresponding to the HKEY_CURRENT_USER keys for each user profile actively loaded on the machine, though user hives are usually only loaded for currently logged-in users.


HKEY_CURRENT_CONFIG
Abbreviated HKCC, HKEY_CURRENT_CONFIG contains information gathered at runtime; information stored in this key is not permanently stored on disk, but rather regenerated at boot time.


HKEY_PERFORMANCE_DATA
This key provides runtime information into performance data provided by either the NT kernel itself or other programs that provide performance data. This key is not displayed in the Registry Editor, but it is visible through the registry functions in the Windows API.


HKEY_DYN_DATA
This key is used only on Windows 95, Windows 98 and Windows Me. [5] It contains information about hardware devices, including Plug-and-Play and network performance statistics. The information in this hive is also not stored on the hard drive. The Plug and Play information is gathered and configured at startup and is stored in memory. [6]

AVTeK Institute