- Fix boot CD with 10 lines of code. That's right Fireball, go shame yourself!

svn path=/trunk/; revision=24796
This commit is contained in:
Alex Ionescu 2006-11-22 07:01:32 +00:00
parent 732eec1ad8
commit 9bd055bf1e
2 changed files with 55 additions and 58 deletions

View file

@ -36,6 +36,7 @@ unsigned long reactos_disk_count = 0;
CHAR szHalName[255];
CHAR szBootPath[255];
static CHAR szLoadingMsg[] = "Loading ReactOS...";
BOOLEAN FrLdrBootType;
static BOOLEAN
NTAPI
@ -118,7 +119,14 @@ FrLdrLoadImage(IN PCHAR szFileName,
/* Which means we need to build a path now */
strcpy(szBuffer, szFileName);
strcpy(szFullPath, szBootPath);
strcat(szFullPath, "SYSTEM32\\DRIVERS\\");
if (!FrLdrBootType)
{
strcat(szFullPath, "SYSTEM32\\DRIVERS\\");
}
else
{
strcat(szFullPath, "\\");
}
strcat(szFullPath, szBuffer);
szFileName = szFullPath;
}

View file

@ -26,6 +26,8 @@ LOADER_MODULE reactos_modules[64]; // Array to hold boot module info loaded f
char reactos_module_strings[64][256]; // Array to hold module names
unsigned long reactos_memory_map_descriptor_size;
memory_map_t reactos_memory_map[32]; // Memory map
char szBootPath[256];
char szHalName[256];
#define USE_UI
@ -45,69 +47,49 @@ FreeldrSeekFile(PVOID FileContext, ULONG_PTR Position)
return TRUE;
}
static BOOLEAN
LoadKernel(PCSTR szSourcePath, PCSTR szFileName)
BOOLEAN
NTAPI
static FrLdrLoadKernel(IN PCHAR szFileName,
IN INT nPos)
{
CHAR szFullName[256];
#ifdef USE_UI
CHAR szBuffer[80];
#endif
PFILE FilePointer;
PCSTR szShortName;
PFILE FilePointer;
PCHAR szShortName;
CHAR szBuffer[256];
if (szSourcePath[0] != '\\')
/* Extract Kernel filename without path */
szShortName = strrchr(szFileName, '\\');
if (!szShortName)
{
strcpy(szFullName, "\\");
strcat(szFullName, szSourcePath);
/* No path, leave it alone */
szShortName = szFileName;
}
else
else
{
strcpy(szFullName, szSourcePath);
/* Skip the path */
szShortName = szShortName + 1;
}
if (szFullName[strlen(szFullName)] != '\\')
/* Open the Kernel */
FilePointer = FsOpenFile(szFileName);
if (!FilePointer)
{
strcat(szFullName, "\\");
/* Return failure on the short name */
strcpy(szBuffer, szShortName);
strcat(szBuffer, " not found.");
UiMessageBox(szBuffer);
return FALSE;
}
if (szFileName[0] != '\\')
{
strcat(szFullName, szFileName);
}
else
{
strcat(szFullName, szFileName + 1);
}
/* Update the status bar with the current file */
strcpy(szBuffer, "Reading ");
strcat(szBuffer, szShortName);
UiDrawStatusText(szBuffer);
szShortName = strrchr(szFileName, '\\');
if (szShortName == NULL)
szShortName = szFileName;
else
szShortName = szShortName + 1;
/* Do the actual loading */
FrLdrMapKernel(FilePointer);
FilePointer = FsOpenFile(szFullName);
if (FilePointer == NULL)
{
printf("Could not find %s\n", szShortName);
return(FALSE);
}
/*
* Update the status bar with the current file
*/
#ifdef USE_UI
sprintf(szBuffer, "Setup is loading files (%s)", szShortName);
UiDrawStatusText(szBuffer);
#else
printf("Reading %s\n", szShortName);
#endif
/*
* Load the kernel
*/
FrLdrMapKernel(FilePointer);
return(TRUE);
/* Update Processbar and return success */
return TRUE;
}
static BOOLEAN
@ -301,6 +283,7 @@ VOID RunLoader(VOID)
const char *SourcePath;
const char *LoadOptions;
UINT i;
char szKernelName[256];
HINF InfHandle;
ULONG ErrorLine;
@ -359,6 +342,9 @@ VOID RunLoader(VOID)
UiDrawStatusText("");
#endif
extern BOOLEAN FrLdrBootType;
FrLdrBootType = TRUE;
/* Initialize registry */
RegInitializeRegistry();
@ -433,14 +419,17 @@ VOID RunLoader(VOID)
strcat(strcat(strcat(reactos_kernel_cmdline, SourcePath), " "),
LoadOptions);
/* Load ntoskrnl.exe */
if (!LoadKernel(SourcePath, "ntoskrnl.exe"))
return;
/* Setup the boot path and kernel path */
strcpy(szBootPath, SourcePath);
strcpy(szKernelName, szBootPath);
strcat(szKernelName, "\\ntoskrnl.exe");
/* Setup the HAL path */
strcpy(szHalName, szBootPath);
strcat(szHalName, "\\hal.dll");
/* Load hal.dll */
if (!LoadDriver(SourcePath, "hal.dll"))
return;
/* Load the kernel */
if (!FrLdrLoadKernel(szKernelName, 5)) return;
/* Create ntoskrnl.sym */
LoadKernelSymbols(SourcePath, "ntoskrnl.exe");