6dd9a33c6fa791abc454e47f880f7ac25ff88224
[reactos.git] / freeldr / freeldr / reactos / reactos.c
1 /*
2 * FreeLoader
3 *
4 * Copyright (C) 1998-2003 Brian Palmer <brianp@sginet.com>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include <freeldr.h>
22 #include <debug.h>
23 #include <arch.h>
24 #include <reactos.h>
25 #include <rtl.h>
26 #include <disk.h>
27 #include <fs.h>
28 #include <ui.h>
29 #include <multiboot.h>
30 #include <mm.h>
31 #include <inifile.h>
32
33 #include "registry.h"
34
35
36 #define NDEBUG
37
38 #define IsRecognizedPartition(P) \
39 ((P) == PARTITION_FAT_12 || \
40 (P) == PARTITION_FAT_16 || \
41 (P) == PARTITION_HUGE || \
42 (P) == PARTITION_IFS || \
43 (P) == PARTITION_FAT32 || \
44 (P) == PARTITION_FAT32_XINT13 || \
45 (P) == PARTITION_XINT13)
46
47 static BOOL
48 LoadKernel(PCHAR szFileName, int nPos)
49 {
50 PFILE FilePointer;
51 PCHAR szShortName;
52 char szBuffer[256];
53
54 szShortName = strrchr(szFileName, '\\');
55 if (szShortName == NULL)
56 szShortName = szFileName;
57 else
58 szShortName = szShortName + 1;
59
60 FilePointer = FsOpenFile(szFileName);
61 if (FilePointer == NULL)
62 {
63 strcpy(szBuffer, szShortName);
64 strcat(szBuffer, " not found.");
65 UiMessageBox(szBuffer);
66 return(FALSE);
67 }
68
69 /*
70 * Update the status bar with the current file
71 */
72 strcpy(szBuffer, "Reading ");
73 strcat(szBuffer, szShortName);
74 UiDrawStatusText(szBuffer);
75
76 /*
77 * Load the kernel
78 */
79 MultiBootLoadKernel(FilePointer);
80
81 UiDrawProgressBarCenter(nPos, 100, "Loading ReactOS...");
82
83 return(TRUE);
84 }
85
86 static BOOL
87 LoadSymbolFile(PCHAR szSystemRoot,
88 PCHAR ModuleName,
89 int nPos)
90 {
91 CHAR SymbolFileName[1024];
92 PFILE FilePointer;
93 U32 Length;
94 PCHAR Start;
95 PCHAR Ext;
96 char value[256];
97 char *p;
98
99 /* Get the path to the symbol store */
100 strcpy(SymbolFileName, szSystemRoot);
101 strcat(SymbolFileName, "symbols\\");
102
103 /* Get the symbol filename from the module name */
104 Start = strrchr(ModuleName, '\\');
105 if (Start == NULL)
106 Start = ModuleName;
107 else
108 Start++;
109
110 Ext = strrchr(ModuleName, '.');
111 if (Ext != NULL)
112 Length = Ext - Start;
113 else
114 Length = strlen(Start);
115
116 strncat(SymbolFileName, Start, Length);
117 strcat(SymbolFileName, ".sym");
118
119 FilePointer = FsOpenFile((PCHAR)&SymbolFileName[0]);
120 if (FilePointer == NULL)
121 {
122 DbgPrint((DPRINT_REACTOS, "Symbol file %s not loaded.\n", SymbolFileName));
123 /* This is not critical */
124 return FALSE;
125 }
126
127 DbgPrint((DPRINT_REACTOS, "Symbol file %s is loaded.\n", SymbolFileName));
128
129 /*
130 * Update the status bar with the current file
131 */
132 strcpy(value, "Reading ");
133 p = strrchr(SymbolFileName, '\\');
134 if (p == NULL)
135 strcat(value, SymbolFileName);
136 else
137 strcat(value, p + 1);
138 UiDrawStatusText(value);
139
140 /*
141 * Load the symbol file
142 */
143 MultiBootLoadModule(FilePointer, SymbolFileName, NULL);
144
145 UiDrawProgressBarCenter(nPos, 100, "Loading ReactOS...");
146
147 return (TRUE);
148 }
149
150
151 static BOOL
152 LoadDriver(PCHAR szFileName, int nPos)
153 {
154 PFILE FilePointer;
155 char value[256];
156 char *p;
157
158 FilePointer = FsOpenFile(szFileName);
159 if (FilePointer == NULL)
160 {
161 strcpy(value, szFileName);
162 strcat(value, " not found.");
163 UiMessageBox(value);
164 return(FALSE);
165 }
166
167 /*
168 * Update the status bar with the current file
169 */
170 strcpy(value, "Reading ");
171 p = strrchr(szFileName, '\\');
172 if (p == NULL)
173 strcat(value, szFileName);
174 else
175 strcat(value, p + 1);
176 UiDrawStatusText(value);
177
178 /*
179 * Load the driver
180 */
181 MultiBootLoadModule(FilePointer, szFileName, NULL);
182
183 UiDrawProgressBarCenter(nPos, 100, "Loading ReactOS...");
184
185 return(TRUE);
186 }
187
188
189 static BOOL
190 LoadNlsFile(PCHAR szFileName, PCHAR szModuleName)
191 {
192 PFILE FilePointer;
193 char value[256];
194 char *p;
195
196 FilePointer = FsOpenFile(szFileName);
197 if (FilePointer == NULL)
198 {
199 strcpy(value, szFileName);
200 strcat(value, " not found.");
201 UiMessageBox(value);
202 return(FALSE);
203 }
204
205 /*
206 * Update the status bar with the current file
207 */
208 strcpy(value, "Reading ");
209 p = strrchr(szFileName, '\\');
210 if (p == NULL)
211 strcat(value, szFileName);
212 else
213 strcat(value, p + 1);
214 UiDrawStatusText(value);
215
216 /*
217 * Load the driver
218 */
219 MultiBootLoadModule(FilePointer, szModuleName, NULL);
220
221 return(TRUE);
222 }
223
224
225 static VOID
226 LoadBootDrivers(PCHAR szSystemRoot, int nPos)
227 {
228 S32 rc = 0;
229 HKEY hGroupKey, hServiceKey, hDriverKey;
230 char ValueBuffer[512];
231 char ServiceName[256];
232 U32 BufferSize;
233 U32 Index;
234 char *GroupName;
235
236 U32 ValueSize;
237 U32 ValueType;
238 U32 StartValue;
239 UCHAR DriverGroup[256];
240 U32 DriverGroupSize;
241
242 UCHAR ImagePath[256];
243 UCHAR TempImagePath[256];
244
245 /* get 'service group order' key */
246 rc = RegOpenKey(NULL,
247 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
248 &hGroupKey);
249 if (rc != ERROR_SUCCESS)
250 {
251 DbgPrint((DPRINT_REACTOS, "Failed to open the 'ServiceGroupOrder key (rc %d)\n", (int)rc));
252 return;
253 }
254
255 /* enumerate drivers */
256 rc = RegOpenKey(NULL,
257 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
258 &hServiceKey);
259 if (rc != ERROR_SUCCESS)
260 {
261 DbgPrint((DPRINT_REACTOS, "Failed to open the 'Services' key (rc %d)\n", (int)rc));
262 return;
263 }
264
265 BufferSize = sizeof(ValueBuffer);
266 rc = RegQueryValue(hGroupKey, "List", NULL, (PUCHAR)ValueBuffer, &BufferSize);
267 DbgPrint((DPRINT_REACTOS, "RegQueryValue(): rc %d\n", (int)rc));
268 if (rc != ERROR_SUCCESS)
269 return;
270
271 DbgPrint((DPRINT_REACTOS, "BufferSize: %d \n", (int)BufferSize));
272
273 DbgPrint((DPRINT_REACTOS, "ValueBuffer: '%s' \n", ValueBuffer));
274
275 GroupName = ValueBuffer;
276 while (*GroupName)
277 {
278 DbgPrint((DPRINT_REACTOS, "Driver group: '%s'\n", GroupName));
279
280 /* enumerate all drivers */
281 Index = 0;
282 while (TRUE)
283 {
284 ValueSize = sizeof(ValueBuffer);
285 rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize);
286 DbgPrint((DPRINT_REACTOS, "RegEnumKey(): rc %d\n", (int)rc));
287 if (rc == ERROR_NO_MORE_ITEMS)
288 break;
289 if (rc != ERROR_SUCCESS)
290 return;
291 DbgPrint((DPRINT_REACTOS, "Service %d: '%s'\n", (int)Index, ServiceName));
292
293 /* open driver Key */
294 rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
295
296 ValueSize = sizeof(U32);
297 rc = RegQueryValue(hDriverKey, "Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
298 DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
299
300 DriverGroupSize = 256;
301 rc = RegQueryValue(hDriverKey, "Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
302 DbgPrint((DPRINT_REACTOS, " Group: '%s' \n", DriverGroup));
303
304 if ((StartValue == 0) && (stricmp(DriverGroup, GroupName) == 0))
305 {
306 ValueSize = 256;
307 rc = RegQueryValue(hDriverKey,
308 "ImagePath",
309 NULL,
310 (PUCHAR)TempImagePath,
311 &ValueSize);
312 if (rc != ERROR_SUCCESS)
313 {
314 DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
315 strcpy(ImagePath, szSystemRoot);
316 strcat(ImagePath, "system32\\drivers\\");
317 strcat(ImagePath, ServiceName);
318 strcat(ImagePath, ".sys");
319 }
320 else if (TempImagePath[0] != '\\')
321 {
322 strcpy(ImagePath, szSystemRoot);
323 strcat(ImagePath, TempImagePath);
324 }
325 else
326 {
327 strcpy(ImagePath, TempImagePath);
328 DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
329 }
330 DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
331
332 if (nPos < 100)
333 nPos += 5;
334
335 LoadDriver(ImagePath, nPos);
336 LoadSymbolFile(szSystemRoot, ImagePath, nPos);
337 }
338 else
339 {
340 DbgPrint((DPRINT_REACTOS, " Skipping driver '%s' with Start %d and Group '%s' (Current group '%s')\n",
341 ImagePath, StartValue, DriverGroup, GroupName));
342 }
343 Index++;
344 }
345
346 GroupName = GroupName + strlen(GroupName) + 1;
347 }
348 }
349
350
351 static BOOL
352 LoadNlsFiles(PCHAR szSystemRoot, PCHAR szErrorOut)
353 {
354 S32 rc = ERROR_SUCCESS;
355 HKEY hKey;
356 char szIdBuffer[80];
357 char szNameBuffer[80];
358 char szFileName[256];
359 U32 BufferSize;
360
361 /* open the codepage key */
362 rc = RegOpenKey(NULL,
363 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
364 &hKey);
365 if (rc != ERROR_SUCCESS) {
366 strcpy(szErrorOut, "Couldn't open CodePage registry key");
367 return(FALSE);
368 }
369
370
371 /* get ANSI codepage */
372 BufferSize = 80;
373 rc = RegQueryValue(hKey, "ACP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
374 if (rc != ERROR_SUCCESS) {
375 strcpy(szErrorOut, "Couldn't get ACP NLS setting");
376 return(FALSE);
377 }
378
379 BufferSize = 80;
380 rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
381 if (rc != ERROR_SUCCESS) {
382 strcpy(szErrorOut, "ACP NLS Setting exists, but isn't readable");
383 return(FALSE);
384 }
385
386 /* load ANSI codepage table */
387 strcpy(szFileName, szSystemRoot);
388 strcat(szFileName, "system32\\");
389 strcat(szFileName, szNameBuffer);
390 DbgPrint((DPRINT_REACTOS, "ANSI file: %s\n", szFileName));
391 if (!LoadNlsFile(szFileName, "ansi.nls")) {
392 strcpy(szErrorOut, "Couldn't load ansi.nls");
393 return(FALSE);
394 }
395
396 /* get OEM codepage */
397 BufferSize = 80;
398 rc = RegQueryValue(hKey, "OEMCP", NULL, (PUCHAR)szIdBuffer, &BufferSize);
399 if (rc != ERROR_SUCCESS) {
400 strcpy(szErrorOut, "Couldn't get OEMCP NLS setting");
401 return(FALSE);
402 }
403
404 BufferSize = 80;
405 rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
406 if (rc != ERROR_SUCCESS) {
407 strcpy(szErrorOut, "OEMCP NLS setting exists, but isn't readable");
408 return(FALSE);
409 }
410
411 /* load OEM codepage table */
412 strcpy(szFileName, szSystemRoot);
413 strcat(szFileName, "system32\\");
414 strcat(szFileName, szNameBuffer);
415 DbgPrint((DPRINT_REACTOS, "Oem file: %s\n", szFileName));
416 if (!LoadNlsFile(szFileName, "oem.nls")) {
417 strcpy(szErrorOut, "Couldn't load oem.nls");
418 return(FALSE);
419 }
420
421 /* open the language key */
422 rc = RegOpenKey(NULL,
423 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
424 &hKey);
425 if (rc != ERROR_SUCCESS) {
426 strcpy(szErrorOut, "Couldn't open Language registry key");
427 return(FALSE);
428 }
429
430 /* get the Unicode case table */
431 BufferSize = 80;
432 rc = RegQueryValue(hKey, "Default", NULL, (PUCHAR)szIdBuffer, &BufferSize);
433 if (rc != ERROR_SUCCESS) {
434 strcpy(szErrorOut, "Couldn't get Language Default setting");
435 return(FALSE);
436 }
437
438 BufferSize = 80;
439 rc = RegQueryValue(hKey, szIdBuffer, NULL, (PUCHAR)szNameBuffer, &BufferSize);
440 if (rc != ERROR_SUCCESS) {
441 strcpy(szErrorOut,
442 "Language Default setting exists, but isn't readable");
443 return(FALSE);
444 }
445
446 /* load Unicode case table */
447 strcpy(szFileName, szSystemRoot);
448 strcat(szFileName, "system32\\");
449 strcat(szFileName, szNameBuffer);
450 DbgPrint((DPRINT_REACTOS, "Casemap file: %s\n", szFileName));
451 if (!LoadNlsFile(szFileName, "casemap.nls")) {
452 strcpy(szErrorOut, "casemap.nls");
453 return(FALSE);
454 }
455
456 return(TRUE);
457 }
458
459
460 void
461 LoadAndBootReactOS(PUCHAR OperatingSystemName)
462 {
463 PFILE FilePointer;
464 char name[1024];
465 char value[1024];
466 char szKernelName[1024];
467 char szHalName[1024];
468 char szFileName[1024];
469 char szBootPath[256];
470 int i;
471 // int nNumDriverFiles=0;
472 // int nNumFilesLoaded=0;
473 char MsgBuffer[256];
474 U32 SectionId;
475
476 char* Base;
477 U32 Size;
478
479 PARTITION_TABLE_ENTRY PartitionTableEntry;
480 U32 rosPartition;
481
482 //
483 // Open the operating system section
484 // specified in the .ini file
485 //
486 if (!IniOpenSection(OperatingSystemName, &SectionId))
487 {
488 sprintf(MsgBuffer,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName);
489 UiMessageBox(MsgBuffer);
490 return;
491 }
492
493 /*
494 * Setup multiboot information structure
495 */
496 mb_info.flags = MB_INFO_FLAG_MEM_SIZE | MB_INFO_FLAG_BOOT_DEVICE | MB_INFO_FLAG_COMMAND_LINE | MB_INFO_FLAG_MODULES;
497 mb_info.mem_lower = GetConventionalMemorySize();
498 mb_info.mem_upper = GetExtendedMemorySize();
499 mb_info.boot_device = 0xffffffff;
500 mb_info.cmdline = (unsigned long)multiboot_kernel_cmdline;
501 mb_info.mods_count = 0;
502 mb_info.mods_addr = (unsigned long)multiboot_modules;
503 mb_info.mmap_length = (unsigned long)GetBiosMemoryMap((PBIOS_MEMORY_MAP)&multiboot_memory_map, 32) * sizeof(memory_map_t);
504 if (mb_info.mmap_length)
505 {
506 mb_info.mmap_addr = (unsigned long)&multiboot_memory_map;
507 mb_info.flags |= MB_INFO_FLAG_MEMORY_MAP;
508 multiboot_memory_map_descriptor_size = sizeof(memory_map_t); // GetBiosMemoryMap uses a fixed value of 24
509 DbgPrint((DPRINT_REACTOS, "memory map length: %d\n", mb_info.mmap_length));
510 DbgPrint((DPRINT_REACTOS, "dumping memory map:\n"));
511 for (i=0; i<(mb_info.mmap_length/sizeof(memory_map_t)); i++)
512 {
513 DbgPrint((DPRINT_REACTOS, "start: %x\t size: %x\t type %d\n",
514 multiboot_memory_map[i].base_addr_low,
515 multiboot_memory_map[i].length_low,
516 multiboot_memory_map[i].type));
517 }
518 }
519 DbgPrint((DPRINT_REACTOS, "low_mem = %d\n", mb_info.mem_lower));
520 DbgPrint((DPRINT_REACTOS, "high_mem = %d\n", mb_info.mem_upper));
521
522 /*
523 * Initialize the registry
524 */
525 RegInitializeRegistry();
526
527 /*
528 * Make sure the system path is set in the .ini file
529 */
530 if (!IniReadSettingByName(SectionId, "SystemPath", value, 1024))
531 {
532 UiMessageBox("System path not specified for selected operating system.");
533 return;
534 }
535
536 /*
537 * Special case for Live CD.
538 */
539 if (!stricmp(value, "LiveCD"))
540 {
541 strcpy(szBootPath, "\\reactos");
542
543 /* Set kernel command line */
544 sprintf(multiboot_kernel_cmdline,
545 "multi(0)disk(0)cdrom(%u)\\reactos /MININT",
546 (unsigned int)BootDrive);
547 }
548 else
549 {
550 /*
551 * Verify system path
552 */
553 if (!DissectArcPath(value, szBootPath, &BootDrive, &BootPartition))
554 {
555 sprintf(MsgBuffer,"Invalid system path: '%s'", value);
556 UiMessageBox(MsgBuffer);
557 return;
558 }
559
560 /* recalculate the boot partition for freeldr */
561 i = 0;
562 rosPartition = 0;
563 while (1)
564 {
565 if (!DiskGetPartitionEntry(BootDrive, ++i, &PartitionTableEntry))
566 {
567 BootPartition = 0;
568 break;
569 }
570 if (IsRecognizedPartition(PartitionTableEntry.SystemIndicator))
571 {
572 if (++rosPartition == BootPartition)
573 {
574 BootPartition = i;
575 break;
576 }
577 }
578 }
579 if (BootPartition == 0)
580 {
581 sprintf(MsgBuffer,"Invalid system path: '%s'", value);
582 UiMessageBox(MsgBuffer);
583 return;
584 }
585
586 /* copy ARC path into kernel command line */
587 strcpy(multiboot_kernel_cmdline, value);
588 }
589
590 /* Set boot drive and partition */
591 ((char *)(&mb_info.boot_device))[0] = (char)BootDrive;
592 ((char *)(&mb_info.boot_device))[1] = (char)BootPartition;
593
594 /*
595 * Read the optional kernel parameters (if any)
596 */
597 if (IniReadSettingByName(SectionId, "Options", value, 1024))
598 {
599 strcat(multiboot_kernel_cmdline, " ");
600 strcat(multiboot_kernel_cmdline, value);
601 }
602
603 /* append a backslash */
604 if ((strlen(szBootPath)==0) ||
605 szBootPath[strlen(szBootPath)] != '\\')
606 strcat(szBootPath, "\\");
607
608 DbgPrint((DPRINT_REACTOS,"SystemRoot: '%s'\n", szBootPath));
609
610
611 UiDrawBackdrop();
612 UiDrawStatusText("Detecting Hardware...");
613
614 /*
615 * Detect hardware
616 */
617 DetectHardware();
618
619
620 UiDrawStatusText("Loading...");
621 UiDrawProgressBarCenter(0, 100, "Loading ReactOS...");
622
623 /*
624 * Try to open boot drive
625 */
626 if (!FsOpenVolume(BootDrive, BootPartition))
627 {
628 UiMessageBox("Failed to open boot drive.");
629 return;
630 }
631
632 /*
633 * Find the kernel image name
634 * and try to load the kernel off the disk
635 */
636 if(IniReadSettingByName(SectionId, "Kernel", value, 1024))
637 {
638 /*
639 * Set the name and
640 */
641 if (value[0] == '\\')
642 {
643 strcpy(szKernelName, value);
644 }
645 else
646 {
647 strcpy(szKernelName, szBootPath);
648 strcat(szKernelName, "SYSTEM32\\");
649 strcat(szKernelName, value);
650 }
651 }
652 else
653 {
654 strcpy(value, "NTOSKRNL.EXE");
655 strcpy(szKernelName, szBootPath);
656 strcat(szKernelName, "SYSTEM32\\");
657 strcat(szKernelName, value);
658 }
659
660 if (!LoadKernel(szKernelName, 5))
661 return;
662
663 /*
664 * Find the HAL image name
665 * and try to load the kernel off the disk
666 */
667 if(IniReadSettingByName(SectionId, "Hal", value, 1024))
668 {
669 /*
670 * Set the name and
671 */
672 if (value[0] == '\\')
673 {
674 strcpy(szHalName, value);
675 }
676 else
677 {
678 strcpy(szHalName, szBootPath);
679 strcat(szHalName, "SYSTEM32\\");
680 strcat(szHalName, value);
681 }
682 }
683 else
684 {
685 strcpy(value, "HAL.DLL");
686 strcpy(szHalName, szBootPath);
687 strcat(szHalName, "SYSTEM32\\");
688 strcat(szHalName, value);
689 }
690
691 if (!LoadDriver(szHalName, 10))
692 return;
693
694 /*
695 * Load the System hive from disk
696 */
697 strcpy(szFileName, szBootPath);
698 strcat(szFileName, "SYSTEM32\\CONFIG\\SYSTEM");
699
700 DbgPrint((DPRINT_REACTOS, "SystemHive: '%s'", szFileName));
701
702 FilePointer = FsOpenFile(szFileName);
703 if (FilePointer == NULL)
704 {
705 UiMessageBox("Could not find the System hive!");
706 return;
707 }
708
709 /*
710 * Update the status bar with the current file
711 */
712 strcpy(name, "Reading ");
713 strcat(name, value);
714 while (strlen(name) < 80)
715 strcat(name, " ");
716 UiDrawStatusText(name);
717
718 /*
719 * Load the System hive
720 */
721 Base = MultiBootLoadModule(FilePointer, szFileName, &Size);
722 if (Base == NULL || Size == 0)
723 {
724 UiMessageBox("Could not load the System hive!\n");
725 return;
726 }
727 DbgPrint((DPRINT_REACTOS, "SystemHive loaded at 0x%x size %u", (unsigned)Base, (unsigned)Size));
728
729 /*
730 * Import the loaded system hive
731 */
732 RegImportBinaryHive(Base, Size);
733
734 /*
735 * Initialize the 'CurrentControlSet' link
736 */
737 RegInitCurrentControlSet(FALSE);
738
739 UiDrawProgressBarCenter(15, 100, "Loading ReactOS...");
740
741 /*
742 * Export the hardware hive
743 */
744 Base = MultiBootCreateModule ("HARDWARE");
745 RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", Base, &Size);
746 MultiBootCloseModule (Base, Size);
747
748 UiDrawProgressBarCenter(20, 100, "Loading ReactOS...");
749
750 /*
751 * Load NLS files
752 */
753 if (!LoadNlsFiles(szBootPath, MsgBuffer))
754 {
755 UiMessageBox(MsgBuffer);
756 return;
757 }
758 UiDrawProgressBarCenter(25, 100, "Loading ReactOS...");
759
760 /*
761 * Load symbol files
762 */
763 LoadSymbolFile(szBootPath, szKernelName, 30);
764 LoadSymbolFile(szBootPath, szHalName, 30);
765
766 UiDrawProgressBarCenter(30, 100, "Loading ReactOS...");
767
768 /*
769 * Load boot drivers
770 */
771 LoadBootDrivers(szBootPath, 30);
772
773
774 #if 0
775 /*
776 * Clear the screen and redraw the backdrop and status bar
777 */
778 UiDrawBackdrop();
779 UiDrawStatusText("Press any key to boot");
780
781 /*
782 * Wait for user
783 */
784 strcpy(name, "Kernel and Drivers loaded.\nPress any key to boot ");
785 strcat(name, OperatingSystemName);
786 strcat(name, ".");
787 MessageBox(name);
788 #endif
789
790 UiUnInitialize("Booting ReactOS...");
791
792 /*
793 * Now boot the kernel
794 */
795 DiskStopFloppyMotor();
796 boot_reactos();
797 }
798
799 /* EOF */