2 * COPYRIGHT: See COPYING in the top level directory
4 * FILE: boot/freeldr/freeldr/reactos/rosboot.c
5 * PURPOSE: ReactOS Loader
6 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
10 #include <internal/i386/ke.h>
11 #include <reactos/rossym.h>
18 #define IsRecognizedPartition(P) \
19 ((P) == PARTITION_FAT_12 || \
20 (P) == PARTITION_FAT_16 || \
21 (P) == PARTITION_HUGE || \
22 (P) == PARTITION_IFS || \
23 (P) == PARTITION_EXT2 || \
24 (P) == PARTITION_FAT32 || \
25 (P) == PARTITION_FAT32_XINT13 || \
26 (P) == PARTITION_XINT13)
30 FrLdrLoadKernel(PCHAR szFileName
,
37 /* Extract Kernel filename without path */
38 szShortName
= strrchr(szFileName
, '\\');
39 if (szShortName
== NULL
) {
41 /* No path, leave it alone */
42 szShortName
= szFileName
;
47 szShortName
= szShortName
+ 1;
51 FilePointer
= FsOpenFile(szFileName
);
53 /* Make sure it worked */
54 if (FilePointer
== NULL
) {
56 /* Return failure on the short name */
57 strcpy(szBuffer
, szShortName
);
58 strcat(szBuffer
, " not found.");
59 UiMessageBox(szBuffer
);
63 /* Update the status bar with the current file */
64 strcpy(szBuffer
, "Reading ");
65 strcat(szBuffer
, szShortName
);
66 UiDrawStatusText(szBuffer
);
68 /* Do the actual loading */
69 FrLdrMapKernel(FilePointer
);
71 /* Update Processbar and return success */
72 UiDrawProgressBarCenter(nPos
, 100, "Loading ReactOS...");
77 FreeldrFreeMem(PVOID Area
)
83 FreeldrAllocMem(ULONG_PTR Size
)
85 return MmAllocateMemory((ULONG
) Size
);
89 FreeldrReadFile(PVOID FileContext
, PVOID Buffer
, ULONG Size
)
93 return FsReadFile((PFILE
) FileContext
, (ULONG
) Size
, &BytesRead
, Buffer
)
98 FreeldrSeekFile(PVOID FileContext
, ULONG_PTR Position
)
100 FsSetFilePointer((PFILE
) FileContext
, (ULONG
) Position
);
105 LoadKernelSymbols(PCHAR szKernelName
, int nPos
)
107 static ROSSYM_CALLBACKS FreeldrCallbacks
=
115 PROSSYM_INFO RosSymInfo
;
119 RosSymInit(&FreeldrCallbacks
);
121 FilePointer
= FsOpenFile(szKernelName
);
122 if (FilePointer
== NULL
)
126 if (! RosSymCreateFromFile(FilePointer
, &RosSymInfo
))
130 Base
= FrLdrCreateModule("NTOSKRNL.SYM");
131 Size
= RosSymGetRawDataLength(RosSymInfo
);
132 RosSymGetRawData(RosSymInfo
, (PVOID
)Base
);
133 FrLdrCloseModule(Base
, Size
);
134 RosSymDelete(RosSymInfo
);
139 FrLdrLoadNlsFile(PCHAR szFileName
,
146 /* Open the Driver */
147 FilePointer
= FsOpenFile(szFileName
);
149 /* Make sure we did */
150 if (FilePointer
== NULL
) {
152 /* Fail if file wasn't opened */
153 strcpy(value
, szFileName
);
154 strcat(value
, " not found.");
159 /* Update the status bar with the current file */
160 strcpy(value
, "Reading ");
161 p
= strrchr(szFileName
, '\\');
164 strcat(value
, szFileName
);
168 strcat(value
, p
+ 1);
170 UiDrawStatusText(value
);
172 /* Load the driver */
173 FrLdrLoadModule(FilePointer
, szModuleName
, NULL
);
178 FrLdrLoadNlsFiles(PCHAR szSystemRoot
,
181 LONG rc
= ERROR_SUCCESS
;
184 CHAR szNameBuffer
[80];
185 CHAR szFileName
[256];
188 /* open the codepage key */
189 rc
= RegOpenKey(NULL
,
190 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
192 if (rc
!= ERROR_SUCCESS
) {
194 strcpy(szErrorOut
, "Couldn't open CodePage registry key");
198 /* get ANSI codepage */
200 rc
= RegQueryValue(hKey
, "ACP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
201 if (rc
!= ERROR_SUCCESS
) {
203 strcpy(szErrorOut
, "Couldn't get ACP NLS setting");
208 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
209 if (rc
!= ERROR_SUCCESS
) {
211 strcpy(szErrorOut
, "ACP NLS Setting exists, but isn't readable");
215 /* load ANSI codepage table */
216 strcpy(szFileName
, szSystemRoot
);
217 strcat(szFileName
, "system32\\");
218 strcat(szFileName
, szNameBuffer
);
219 DbgPrint((DPRINT_REACTOS
, "ANSI file: %s\n", szFileName
));
220 if (!FrLdrLoadNlsFile(szFileName
, "ansi.nls")) {
222 strcpy(szErrorOut
, "Couldn't load ansi.nls");
226 /* get OEM codepage */
228 rc
= RegQueryValue(hKey
, "OEMCP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
229 if (rc
!= ERROR_SUCCESS
) {
231 strcpy(szErrorOut
, "Couldn't get OEMCP NLS setting");
236 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
237 if (rc
!= ERROR_SUCCESS
) {
239 strcpy(szErrorOut
, "OEMCP NLS setting exists, but isn't readable");
243 /* load OEM codepage table */
244 strcpy(szFileName
, szSystemRoot
);
245 strcat(szFileName
, "system32\\");
246 strcat(szFileName
, szNameBuffer
);
247 DbgPrint((DPRINT_REACTOS
, "Oem file: %s\n", szFileName
));
248 if (!FrLdrLoadNlsFile(szFileName
, "oem.nls")) {
250 strcpy(szErrorOut
, "Couldn't load oem.nls");
254 /* open the language key */
255 rc
= RegOpenKey(NULL
,
256 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
258 if (rc
!= ERROR_SUCCESS
) {
260 strcpy(szErrorOut
, "Couldn't open Language registry key");
264 /* get the Unicode case table */
266 rc
= RegQueryValue(hKey
, "Default", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
267 if (rc
!= ERROR_SUCCESS
) {
269 strcpy(szErrorOut
, "Couldn't get Language Default setting");
274 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
275 if (rc
!= ERROR_SUCCESS
) {
277 strcpy(szErrorOut
, "Language Default setting exists, but isn't readable");
281 /* load Unicode case table */
282 strcpy(szFileName
, szSystemRoot
);
283 strcat(szFileName
, "system32\\");
284 strcat(szFileName
, 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, "Loading ReactOS...");
339 FrLdrLoadBootDrivers(PCHAR szSystemRoot
,
343 FRLDRHKEY hGroupKey
, hOrderKey
, hServiceKey
, hDriverKey
;
344 CHAR GroupNameBuffer
[512];
345 CHAR ServiceName
[256];
346 ULONG OrderList
[128];
356 UCHAR DriverGroup
[256];
357 ULONG DriverGroupSize
;
359 UCHAR ImagePath
[256];
360 UCHAR TempImagePath
[256];
362 /* get 'service group order' key */
363 rc
= RegOpenKey(NULL
,
364 "\\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 "\\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 "\\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
, "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
, "Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
433 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
436 ValueSize
= sizeof(ULONG
);
437 rc
= RegQueryValue(hDriverKey
, "Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
438 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
439 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
441 /* Read the driver's group */
442 DriverGroupSize
= 256;
443 rc
= RegQueryValue(hDriverKey
, "Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
444 DbgPrint((DPRINT_REACTOS
, " Group: '%s' \n", DriverGroup
));
446 /* Make sure it should be started */
447 if ((StartValue
== 0) &&
448 (TagValue
== OrderList
[TagIndex
]) &&
449 (stricmp(DriverGroup
, GroupName
) == 0)) {
451 /* Get the Driver's Location */
453 rc
= RegQueryValue(hDriverKey
, "ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
455 /* Write the whole path if it suceeded, else prepare to fail */
456 if (rc
!= ERROR_SUCCESS
) {
457 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
458 strcpy(ImagePath
, szSystemRoot
);
459 strcat(ImagePath
, "system32\\drivers\\");
460 strcat(ImagePath
, ServiceName
);
461 strcat(ImagePath
, ".sys");
462 } else if (TempImagePath
[0] != '\\') {
463 strcpy(ImagePath
, szSystemRoot
);
464 strcat(ImagePath
, TempImagePath
);
466 strcpy(ImagePath
, TempImagePath
);
467 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
470 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
472 /* Update the position if needed */
473 if (nPos
< 100) nPos
+= 5;
475 FrLdrLoadDriver(ImagePath
, nPos
);
479 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current Tag %d, current group '%s')\n",
480 ServiceName
, StartValue
, TagValue
, DriverGroup
, OrderList
[TagIndex
], GroupName
));
490 /* Get the Driver's Name */
491 ValueSize
= sizeof(ServiceName
);
492 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
494 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
495 if (rc
== ERROR_NO_MORE_ITEMS
) break;
496 if (rc
!= ERROR_SUCCESS
) return;
497 DbgPrint((DPRINT_REACTOS
, "Service %d: '%s'\n", (int)Index
, ServiceName
));
499 /* open driver Key */
500 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
502 /* Read the Start Value */
503 ValueSize
= sizeof(ULONG
);
504 rc
= RegQueryValue(hDriverKey
, "Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
505 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
508 ValueSize
= sizeof(ULONG
);
509 rc
= RegQueryValue(hDriverKey
, "Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
510 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
511 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
513 /* Read the driver's group */
514 DriverGroupSize
= 256;
515 rc
= RegQueryValue(hDriverKey
, "Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
516 DbgPrint((DPRINT_REACTOS
, " Group: '%s' \n", DriverGroup
));
518 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
519 if (TagValue
== OrderList
[TagIndex
]) break;
522 if ((StartValue
== 0) &&
523 (TagIndex
> OrderList
[0]) &&
524 (stricmp(DriverGroup
, GroupName
) == 0)) {
527 rc
= RegQueryValue(hDriverKey
, "ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
528 if (rc
!= ERROR_SUCCESS
) {
529 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
530 strcpy(ImagePath
, szSystemRoot
);
531 strcat(ImagePath
, "system32\\drivers\\");
532 strcat(ImagePath
, ServiceName
);
533 strcat(ImagePath
, ".sys");
534 } else if (TempImagePath
[0] != '\\') {
535 strcpy(ImagePath
, szSystemRoot
);
536 strcat(ImagePath
, TempImagePath
);
538 strcpy(ImagePath
, TempImagePath
);
539 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
541 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
543 if (nPos
< 100) nPos
+= 5;
545 FrLdrLoadDriver(ImagePath
, nPos
);
549 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current group '%s')\n",
550 ServiceName
, StartValue
, TagValue
, DriverGroup
, GroupName
));
556 /* Move to the next group name */
557 GroupName
= GroupName
+ strlen(GroupName
) + 1;
562 LoadAndBootReactOS(PUCHAR OperatingSystemName
)
567 CHAR szKernelName
[1024];
568 CHAR szHalName
[1024];
569 CHAR szFileName
[1024];
570 CHAR szBootPath
[256];
578 PARTITION_TABLE_ENTRY PartitionTableEntry
;
581 extern ULONG PageDirectoryStart
;
582 extern ULONG PageDirectoryEnd
;
583 extern BOOLEAN AcpiPresent
;
586 // Open the operating system section
587 // specified in the .ini file
589 if (!IniOpenSection(OperatingSystemName
, &SectionId
))
591 sprintf(MsgBuffer
,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName
);
592 UiMessageBox(MsgBuffer
);
597 * Setup multiboot information structure
599 LoaderBlock
.Flags
= MB_INFO_FLAG_MEM_SIZE
| MB_INFO_FLAG_BOOT_DEVICE
| MB_INFO_FLAG_COMMAND_LINE
| MB_INFO_FLAG_MODULES
;
600 LoaderBlock
.PageDirectoryStart
= (ULONG
)&PageDirectoryStart
;
601 LoaderBlock
.PageDirectoryEnd
= (ULONG
)&PageDirectoryEnd
;
602 LoaderBlock
.BootDevice
= 0xffffffff;
603 LoaderBlock
.CommandLine
= (unsigned long)multiboot_kernel_cmdline
;
604 LoaderBlock
.ModsCount
= 0;
605 LoaderBlock
.ModsAddr
= (unsigned long)multiboot_modules
;
606 LoaderBlock
.MmapLength
= (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP
)(PVOID
)&multiboot_memory_map
, 32) * sizeof(memory_map_t
);
607 if (LoaderBlock
.MmapLength
)
609 LoaderBlock
.MmapAddr
= (unsigned long)&multiboot_memory_map
;
610 LoaderBlock
.Flags
|= MB_INFO_FLAG_MEM_SIZE
| MB_INFO_FLAG_MEMORY_MAP
;
611 multiboot_memory_map_descriptor_size
= sizeof(memory_map_t
); // GetBiosMemoryMap uses a fixed value of 24
612 DbgPrint((DPRINT_REACTOS
, "memory map length: %d\n", LoaderBlock
.MmapLength
));
613 DbgPrint((DPRINT_REACTOS
, "dumping memory map:\n"));
614 for (i
=0; i
<(LoaderBlock
.MmapLength
/sizeof(memory_map_t
)); i
++)
616 if (MEMTYPE_USABLE
== multiboot_memory_map
[i
].type
&&
617 0 == multiboot_memory_map
[i
].base_addr_low
)
619 LoaderBlock
.MemLower
= (multiboot_memory_map
[i
].base_addr_low
+ multiboot_memory_map
[i
].length_low
) / 1024;
620 if (640 < LoaderBlock
.MemLower
)
622 LoaderBlock
.MemLower
= 640;
625 if (MEMTYPE_USABLE
== multiboot_memory_map
[i
].type
&&
626 multiboot_memory_map
[i
].base_addr_low
<= 1024 * 1024 &&
627 1024 * 1024 <= multiboot_memory_map
[i
].base_addr_low
+ multiboot_memory_map
[i
].length_low
)
629 LoaderBlock
.MemHigher
= (multiboot_memory_map
[i
].base_addr_low
+ multiboot_memory_map
[i
].length_low
) / 1024 - 1024;
631 DbgPrint((DPRINT_REACTOS
, "start: %x\t size: %x\t type %d\n",
632 multiboot_memory_map
[i
].base_addr_low
,
633 multiboot_memory_map
[i
].length_low
,
634 multiboot_memory_map
[i
].type
));
637 DbgPrint((DPRINT_REACTOS
, "low_mem = %d\n", LoaderBlock
.MemLower
));
638 DbgPrint((DPRINT_REACTOS
, "high_mem = %d\n", LoaderBlock
.MemHigher
));
641 * Initialize the registry
643 RegInitializeRegistry();
646 * Make sure the system path is set in the .ini file
648 if (!IniReadSettingByName(SectionId
, "SystemPath", value
, 1024))
650 UiMessageBox("System path not specified for selected operating system.");
655 * Special case for Live CD.
657 if (!stricmp(value
, "LiveCD"))
659 strcpy(szBootPath
, "\\reactos");
661 /* Set kernel command line */
662 sprintf(multiboot_kernel_cmdline
,
663 "multi(0)disk(0)cdrom(%u)\\reactos /MININT",
664 (unsigned int)BootDrive
);
671 if (!DissectArcPath(value
, szBootPath
, &BootDrive
, &BootPartition
))
673 sprintf(MsgBuffer
,"Invalid system path: '%s'", value
);
674 UiMessageBox(MsgBuffer
);
678 /* recalculate the boot partition for freeldr */
683 if (!MachDiskGetPartitionEntry(BootDrive
, ++i
, &PartitionTableEntry
))
688 if (IsRecognizedPartition(PartitionTableEntry
.SystemIndicator
))
690 if (++rosPartition
== BootPartition
)
698 if (BootPartition
== 0)
700 sprintf(MsgBuffer
,"Invalid system path: '%s'", value
);
701 UiMessageBox(MsgBuffer
);
705 /* copy ARC path into kernel command line */
706 strcpy(multiboot_kernel_cmdline
, value
);
709 /* Set boot drive and partition */
710 ((LPSTR
)(&LoaderBlock
.BootDevice
))[0] = (CHAR
)BootDrive
;
711 ((LPSTR
)(&LoaderBlock
.BootDevice
))[1] = (CHAR
)BootPartition
;
714 * Read the optional kernel parameters (if any)
716 if (IniReadSettingByName(SectionId
, "Options", value
, 1024))
718 strcat(multiboot_kernel_cmdline
, " ");
719 strcat(multiboot_kernel_cmdline
, value
);
722 /* append a backslash */
723 if ((strlen(szBootPath
)==0) ||
724 szBootPath
[strlen(szBootPath
)] != '\\')
725 strcat(szBootPath
, "\\");
727 DbgPrint((DPRINT_REACTOS
,"SystemRoot: '%s'\n", szBootPath
));
731 UiDrawStatusText("Detecting Hardware...");
738 if (AcpiPresent
) LoaderBlock
.Flags
|= MB_INFO_FLAG_ACPI_TABLE
;
740 UiDrawStatusText("Loading...");
741 UiDrawProgressBarCenter(0, 100, "Loading ReactOS...");
744 * Try to open boot drive
746 if (!FsOpenVolume(BootDrive
, BootPartition
))
748 UiMessageBox("Failed to open boot drive.");
753 * Find the kernel image name
754 * and try to load the kernel off the disk
756 if(IniReadSettingByName(SectionId
, "Kernel", value
, 1024))
761 if (value
[0] == '\\')
763 strcpy(szKernelName
, value
);
767 strcpy(szKernelName
, szBootPath
);
768 strcat(szKernelName
, "SYSTEM32\\");
769 strcat(szKernelName
, value
);
774 strcpy(value
, "NTOSKRNL.EXE");
775 strcpy(szKernelName
, szBootPath
);
776 strcat(szKernelName
, "SYSTEM32\\");
777 strcat(szKernelName
, value
);
780 if (!FrLdrLoadKernel(szKernelName
, 5)) return;
783 * Find the HAL image name
784 * and try to load the kernel off the disk
786 if(IniReadSettingByName(SectionId
, "Hal", value
, 1024))
791 if (value
[0] == '\\')
793 strcpy(szHalName
, value
);
797 strcpy(szHalName
, szBootPath
);
798 strcat(szHalName
, "SYSTEM32\\");
799 strcat(szHalName
, value
);
804 strcpy(value
, "HAL.DLL");
805 strcpy(szHalName
, szBootPath
);
806 strcat(szHalName
, "SYSTEM32\\");
807 strcat(szHalName
, value
);
810 if (!FrLdrLoadDriver(szHalName
, 10))
814 * Load the System hive from disk
816 strcpy(szFileName
, szBootPath
);
817 strcat(szFileName
, "SYSTEM32\\CONFIG\\SYSTEM");
819 DbgPrint((DPRINT_REACTOS
, "SystemHive: '%s'", szFileName
));
821 FilePointer
= FsOpenFile(szFileName
);
822 if (FilePointer
== NULL
)
824 UiMessageBox("Could not find the System hive!");
829 * Update the status bar with the current file
831 strcpy(name
, "Reading ");
833 while (strlen(name
) < 80)
835 UiDrawStatusText(name
);
838 * Load the System hive
840 Base
= FrLdrLoadModule(FilePointer
, szFileName
, &Size
);
841 if (Base
== 0 || Size
== 0)
843 UiMessageBox("Could not load the System hive!\n");
846 DbgPrint((DPRINT_REACTOS
, "SystemHive loaded at 0x%x size %u", (unsigned)Base
, (unsigned)Size
));
849 * Import the loaded system hive
851 RegImportBinaryHive((PCHAR
)Base
, Size
);
854 * Initialize the 'CurrentControlSet' link
856 RegInitCurrentControlSet(FALSE
);
858 UiDrawProgressBarCenter(15, 100, "Loading ReactOS...");
861 * Export the hardware hive
863 Base
= FrLdrCreateModule ("HARDWARE");
864 RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", (PCHAR
)Base
, &Size
);
865 FrLdrCloseModule (Base
, Size
);
867 UiDrawProgressBarCenter(20, 100, "Loading ReactOS...");
872 if (!FrLdrLoadNlsFiles(szBootPath
, MsgBuffer
))
874 UiMessageBox(MsgBuffer
);
877 UiDrawProgressBarCenter(30, 100, "Loading ReactOS...");
880 * Load kernel symbols
882 LoadKernelSymbols(szKernelName
, 30);
883 UiDrawProgressBarCenter(40, 100, "Loading ReactOS...");
888 FrLdrLoadBootDrivers(szBootPath
, 40);
889 UiUnInitialize("Booting ReactOS...");
892 * Now boot the kernel
894 DiskStopFloppyMotor();
895 MachVideoPrepareForReactOS();
896 FrLdrStartup(0x2badb002);
901 DbgPrint(char *Fmt
, ...)