mirror of
https://github.com/reactos/reactos.git
synced 2025-08-06 16:32:57 +00:00
[FREELDR] Adjust WinLdrInitSystemHive() and its callers to load at startup either the regular SYSTEM hive, or the SETUPREG.HIV setup system hive.
We now run the 1st-stage setup with a regular system hive, similarly to what's done for the LiveCD, or for a regular ROS installation. The ExpInTextModeSetup hacks I previously removed are now completely unneeded. svn path=/branches/setup_improvements/; revision=74762
This commit is contained in:
parent
5e705d0683
commit
0b2b53b9c3
3 changed files with 69 additions and 29 deletions
|
@ -74,8 +74,13 @@ SetupLdrLoadNlsData(PLOADER_PARAMETER_BLOCK LoaderBlock, HINF InfHandle, LPCSTR
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TRACE("NLS data %s %s %s\n", AnsiName, OemName, LangName);
|
||||||
|
|
||||||
Success = WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName);
|
Success = WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName);
|
||||||
TRACE("NLS data loading %s\n", Success ? "successful" : "failed");
|
TRACE("NLS data loading %s\n", Success ? "successful" : "failed");
|
||||||
|
|
||||||
|
/* TODO: Load OEM HAL font */
|
||||||
|
// Value "OemHalFont"
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
|
@ -128,6 +133,9 @@ SetupLdrScanBootDrivers(PLIST_ENTRY BootDriverListHead, HINF InfHandle, LPCSTR S
|
||||||
} while (InfFindNextLine(&InfContext, &InfContext));
|
} while (InfFindNextLine(&InfContext, &InfContext));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* SETUP STARTER **************************************************************/
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
||||||
IN USHORT OperatingSystemVersion)
|
IN USHORT OperatingSystemVersion)
|
||||||
|
@ -143,6 +151,7 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
||||||
LPCSTR LoadOptions;
|
LPCSTR LoadOptions;
|
||||||
LPSTR BootOptions;
|
LPSTR BootOptions;
|
||||||
BOOLEAN BootFromFloppy;
|
BOOLEAN BootFromFloppy;
|
||||||
|
BOOLEAN Success;
|
||||||
ULONG i, ErrorLine;
|
ULONG i, ErrorLine;
|
||||||
HINF InfHandle;
|
HINF InfHandle;
|
||||||
INFCONTEXT InfContext;
|
INFCONTEXT InfContext;
|
||||||
|
@ -163,6 +172,8 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
UiDrawStatusText("Setup is loading...");
|
||||||
|
|
||||||
/* Get OS setting value */
|
/* Get OS setting value */
|
||||||
SettingsValue[0] = ANSI_NULL;
|
SettingsValue[0] = ANSI_NULL;
|
||||||
IniOpenSection("Operating Systems", &SectionId);
|
IniOpenSection("Operating Systems", &SectionId);
|
||||||
|
@ -303,8 +314,6 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
||||||
|
|
||||||
TRACE("BootOptions: '%s'\n", BootOptions);
|
TRACE("BootOptions: '%s'\n", BootOptions);
|
||||||
|
|
||||||
UiDrawStatusText("Setup is loading...");
|
|
||||||
|
|
||||||
/* Allocate and minimalist-initialize LPB */
|
/* Allocate and minimalist-initialize LPB */
|
||||||
AllocateAndInitLPB(&LoaderBlock);
|
AllocateAndInitLPB(&LoaderBlock);
|
||||||
|
|
||||||
|
@ -315,17 +324,30 @@ LoadReactOSSetup(IN OperatingSystemItem* OperatingSystem,
|
||||||
/* Set textmode setup flag */
|
/* Set textmode setup flag */
|
||||||
SetupBlock->Flags = SETUPLDR_TEXT_MODE;
|
SetupBlock->Flags = SETUPLDR_TEXT_MODE;
|
||||||
|
|
||||||
/* Load NLS data, they are in system32 */
|
/* Load the system hive "setupreg.hiv" for setup */
|
||||||
|
UiDrawBackdrop();
|
||||||
|
UiDrawProgressBarCenter(15, 100, "Loading setup system hive...");
|
||||||
|
Success = WinLdrInitSystemHive(LoaderBlock, BootPath, TRUE);
|
||||||
|
TRACE("Setup SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
|
||||||
|
/* Bail out if failure */
|
||||||
|
if (!Success)
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Load NLS data, they are in the System32 directory of the installation medium */
|
||||||
strcpy(FileName, BootPath);
|
strcpy(FileName, BootPath);
|
||||||
strcat(FileName, "system32\\");
|
strcat(FileName, "system32\\");
|
||||||
SetupLdrLoadNlsData(LoaderBlock, InfHandle, FileName);
|
SetupLdrLoadNlsData(LoaderBlock, InfHandle, FileName);
|
||||||
|
|
||||||
|
// UiDrawStatusText("Press F6 if you need to install a 3rd-party SCSI or RAID driver...");
|
||||||
|
|
||||||
/* Get a list of boot drivers */
|
/* Get a list of boot drivers */
|
||||||
SetupLdrScanBootDrivers(&LoaderBlock->BootDriverListHead, InfHandle, BootPath);
|
SetupLdrScanBootDrivers(&LoaderBlock->BootDriverListHead, InfHandle, BootPath);
|
||||||
|
|
||||||
/* Close the inf file */
|
/* Close the inf file */
|
||||||
InfCloseFile(InfHandle);
|
InfCloseFile(InfHandle);
|
||||||
|
|
||||||
|
UiDrawStatusText("The Setup program is starting...");
|
||||||
|
|
||||||
/* Load ReactOS Setup */
|
/* Load ReactOS Setup */
|
||||||
LoadAndBootWindowsCommon(_WIN32_WINNT_WS03,
|
LoadAndBootWindowsCommon(_WIN32_WINNT_WS03,
|
||||||
LoaderBlock,
|
LoaderBlock,
|
||||||
|
|
|
@ -750,7 +750,7 @@ LoadAndBootWindows(IN OperatingSystemItem* OperatingSystem,
|
||||||
/* Load the system hive */
|
/* Load the system hive */
|
||||||
UiDrawBackdrop();
|
UiDrawBackdrop();
|
||||||
UiDrawProgressBarCenter(15, 100, "Loading system hive...");
|
UiDrawProgressBarCenter(15, 100, "Loading system hive...");
|
||||||
Success = WinLdrInitSystemHive(LoaderBlock, BootPath);
|
Success = WinLdrInitSystemHive(LoaderBlock, BootPath, FALSE);
|
||||||
TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
|
TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
|
||||||
/* Bail out if failure */
|
/* Bail out if failure */
|
||||||
if (!Success)
|
if (!Success)
|
||||||
|
|
|
@ -30,20 +30,21 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
|
||||||
|
|
||||||
/* FUNCTIONS **************************************************************/
|
/* FUNCTIONS **************************************************************/
|
||||||
|
|
||||||
BOOLEAN
|
static BOOLEAN
|
||||||
WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
WinLdrLoadSystemHive(
|
||||||
IN LPCSTR DirectoryPath,
|
IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
IN LPCSTR HiveName)
|
IN PCSTR DirectoryPath,
|
||||||
|
IN PCSTR HiveName)
|
||||||
{
|
{
|
||||||
ULONG FileId;
|
ULONG FileId;
|
||||||
CHAR FullHiveName[256];
|
CHAR FullHiveName[MAX_PATH];
|
||||||
ARC_STATUS Status;
|
ARC_STATUS Status;
|
||||||
FILEINFORMATION FileInfo;
|
FILEINFORMATION FileInfo;
|
||||||
ULONG HiveFileSize;
|
ULONG HiveFileSize;
|
||||||
ULONG_PTR HiveDataPhysical;
|
ULONG_PTR HiveDataPhysical;
|
||||||
PVOID HiveDataVirtual;
|
PVOID HiveDataVirtual;
|
||||||
ULONG BytesRead;
|
ULONG BytesRead;
|
||||||
LPCWSTR FsService;
|
PCWSTR FsService;
|
||||||
|
|
||||||
/* Concatenate path and filename to get the full name */
|
/* Concatenate path and filename to get the full name */
|
||||||
strcpy(FullHiveName, DirectoryPath);
|
strcpy(FullHiveName, DirectoryPath);
|
||||||
|
@ -94,7 +95,7 @@ WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add boot filesystem driver to the list
|
/* Add boot filesystem driver to the list */
|
||||||
FsService = FsGetServiceName(FileId);
|
FsService = FsGetServiceName(FileId);
|
||||||
if (FsService)
|
if (FsService)
|
||||||
{
|
{
|
||||||
|
@ -116,25 +117,40 @@ WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
BOOLEAN
|
||||||
IN LPCSTR DirectoryPath)
|
WinLdrInitSystemHive(
|
||||||
|
IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
|
IN PCSTR SystemRoot,
|
||||||
|
IN BOOLEAN Setup)
|
||||||
{
|
{
|
||||||
CHAR SearchPath[1024];
|
CHAR SearchPath[1024];
|
||||||
|
PCSTR HiveName;
|
||||||
BOOLEAN Success;
|
BOOLEAN Success;
|
||||||
|
|
||||||
|
if (Setup)
|
||||||
|
{
|
||||||
|
strcpy(SearchPath, SystemRoot);
|
||||||
|
HiveName = "SETUPREG.HIV";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// There is a simple logic here: try to load usual hive (system), if it
|
// There is a simple logic here: try to load usual hive (system), if it
|
||||||
// fails, then give system.alt a try, and finally try a system.sav
|
// fails, then give system.alt a try, and finally try a system.sav
|
||||||
|
|
||||||
// FIXME: For now we only try system
|
// FIXME: For now we only try system
|
||||||
strcpy(SearchPath, DirectoryPath);
|
strcpy(SearchPath, SystemRoot);
|
||||||
strcat(SearchPath, "system32\\config\\");
|
strcat(SearchPath, "system32\\config\\");
|
||||||
Success = WinLdrLoadSystemHive(LoaderBlock, SearchPath, "SYSTEM");
|
HiveName = "SYSTEM";
|
||||||
|
}
|
||||||
|
|
||||||
// Fail if failed...
|
ERR("WinLdrInitSystemHive: try to load hive %s%s\n", SearchPath, HiveName);
|
||||||
|
Success = WinLdrLoadSystemHive(LoaderBlock, SearchPath, HiveName);
|
||||||
|
|
||||||
|
/* Fail if failed... */
|
||||||
if (!Success)
|
if (!Success)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Import what was loaded
|
/* Import what was loaded */
|
||||||
Success = RegImportBinaryHive(VaToPa(LoaderBlock->RegistryBase), LoaderBlock->RegistryLength);
|
Success = RegImportBinaryHive(VaToPa(LoaderBlock->RegistryBase), LoaderBlock->RegistryLength);
|
||||||
if (!Success)
|
if (!Success)
|
||||||
{
|
{
|
||||||
|
@ -142,7 +158,7 @@ BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the 'CurrentControlSet' link
|
/* Initialize the 'CurrentControlSet' link */
|
||||||
if (RegInitCurrentControlSet(FALSE) != ERROR_SUCCESS)
|
if (RegInitCurrentControlSet(FALSE) != ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
UiMessageBox("Initializing CurrentControlSet link failed!");
|
UiMessageBox("Initializing CurrentControlSet link failed!");
|
||||||
|
@ -159,10 +175,10 @@ BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
CHAR AnsiName[256], OemName[256], LangName[256];
|
CHAR AnsiName[256], OemName[256], LangName[256];
|
||||||
BOOLEAN Success;
|
BOOLEAN Success;
|
||||||
|
|
||||||
// Scan registry and prepare boot drivers list
|
/* Scan registry and prepare boot drivers list */
|
||||||
WinLdrScanRegistry(&LoaderBlock->BootDriverListHead, DirectoryPath);
|
WinLdrScanRegistry(&LoaderBlock->BootDriverListHead, DirectoryPath);
|
||||||
|
|
||||||
// Get names of NLS files
|
/* Get names of NLS files */
|
||||||
Success = WinLdrGetNLSNames(AnsiName, OemName, LangName);
|
Success = WinLdrGetNLSNames(AnsiName, OemName, LangName);
|
||||||
if (!Success)
|
if (!Success)
|
||||||
{
|
{
|
||||||
|
@ -172,13 +188,15 @@ BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
|
||||||
|
|
||||||
TRACE("NLS data %s %s %s\n", AnsiName, OemName, LangName);
|
TRACE("NLS data %s %s %s\n", AnsiName, OemName, LangName);
|
||||||
|
|
||||||
// Load NLS data
|
/* Load NLS data */
|
||||||
strcpy(SearchPath, DirectoryPath);
|
strcpy(SearchPath, DirectoryPath);
|
||||||
strcat(SearchPath, "system32\\");
|
strcat(SearchPath, "system32\\");
|
||||||
Success = WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName);
|
Success = WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName);
|
||||||
TRACE("NLS data loading %s\n", Success ? "successful" : "failed");
|
TRACE("NLS data loading %s\n", Success ? "successful" : "failed");
|
||||||
|
|
||||||
/* TODO: Load OEM HAL font */
|
/* TODO: Load OEM HAL font */
|
||||||
|
// In HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage,
|
||||||
|
// REG_SZ value "OEMHAL"
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +226,7 @@ WinLdrGetNLSNames(LPSTR AnsiName,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get ANSI codepage */
|
/* Get ANSI codepage */
|
||||||
BufferSize = sizeof(szIdBuffer);
|
BufferSize = sizeof(szIdBuffer);
|
||||||
rc = RegQueryValue(hKey, L"ACP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
|
rc = RegQueryValue(hKey, L"ACP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
|
@ -227,7 +245,7 @@ WinLdrGetNLSNames(LPSTR AnsiName,
|
||||||
}
|
}
|
||||||
sprintf(AnsiName, "%S", NameBuffer);
|
sprintf(AnsiName, "%S", NameBuffer);
|
||||||
|
|
||||||
/* get OEM codepage */
|
/* Get OEM codepage */
|
||||||
BufferSize = sizeof(szIdBuffer);
|
BufferSize = sizeof(szIdBuffer);
|
||||||
rc = RegQueryValue(hKey, L"OEMCP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
|
rc = RegQueryValue(hKey, L"OEMCP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
|
@ -246,7 +264,7 @@ WinLdrGetNLSNames(LPSTR AnsiName,
|
||||||
}
|
}
|
||||||
sprintf(OemName, "%S", NameBuffer);
|
sprintf(OemName, "%S", NameBuffer);
|
||||||
|
|
||||||
/* open the language key */
|
/* Open the language key */
|
||||||
rc = RegOpenKey(NULL,
|
rc = RegOpenKey(NULL,
|
||||||
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
|
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
|
||||||
&hKey);
|
&hKey);
|
||||||
|
@ -256,7 +274,7 @@ WinLdrGetNLSNames(LPSTR AnsiName,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the Unicode case table */
|
/* Get the Unicode case table */
|
||||||
BufferSize = sizeof(szIdBuffer);
|
BufferSize = sizeof(szIdBuffer);
|
||||||
rc = RegQueryValue(hKey, L"Default", NULL, (PUCHAR)szIdBuffer, &BufferSize);
|
rc = RegQueryValue(hKey, L"Default", NULL, (PUCHAR)szIdBuffer, &BufferSize);
|
||||||
if (rc != ERROR_SUCCESS)
|
if (rc != ERROR_SUCCESS)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue