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>
20 FrLdrLoadKernel(PCHAR szFileName
,
27 /* Extract Kernel filename without path */
28 szShortName
= strrchr(szFileName
, '\\');
29 if (szShortName
== NULL
) {
31 /* No path, leave it alone */
32 szShortName
= szFileName
;
37 szShortName
= szShortName
+ 1;
41 FilePointer
= FsOpenFile(szFileName
);
43 /* Make sure it worked */
44 if (FilePointer
== NULL
) {
46 /* Return failure on the short name */
47 strcpy(szBuffer
, szShortName
);
48 strcat(szBuffer
, " not found.");
49 UiMessageBox(szBuffer
);
53 /* Update the status bar with the current file */
54 strcpy(szBuffer
, "Reading ");
55 strcat(szBuffer
, szShortName
);
56 UiDrawStatusText(szBuffer
);
58 /* Do the actual loading */
59 FrLdrMapKernel(FilePointer
);
61 /* Update Processbar and return success */
62 UiDrawProgressBarCenter(nPos
, 100, "Loading ReactOS...");
67 FreeldrFreeMem(PVOID Area
)
73 FreeldrAllocMem(ULONG_PTR Size
)
75 return MmAllocateMemory((ULONG
) Size
);
79 FreeldrReadFile(PVOID FileContext
, PVOID Buffer
, ULONG Size
)
83 return FsReadFile((PFILE
) FileContext
, (ULONG
) Size
, &BytesRead
, Buffer
)
88 FreeldrSeekFile(PVOID FileContext
, ULONG_PTR Position
)
90 FsSetFilePointer((PFILE
) FileContext
, (ULONG
) Position
);
95 LoadKernelSymbols(PCHAR szKernelName
, int nPos
)
97 static ROSSYM_CALLBACKS FreeldrCallbacks
=
105 PROSSYM_INFO RosSymInfo
;
109 RosSymInit(&FreeldrCallbacks
);
111 FilePointer
= FsOpenFile(szKernelName
);
112 if (FilePointer
== NULL
)
116 if (! RosSymCreateFromFile(FilePointer
, &RosSymInfo
))
120 Base
= FrLdrCreateModule("NTOSKRNL.SYM");
121 Size
= RosSymGetRawDataLength(RosSymInfo
);
122 RosSymGetRawData(RosSymInfo
, (PVOID
)Base
);
123 FrLdrCloseModule(Base
, Size
);
124 RosSymDelete(RosSymInfo
);
129 FrLdrLoadNlsFile(PCHAR szFileName
,
136 /* Open the Driver */
137 FilePointer
= FsOpenFile(szFileName
);
139 /* Make sure we did */
140 if (FilePointer
== NULL
) {
142 /* Fail if file wasn't opened */
143 strcpy(value
, szFileName
);
144 strcat(value
, " not found.");
149 /* Update the status bar with the current file */
150 strcpy(value
, "Reading ");
151 p
= strrchr(szFileName
, '\\');
154 strcat(value
, szFileName
);
158 strcat(value
, p
+ 1);
160 UiDrawStatusText(value
);
162 /* Load the driver */
163 FrLdrLoadModule(FilePointer
, szModuleName
, NULL
);
168 FrLdrLoadNlsFiles(PCHAR szSystemRoot
,
171 LONG rc
= ERROR_SUCCESS
;
174 CHAR szNameBuffer
[80];
175 CHAR szFileName
[256];
178 /* open the codepage key */
179 rc
= RegOpenKey(NULL
,
180 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
182 if (rc
!= ERROR_SUCCESS
) {
184 strcpy(szErrorOut
, "Couldn't open CodePage registry key");
188 /* get ANSI codepage */
190 rc
= RegQueryValue(hKey
, "ACP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
191 if (rc
!= ERROR_SUCCESS
) {
193 strcpy(szErrorOut
, "Couldn't get ACP NLS setting");
198 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
199 if (rc
!= ERROR_SUCCESS
) {
201 strcpy(szErrorOut
, "ACP NLS Setting exists, but isn't readable");
205 /* load ANSI codepage table */
206 strcpy(szFileName
, szSystemRoot
);
207 strcat(szFileName
, "system32\\");
208 strcat(szFileName
, szNameBuffer
);
209 DbgPrint((DPRINT_REACTOS
, "ANSI file: %s\n", szFileName
));
210 if (!FrLdrLoadNlsFile(szFileName
, "ansi.nls")) {
212 strcpy(szErrorOut
, "Couldn't load ansi.nls");
216 /* get OEM codepage */
218 rc
= RegQueryValue(hKey
, "OEMCP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
219 if (rc
!= ERROR_SUCCESS
) {
221 strcpy(szErrorOut
, "Couldn't get OEMCP NLS setting");
226 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
227 if (rc
!= ERROR_SUCCESS
) {
229 strcpy(szErrorOut
, "OEMCP NLS setting exists, but isn't readable");
233 /* load OEM codepage table */
234 strcpy(szFileName
, szSystemRoot
);
235 strcat(szFileName
, "system32\\");
236 strcat(szFileName
, szNameBuffer
);
237 DbgPrint((DPRINT_REACTOS
, "Oem file: %s\n", szFileName
));
238 if (!FrLdrLoadNlsFile(szFileName
, "oem.nls")) {
240 strcpy(szErrorOut
, "Couldn't load oem.nls");
244 /* open the language key */
245 rc
= RegOpenKey(NULL
,
246 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
248 if (rc
!= ERROR_SUCCESS
) {
250 strcpy(szErrorOut
, "Couldn't open Language registry key");
254 /* get the Unicode case table */
256 rc
= RegQueryValue(hKey
, "Default", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
257 if (rc
!= ERROR_SUCCESS
) {
259 strcpy(szErrorOut
, "Couldn't get Language Default setting");
264 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
265 if (rc
!= ERROR_SUCCESS
) {
267 strcpy(szErrorOut
, "Language Default setting exists, but isn't readable");
271 /* load Unicode case table */
272 strcpy(szFileName
, szSystemRoot
);
273 strcat(szFileName
, "system32\\");
274 strcat(szFileName
, szNameBuffer
);
275 DbgPrint((DPRINT_REACTOS
, "Casemap file: %s\n", szFileName
));
276 if (!FrLdrLoadNlsFile(szFileName
, "casemap.nls")) {
278 strcpy(szErrorOut
, "casemap.nls");
286 FrLdrLoadDriver(PCHAR szFileName
,
293 /* Open the Driver */
294 FilePointer
= FsOpenFile(szFileName
);
296 /* Make sure we did */
297 if (FilePointer
== NULL
) {
299 /* Fail if file wasn't opened */
300 strcpy(value
, szFileName
);
301 strcat(value
, " not found.");
306 /* Update the status bar with the current file */
307 strcpy(value
, "Reading ");
308 p
= strrchr(szFileName
, '\\');
311 strcat(value
, szFileName
);
315 strcat(value
, p
+ 1);
318 UiDrawStatusText(value
);
320 /* Load the driver */
321 FrLdrLoadModule(FilePointer
, szFileName
, NULL
);
323 /* Update status and return */
324 UiDrawProgressBarCenter(nPos
, 100, "Loading ReactOS...");
329 FrLdrLoadBootDrivers(PCHAR szSystemRoot
,
333 FRLDRHKEY hGroupKey
, hOrderKey
, hServiceKey
, hDriverKey
;
334 CHAR GroupNameBuffer
[512];
335 CHAR ServiceName
[256];
336 ULONG OrderList
[128];
346 CHAR DriverGroup
[256];
347 ULONG DriverGroupSize
;
350 CHAR TempImagePath
[256];
352 /* get 'service group order' key */
353 rc
= RegOpenKey(NULL
,
354 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
356 if (rc
!= ERROR_SUCCESS
) {
358 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'ServiceGroupOrder' key (rc %d)\n", (int)rc
));
362 /* get 'group order list' key */
363 rc
= RegOpenKey(NULL
,
364 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
366 if (rc
!= ERROR_SUCCESS
) {
368 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'GroupOrderList' key (rc %d)\n", (int)rc
));
372 /* enumerate drivers */
373 rc
= RegOpenKey(NULL
,
374 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
376 if (rc
!= ERROR_SUCCESS
) {
378 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'Services' key (rc %d)\n", (int)rc
));
382 /* Get the Name Group */
383 BufferSize
= sizeof(GroupNameBuffer
);
384 rc
= RegQueryValue(hGroupKey
, "List", NULL
, (PUCHAR
)GroupNameBuffer
, &BufferSize
);
385 DbgPrint((DPRINT_REACTOS
, "RegQueryValue(): rc %d\n", (int)rc
));
386 if (rc
!= ERROR_SUCCESS
) return;
387 DbgPrint((DPRINT_REACTOS
, "BufferSize: %d \n", (int)BufferSize
));
388 DbgPrint((DPRINT_REACTOS
, "GroupNameBuffer: '%s' \n", GroupNameBuffer
));
390 /* Loop through each group */
391 GroupName
= GroupNameBuffer
;
393 DbgPrint((DPRINT_REACTOS
, "Driver group: '%s'\n", GroupName
));
395 /* Query the Order */
396 BufferSize
= sizeof(OrderList
);
397 rc
= RegQueryValue(hOrderKey
, GroupName
, NULL
, (PUCHAR
)OrderList
, &BufferSize
);
398 if (rc
!= ERROR_SUCCESS
) OrderList
[0] = 0;
400 /* enumerate all drivers */
401 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
407 /* Get the Driver's Name */
408 ValueSize
= sizeof(ServiceName
);
409 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
410 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
412 /* Makre sure it's valid, and check if we're done */
413 if (rc
== ERROR_NO_MORE_ITEMS
) break;
414 if (rc
!= ERROR_SUCCESS
) return;
415 DbgPrint((DPRINT_REACTOS
, "Service %d: '%s'\n", (int)Index
, ServiceName
));
417 /* open driver Key */
418 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
420 /* Read the Start Value */
421 ValueSize
= sizeof(ULONG
);
422 rc
= RegQueryValue(hDriverKey
, "Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
423 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
426 ValueSize
= sizeof(ULONG
);
427 rc
= RegQueryValue(hDriverKey
, "Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
428 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
429 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
431 /* Read the driver's group */
432 DriverGroupSize
= 256;
433 rc
= RegQueryValue(hDriverKey
, "Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
434 DbgPrint((DPRINT_REACTOS
, " Group: '%s' \n", DriverGroup
));
436 /* Make sure it should be started */
437 if ((StartValue
== 0) &&
438 (TagValue
== OrderList
[TagIndex
]) &&
439 (stricmp(DriverGroup
, GroupName
) == 0)) {
441 /* Get the Driver's Location */
443 rc
= RegQueryValue(hDriverKey
, "ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
445 /* Write the whole path if it suceeded, else prepare to fail */
446 if (rc
!= ERROR_SUCCESS
) {
447 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
448 strcpy(ImagePath
, szSystemRoot
);
449 strcat(ImagePath
, "system32\\drivers\\");
450 strcat(ImagePath
, ServiceName
);
451 strcat(ImagePath
, ".sys");
452 } else if (TempImagePath
[0] != '\\') {
453 strcpy(ImagePath
, szSystemRoot
);
454 strcat(ImagePath
, TempImagePath
);
456 strcpy(ImagePath
, TempImagePath
);
457 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
460 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
462 /* Update the position if needed */
463 if (nPos
< 100) nPos
+= 5;
465 FrLdrLoadDriver(ImagePath
, nPos
);
469 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current Tag %d, current group '%s')\n",
470 ServiceName
, StartValue
, TagValue
, DriverGroup
, OrderList
[TagIndex
], GroupName
));
480 /* Get the Driver's Name */
481 ValueSize
= sizeof(ServiceName
);
482 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
484 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
485 if (rc
== ERROR_NO_MORE_ITEMS
) break;
486 if (rc
!= ERROR_SUCCESS
) return;
487 DbgPrint((DPRINT_REACTOS
, "Service %d: '%s'\n", (int)Index
, ServiceName
));
489 /* open driver Key */
490 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
492 /* Read the Start Value */
493 ValueSize
= sizeof(ULONG
);
494 rc
= RegQueryValue(hDriverKey
, "Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
495 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
498 ValueSize
= sizeof(ULONG
);
499 rc
= RegQueryValue(hDriverKey
, "Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
500 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
501 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
503 /* Read the driver's group */
504 DriverGroupSize
= 256;
505 rc
= RegQueryValue(hDriverKey
, "Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
506 DbgPrint((DPRINT_REACTOS
, " Group: '%s' \n", DriverGroup
));
508 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
509 if (TagValue
== OrderList
[TagIndex
]) break;
512 if ((StartValue
== 0) &&
513 (TagIndex
> OrderList
[0]) &&
514 (stricmp(DriverGroup
, GroupName
) == 0)) {
517 rc
= RegQueryValue(hDriverKey
, "ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
518 if (rc
!= ERROR_SUCCESS
) {
519 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
520 strcpy(ImagePath
, szSystemRoot
);
521 strcat(ImagePath
, "system32\\drivers\\");
522 strcat(ImagePath
, ServiceName
);
523 strcat(ImagePath
, ".sys");
524 } else if (TempImagePath
[0] != '\\') {
525 strcpy(ImagePath
, szSystemRoot
);
526 strcat(ImagePath
, TempImagePath
);
528 strcpy(ImagePath
, TempImagePath
);
529 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
531 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
533 if (nPos
< 100) nPos
+= 5;
535 FrLdrLoadDriver(ImagePath
, nPos
);
539 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current group '%s')\n",
540 ServiceName
, StartValue
, TagValue
, DriverGroup
, GroupName
));
546 /* Move to the next group name */
547 GroupName
= GroupName
+ strlen(GroupName
) + 1;
552 LoadAndBootReactOS(PCHAR OperatingSystemName
)
557 CHAR SystemPath
[1024];
558 CHAR szKernelName
[1024];
559 CHAR szHalName
[1024];
560 CHAR szFileName
[1024];
561 CHAR szBootPath
[256];
569 extern ULONG PageDirectoryStart
;
570 extern ULONG PageDirectoryEnd
;
571 extern BOOLEAN AcpiPresent
;
574 // Open the operating system section
575 // specified in the .ini file
577 if (!IniOpenSection(OperatingSystemName
, &SectionId
))
579 sprintf(MsgBuffer
,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName
);
580 UiMessageBox(MsgBuffer
);
585 * Setup multiboot information structure
587 LoaderBlock
.Flags
= MB_INFO_FLAG_MEM_SIZE
| MB_INFO_FLAG_BOOT_DEVICE
| MB_INFO_FLAG_COMMAND_LINE
| MB_INFO_FLAG_MODULES
;
588 LoaderBlock
.PageDirectoryStart
= (ULONG
)&PageDirectoryStart
;
589 LoaderBlock
.PageDirectoryEnd
= (ULONG
)&PageDirectoryEnd
;
590 LoaderBlock
.BootDevice
= 0xffffffff;
591 LoaderBlock
.CommandLine
= (unsigned long)multiboot_kernel_cmdline
;
592 LoaderBlock
.ModsCount
= 0;
593 LoaderBlock
.ModsAddr
= (unsigned long)multiboot_modules
;
594 LoaderBlock
.MmapLength
= (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP
)(PVOID
)&multiboot_memory_map
, 32) * sizeof(memory_map_t
);
595 if (LoaderBlock
.MmapLength
)
597 LoaderBlock
.MmapAddr
= (unsigned long)&multiboot_memory_map
;
598 LoaderBlock
.Flags
|= MB_INFO_FLAG_MEM_SIZE
| MB_INFO_FLAG_MEMORY_MAP
;
599 multiboot_memory_map_descriptor_size
= sizeof(memory_map_t
); // GetBiosMemoryMap uses a fixed value of 24
600 DbgPrint((DPRINT_REACTOS
, "memory map length: %d\n", LoaderBlock
.MmapLength
));
601 DbgPrint((DPRINT_REACTOS
, "dumping memory map:\n"));
602 for (i
=0; i
<(LoaderBlock
.MmapLength
/sizeof(memory_map_t
)); i
++)
604 if (MEMTYPE_USABLE
== multiboot_memory_map
[i
].type
&&
605 0 == multiboot_memory_map
[i
].base_addr_low
)
607 LoaderBlock
.MemLower
= (multiboot_memory_map
[i
].base_addr_low
+ multiboot_memory_map
[i
].length_low
) / 1024;
608 if (640 < LoaderBlock
.MemLower
)
610 LoaderBlock
.MemLower
= 640;
613 if (MEMTYPE_USABLE
== multiboot_memory_map
[i
].type
&&
614 multiboot_memory_map
[i
].base_addr_low
<= 1024 * 1024 &&
615 1024 * 1024 <= multiboot_memory_map
[i
].base_addr_low
+ multiboot_memory_map
[i
].length_low
)
617 LoaderBlock
.MemHigher
= (multiboot_memory_map
[i
].base_addr_low
+ multiboot_memory_map
[i
].length_low
) / 1024 - 1024;
619 DbgPrint((DPRINT_REACTOS
, "start: %x\t size: %x\t type %d\n",
620 multiboot_memory_map
[i
].base_addr_low
,
621 multiboot_memory_map
[i
].length_low
,
622 multiboot_memory_map
[i
].type
));
625 DbgPrint((DPRINT_REACTOS
, "low_mem = %d\n", LoaderBlock
.MemLower
));
626 DbgPrint((DPRINT_REACTOS
, "high_mem = %d\n", LoaderBlock
.MemHigher
));
629 * Initialize the registry
631 RegInitializeRegistry();
634 * Make sure the system path is set in the .ini file
636 if (!IniReadSettingByName(SectionId
, "SystemPath", SystemPath
, sizeof(SystemPath
)))
638 UiMessageBox("System path not specified for selected operating system.");
643 * Special case for Live CD.
645 if (!stricmp(SystemPath
, "LiveCD"))
648 MachDiskGetBootPath(SystemPath
, sizeof(SystemPath
));
649 strcat(SystemPath
, "\\reactos");
650 strcat(strcpy(multiboot_kernel_cmdline
, SystemPath
),
655 /* copy system path into kernel command line */
656 strcpy(multiboot_kernel_cmdline
, SystemPath
);
660 * Read the optional kernel parameters (if any)
662 if (IniReadSettingByName(SectionId
, "Options", value
, 1024))
664 strcat(multiboot_kernel_cmdline
, " ");
665 strcat(multiboot_kernel_cmdline
, value
);
670 UiDrawStatusText("Detecting Hardware...");
677 if (AcpiPresent
) LoaderBlock
.Flags
|= MB_INFO_FLAG_ACPI_TABLE
;
679 UiDrawStatusText("Loading...");
680 UiDrawProgressBarCenter(0, 100, "Loading ReactOS...");
683 * Try to open system drive
685 if (!FsOpenSystemVolume(SystemPath
, szBootPath
, &LoaderBlock
.BootDevice
))
687 UiMessageBox("Failed to open boot drive.");
691 /* append a backslash */
692 if ((strlen(szBootPath
)==0) ||
693 szBootPath
[strlen(szBootPath
)] != '\\')
694 strcat(szBootPath
, "\\");
696 DbgPrint((DPRINT_REACTOS
,"SystemRoot: '%s'\n", szBootPath
));
699 * Find the kernel image name
700 * and try to load the kernel off the disk
702 if(IniReadSettingByName(SectionId
, "Kernel", value
, 1024))
707 if (value
[0] == '\\')
709 strcpy(szKernelName
, value
);
713 strcpy(szKernelName
, szBootPath
);
714 strcat(szKernelName
, "SYSTEM32\\");
715 strcat(szKernelName
, value
);
720 strcpy(value
, "NTOSKRNL.EXE");
721 strcpy(szKernelName
, szBootPath
);
722 strcat(szKernelName
, "SYSTEM32\\");
723 strcat(szKernelName
, value
);
726 if (!FrLdrLoadKernel(szKernelName
, 5)) return;
729 * Find the HAL image name
730 * and try to load the kernel off the disk
732 if(IniReadSettingByName(SectionId
, "Hal", value
, 1024))
737 if (value
[0] == '\\')
739 strcpy(szHalName
, value
);
743 strcpy(szHalName
, szBootPath
);
744 strcat(szHalName
, "SYSTEM32\\");
745 strcat(szHalName
, value
);
750 strcpy(value
, "HAL.DLL");
751 strcpy(szHalName
, szBootPath
);
752 strcat(szHalName
, "SYSTEM32\\");
753 strcat(szHalName
, value
);
756 if (!FrLdrLoadDriver(szHalName
, 10))
761 strcpy(value
, "INBV.DLL");
762 strcpy(szHalName
, szBootPath
);
763 strcat(szHalName
, "SYSTEM32\\");
764 strcat(szHalName
, value
);
766 if (!FrLdrLoadDriver(szHalName
, 10))
770 * Load the System hive from disk
772 strcpy(szFileName
, szBootPath
);
773 strcat(szFileName
, "SYSTEM32\\CONFIG\\SYSTEM");
775 DbgPrint((DPRINT_REACTOS
, "SystemHive: '%s'", szFileName
));
777 FilePointer
= FsOpenFile(szFileName
);
778 if (FilePointer
== NULL
)
780 UiMessageBox("Could not find the System hive!");
785 * Update the status bar with the current file
787 strcpy(name
, "Reading ");
789 while (strlen(name
) < 80)
791 UiDrawStatusText(name
);
794 * Load the System hive
796 Base
= FrLdrLoadModule(FilePointer
, szFileName
, &Size
);
797 if (Base
== 0 || Size
== 0)
799 UiMessageBox("Could not load the System hive!\n");
802 DbgPrint((DPRINT_REACTOS
, "SystemHive loaded at 0x%x size %u", (unsigned)Base
, (unsigned)Size
));
805 * Import the loaded system hive
807 RegImportBinaryHive((PCHAR
)Base
, Size
);
810 * Initialize the 'CurrentControlSet' link
812 RegInitCurrentControlSet(FALSE
);
814 UiDrawProgressBarCenter(15, 100, "Loading ReactOS...");
817 * Export the hardware hive
819 Base
= FrLdrCreateModule ("HARDWARE");
820 RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", (PCHAR
)Base
, &Size
);
821 FrLdrCloseModule (Base
, Size
);
823 UiDrawProgressBarCenter(20, 100, "Loading ReactOS...");
828 if (!FrLdrLoadNlsFiles(szBootPath
, MsgBuffer
))
830 UiMessageBox(MsgBuffer
);
833 UiDrawProgressBarCenter(30, 100, "Loading ReactOS...");
836 * Load kernel symbols
838 LoadKernelSymbols(szKernelName
, 30);
839 UiDrawProgressBarCenter(40, 100, "Loading ReactOS...");
844 FrLdrLoadBootDrivers(szBootPath
, 40);
845 UiUnInitialize("Booting ReactOS...");
848 * Now boot the kernel
850 DiskStopFloppyMotor();
851 MachVideoPrepareForReactOS();
852 FrLdrStartup(0x2badb002);
857 DbgPrint(char *Fmt
, ...)