- WINLDR: Fix SystemRoot path when booting in non-setup mode.

- WINLDR: Change path buffers to be MAX_PATH sized instead of an arbitrary 512 bytes value.

svn path=/trunk/; revision=40685
This commit is contained in:
Aleksey Bragin 2009-04-24 19:03:10 +00:00
parent c9c9947227
commit 7d9f43ff96

View file

@ -431,10 +431,10 @@ VOID
LoadAndBootWindows(PCSTR OperatingSystemName, USHORT OperatingSystemVersion) LoadAndBootWindows(PCSTR OperatingSystemName, USHORT OperatingSystemVersion)
{ {
CHAR MsgBuffer[256]; CHAR MsgBuffer[256];
CHAR SystemPath[512], SearchPath[512]; CHAR FullPath[MAX_PATH], SystemRoot[MAX_PATH], BootPath[MAX_PATH];
CHAR FileName[512]; CHAR FileName[MAX_PATH];
CHAR BootPath[512];
CHAR BootOptions[256]; CHAR BootOptions[256];
PCHAR PathSeparator;
PVOID NtosBase = NULL, HalBase = NULL, KdComBase = NULL; PVOID NtosBase = NULL, HalBase = NULL, KdComBase = NULL;
BOOLEAN Status; BOOLEAN Status;
ULONG SectionId; ULONG SectionId;
@ -463,12 +463,17 @@ LoadAndBootWindows(PCSTR OperatingSystemName, USHORT OperatingSystemVersion)
UiDrawProgressBarCenter(1, 100, "Loading Windows..."); UiDrawProgressBarCenter(1, 100, "Loading Windows...");
/* Make sure the system path is set in the .ini file */ /* Make sure the system path is set in the .ini file */
if (!IniReadSettingByName(SectionId, "SystemPath", SystemPath, sizeof(SystemPath))) if (!IniReadSettingByName(SectionId, "SystemPath", FullPath, sizeof(FullPath)))
{ {
UiMessageBox("System path not specified for selected operating system."); UiMessageBox("System path not specified for selected operating system.");
return; return;
} }
/* Convert FullPath to SystemRoot */
PathSeparator = strstr(FullPath, "\\");
strcpy(SystemRoot, PathSeparator);
strcat(SystemRoot, "\\");
/* Read booting options */ /* Read booting options */
if (!IniReadSettingByName(SectionId, "Options", BootOptions, sizeof(BootOptions))) if (!IniReadSettingByName(SectionId, "Options", BootOptions, sizeof(BootOptions)))
{ {
@ -477,23 +482,23 @@ LoadAndBootWindows(PCSTR OperatingSystemName, USHORT OperatingSystemVersion)
} }
/* Special case for LiveCD */ /* Special case for LiveCD */
if (!_strnicmp(SystemPath, "LiveCD", strlen("LiveCD"))) if (!_strnicmp(SystemRoot, "LiveCD", strlen("LiveCD")))
{ {
strcpy(BootPath, SystemPath + strlen("LiveCD")); strcpy(BootPath, SystemRoot + strlen("LiveCD"));
MachDiskGetBootPath(SystemPath, sizeof(SystemPath)); MachDiskGetBootPath(SystemRoot, sizeof(SystemRoot));
strcat(SystemPath, BootPath); strcat(SystemRoot, BootPath);
} }
/* Let user know we started loading */ /* Let user know we started loading */
UiDrawStatusText("Loading..."); UiDrawStatusText("Loading...");
/* append a backslash */ /* append a backslash */
strcpy(BootPath, SystemPath); strcpy(BootPath, FullPath);
if ((strlen(BootPath)==0) || if ((strlen(BootPath)==0) ||
BootPath[strlen(BootPath)] != '\\') BootPath[strlen(BootPath)] != '\\')
strcat(BootPath, "\\"); strcat(BootPath, "\\");
DPRINTM(DPRINT_WINDOWS,"SystemRoot: '%s'\n", BootPath); DPRINTM(DPRINT_WINDOWS,"BootPath: '%s'\n", BootPath);
/* Allocate and minimalistic-initialize LPB */ /* Allocate and minimalistic-initialize LPB */
AllocateAndInitLPB(&LoaderBlock); AllocateAndInitLPB(&LoaderBlock);
@ -535,12 +540,12 @@ LoadAndBootWindows(PCSTR OperatingSystemName, USHORT OperatingSystemVersion)
} }
/* Load all referenced DLLs for kernel, HAL and kdcom.dll */ /* Load all referenced DLLs for kernel, HAL and kdcom.dll */
strcpy(SearchPath, BootPath); strcpy(FileName, BootPath);
strcat(SearchPath, "SYSTEM32\\"); strcat(FileName, "SYSTEM32\\");
WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, KernelDTE); WinLdrScanImportDescriptorTable(LoaderBlock, FileName, KernelDTE);
WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, HalDTE); WinLdrScanImportDescriptorTable(LoaderBlock, FileName, HalDTE);
if (KdComDTE) if (KdComDTE)
WinLdrScanImportDescriptorTable(LoaderBlock, SearchPath, KdComDTE); WinLdrScanImportDescriptorTable(LoaderBlock, FileName, KdComDTE);
/* Load Hive, and then NLS data, OEM font, and prepare boot drivers list */ /* Load Hive, and then NLS data, OEM font, and prepare boot drivers list */
Status = WinLdrLoadAndScanSystemHive(LoaderBlock, BootPath); Status = WinLdrLoadAndScanSystemHive(LoaderBlock, BootPath);
@ -554,7 +559,7 @@ LoadAndBootWindows(PCSTR OperatingSystemName, USHORT OperatingSystemVersion)
WinLdrSetupForNt(LoaderBlock, &GdtIdt, &PcrBasePage, &TssBasePage); WinLdrSetupForNt(LoaderBlock, &GdtIdt, &PcrBasePage, &TssBasePage);
/* Initialize Phase 1 - no drivers loading anymore */ /* Initialize Phase 1 - no drivers loading anymore */
WinLdrInitializePhase1(LoaderBlock, BootOptions, SystemPath, BootPath, OperatingSystemVersion); WinLdrInitializePhase1(LoaderBlock, BootOptions, SystemRoot, BootPath, OperatingSystemVersion);
/* Save entry-point pointer and Loader block VAs */ /* Save entry-point pointer and Loader block VAs */
KiSystemStartup = (KERNEL_ENTRY_POINT)KernelDTE->EntryPoint; KiSystemStartup = (KERNEL_ENTRY_POINT)KernelDTE->EntryPoint;