Author: hbelusca Date: Sun Sep 3 16:17:27 2017 New Revision: 75750
URL: http://svn.reactos.org/svn/reactos?rev=75750&view=rev Log: [SETUPLIB][USETUP]: Move the registry-update procedure into setuplib, where it can also be used by the 1st-stage GUI setup, and make the necessary changes in usetup. [REACTOS]: Fix build.
Modified: branches/setup_improvements/base/setup/lib/setuplib.c branches/setup_improvements/base/setup/lib/setuplib.h branches/setup_improvements/base/setup/reactos/CMakeLists.txt branches/setup_improvements/base/setup/usetup/usetup.c
Modified: branches/setup_improvements/base/setup/lib/setuplib.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/li... ============================================================================== --- branches/setup_improvements/base/setup/lib/setuplib.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/setuplib.c [iso-8859-1] Sun Sep 3 16:17:27 2017 @@ -565,4 +565,240 @@ 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 PWCHAR 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 */
Modified: branches/setup_improvements/base/setup/lib/setuplib.h URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/li... ============================================================================== --- branches/setup_improvements/base/setup/lib/setuplib.h [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/lib/setuplib.h [iso-8859-1] Sun Sep 3 16:17:27 2017 @@ -124,4 +124,32 @@ IN OUT PUSETUP_DATA pSetupData);
+typedef enum _REGISTRY_STATUS +{ + Success = 0, + RegHiveUpdate, + ImportRegHive, + DisplaySettingsUpdate, + LocaleSettingsUpdate, + KeybLayouts, + KeybSettingsUpdate, + CodePageInfoUpdate, +} REGISTRY_STATUS; + +typedef VOID +(NTAPI *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 PWCHAR SelectedLanguageId, /* HACK HACK! */ + IN PGENERIC_LIST DisplayList, + IN PGENERIC_LIST LayoutList, + IN PGENERIC_LIST LanguageList, + IN PREGISTRY_STATUS_ROUTINE StatusRoutine OPTIONAL); + /* EOF */
Modified: branches/setup_improvements/base/setup/reactos/CMakeLists.txt URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/re... ============================================================================== --- branches/setup_improvements/base/setup/reactos/CMakeLists.txt [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/reactos/CMakeLists.txt [iso-8859-1] Sun Sep 3 16:17:27 2017 @@ -17,6 +17,6 @@ add_executable(reactos ${SOURCE} reactos.rc) set_module_type(reactos win32gui UNICODE) add_pch(reactos reactos.h SOURCE) -target_link_libraries(reactos uuid setuplib) +target_link_libraries(reactos uuid setuplib ext2lib vfatlib) add_importlibs(reactos advapi32 gdi32 user32 comctl32 setupapi msvcrt kernel32 ntdll) add_cd_file(TARGET reactos DESTINATION reactos NO_CAB FOR bootcd)
Modified: branches/setup_improvements/base/setup/usetup/usetup.c URL: http://svn.reactos.org/svn/reactos/branches/setup_improvements/base/setup/us... ============================================================================== --- branches/setup_improvements/base/setup/usetup/usetup.c [iso-8859-1] (original) +++ branches/setup_improvements/base/setup/usetup/usetup.c [iso-8859-1] Sun Sep 3 16:17:27 2017 @@ -3864,6 +3864,37 @@ }
+static VOID +NTAPI +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. * @@ -3873,10 +3904,7 @@ * QuitPage * * SIDEEFFECTS - * Calls RegInitializeRegistry - * Calls ImportRegistryFile - * Calls SetDefaultPagefile - * Calls SetMountedDeviceValues + * Calls UpdateRegistry * * RETURNS * Number of the next page. @@ -3884,225 +3912,29 @@ static PAGE_NUMBER RegistryPage(PINPUT_RECORD Ir) { - NTSTATUS Status; - INFCONTEXT InfContext; - PWSTR Action; - PWSTR File; - PWSTR Section; - BOOLEAN Success; - BOOLEAN ShouldRepairRegistry = FALSE; - BOOLEAN Delete; + ULONG Error;
MUIDisplayPage(REGISTRY_PAGE);
- 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(&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); - } + Error = UpdateRegistry(SetupInf, + &USetupData, + RepairUpdateFlag, + PartitionList, + DestinationDriveLetter, + SelectedLanguageId, + DisplayList, + LayoutList, + LanguageList, + RegistryStatus); + if (Error != ERROR_SUCCESS) + { + MUIDisplayError(Error, Ir, POPUP_WAIT_ENTER); 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 - { - 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)) + else { CONSOLE_SetStatusText(MUIGetString(STRING_DONE)); return BOOT_LOADER_PAGE; - } - else - { - return QUIT_PAGE; } }