Initializing the File-based Registry

To initialize the registry, call OEMIoControl with IOCTL_HAL_GETREGSECUREKEYS.

To initialize a file-based registry

  1. Mount the boot hive from ROM to determine where the registry is stored.

  2. Call the OEM through OEMIoControl with IOCTL_HAL_INITREGISTRY.

  3. Start Device.exe if the registry value Start DevMgr under HKEY_LOCAL_MACHINE\init\BootVars is set to 1.

    Load the storage manager if HKEY_LOCAL_MACHINE\System\StorageManager points to a loadable DLL.

    If storage manager is loaded, create a thread to initialize it. The thread will exit when done.

    Create an event called SYSTEM/BootPhase2, which will be triggered when the real system registry is loaded.

    Wait for a file system to register as the storage location for registry hives.

  4. Mount the ROM portion of the system registry.

  5. Call the OEM with IOCTL_HAL_GET_HIVE_CLEAN_FLAG if there is a mismatch between the ROM portion of the system registry and the file portion.

  6. Mount the RAM portion of the system registry if a clean registry is not required. If this is a clean registry, the old registry file will be deleted and a new file will be created.

  7. Invalidate any currently open system registry handles before swapping out the boot registry hive.

  8. When the system registry is loaded, perform the following actions:

    • Mount the ROM portion of the system registry hive.
    • Mount the RAM portion of the system registry hive.
    • If the ROM and RAM portions of the registry are not synchronized, perform a clean boot on the system hive.
  9. Migrate changes from the boot registry hive to the system hive.

  10. If this is not a clean boot, set the registry value RegPersisted under HKEY_LOCAL_MACHINE to 1. At this point, non-user specific registry data becomes available.

  11. Determine where the user profiles are stored by looking at the registry value ProfileDir under HKEY_LOCAL_MACHINE\init\BootVars.

  12. Call the OEM with IOCTL_HAL_GET_HIVE_CLEAN_FLAG if there is a mismatch between the ROM porting of the system registry and the file portion. If you indicate that they should be cleaned, all user profile directories are removed, along with their contents.

  13. Determine if the default user profile should be loaded. If the registry value NoDefaultUser under HKEY_LOCAL_MACHINE\init\BootVars is set to 1, a call to SetCurrentUser is required to load a user profile. If NoDefaultUser is set to 0, the default user profile is loaded.

    The default user hive to load is determined by the value of DefaultUser, a REG_SZ value, in HKEY_LOCAL_MACHINE\init\BootVars. The DefaultUser is set to the name of the user to use as the default profile when the system boots. If it is an existing user, the appropriate user hive is loaded. If it is a new user, the user profile can be created. If DefaultUser is not set, the default user profile is loaded. You can implement this with the following registry key.

    [HKEY_LOCAL_MACHINE\init\BootVars]
        "DefaultUser"=<username>
    
  14. When the user registry is loaded, perform the following actions:

    • Mount the ROM portion of the user registry hive.
    • Mount the RAM portion of the user registry hive.
    • If the ROM and RAM portions of the registry are not synchronized, perform a clean boot of the user profile.
    • If this is not a clean registry, set the registry value RegPersisted under HKEY_CURRENT_USER to 1.

See Also

Initializing the Registry

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.