4 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 * Copyright (C) 2005 Alex Ionescu <alex@relsoft.net>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 LOADER_PARAMETER_BLOCK LoaderBlock
;
28 char reactos_kernel_cmdline
[255]; // Command line passed to kernel
29 LOADER_MODULE reactos_modules
[64]; // Array to hold boot module info loaded for the kernel
30 char reactos_module_strings
[64][256]; // Array to hold module names
31 unsigned long reactos_memory_map_descriptor_size
;
32 memory_map_t reactos_memory_map
[32]; // Memory map
36 FrLdrLoadKernel(PCHAR szFileName
,
43 /* Extract Kernel filename without path */
44 szShortName
= strrchr(szFileName
, '\\');
45 if (szShortName
== NULL
) {
47 /* No path, leave it alone */
48 szShortName
= szFileName
;
53 szShortName
= szShortName
+ 1;
57 FilePointer
= FsOpenFile(szFileName
);
59 /* Make sure it worked */
60 if (FilePointer
== NULL
) {
62 /* Return failure on the short name */
63 strcpy(szBuffer
, szShortName
);
64 strcat(szBuffer
, " not found.");
65 UiMessageBox(szBuffer
);
69 /* Update the status bar with the current file */
70 strcpy(szBuffer
, "Reading ");
71 strcat(szBuffer
, szShortName
);
72 UiDrawStatusText(szBuffer
);
74 /* Do the actual loading */
75 FrLdrMapKernel(FilePointer
);
77 /* Update Processbar and return success */
78 UiDrawProgressBarCenter(nPos
, 100, (PCHAR
)"Loading ReactOS...");
83 FreeldrFreeMem(PVOID Area
)
89 FreeldrAllocMem(ULONG_PTR Size
)
91 return MmAllocateMemory((ULONG
) Size
);
95 FreeldrReadFile(PVOID FileContext
, PVOID Buffer
, ULONG Size
)
99 return FsReadFile((PFILE
) FileContext
, (ULONG
) Size
, &BytesRead
, Buffer
)
100 && Size
== BytesRead
;
104 FreeldrSeekFile(PVOID FileContext
, ULONG_PTR Position
)
106 FsSetFilePointer((PFILE
) FileContext
, (ULONG
) Position
);
111 LoadKernelSymbols(PCHAR szKernelName
, int nPos
)
113 static ROSSYM_CALLBACKS FreeldrCallbacks
=
121 PROSSYM_INFO RosSymInfo
;
125 RosSymInit(&FreeldrCallbacks
);
127 FilePointer
= FsOpenFile(szKernelName
);
128 if (FilePointer
== NULL
)
132 if (! RosSymCreateFromFile(FilePointer
, &RosSymInfo
))
136 Base
= FrLdrCreateModule("NTOSKRNL.SYM");
137 Size
= RosSymGetRawDataLength(RosSymInfo
);
138 RosSymGetRawData(RosSymInfo
, (PVOID
)Base
);
139 FrLdrCloseModule(Base
, Size
);
140 RosSymDelete(RosSymInfo
);
145 FrLdrLoadNlsFile(PCSTR szFileName
,
152 /* Open the Driver */
153 FilePointer
= FsOpenFile(szFileName
);
155 /* Make sure we did */
156 if (FilePointer
== NULL
) {
158 /* Fail if file wasn't opened */
159 strcpy(value
, szFileName
);
160 strcat(value
, " not found.");
165 /* Update the status bar with the current file */
166 strcpy(value
, "Reading ");
167 p
= strrchr(szFileName
, '\\');
170 strcat(value
, szFileName
);
174 strcat(value
, p
+ 1);
176 UiDrawStatusText(value
);
178 /* Load the driver */
179 FrLdrLoadModule(FilePointer
, szModuleName
, NULL
);
184 FrLdrLoadNlsFiles(PCHAR szSystemRoot
,
187 LONG rc
= ERROR_SUCCESS
;
189 WCHAR szIdBuffer
[80];
190 WCHAR szNameBuffer
[80];
191 CHAR szFileName
[256];
194 /* open the codepage key */
195 rc
= RegOpenKey(NULL
,
196 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
198 if (rc
!= ERROR_SUCCESS
) {
200 strcpy(szErrorOut
, "Couldn't open CodePage registry key");
204 /* get ANSI codepage */
205 BufferSize
= sizeof(szIdBuffer
);
206 rc
= RegQueryValue(hKey
, L
"ACP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
207 if (rc
!= ERROR_SUCCESS
) {
209 strcpy(szErrorOut
, "Couldn't get ACP NLS setting");
213 BufferSize
= sizeof(szNameBuffer
);
214 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
215 if (rc
!= ERROR_SUCCESS
) {
217 strcpy(szErrorOut
, "ACP NLS Setting exists, but isn't readable");
221 /* load ANSI codepage table */
222 sprintf(szFileName
,"%ssystem32\\%S", szSystemRoot
, szNameBuffer
);
223 DbgPrint((DPRINT_REACTOS
, "ANSI file: %s\n", szFileName
));
224 if (!FrLdrLoadNlsFile(szFileName
, "ansi.nls")) {
226 strcpy(szErrorOut
, "Couldn't load ansi.nls");
230 /* get OEM codepage */
231 BufferSize
= sizeof(szIdBuffer
);
232 rc
= RegQueryValue(hKey
, L
"OEMCP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
233 if (rc
!= ERROR_SUCCESS
) {
235 strcpy(szErrorOut
, "Couldn't get OEMCP NLS setting");
239 BufferSize
= sizeof(szNameBuffer
);
240 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
241 if (rc
!= ERROR_SUCCESS
) {
243 strcpy(szErrorOut
, "OEMCP NLS setting exists, but isn't readable");
247 /* load OEM codepage table */
248 sprintf(szFileName
, "%ssystem32\\%S", szSystemRoot
, szNameBuffer
);
249 DbgPrint((DPRINT_REACTOS
, "Oem file: %s\n", szFileName
));
250 if (!FrLdrLoadNlsFile(szFileName
, "oem.nls")) {
252 strcpy(szErrorOut
, "Couldn't load oem.nls");
256 /* open the language key */
257 rc
= RegOpenKey(NULL
,
258 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
260 if (rc
!= ERROR_SUCCESS
) {
262 strcpy(szErrorOut
, "Couldn't open Language registry key");
266 /* get the Unicode case table */
267 BufferSize
= sizeof(szIdBuffer
);
268 rc
= RegQueryValue(hKey
, L
"Default", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
269 if (rc
!= ERROR_SUCCESS
) {
271 strcpy(szErrorOut
, "Couldn't get Language Default setting");
275 BufferSize
= sizeof(szNameBuffer
);
276 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
277 if (rc
!= ERROR_SUCCESS
) {
279 strcpy(szErrorOut
, "Language Default setting exists, but isn't readable");
283 /* load Unicode case table */
284 sprintf(szFileName
, "%ssystem32\\%S", szSystemRoot
, szNameBuffer
);
285 DbgPrint((DPRINT_REACTOS
, "Casemap file: %s\n", szFileName
));
286 if (!FrLdrLoadNlsFile(szFileName
, "casemap.nls")) {
288 strcpy(szErrorOut
, "casemap.nls");
296 FrLdrLoadDriver(PCHAR szFileName
,
303 /* Open the Driver */
304 FilePointer
= FsOpenFile(szFileName
);
306 /* Make sure we did */
307 if (FilePointer
== NULL
) {
309 /* Fail if file wasn't opened */
310 strcpy(value
, szFileName
);
311 strcat(value
, " not found.");
316 /* Update the status bar with the current file */
317 strcpy(value
, "Reading ");
318 p
= strrchr(szFileName
, '\\');
321 strcat(value
, szFileName
);
325 strcat(value
, p
+ 1);
328 UiDrawStatusText(value
);
330 /* Load the driver */
331 FrLdrLoadModule(FilePointer
, szFileName
, NULL
);
333 /* Update status and return */
334 UiDrawProgressBarCenter(nPos
, 100, (PCHAR
)"Loading ReactOS...");
339 FrLdrLoadBootDrivers(PCHAR szSystemRoot
,
343 FRLDRHKEY hGroupKey
, hOrderKey
, hServiceKey
, hDriverKey
;
344 WCHAR GroupNameBuffer
[512];
345 WCHAR ServiceName
[256];
346 ULONG OrderList
[128];
356 WCHAR DriverGroup
[256];
357 ULONG DriverGroupSize
;
360 WCHAR TempImagePath
[256];
362 /* get 'service group order' key */
363 rc
= RegOpenKey(NULL
,
364 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
366 if (rc
!= ERROR_SUCCESS
) {
368 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'ServiceGroupOrder' key (rc %d)\n", (int)rc
));
372 /* get 'group order list' key */
373 rc
= RegOpenKey(NULL
,
374 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
376 if (rc
!= ERROR_SUCCESS
) {
378 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'GroupOrderList' key (rc %d)\n", (int)rc
));
382 /* enumerate drivers */
383 rc
= RegOpenKey(NULL
,
384 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
386 if (rc
!= ERROR_SUCCESS
) {
388 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'Services' key (rc %d)\n", (int)rc
));
392 /* Get the Name Group */
393 BufferSize
= sizeof(GroupNameBuffer
);
394 rc
= RegQueryValue(hGroupKey
, L
"List", NULL
, (PUCHAR
)GroupNameBuffer
, &BufferSize
);
395 DbgPrint((DPRINT_REACTOS
, "RegQueryValue(): rc %d\n", (int)rc
));
396 if (rc
!= ERROR_SUCCESS
) return;
397 DbgPrint((DPRINT_REACTOS
, "BufferSize: %d \n", (int)BufferSize
));
398 DbgPrint((DPRINT_REACTOS
, "GroupNameBuffer: '%S' \n", GroupNameBuffer
));
400 /* Loop through each group */
401 GroupName
= GroupNameBuffer
;
403 DbgPrint((DPRINT_REACTOS
, "Driver group: '%S'\n", GroupName
));
405 /* Query the Order */
406 BufferSize
= sizeof(OrderList
);
407 rc
= RegQueryValue(hOrderKey
, GroupName
, NULL
, (PUCHAR
)OrderList
, &BufferSize
);
408 if (rc
!= ERROR_SUCCESS
) OrderList
[0] = 0;
410 /* enumerate all drivers */
411 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
417 /* Get the Driver's Name */
418 ValueSize
= sizeof(ServiceName
);
419 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
420 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
422 /* Makre sure it's valid, and check if we're done */
423 if (rc
== ERROR_NO_MORE_ITEMS
) break;
424 if (rc
!= ERROR_SUCCESS
) return;
425 DbgPrint((DPRINT_REACTOS
, "Service %d: '%S'\n", (int)Index
, ServiceName
));
427 /* open driver Key */
428 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
430 /* Read the Start Value */
431 ValueSize
= sizeof(ULONG
);
432 rc
= RegQueryValue(hDriverKey
, L
"Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
433 if (rc
!= ERROR_SUCCESS
) StartValue
= (ULONG
)-1;
434 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
437 ValueSize
= sizeof(ULONG
);
438 rc
= RegQueryValue(hDriverKey
, L
"Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
439 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
440 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
442 /* Read the driver's group */
443 DriverGroupSize
= sizeof(DriverGroup
);
444 rc
= RegQueryValue(hDriverKey
, L
"Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
445 DbgPrint((DPRINT_REACTOS
, " Group: '%S' \n", DriverGroup
));
447 /* Make sure it should be started */
448 if ((StartValue
== 0) &&
449 (TagValue
== OrderList
[TagIndex
]) &&
450 (_wcsicmp(DriverGroup
, GroupName
) == 0)) {
452 /* Get the Driver's Location */
453 ValueSize
= sizeof(TempImagePath
);
454 rc
= RegQueryValue(hDriverKey
, L
"ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
456 /* Write the whole path if it suceeded, else prepare to fail */
457 if (rc
!= ERROR_SUCCESS
) {
458 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
459 sprintf(ImagePath
, "%s\\system32\\drivers\\%S.sys", szSystemRoot
, ServiceName
);
460 } else if (TempImagePath
[0] != L
'\\') {
461 sprintf(ImagePath
, "%s%S", szSystemRoot
, TempImagePath
);
463 sprintf(ImagePath
, "%S", TempImagePath
);
464 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
467 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
469 /* Update the position if needed */
470 if (nPos
< 100) nPos
+= 5;
472 FrLdrLoadDriver(ImagePath
, nPos
);
476 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current Tag %d, current group '%S')\n",
477 ServiceName
, StartValue
, TagValue
, DriverGroup
, OrderList
[TagIndex
], GroupName
));
487 /* Get the Driver's Name */
488 ValueSize
= sizeof(ServiceName
);
489 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
491 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
492 if (rc
== ERROR_NO_MORE_ITEMS
) break;
493 if (rc
!= ERROR_SUCCESS
) return;
494 DbgPrint((DPRINT_REACTOS
, "Service %d: '%S'\n", (int)Index
, ServiceName
));
496 /* open driver Key */
497 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
499 /* Read the Start Value */
500 ValueSize
= sizeof(ULONG
);
501 rc
= RegQueryValue(hDriverKey
, L
"Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
502 if (rc
!= ERROR_SUCCESS
) StartValue
= (ULONG
)-1;
503 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
506 ValueSize
= sizeof(ULONG
);
507 rc
= RegQueryValue(hDriverKey
, L
"Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
508 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
509 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
511 /* Read the driver's group */
512 DriverGroupSize
= sizeof(DriverGroup
);
513 rc
= RegQueryValue(hDriverKey
, L
"Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
514 DbgPrint((DPRINT_REACTOS
, " Group: '%S' \n", DriverGroup
));
516 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
517 if (TagValue
== OrderList
[TagIndex
]) break;
520 if ((StartValue
== 0) &&
521 (TagIndex
> OrderList
[0]) &&
522 (_wcsicmp(DriverGroup
, GroupName
) == 0)) {
524 ValueSize
= sizeof(TempImagePath
);
525 rc
= RegQueryValue(hDriverKey
, L
"ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
526 if (rc
!= ERROR_SUCCESS
) {
527 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
528 sprintf(ImagePath
, "%ssystem32\\drivers\\%S.sys", szSystemRoot
, ServiceName
);
529 } else if (TempImagePath
[0] != L
'\\') {
530 sprintf(ImagePath
, "%s%S", szSystemRoot
, TempImagePath
);
532 sprintf(ImagePath
, "%S", TempImagePath
);
533 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
535 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
537 if (nPos
< 100) nPos
+= 5;
539 FrLdrLoadDriver(ImagePath
, nPos
);
543 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current group '%S')\n",
544 ServiceName
, StartValue
, TagValue
, DriverGroup
, GroupName
));
550 /* Move to the next group name */
551 GroupName
= GroupName
+ wcslen(GroupName
) + 1;
556 LoadAndBootReactOS(PCSTR OperatingSystemName
)
561 CHAR SystemPath
[1024];
562 CHAR szKernelName
[1024];
563 CHAR szHalName
[1024];
564 CHAR szFileName
[1024];
565 CHAR szBootPath
[256];
573 extern ULONG PageDirectoryStart
;
574 extern ULONG PageDirectoryEnd
;
575 extern BOOLEAN AcpiPresent
;
578 // Open the operating system section
579 // specified in the .ini file
581 if (!IniOpenSection(OperatingSystemName
, &SectionId
))
583 sprintf(MsgBuffer
,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName
);
584 UiMessageBox(MsgBuffer
);
589 * Setup multiboot information structure
591 LoaderBlock
.Flags
= MB_FLAGS_BOOT_DEVICE
| MB_FLAGS_COMMAND_LINE
| MB_FLAGS_MODULE_INFO
;
592 LoaderBlock
.PageDirectoryStart
= (ULONG
)&PageDirectoryStart
;
593 LoaderBlock
.PageDirectoryEnd
= (ULONG
)&PageDirectoryEnd
;
594 LoaderBlock
.BootDevice
= 0xffffffff;
595 LoaderBlock
.CommandLine
= (unsigned long)reactos_kernel_cmdline
;
596 LoaderBlock
.ModsCount
= 0;
597 LoaderBlock
.ModsAddr
= (unsigned long)reactos_modules
;
598 LoaderBlock
.MmapLength
= (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP
)(PVOID
)&reactos_memory_map
, 32) * sizeof(memory_map_t
);
599 if (LoaderBlock
.MmapLength
)
601 LoaderBlock
.MmapAddr
= (unsigned long)&reactos_memory_map
;
602 LoaderBlock
.Flags
|= MB_FLAGS_MEM_INFO
| MB_FLAGS_MMAP_INFO
;
603 reactos_memory_map_descriptor_size
= sizeof(memory_map_t
); // GetBiosMemoryMap uses a fixed value of 24
604 DbgPrint((DPRINT_REACTOS
, "memory map length: %d\n", LoaderBlock
.MmapLength
));
605 DbgPrint((DPRINT_REACTOS
, "dumping memory map:\n"));
606 for (i
=0; i
<(LoaderBlock
.MmapLength
/sizeof(memory_map_t
)); i
++)
608 if (MEMTYPE_USABLE
== reactos_memory_map
[i
].type
&&
609 0 == reactos_memory_map
[i
].base_addr_low
)
611 LoaderBlock
.MemLower
= (reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
) / 1024;
612 if (640 < LoaderBlock
.MemLower
)
614 LoaderBlock
.MemLower
= 640;
617 if (MEMTYPE_USABLE
== reactos_memory_map
[i
].type
&&
618 reactos_memory_map
[i
].base_addr_low
<= 1024 * 1024 &&
619 1024 * 1024 <= reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
)
621 LoaderBlock
.MemHigher
= (reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
) / 1024 - 1024;
623 DbgPrint((DPRINT_REACTOS
, "start: %x\t size: %x\t type %d\n",
624 reactos_memory_map
[i
].base_addr_low
,
625 reactos_memory_map
[i
].length_low
,
626 reactos_memory_map
[i
].type
));
629 DbgPrint((DPRINT_REACTOS
, "low_mem = %d\n", LoaderBlock
.MemLower
));
630 DbgPrint((DPRINT_REACTOS
, "high_mem = %d\n", LoaderBlock
.MemHigher
));
633 * Initialize the registry
635 RegInitializeRegistry();
638 * Make sure the system path is set in the .ini file
640 if (!IniReadSettingByName(SectionId
, "SystemPath", SystemPath
, sizeof(SystemPath
)))
642 UiMessageBox("System path not specified for selected operating system.");
647 * Special case for Live CD.
649 if (!_stricmp(SystemPath
, "LiveCD"))
652 MachDiskGetBootPath(SystemPath
, sizeof(SystemPath
));
653 strcat(SystemPath
, "\\reactos");
654 strcat(strcpy(reactos_kernel_cmdline
, SystemPath
),
659 if (! MachDiskNormalizeSystemPath(SystemPath
,
662 UiMessageBox("Invalid system path");
665 /* copy system path into kernel command line */
666 strcpy(reactos_kernel_cmdline
, SystemPath
);
670 * Read the optional kernel parameters (if any)
672 if (IniReadSettingByName(SectionId
, "Options", value
, 1024))
674 strcat(reactos_kernel_cmdline
, " ");
675 strcat(reactos_kernel_cmdline
, value
);
680 UiDrawStatusText("Detecting Hardware...");
687 if (AcpiPresent
) LoaderBlock
.Flags
|= MB_FLAGS_ACPI_TABLE
;
689 UiDrawStatusText("Loading...");
690 UiDrawProgressBarCenter(0, 100, (PCHAR
)"Loading ReactOS...");
693 * Try to open system drive
695 if (!FsOpenSystemVolume(SystemPath
, szBootPath
, &LoaderBlock
.BootDevice
))
697 UiMessageBox("Failed to open boot drive.");
701 /* append a backslash */
702 if ((strlen(szBootPath
)==0) ||
703 szBootPath
[strlen(szBootPath
)] != '\\')
704 strcat(szBootPath
, "\\");
706 DbgPrint((DPRINT_REACTOS
,"SystemRoot: '%s'\n", szBootPath
));
709 * Find the kernel image name
710 * and try to load the kernel off the disk
712 if(IniReadSettingByName(SectionId
, "Kernel", value
, 1024))
717 if (value
[0] == '\\')
719 strcpy(szKernelName
, value
);
723 strcpy(szKernelName
, szBootPath
);
724 strcat(szKernelName
, "SYSTEM32\\");
725 strcat(szKernelName
, value
);
730 strcpy(value
, "NTOSKRNL.EXE");
731 strcpy(szKernelName
, szBootPath
);
732 strcat(szKernelName
, "SYSTEM32\\");
733 strcat(szKernelName
, value
);
736 if (!FrLdrLoadKernel(szKernelName
, 5)) return;
739 * Find the HAL image name
740 * and try to load the kernel off the disk
742 if(IniReadSettingByName(SectionId
, "Hal", value
, 1024))
747 if (value
[0] == '\\')
749 strcpy(szHalName
, value
);
753 strcpy(szHalName
, szBootPath
);
754 strcat(szHalName
, "SYSTEM32\\");
755 strcat(szHalName
, value
);
760 strcpy(value
, "HAL.DLL");
761 strcpy(szHalName
, szBootPath
);
762 strcat(szHalName
, "SYSTEM32\\");
763 strcat(szHalName
, value
);
766 if (!FrLdrLoadDriver(szHalName
, 10))
771 strcpy(value
, "INBV.DLL");
772 strcpy(szHalName
, szBootPath
);
773 strcat(szHalName
, "SYSTEM32\\");
774 strcat(szHalName
, value
);
776 if (!FrLdrLoadDriver(szHalName
, 10))
780 * Load the System hive from disk
782 strcpy(szFileName
, szBootPath
);
783 strcat(szFileName
, "SYSTEM32\\CONFIG\\SYSTEM");
785 DbgPrint((DPRINT_REACTOS
, "SystemHive: '%s'", szFileName
));
787 FilePointer
= FsOpenFile(szFileName
);
788 if (FilePointer
== NULL
)
790 UiMessageBox("Could not find the System hive!");
795 * Update the status bar with the current file
797 strcpy(name
, "Reading ");
799 while (strlen(name
) < 80)
801 UiDrawStatusText(name
);
804 * Load the System hive
806 Base
= FrLdrLoadModule(FilePointer
, szFileName
, &Size
);
807 if (Base
== 0 || Size
== 0)
809 UiMessageBox("Could not load the System hive!\n");
812 DbgPrint((DPRINT_REACTOS
, "SystemHive loaded at 0x%x size %u", (unsigned)Base
, (unsigned)Size
));
815 * Import the loaded system hive
817 RegImportBinaryHive((PCHAR
)Base
, Size
);
820 * Initialize the 'CurrentControlSet' link
822 RegInitCurrentControlSet(FALSE
);
824 UiDrawProgressBarCenter(15, 100, (PCHAR
)"Loading ReactOS...");
827 * Export the hardware hive
829 Base
= FrLdrCreateModule ("HARDWARE");
830 RegExportBinaryHive (L
"\\Registry\\Machine\\HARDWARE", (PCHAR
)Base
, &Size
);
831 FrLdrCloseModule (Base
, Size
);
833 UiDrawProgressBarCenter(20, 100, (PCHAR
)"Loading ReactOS...");
838 if (!FrLdrLoadNlsFiles(szBootPath
, MsgBuffer
))
840 UiMessageBox(MsgBuffer
);
843 UiDrawProgressBarCenter(30, 100, (PCHAR
)"Loading ReactOS...");
846 * Load kernel symbols
848 LoadKernelSymbols(szKernelName
, 30);
849 UiDrawProgressBarCenter(40, 100, (PCHAR
)"Loading ReactOS...");
854 FrLdrLoadBootDrivers(szBootPath
, 40);
855 UiUnInitialize("Booting ReactOS...");
858 * Now boot the kernel
860 DiskStopFloppyMotor();
861 MachVideoPrepareForReactOS();
862 FrLdrStartup(0x2badb002);
867 DbgPrint(char *Fmt
, ...)