mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:52:56 +00:00
[SETUPLIB][USETUP] Move the registry-update procedure into setuplib.
- It can therefore be also used by the 1st-stage GUI setup. - Rename some function parameters to clarify what they should be. Based on: svn path=/branches/setup_improvements/; revision=75750
This commit is contained in:
parent
dae658088a
commit
6c2d3dee04
7 changed files with 332 additions and 236 deletions
|
@ -611,7 +611,7 @@ C_ASSERT(_countof(SecurityRegistryHives) == NUMBER_OF_SECURITY_REGISTRY_HIVES);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VerifyRegistryHives(
|
VerifyRegistryHives(
|
||||||
IN PUNICODE_STRING InstallPath,
|
IN PUNICODE_STRING NtSystemRoot,
|
||||||
OUT PBOOLEAN ShouldRepairRegistry)
|
OUT PBOOLEAN ShouldRepairRegistry)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -642,7 +642,7 @@ VerifyRegistryHives(
|
||||||
|
|
||||||
for (i = 0; i < ARRAYSIZE(RegistryHives); ++i)
|
for (i = 0; i < ARRAYSIZE(RegistryHives); ++i)
|
||||||
{
|
{
|
||||||
Status = VerifyRegistryHive(InstallPath, RegistryHives[i].HiveName);
|
Status = VerifyRegistryHive(NtSystemRoot, RegistryHives[i].HiveName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Registry hive '%S' needs repair!\n", RegistryHives[i].HiveName);
|
DPRINT1("Registry hive '%S' needs repair!\n", RegistryHives[i].HiveName);
|
||||||
|
@ -658,7 +658,7 @@ VerifyRegistryHives(
|
||||||
/** These hives are created by LSASS during 2nd stage setup */
|
/** These hives are created by LSASS during 2nd stage setup */
|
||||||
for (i = 0; i < ARRAYSIZE(SecurityRegistryHives); ++i)
|
for (i = 0; i < ARRAYSIZE(SecurityRegistryHives); ++i)
|
||||||
{
|
{
|
||||||
Status = VerifyRegistryHive(InstallPath, SecurityRegistryHives[i].HiveName);
|
Status = VerifyRegistryHive(NtSystemRoot, SecurityRegistryHives[i].HiveName);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("Registry hive '%S' needs repair!\n", SecurityRegistryHives[i].HiveName);
|
DPRINT1("Registry hive '%S' needs repair!\n", SecurityRegistryHives[i].HiveName);
|
||||||
|
@ -687,7 +687,7 @@ VerifyRegistryHives(
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
RegInitializeRegistry(
|
RegInitializeRegistry(
|
||||||
IN PUNICODE_STRING InstallPath)
|
IN PUNICODE_STRING NtSystemRoot)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
|
@ -750,7 +750,7 @@ RegInitializeRegistry(
|
||||||
if (RegistryHives[i].State != Create && RegistryHives[i].State != Repair)
|
if (RegistryHives[i].State != Create && RegistryHives[i].State != Repair)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Status = CreateRegistryFile(InstallPath,
|
Status = CreateRegistryFile(NtSystemRoot,
|
||||||
RegistryHives[i].HiveName,
|
RegistryHives[i].HiveName,
|
||||||
RegistryHives[i].State != Repair, // RegistryHives[i].State == Create,
|
RegistryHives[i].State != Repair, // RegistryHives[i].State == Create,
|
||||||
KeyHandle);
|
KeyHandle);
|
||||||
|
@ -833,7 +833,7 @@ RegInitializeRegistry(
|
||||||
{
|
{
|
||||||
Status = ConnectRegistry(NULL,
|
Status = ConnectRegistry(NULL,
|
||||||
RegistryHives[i].HiveRegistryPath,
|
RegistryHives[i].HiveRegistryPath,
|
||||||
InstallPath,
|
NtSystemRoot,
|
||||||
RegistryHives[i].HiveName
|
RegistryHives[i].HiveName
|
||||||
/* SystemSecurity, sizeof(SystemSecurity) */);
|
/* SystemSecurity, sizeof(SystemSecurity) */);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -995,7 +995,7 @@ Quit:
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
RegCleanupRegistry(
|
RegCleanupRegistry(
|
||||||
IN PUNICODE_STRING InstallPath)
|
IN PUNICODE_STRING NtSystemRoot)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
HANDLE KeyHandle;
|
HANDLE KeyHandle;
|
||||||
|
@ -1094,7 +1094,7 @@ RegCleanupRegistry(
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 3,
|
CombinePaths(SrcPath, ARRAYSIZE(SrcPath), 3,
|
||||||
InstallPath->Buffer, L"System32\\config", RegistryHives[i].HiveName);
|
NtSystemRoot->Buffer, L"System32\\config", RegistryHives[i].HiveName);
|
||||||
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), SrcPath);
|
RtlStringCchCopyW(DstPath, ARRAYSIZE(DstPath), SrcPath);
|
||||||
RtlStringCchCatW(DstPath, ARRAYSIZE(DstPath), L".sav");
|
RtlStringCchCatW(DstPath, ARRAYSIZE(DstPath), L".sav");
|
||||||
|
|
||||||
|
|
|
@ -47,15 +47,15 @@ ImportRegistryFile(
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
VerifyRegistryHives(
|
VerifyRegistryHives(
|
||||||
IN PUNICODE_STRING InstallPath,
|
IN PUNICODE_STRING NtSystemRoot,
|
||||||
OUT PBOOLEAN ShouldRepairRegistry);
|
OUT PBOOLEAN ShouldRepairRegistry);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
RegInitializeRegistry(
|
RegInitializeRegistry(
|
||||||
IN PUNICODE_STRING InstallPath);
|
IN PUNICODE_STRING NtSystemRoot);
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
RegCleanupRegistry(
|
RegCleanupRegistry(
|
||||||
IN PUNICODE_STRING InstallPath);
|
IN PUNICODE_STRING NtSystemRoot);
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -574,4 +574,240 @@ LoadSetupInf(
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SIDEEFFECTS
|
||||||
|
* Calls RegInitializeRegistry
|
||||||
|
* Calls ImportRegistryFile
|
||||||
|
* Calls SetDefaultPagefile
|
||||||
|
* Calls SetMountedDeviceValues
|
||||||
|
*/
|
||||||
|
ERROR_NUMBER
|
||||||
|
UpdateRegistry(
|
||||||
|
IN HINF SetupInf,
|
||||||
|
IN OUT PUSETUP_DATA pSetupData,
|
||||||
|
/**/IN BOOLEAN RepairUpdateFlag, /* HACK HACK! */
|
||||||
|
/**/IN PPARTLIST PartitionList, /* HACK HACK! */
|
||||||
|
/**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */
|
||||||
|
/**/IN PCWSTR SelectedLanguageId, /* HACK HACK! */
|
||||||
|
IN PGENERIC_LIST DisplayList,
|
||||||
|
IN PGENERIC_LIST LayoutList,
|
||||||
|
IN PGENERIC_LIST LanguageList,
|
||||||
|
IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL)
|
||||||
|
{
|
||||||
|
ERROR_NUMBER ErrorNumber;
|
||||||
|
NTSTATUS Status;
|
||||||
|
INFCONTEXT InfContext;
|
||||||
|
PWSTR Action;
|
||||||
|
PWSTR File;
|
||||||
|
PWSTR Section;
|
||||||
|
BOOLEAN Success;
|
||||||
|
BOOLEAN ShouldRepairRegistry = FALSE;
|
||||||
|
BOOLEAN Delete;
|
||||||
|
|
||||||
|
if (RepairUpdateFlag)
|
||||||
|
{
|
||||||
|
DPRINT1("TODO: Updating / repairing the registry is not completely implemented yet!\n");
|
||||||
|
|
||||||
|
/* Verify the registry hives and check whether we need to update or repair any of them */
|
||||||
|
Status = VerifyRegistryHives(&pSetupData->DestinationPath, &ShouldRepairRegistry);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("VerifyRegistryHives failed, Status 0x%08lx\n", Status);
|
||||||
|
ShouldRepairRegistry = FALSE;
|
||||||
|
}
|
||||||
|
if (!ShouldRepairRegistry)
|
||||||
|
DPRINT1("No need to repair the registry\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
DoUpdate:
|
||||||
|
ErrorNumber = ERROR_SUCCESS;
|
||||||
|
|
||||||
|
/* Update the registry */
|
||||||
|
if (StatusRoutine) StatusRoutine(RegHiveUpdate);
|
||||||
|
|
||||||
|
/* Initialize the registry and setup the registry hives */
|
||||||
|
Status = RegInitializeRegistry(&pSetupData->DestinationPath);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT1("RegInitializeRegistry() failed\n");
|
||||||
|
/********** HACK!!!!!!!!!!! **********/
|
||||||
|
if (Status == STATUS_NOT_IMPLEMENTED)
|
||||||
|
{
|
||||||
|
/* The hack was called, return its corresponding error */
|
||||||
|
return ERROR_INITIALIZE_REGISTRY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
/*************************************/
|
||||||
|
{
|
||||||
|
/* Something else failed */
|
||||||
|
return ERROR_CREATE_HIVE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!RepairUpdateFlag || ShouldRepairRegistry)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* We fully setup the hives, in case we are doing a fresh installation
|
||||||
|
* (RepairUpdateFlag == FALSE), or in case we are doing an update
|
||||||
|
* (RepairUpdateFlag == TRUE) BUT we have some registry hives to
|
||||||
|
* "repair" (aka. recreate: ShouldRepairRegistry == TRUE).
|
||||||
|
*/
|
||||||
|
|
||||||
|
Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible
|
||||||
|
if (!Success)
|
||||||
|
Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific
|
||||||
|
|
||||||
|
if (!Success)
|
||||||
|
{
|
||||||
|
DPRINT1("SetupFindFirstLine() failed\n");
|
||||||
|
ErrorNumber = ERROR_FIND_REGISTRY;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // if (RepairUpdateFlag && !ShouldRepairRegistry)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* In case we are doing an update (RepairUpdateFlag == TRUE) and
|
||||||
|
* NO registry hives need a repair (ShouldRepairRegistry == FALSE),
|
||||||
|
* we only update the hives.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext);
|
||||||
|
if (!Success)
|
||||||
|
{
|
||||||
|
/* Nothing to do for update! */
|
||||||
|
DPRINT1("No update needed for the registry!\n");
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
INF_GetDataField(&InfContext, 0, &Action);
|
||||||
|
INF_GetDataField(&InfContext, 1, &File);
|
||||||
|
INF_GetDataField(&InfContext, 2, &Section);
|
||||||
|
|
||||||
|
DPRINT("Action: %S File: %S Section %S\n", Action, File, Section);
|
||||||
|
|
||||||
|
if (Action == NULL)
|
||||||
|
{
|
||||||
|
INF_FreeData(Action);
|
||||||
|
INF_FreeData(File);
|
||||||
|
INF_FreeData(Section);
|
||||||
|
break; // Hackfix
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_wcsicmp(Action, L"AddReg"))
|
||||||
|
Delete = FALSE;
|
||||||
|
else if (!_wcsicmp(Action, L"DelReg"))
|
||||||
|
Delete = TRUE;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DPRINT1("Unrecognized registry INF action '%S'\n", Action);
|
||||||
|
INF_FreeData(Action);
|
||||||
|
INF_FreeData(File);
|
||||||
|
INF_FreeData(Section);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
INF_FreeData(Action);
|
||||||
|
|
||||||
|
if (StatusRoutine) StatusRoutine(ImportRegHive, File);
|
||||||
|
|
||||||
|
if (!ImportRegistryFile(pSetupData->SourcePath.Buffer,
|
||||||
|
File, Section,
|
||||||
|
pSetupData->LanguageId, Delete))
|
||||||
|
{
|
||||||
|
DPRINT1("Importing %S failed\n", File);
|
||||||
|
INF_FreeData(File);
|
||||||
|
INF_FreeData(Section);
|
||||||
|
ErrorNumber = ERROR_IMPORT_HIVE;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
} while (SetupFindNextLine(&InfContext, &InfContext));
|
||||||
|
|
||||||
|
if (!RepairUpdateFlag || ShouldRepairRegistry)
|
||||||
|
{
|
||||||
|
/* See the explanation for this test above */
|
||||||
|
|
||||||
|
/* Update display registry settings */
|
||||||
|
if (StatusRoutine) StatusRoutine(DisplaySettingsUpdate);
|
||||||
|
if (!ProcessDisplayRegistry(SetupInf, DisplayList))
|
||||||
|
{
|
||||||
|
ErrorNumber = ERROR_UPDATE_DISPLAY_SETTINGS;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the locale */
|
||||||
|
if (StatusRoutine) StatusRoutine(LocaleSettingsUpdate);
|
||||||
|
if (!ProcessLocaleRegistry(LanguageList))
|
||||||
|
{
|
||||||
|
ErrorNumber = ERROR_UPDATE_LOCALESETTINGS;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add keyboard layouts */
|
||||||
|
if (StatusRoutine) StatusRoutine(KeybLayouts);
|
||||||
|
if (!AddKeyboardLayouts(SelectedLanguageId))
|
||||||
|
{
|
||||||
|
ErrorNumber = ERROR_ADDING_KBLAYOUTS;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set GeoID */
|
||||||
|
if (!SetGeoID(MUIGetGeoID(SelectedLanguageId)))
|
||||||
|
{
|
||||||
|
ErrorNumber = ERROR_UPDATE_GEOID;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IsUnattendedSetup)
|
||||||
|
{
|
||||||
|
/* Update keyboard layout settings */
|
||||||
|
if (StatusRoutine) StatusRoutine(KeybSettingsUpdate);
|
||||||
|
if (!ProcessKeyboardLayoutRegistry(LayoutList, SelectedLanguageId))
|
||||||
|
{
|
||||||
|
ErrorNumber = ERROR_UPDATE_KBSETTINGS;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add codepage information to registry */
|
||||||
|
if (StatusRoutine) StatusRoutine(CodePageInfoUpdate);
|
||||||
|
if (!AddCodePage(SelectedLanguageId))
|
||||||
|
{
|
||||||
|
ErrorNumber = ERROR_ADDING_CODEPAGE;
|
||||||
|
goto Cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the default pagefile entry */
|
||||||
|
SetDefaultPagefile(DestinationDriveLetter);
|
||||||
|
|
||||||
|
/* Update the mounted devices list */
|
||||||
|
// FIXME: This should technically be done by mountmgr (if AutoMount is enabled)!
|
||||||
|
SetMountedDeviceValues(PartitionList);
|
||||||
|
}
|
||||||
|
|
||||||
|
Cleanup:
|
||||||
|
//
|
||||||
|
// TODO: Unload all the registry stuff, perform cleanup,
|
||||||
|
// and copy the created hive files into .sav files.
|
||||||
|
//
|
||||||
|
RegCleanupRegistry(&pSetupData->DestinationPath);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check whether we were in update/repair mode but we were actually
|
||||||
|
* repairing the registry hives. If so, we have finished repairing them,
|
||||||
|
* and we now reset the flag and run the proper registry update.
|
||||||
|
* Otherwise we have finished the registry update!
|
||||||
|
*/
|
||||||
|
if (RepairUpdateFlag && ShouldRepairRegistry)
|
||||||
|
{
|
||||||
|
ShouldRepairRegistry = FALSE;
|
||||||
|
goto DoUpdate;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ErrorNumber;
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -123,4 +123,32 @@ LoadSetupInf(
|
||||||
IN OUT PUSETUP_DATA pSetupData);
|
IN OUT PUSETUP_DATA pSetupData);
|
||||||
|
|
||||||
|
|
||||||
|
typedef enum _REGISTRY_STATUS
|
||||||
|
{
|
||||||
|
Success = 0,
|
||||||
|
RegHiveUpdate,
|
||||||
|
ImportRegHive,
|
||||||
|
DisplaySettingsUpdate,
|
||||||
|
LocaleSettingsUpdate,
|
||||||
|
KeybLayouts,
|
||||||
|
KeybSettingsUpdate,
|
||||||
|
CodePageInfoUpdate,
|
||||||
|
} REGISTRY_STATUS;
|
||||||
|
|
||||||
|
typedef VOID
|
||||||
|
(__cdecl *PREGISTRY_STATUS_ROUTINE)(IN REGISTRY_STATUS, ...);
|
||||||
|
|
||||||
|
ERROR_NUMBER
|
||||||
|
UpdateRegistry(
|
||||||
|
IN HINF SetupInf,
|
||||||
|
IN OUT PUSETUP_DATA pSetupData,
|
||||||
|
/**/IN BOOLEAN RepairUpdateFlag, /* HACK HACK! */
|
||||||
|
/**/IN PPARTLIST PartitionList, /* HACK HACK! */
|
||||||
|
/**/IN WCHAR DestinationDriveLetter, /* HACK HACK! */
|
||||||
|
/**/IN PCWSTR SelectedLanguageId, /* HACK HACK! */
|
||||||
|
IN PGENERIC_LIST DisplayList,
|
||||||
|
IN PGENERIC_LIST LayoutList,
|
||||||
|
IN PGENERIC_LIST LanguageList,
|
||||||
|
IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL);
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -133,7 +133,7 @@ CreateNestedKey(PHANDLE KeyHandle,
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
CreateRegistryFile(
|
CreateRegistryFile(
|
||||||
IN PUNICODE_STRING InstallPath,
|
IN PUNICODE_STRING NtSystemRoot,
|
||||||
IN PCWSTR RegistryKey,
|
IN PCWSTR RegistryKey,
|
||||||
IN BOOLEAN IsHiveNew,
|
IN BOOLEAN IsHiveNew,
|
||||||
IN HANDLE ProtoKeyHandle
|
IN HANDLE ProtoKeyHandle
|
||||||
|
@ -156,7 +156,7 @@ CreateRegistryFile(
|
||||||
WCHAR PathBuffer2[MAX_PATH];
|
WCHAR PathBuffer2[MAX_PATH];
|
||||||
|
|
||||||
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 3,
|
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 3,
|
||||||
InstallPath->Buffer, L"System32\\config", RegistryKey);
|
NtSystemRoot->Buffer, L"System32\\config", RegistryKey);
|
||||||
|
|
||||||
Extension = Extensions[IsHiveNew ? 0 : 1];
|
Extension = Extensions[IsHiveNew ? 0 : 1];
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ CreateRegistryFile(
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
&FileName,
|
&FileName,
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
NULL, // Could have been InstallPath, etc...
|
NULL, // Could have been NtSystemRoot, etc...
|
||||||
NULL); // Descriptor
|
NULL); // Descriptor
|
||||||
|
|
||||||
Status = NtCreateFile(&FileHandle,
|
Status = NtCreateFile(&FileHandle,
|
||||||
|
@ -320,7 +320,7 @@ ConnectRegistry(
|
||||||
IN HKEY RootKey OPTIONAL,
|
IN HKEY RootKey OPTIONAL,
|
||||||
IN PCWSTR RegMountPoint,
|
IN PCWSTR RegMountPoint,
|
||||||
// IN HANDLE RootDirectory OPTIONAL,
|
// IN HANDLE RootDirectory OPTIONAL,
|
||||||
IN PUNICODE_STRING InstallPath,
|
IN PUNICODE_STRING NtSystemRoot,
|
||||||
IN PCWSTR RegistryKey
|
IN PCWSTR RegistryKey
|
||||||
/*
|
/*
|
||||||
IN PUCHAR Descriptor,
|
IN PUCHAR Descriptor,
|
||||||
|
@ -341,7 +341,7 @@ ConnectRegistry(
|
||||||
NULL); // Descriptor
|
NULL); // Descriptor
|
||||||
|
|
||||||
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 3,
|
CombinePaths(PathBuffer, ARRAYSIZE(PathBuffer), 3,
|
||||||
InstallPath->Buffer, L"System32\\config", RegistryKey);
|
NtSystemRoot->Buffer, L"System32\\config", RegistryKey);
|
||||||
RtlInitUnicodeString(&FileName, PathBuffer);
|
RtlInitUnicodeString(&FileName, PathBuffer);
|
||||||
InitializeObjectAttributes(&FileObjectAttributes,
|
InitializeObjectAttributes(&FileObjectAttributes,
|
||||||
&FileName,
|
&FileName,
|
||||||
|
@ -383,7 +383,7 @@ NTSTATUS
|
||||||
VerifyRegistryHive(
|
VerifyRegistryHive(
|
||||||
// IN HKEY RootKey OPTIONAL,
|
// IN HKEY RootKey OPTIONAL,
|
||||||
// // IN HANDLE RootDirectory OPTIONAL,
|
// // IN HANDLE RootDirectory OPTIONAL,
|
||||||
IN PUNICODE_STRING InstallPath,
|
IN PUNICODE_STRING NtSystemRoot,
|
||||||
IN PCWSTR RegistryKey /* ,
|
IN PCWSTR RegistryKey /* ,
|
||||||
IN PCWSTR RegMountPoint */)
|
IN PCWSTR RegMountPoint */)
|
||||||
{
|
{
|
||||||
|
@ -392,7 +392,7 @@ VerifyRegistryHive(
|
||||||
/* Try to mount the specified registry hive */
|
/* Try to mount the specified registry hive */
|
||||||
Status = ConnectRegistry(NULL,
|
Status = ConnectRegistry(NULL,
|
||||||
L"\\Registry\\Machine\\USetup_VerifyHive",
|
L"\\Registry\\Machine\\USetup_VerifyHive",
|
||||||
InstallPath,
|
NtSystemRoot,
|
||||||
RegistryKey
|
RegistryKey
|
||||||
/* NULL, 0 */);
|
/* NULL, 0 */);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
|
|
@ -25,7 +25,7 @@ CreateNestedKey(PHANDLE KeyHandle,
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
CreateRegistryFile(
|
CreateRegistryFile(
|
||||||
IN PUNICODE_STRING InstallPath,
|
IN PUNICODE_STRING NtSystemRoot,
|
||||||
IN PCWSTR RegistryKey,
|
IN PCWSTR RegistryKey,
|
||||||
IN BOOLEAN IsHiveNew,
|
IN BOOLEAN IsHiveNew,
|
||||||
IN HANDLE ProtoKeyHandle
|
IN HANDLE ProtoKeyHandle
|
||||||
|
@ -49,7 +49,7 @@ ConnectRegistry(
|
||||||
IN HKEY RootKey OPTIONAL,
|
IN HKEY RootKey OPTIONAL,
|
||||||
IN PCWSTR RegMountPoint,
|
IN PCWSTR RegMountPoint,
|
||||||
// IN HANDLE RootDirectory OPTIONAL,
|
// IN HANDLE RootDirectory OPTIONAL,
|
||||||
IN PUNICODE_STRING InstallPath,
|
IN PUNICODE_STRING NtSystemRoot,
|
||||||
IN PCWSTR RegistryKey
|
IN PCWSTR RegistryKey
|
||||||
/*
|
/*
|
||||||
IN PUCHAR Descriptor,
|
IN PUCHAR Descriptor,
|
||||||
|
@ -73,7 +73,7 @@ NTSTATUS
|
||||||
VerifyRegistryHive(
|
VerifyRegistryHive(
|
||||||
// IN HKEY RootKey OPTIONAL,
|
// IN HKEY RootKey OPTIONAL,
|
||||||
// // IN HANDLE RootDirectory OPTIONAL,
|
// // IN HANDLE RootDirectory OPTIONAL,
|
||||||
IN PUNICODE_STRING InstallPath,
|
IN PUNICODE_STRING NtSystemRoot,
|
||||||
IN PCWSTR RegistryKey /* ,
|
IN PCWSTR RegistryKey /* ,
|
||||||
IN PCWSTR RegMountPoint */);
|
IN PCWSTR RegMountPoint */);
|
||||||
|
|
||||||
|
|
|
@ -4097,6 +4097,37 @@ FileCopyPage(PINPUT_RECORD Ir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static VOID
|
||||||
|
__cdecl
|
||||||
|
RegistryStatus(IN REGISTRY_STATUS RegStatus, ...)
|
||||||
|
{
|
||||||
|
/* WARNING: Please keep this lookup table in sync with the resources! */
|
||||||
|
static const UINT StringIDs[] =
|
||||||
|
{
|
||||||
|
STRING_DONE, /* Success */
|
||||||
|
STRING_REGHIVEUPDATE, /* RegHiveUpdate */
|
||||||
|
STRING_IMPORTFILE, /* ImportRegHive */
|
||||||
|
STRING_DISPLAYSETTINGSUPDATE, /* DisplaySettingsUpdate */
|
||||||
|
STRING_LOCALESETTINGSUPDATE, /* LocaleSettingsUpdate */
|
||||||
|
STRING_ADDKBLAYOUTS, /* KeybLayouts */
|
||||||
|
STRING_KEYBOARDSETTINGSUPDATE, /* KeybSettingsUpdate */
|
||||||
|
STRING_CODEPAGEINFOUPDATE, /* CodePageInfoUpdate */
|
||||||
|
};
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
|
||||||
|
if (RegStatus < ARRAYSIZE(StringIDs))
|
||||||
|
{
|
||||||
|
va_start(args, RegStatus);
|
||||||
|
CONSOLE_SetStatusTextV(MUIGetString(StringIDs[RegStatus]), args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CONSOLE_SetStatusText("Unknown status %d", RegStatus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Displays the RegistryPage.
|
* Displays the RegistryPage.
|
||||||
*
|
*
|
||||||
|
@ -4106,10 +4137,7 @@ FileCopyPage(PINPUT_RECORD Ir)
|
||||||
* QuitPage
|
* QuitPage
|
||||||
*
|
*
|
||||||
* SIDEEFFECTS
|
* SIDEEFFECTS
|
||||||
* Calls RegInitializeRegistry
|
* Calls UpdateRegistry
|
||||||
* Calls ImportRegistryFile
|
|
||||||
* Calls SetDefaultPagefile
|
|
||||||
* Calls SetMountedDeviceValues
|
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* Number of the next page.
|
* Number of the next page.
|
||||||
|
@ -4117,226 +4145,30 @@ FileCopyPage(PINPUT_RECORD Ir)
|
||||||
static PAGE_NUMBER
|
static PAGE_NUMBER
|
||||||
RegistryPage(PINPUT_RECORD Ir)
|
RegistryPage(PINPUT_RECORD Ir)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
ULONG Error;
|
||||||
INFCONTEXT InfContext;
|
|
||||||
PWSTR Action;
|
|
||||||
PWSTR File;
|
|
||||||
PWSTR Section;
|
|
||||||
BOOLEAN Success;
|
|
||||||
BOOLEAN ShouldRepairRegistry = FALSE;
|
|
||||||
BOOLEAN Delete;
|
|
||||||
|
|
||||||
MUIDisplayPage(REGISTRY_PAGE);
|
MUIDisplayPage(REGISTRY_PAGE);
|
||||||
|
|
||||||
if (RepairUpdateFlag)
|
Error = UpdateRegistry(SetupInf,
|
||||||
|
&USetupData,
|
||||||
|
RepairUpdateFlag,
|
||||||
|
PartitionList,
|
||||||
|
DestinationDriveLetter,
|
||||||
|
SelectedLanguageId,
|
||||||
|
DisplayList,
|
||||||
|
LayoutList,
|
||||||
|
LanguageList,
|
||||||
|
RegistryStatus);
|
||||||
|
if (Error != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DPRINT1("TODO: Updating / repairing the registry is not completely implemented yet!\n");
|
MUIDisplayError(Error, Ir, POPUP_WAIT_ENTER);
|
||||||
|
|
||||||
/* Verify the registry hives and check whether we need to update or repair any of them */
|
|
||||||
Status = VerifyRegistryHives(&USetupData.DestinationPath, &ShouldRepairRegistry);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("VerifyRegistryHives failed, Status 0x%08lx\n", Status);
|
|
||||||
ShouldRepairRegistry = FALSE;
|
|
||||||
}
|
|
||||||
if (!ShouldRepairRegistry)
|
|
||||||
DPRINT1("No need to repair the registry\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
DoUpdate:
|
|
||||||
/* Update the registry */
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_REGHIVEUPDATE));
|
|
||||||
|
|
||||||
/* Initialize the registry and setup the registry hives */
|
|
||||||
Status = RegInitializeRegistry(&USetupData.DestinationPath);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT1("RegInitializeRegistry() failed\n");
|
|
||||||
/********** HACK!!!!!!!!!!! **********/
|
|
||||||
if (Status == STATUS_NOT_IMPLEMENTED)
|
|
||||||
{
|
|
||||||
/* The hack was called, display its corresponding error */
|
|
||||||
MUIDisplayError(ERROR_INITIALIZE_REGISTRY, Ir, POPUP_WAIT_ENTER);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
/*************************************/
|
|
||||||
{
|
|
||||||
/* Something else failed */
|
|
||||||
MUIDisplayError(ERROR_CREATE_HIVE, Ir, POPUP_WAIT_ENTER);
|
|
||||||
}
|
|
||||||
return QUIT_PAGE;
|
return QUIT_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RepairUpdateFlag || ShouldRepairRegistry)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* We fully setup the hives, in case we are doing a fresh installation
|
|
||||||
* (RepairUpdateFlag == FALSE), or in case we are doing an update
|
|
||||||
* (RepairUpdateFlag == TRUE) BUT we have some registry hives to
|
|
||||||
* "repair" (aka. recreate: ShouldRepairRegistry == TRUE).
|
|
||||||
*/
|
|
||||||
|
|
||||||
Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Fresh", NULL, &InfContext); // Windows-compatible
|
|
||||||
if (!Success)
|
|
||||||
Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Install", NULL, &InfContext); // ReactOS-specific
|
|
||||||
|
|
||||||
if (!Success)
|
|
||||||
{
|
|
||||||
DPRINT1("SetupFindFirstLine() failed\n");
|
|
||||||
MUIDisplayError(ERROR_FIND_REGISTRY, Ir, POPUP_WAIT_ENTER);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else // if (RepairUpdateFlag && !ShouldRepairRegistry)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* In case we are doing an update (RepairUpdateFlag == TRUE) and
|
|
||||||
* NO registry hives need a repair (ShouldRepairRegistry == FALSE),
|
|
||||||
* we only update the hives.
|
|
||||||
*/
|
|
||||||
|
|
||||||
Success = SetupFindFirstLineW(SetupInf, L"HiveInfs.Upgrade", NULL, &InfContext);
|
|
||||||
if (!Success)
|
|
||||||
{
|
|
||||||
/* Nothing to do for update! */
|
|
||||||
DPRINT1("No update needed for the registry!\n");
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
INF_GetDataField(&InfContext, 0, &Action);
|
|
||||||
INF_GetDataField(&InfContext, 1, &File);
|
|
||||||
INF_GetDataField(&InfContext, 2, &Section);
|
|
||||||
|
|
||||||
DPRINT("Action: %S File: %S Section %S\n", Action, File, Section);
|
|
||||||
|
|
||||||
if (Action == NULL)
|
|
||||||
{
|
|
||||||
INF_FreeData(Action);
|
|
||||||
INF_FreeData(File);
|
|
||||||
INF_FreeData(Section);
|
|
||||||
break; // Hackfix
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!_wcsicmp(Action, L"AddReg"))
|
|
||||||
Delete = FALSE;
|
|
||||||
else if (!_wcsicmp(Action, L"DelReg"))
|
|
||||||
Delete = TRUE;
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
DPRINT1("Unrecognized registry INF action '%S'\n", Action);
|
|
||||||
INF_FreeData(Action);
|
|
||||||
INF_FreeData(File);
|
|
||||||
INF_FreeData(Section);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
INF_FreeData(Action);
|
|
||||||
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_IMPORTFILE), File);
|
|
||||||
|
|
||||||
if (!ImportRegistryFile(USetupData.SourcePath.Buffer, File, Section, USetupData.LanguageId, Delete))
|
|
||||||
{
|
|
||||||
DPRINT1("Importing %S failed\n", File);
|
|
||||||
INF_FreeData(File);
|
|
||||||
INF_FreeData(Section);
|
|
||||||
MUIDisplayError(ERROR_IMPORT_HIVE, Ir, POPUP_WAIT_ENTER);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
} while (SetupFindNextLine(&InfContext, &InfContext));
|
|
||||||
|
|
||||||
if (!RepairUpdateFlag || ShouldRepairRegistry)
|
|
||||||
{
|
|
||||||
/* See the explanation for this test above */
|
|
||||||
|
|
||||||
/* Update display registry settings */
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_DISPLAYSETTINGSUPDATE));
|
|
||||||
if (!ProcessDisplayRegistry(SetupInf, DisplayList))
|
|
||||||
{
|
|
||||||
MUIDisplayError(ERROR_UPDATE_DISPLAY_SETTINGS, Ir, POPUP_WAIT_ENTER);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the locale */
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_LOCALESETTINGSUPDATE));
|
|
||||||
if (!ProcessLocaleRegistry(LanguageList))
|
|
||||||
{
|
|
||||||
MUIDisplayError(ERROR_UPDATE_LOCALESETTINGS, Ir, POPUP_WAIT_ENTER);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add keyboard layouts */
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_ADDKBLAYOUTS));
|
|
||||||
if (!AddKeyboardLayouts(SelectedLanguageId))
|
|
||||||
{
|
|
||||||
MUIDisplayError(ERROR_ADDING_KBLAYOUTS, Ir, POPUP_WAIT_ENTER);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set GeoID */
|
|
||||||
if (!SetGeoID(MUIGetGeoID(SelectedLanguageId)))
|
|
||||||
{
|
|
||||||
MUIDisplayError(ERROR_UPDATE_GEOID, Ir, POPUP_WAIT_ENTER);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsUnattendedSetup)
|
|
||||||
{
|
|
||||||
/* Update keyboard layout settings */
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_KEYBOARDSETTINGSUPDATE));
|
|
||||||
if (!ProcessKeyboardLayoutRegistry(LayoutList, SelectedLanguageId))
|
|
||||||
{
|
|
||||||
MUIDisplayError(ERROR_UPDATE_KBSETTINGS, Ir, POPUP_WAIT_ENTER);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add codepage information to registry */
|
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_CODEPAGEINFOUPDATE));
|
|
||||||
if (!AddCodePage(SelectedLanguageId))
|
|
||||||
{
|
|
||||||
MUIDisplayError(ERROR_ADDING_CODEPAGE, Ir, POPUP_WAIT_ENTER);
|
|
||||||
goto Cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the default pagefile entry */
|
|
||||||
SetDefaultPagefile(DestinationDriveLetter);
|
|
||||||
|
|
||||||
/* Update the mounted devices list */
|
|
||||||
// FIXME: This should technically be done by mountmgr (if AutoMount is enabled)!
|
|
||||||
SetMountedDeviceValues(PartitionList);
|
|
||||||
}
|
|
||||||
|
|
||||||
Cleanup:
|
|
||||||
//
|
|
||||||
// TODO: Unload all the registry stuff, perform cleanup,
|
|
||||||
// and copy the created hive files into .sav files.
|
|
||||||
//
|
|
||||||
RegCleanupRegistry(&USetupData.DestinationPath);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check whether we were in update/repair mode but we were actually
|
|
||||||
* repairing the registry hives. If so, we have finished repairing them,
|
|
||||||
* and we now reset the flag and run the proper registry update.
|
|
||||||
* Otherwise we have finished the registry update!
|
|
||||||
*/
|
|
||||||
if (RepairUpdateFlag && ShouldRepairRegistry)
|
|
||||||
{
|
|
||||||
ShouldRepairRegistry = FALSE;
|
|
||||||
goto DoUpdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
CONSOLE_SetStatusText(MUIGetString(STRING_DONE));
|
CONSOLE_SetStatusText(MUIGetString(STRING_DONE));
|
||||||
return BOOT_LOADER_PAGE;
|
return BOOT_LOADER_PAGE;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return QUIT_PAGE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue