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 ROS_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
33 ARC_DISK_SIGNATURE reactos_arc_disk_info
[32]; // ARC Disk Information
34 char reactos_arc_strings
[32][256];
35 unsigned long reactos_disk_count
= 0;
38 static CHAR szLoadingMsg
[] = "Loading ReactOS...";
39 BOOLEAN FrLdrBootType
;
40 extern ULONG_PTR KernelBase
, KernelEntry
;
44 FrLdrLoadImage(IN PCHAR szFileName
,
50 CHAR szBuffer
[256], szFullPath
[256];
53 /* Check if this the HAL being loaded */
54 if (!_stricmp(szFileName
, "hal.dll"))
56 /* Use the boot.ini name instead */
57 szFileName
= szHalName
;
60 /* Extract filename without path */
61 szShortName
= strrchr(szFileName
, '\\');
64 /* No path, leave it alone */
65 szShortName
= szFileName
;
67 /* Which means we need to build a path now */
68 strcpy(szBuffer
, szFileName
);
69 strcpy(szFullPath
, szBootPath
);
72 strcat(szFullPath
, "SYSTEM32\\DRIVERS\\");
76 strcat(szFullPath
, "\\");
78 strcat(szFullPath
, szBuffer
);
79 szFileName
= szFullPath
;
84 szShortName
= szShortName
+ 1;
88 FilePointer
= FsOpenFile(szFileName
);
91 /* Return failure on the short name */
92 strcpy(szBuffer
, szShortName
);
93 strcat(szBuffer
, " not found.");
94 UiMessageBox(szBuffer
);
98 /* Update the status bar with the current file */
99 strcpy(szBuffer
, "Reading ");
100 strcat(szBuffer
, szShortName
);
101 UiDrawStatusText(szBuffer
);
103 /* Do the actual loading */
104 LoadBase
= FrLdrMapImage(FilePointer
, szShortName
, ImageType
);
106 /* Update Processbar and return success */
107 if (!FrLdrBootType
) UiDrawProgressBarCenter(nPos
, 100, szLoadingMsg
);
112 FrLdrLoadNlsFile(PCSTR szFileName
,
119 /* Open the Driver */
120 FilePointer
= FsOpenFile(szFileName
);
122 /* Make sure we did */
123 if (FilePointer
== NULL
) {
125 /* Fail if file wasn't opened */
126 strcpy(value
, szFileName
);
127 strcat(value
, " not found.");
132 /* Update the status bar with the current file */
133 strcpy(value
, "Reading ");
134 p
= strrchr(szFileName
, '\\');
137 strcat(value
, szFileName
);
141 strcat(value
, p
+ 1);
143 UiDrawStatusText(value
);
145 /* Load the driver */
146 FrLdrLoadModule(FilePointer
, szModuleName
, NULL
);
151 FrLdrLoadNlsFiles(PCHAR szSystemRoot
,
154 LONG rc
= ERROR_SUCCESS
;
156 WCHAR szIdBuffer
[80];
157 WCHAR szNameBuffer
[80];
158 CHAR szFileName
[256];
161 /* open the codepage key */
162 rc
= RegOpenKey(NULL
,
163 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
165 if (rc
!= ERROR_SUCCESS
) {
167 strcpy(szErrorOut
, "Couldn't open CodePage registry key");
171 /* get ANSI codepage */
172 BufferSize
= sizeof(szIdBuffer
);
173 rc
= RegQueryValue(hKey
, L
"ACP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
174 if (rc
!= ERROR_SUCCESS
) {
176 strcpy(szErrorOut
, "Couldn't get ACP NLS setting");
180 BufferSize
= sizeof(szNameBuffer
);
181 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
182 if (rc
!= ERROR_SUCCESS
) {
184 strcpy(szErrorOut
, "ACP NLS Setting exists, but isn't readable");
188 /* load ANSI codepage table */
189 sprintf(szFileName
,"%ssystem32\\%S", szSystemRoot
, szNameBuffer
);
190 DbgPrint((DPRINT_REACTOS
, "ANSI file: %s\n", szFileName
));
191 if (!FrLdrLoadNlsFile(szFileName
, "ansi.nls")) {
193 strcpy(szErrorOut
, "Couldn't load ansi.nls");
197 /* get OEM codepage */
198 BufferSize
= sizeof(szIdBuffer
);
199 rc
= RegQueryValue(hKey
, L
"OEMCP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
200 if (rc
!= ERROR_SUCCESS
) {
202 strcpy(szErrorOut
, "Couldn't get OEMCP NLS setting");
206 BufferSize
= sizeof(szNameBuffer
);
207 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
208 if (rc
!= ERROR_SUCCESS
) {
210 strcpy(szErrorOut
, "OEMCP NLS setting exists, but isn't readable");
214 /* load OEM codepage table */
215 sprintf(szFileName
, "%ssystem32\\%S", szSystemRoot
, szNameBuffer
);
216 DbgPrint((DPRINT_REACTOS
, "Oem file: %s\n", szFileName
));
217 if (!FrLdrLoadNlsFile(szFileName
, "oem.nls")) {
219 strcpy(szErrorOut
, "Couldn't load oem.nls");
223 /* open the language key */
224 rc
= RegOpenKey(NULL
,
225 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
227 if (rc
!= ERROR_SUCCESS
) {
229 strcpy(szErrorOut
, "Couldn't open Language registry key");
233 /* get the Unicode case table */
234 BufferSize
= sizeof(szIdBuffer
);
235 rc
= RegQueryValue(hKey
, L
"Default", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
236 if (rc
!= ERROR_SUCCESS
) {
238 strcpy(szErrorOut
, "Couldn't get Language Default setting");
242 BufferSize
= sizeof(szNameBuffer
);
243 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
244 if (rc
!= ERROR_SUCCESS
) {
246 strcpy(szErrorOut
, "Language Default setting exists, but isn't readable");
250 /* load Unicode case table */
251 sprintf(szFileName
, "%ssystem32\\%S", szSystemRoot
, szNameBuffer
);
252 DbgPrint((DPRINT_REACTOS
, "Casemap file: %s\n", szFileName
));
253 if (!FrLdrLoadNlsFile(szFileName
, "casemap.nls")) {
255 strcpy(szErrorOut
, "casemap.nls");
263 FrLdrLoadBootDrivers(PCHAR szSystemRoot
,
267 FRLDRHKEY hGroupKey
, hOrderKey
, hServiceKey
, hDriverKey
;
268 WCHAR GroupNameBuffer
[512];
269 WCHAR ServiceName
[256];
270 ULONG OrderList
[128];
280 WCHAR DriverGroup
[256];
281 ULONG DriverGroupSize
;
284 WCHAR TempImagePath
[256];
286 /* get 'service group order' key */
287 rc
= RegOpenKey(NULL
,
288 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
290 if (rc
!= ERROR_SUCCESS
) {
292 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'ServiceGroupOrder' key (rc %d)\n", (int)rc
));
296 /* get 'group order list' key */
297 rc
= RegOpenKey(NULL
,
298 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
300 if (rc
!= ERROR_SUCCESS
) {
302 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'GroupOrderList' key (rc %d)\n", (int)rc
));
306 /* enumerate drivers */
307 rc
= RegOpenKey(NULL
,
308 L
"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
310 if (rc
!= ERROR_SUCCESS
) {
312 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'Services' key (rc %d)\n", (int)rc
));
316 /* Get the Name Group */
317 BufferSize
= sizeof(GroupNameBuffer
);
318 rc
= RegQueryValue(hGroupKey
, L
"List", NULL
, (PUCHAR
)GroupNameBuffer
, &BufferSize
);
319 DbgPrint((DPRINT_REACTOS
, "RegQueryValue(): rc %d\n", (int)rc
));
320 if (rc
!= ERROR_SUCCESS
) return;
321 DbgPrint((DPRINT_REACTOS
, "BufferSize: %d \n", (int)BufferSize
));
322 DbgPrint((DPRINT_REACTOS
, "GroupNameBuffer: '%S' \n", GroupNameBuffer
));
324 /* Loop through each group */
325 GroupName
= GroupNameBuffer
;
327 DbgPrint((DPRINT_REACTOS
, "Driver group: '%S'\n", GroupName
));
329 /* Query the Order */
330 BufferSize
= sizeof(OrderList
);
331 rc
= RegQueryValue(hOrderKey
, GroupName
, NULL
, (PUCHAR
)OrderList
, &BufferSize
);
332 if (rc
!= ERROR_SUCCESS
) OrderList
[0] = 0;
334 /* enumerate all drivers */
335 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
341 /* Get the Driver's Name */
342 ValueSize
= sizeof(ServiceName
);
343 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
344 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
346 /* Makre sure it's valid, and check if we're done */
347 if (rc
== ERROR_NO_MORE_ITEMS
) break;
348 if (rc
!= ERROR_SUCCESS
) return;
349 DbgPrint((DPRINT_REACTOS
, "Service %d: '%S'\n", (int)Index
, ServiceName
));
351 /* open driver Key */
352 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
353 if (rc
== ERROR_SUCCESS
)
355 /* Read the Start Value */
356 ValueSize
= sizeof(ULONG
);
357 rc
= RegQueryValue(hDriverKey
, L
"Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
358 if (rc
!= ERROR_SUCCESS
) StartValue
= (ULONG
)-1;
359 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
362 ValueSize
= sizeof(ULONG
);
363 rc
= RegQueryValue(hDriverKey
, L
"Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
364 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
365 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
367 /* Read the driver's group */
368 DriverGroupSize
= sizeof(DriverGroup
);
369 rc
= RegQueryValue(hDriverKey
, L
"Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
370 DbgPrint((DPRINT_REACTOS
, " Group: '%S' \n", DriverGroup
));
372 /* Make sure it should be started */
373 if ((StartValue
== 0) &&
374 (TagValue
== OrderList
[TagIndex
]) &&
375 (_wcsicmp(DriverGroup
, GroupName
) == 0)) {
377 /* Get the Driver's Location */
378 ValueSize
= sizeof(TempImagePath
);
379 rc
= RegQueryValue(hDriverKey
, L
"ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
381 /* Write the whole path if it suceeded, else prepare to fail */
382 if (rc
!= ERROR_SUCCESS
) {
383 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
384 sprintf(ImagePath
, "%s\\system32\\drivers\\%S.sys", szSystemRoot
, ServiceName
);
385 } else if (TempImagePath
[0] != L
'\\') {
386 sprintf(ImagePath
, "%s%S", szSystemRoot
, TempImagePath
);
388 sprintf(ImagePath
, "%S", TempImagePath
);
389 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
392 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
394 /* Update the position if needed */
395 if (nPos
< 100) nPos
+= 5;
397 FrLdrLoadImage(ImagePath
, nPos
, 2);
401 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current Tag %d, current group '%S')\n",
402 ServiceName
, StartValue
, TagValue
, DriverGroup
, OrderList
[TagIndex
], GroupName
));
413 /* Get the Driver's Name */
414 ValueSize
= sizeof(ServiceName
);
415 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
417 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
418 if (rc
== ERROR_NO_MORE_ITEMS
) break;
419 if (rc
!= ERROR_SUCCESS
) return;
420 DbgPrint((DPRINT_REACTOS
, "Service %d: '%S'\n", (int)Index
, ServiceName
));
422 /* open driver Key */
423 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
424 if (rc
== ERROR_SUCCESS
)
426 /* Read the Start Value */
427 ValueSize
= sizeof(ULONG
);
428 rc
= RegQueryValue(hDriverKey
, L
"Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
429 if (rc
!= ERROR_SUCCESS
) StartValue
= (ULONG
)-1;
430 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
433 ValueSize
= sizeof(ULONG
);
434 rc
= RegQueryValue(hDriverKey
, L
"Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
435 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
436 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
438 /* Read the driver's group */
439 DriverGroupSize
= sizeof(DriverGroup
);
440 rc
= RegQueryValue(hDriverKey
, L
"Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
441 DbgPrint((DPRINT_REACTOS
, " Group: '%S' \n", DriverGroup
));
443 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
444 if (TagValue
== OrderList
[TagIndex
]) break;
447 if ((StartValue
== 0) &&
448 (TagIndex
> OrderList
[0]) &&
449 (_wcsicmp(DriverGroup
, GroupName
) == 0)) {
451 ValueSize
= sizeof(TempImagePath
);
452 rc
= RegQueryValue(hDriverKey
, L
"ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
453 if (rc
!= ERROR_SUCCESS
) {
454 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
455 sprintf(ImagePath
, "%ssystem32\\drivers\\%S.sys", szSystemRoot
, ServiceName
);
456 } else if (TempImagePath
[0] != L
'\\') {
457 sprintf(ImagePath
, "%s%S", szSystemRoot
, TempImagePath
);
459 sprintf(ImagePath
, "%S", TempImagePath
);
460 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
462 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
464 if (nPos
< 100) nPos
+= 5;
466 FrLdrLoadImage(ImagePath
, nPos
, 2);
470 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current group '%S')\n",
471 ServiceName
, StartValue
, TagValue
, DriverGroup
, GroupName
));
478 /* Move to the next group name */
479 GroupName
= GroupName
+ wcslen(GroupName
) + 1;
484 LoadAndBootReactOS(PCSTR OperatingSystemName
)
489 CHAR SystemPath
[255];
490 CHAR szKernelName
[255];
491 CHAR szFileName
[255];
494 PIMAGE_NT_HEADERS NtHeader
;
500 extern BOOLEAN AcpiPresent
;
503 // Open the operating system section
504 // specified in the .ini file
506 if (!IniOpenSection(OperatingSystemName
, &SectionId
))
508 sprintf(MsgBuffer
,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName
);
509 UiMessageBox(MsgBuffer
);
514 UiDrawStatusText("Detecting Hardware...");
515 UiDrawProgressBarCenter(1, 100, szLoadingMsg
);
518 * Setup multiboot information structure
520 LoaderBlock
.CommandLine
= reactos_kernel_cmdline
;
521 LoaderBlock
.ModsCount
= 0;
522 LoaderBlock
.ModsAddr
= reactos_modules
;
523 LoaderBlock
.DrivesAddr
= reactos_arc_disk_info
;
524 LoaderBlock
.MmapLength
= (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP
)(PVOID
)&reactos_memory_map
, 32) * sizeof(memory_map_t
);
525 if (LoaderBlock
.MmapLength
)
529 LoaderBlock
.MmapAddr
= (unsigned long)&reactos_memory_map
;
530 reactos_memory_map_descriptor_size
= sizeof(memory_map_t
); // GetBiosMemoryMap uses a fixed value of 24
531 for (i
=0; i
<(LoaderBlock
.MmapLength
/sizeof(memory_map_t
)); i
++)
533 if (BiosMemoryUsable
== reactos_memory_map
[i
].type
&&
534 0 == reactos_memory_map
[i
].base_addr_low
)
536 LoaderBlock
.MemLower
= (reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
) / 1024;
537 if (640 < LoaderBlock
.MemLower
)
539 LoaderBlock
.MemLower
= 640;
542 if (BiosMemoryUsable
== reactos_memory_map
[i
].type
&&
543 reactos_memory_map
[i
].base_addr_low
<= 1024 * 1024 &&
544 1024 * 1024 <= reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
)
546 LoaderBlock
.MemHigher
= (reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
) / 1024 - 1024;
552 * Initialize the registry
554 RegInitializeRegistry();
557 * Make sure the system path is set in the .ini file
559 if (!IniReadSettingByName(SectionId
, "SystemPath", SystemPath
, sizeof(SystemPath
)))
561 UiMessageBox("System path not specified for selected operating system.");
566 * Special case for Live CD.
568 if (!_stricmp(SystemPath
, "LiveCD"))
571 MachDiskGetBootPath(SystemPath
, sizeof(SystemPath
));
572 strcat(SystemPath
, "\\reactos");
573 strcat(strcpy(reactos_kernel_cmdline
, SystemPath
),
578 if (! MachDiskNormalizeSystemPath(SystemPath
,
581 UiMessageBox("Invalid system path");
584 /* copy system path into kernel command line */
585 strcpy(reactos_kernel_cmdline
, SystemPath
);
589 * Read the optional kernel parameters (if any)
591 if (IniReadSettingByName(SectionId
, "Options", value
, sizeof(value
)))
593 strcat(reactos_kernel_cmdline
, " ");
594 strcat(reactos_kernel_cmdline
, value
);
601 UiDrawProgressBarCenter(5, 100, szLoadingMsg
);
603 if (AcpiPresent
) LoaderBlock
.Flags
|= MB_FLAGS_ACPI_TABLE
;
604 LoaderBlock
.DrivesCount
= reactos_disk_count
;
606 UiDrawStatusText("Loading...");
609 * Try to open system drive
611 if (!FsOpenSystemVolume(SystemPath
, szBootPath
, &LoaderBlock
.BootDevice
))
613 UiMessageBox("Failed to open boot drive.");
617 /* append a backslash */
618 if ((strlen(szBootPath
)==0) ||
619 szBootPath
[strlen(szBootPath
)] != '\\')
620 strcat(szBootPath
, "\\");
622 DbgPrint((DPRINT_REACTOS
,"SystemRoot: '%s'\n", szBootPath
));
625 * Find the kernel image name
626 * and try to load the kernel off the disk
628 if(IniReadSettingByName(SectionId
, "Kernel", value
, sizeof(value
)))
633 if (value
[0] == '\\')
635 strcpy(szKernelName
, value
);
639 strcpy(szKernelName
, szBootPath
);
640 strcat(szKernelName
, "SYSTEM32\\");
641 strcat(szKernelName
, value
);
646 strcpy(value
, "NTOSKRNL.EXE");
647 strcpy(szKernelName
, szBootPath
);
648 strcat(szKernelName
, "SYSTEM32\\");
649 strcat(szKernelName
, value
);
653 * Find the HAL image name
654 * and try to load the kernel off the disk
656 if(IniReadSettingByName(SectionId
, "Hal", value
, sizeof(value
)))
661 if (value
[0] == '\\')
663 strcpy(szHalName
, value
);
667 strcpy(szHalName
, szBootPath
);
668 strcat(szHalName
, "SYSTEM32\\");
669 strcat(szHalName
, value
);
674 strcpy(value
, "HAL.DLL");
675 strcpy(szHalName
, szBootPath
);
676 strcat(szHalName
, "SYSTEM32\\");
677 strcat(szHalName
, value
);
680 /* Load the kernel */
681 LoadBase
= FrLdrLoadImage(szKernelName
, 5, 1);
682 if (!LoadBase
) return;
684 /* Get the NT header, kernel base and kernel entry */
685 NtHeader
= RtlImageNtHeader(LoadBase
);
686 KernelBase
= NtHeader
->OptionalHeader
.ImageBase
;
687 KernelEntry
= RaToPa(NtHeader
->OptionalHeader
.AddressOfEntryPoint
);
688 LoaderBlock
.KernelBase
= KernelBase
;
691 * Load the System hive from disk
693 strcpy(szFileName
, szBootPath
);
694 strcat(szFileName
, "SYSTEM32\\CONFIG\\SYSTEM");
696 DbgPrint((DPRINT_REACTOS
, "SystemHive: '%s'", szFileName
));
698 FilePointer
= FsOpenFile(szFileName
);
699 if (FilePointer
== NULL
)
701 UiMessageBox("Could not find the System hive!");
706 * Update the status bar with the current file
708 strcpy(name
, "Reading ");
710 while (strlen(name
) < 80)
712 UiDrawStatusText(name
);
715 * Load the System hive
717 Base
= FrLdrLoadModule(FilePointer
, szFileName
, &Size
);
718 if (Base
== 0 || Size
== 0)
720 UiMessageBox("Could not load the System hive!\n");
723 DbgPrint((DPRINT_REACTOS
, "SystemHive loaded at 0x%x size %u", (unsigned)Base
, (unsigned)Size
));
726 * Import the loaded system hive
728 RegImportBinaryHive((PCHAR
)Base
, Size
);
731 * Initialize the 'CurrentControlSet' link
733 RegInitCurrentControlSet(FALSE
);
735 UiDrawProgressBarCenter(15, 100, szLoadingMsg
);
738 * Export the hardware hive
740 Base
= FrLdrCreateModule ("HARDWARE");
741 RegExportBinaryHive (L
"\\Registry\\Machine\\HARDWARE", (PCHAR
)Base
, &Size
);
742 FrLdrCloseModule (Base
, Size
);
744 UiDrawProgressBarCenter(20, 100, szLoadingMsg
);
749 if (!FrLdrLoadNlsFiles(szBootPath
, MsgBuffer
))
751 UiMessageBox(MsgBuffer
);
754 UiDrawProgressBarCenter(30, 100, szLoadingMsg
);
759 FrLdrLoadBootDrivers(szBootPath
, 40);
760 //UiUnInitialize("Booting ReactOS...");
763 * Now boot the kernel
765 DiskStopFloppyMotor();
766 MachVideoPrepareForReactOS(FALSE
);
767 FrLdrStartup(0x2badb002);
772 DbgPrint(const char *Format
, ...)
778 va_start(ap
, Format
);
780 /* Construct a string */
781 Length
= _vsnprintf(Buffer
, 512, Format
, ap
);
783 /* Check if we went past the buffer */
786 /* Terminate it if we went over-board */
787 Buffer
[sizeof(Buffer
) - 1] = '\n';
790 Length
= sizeof(Buffer
);
793 /* Show it as a message box */
794 UiMessageBox(Buffer
);
796 /* Cleanup and exit */