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.
23 #include <reactos/rossym.h>
30 LOADER_PARAMETER_BLOCK LoaderBlock
;
31 char reactos_kernel_cmdline
[255]; // Command line passed to kernel
32 LOADER_MODULE reactos_modules
[64]; // Array to hold boot module info loaded for the kernel
33 char reactos_module_strings
[64][256]; // Array to hold module names
34 unsigned long reactos_memory_map_descriptor_size
;
35 memory_map_t reactos_memory_map
[32]; // Memory map
39 FrLdrLoadKernel(PCHAR szFileName
,
46 /* Extract Kernel filename without path */
47 szShortName
= strrchr(szFileName
, '\\');
48 if (szShortName
== NULL
) {
50 /* No path, leave it alone */
51 szShortName
= szFileName
;
56 szShortName
= szShortName
+ 1;
60 FilePointer
= FsOpenFile(szFileName
);
62 /* Make sure it worked */
63 if (FilePointer
== NULL
) {
65 /* Return failure on the short name */
66 strcpy(szBuffer
, szShortName
);
67 strcat(szBuffer
, " not found.");
68 UiMessageBox(szBuffer
);
72 /* Update the status bar with the current file */
73 strcpy(szBuffer
, "Reading ");
74 strcat(szBuffer
, szShortName
);
75 UiDrawStatusText(szBuffer
);
77 /* Do the actual loading */
78 FrLdrMapKernel(FilePointer
);
80 /* Update Processbar and return success */
81 UiDrawProgressBarCenter(nPos
, 100, "Loading ReactOS...");
86 FreeldrFreeMem(PVOID Area
)
92 FreeldrAllocMem(ULONG_PTR Size
)
94 return MmAllocateMemory((ULONG
) Size
);
98 FreeldrReadFile(PVOID FileContext
, PVOID Buffer
, ULONG Size
)
102 return FsReadFile((PFILE
) FileContext
, (ULONG
) Size
, &BytesRead
, Buffer
)
103 && Size
== BytesRead
;
107 FreeldrSeekFile(PVOID FileContext
, ULONG_PTR Position
)
109 FsSetFilePointer((PFILE
) FileContext
, (ULONG
) Position
);
114 LoadKernelSymbols(PCHAR szKernelName
, int nPos
)
116 static ROSSYM_CALLBACKS FreeldrCallbacks
=
124 PROSSYM_INFO RosSymInfo
;
128 RosSymInit(&FreeldrCallbacks
);
130 FilePointer
= FsOpenFile(szKernelName
);
131 if (FilePointer
== NULL
)
135 if (! RosSymCreateFromFile(FilePointer
, &RosSymInfo
))
139 Base
= FrLdrCreateModule("NTOSKRNL.SYM");
140 Size
= RosSymGetRawDataLength(RosSymInfo
);
141 RosSymGetRawData(RosSymInfo
, (PVOID
)Base
);
142 FrLdrCloseModule(Base
, Size
);
143 RosSymDelete(RosSymInfo
);
148 FrLdrLoadNlsFile(PCHAR szFileName
,
155 /* Open the Driver */
156 FilePointer
= FsOpenFile(szFileName
);
158 /* Make sure we did */
159 if (FilePointer
== NULL
) {
161 /* Fail if file wasn't opened */
162 strcpy(value
, szFileName
);
163 strcat(value
, " not found.");
168 /* Update the status bar with the current file */
169 strcpy(value
, "Reading ");
170 p
= strrchr(szFileName
, '\\');
173 strcat(value
, szFileName
);
177 strcat(value
, p
+ 1);
179 UiDrawStatusText(value
);
181 /* Load the driver */
182 FrLdrLoadModule(FilePointer
, szModuleName
, NULL
);
187 FrLdrLoadNlsFiles(PCHAR szSystemRoot
,
190 LONG rc
= ERROR_SUCCESS
;
193 CHAR szNameBuffer
[80];
194 CHAR szFileName
[256];
197 /* open the codepage key */
198 rc
= RegOpenKey(NULL
,
199 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\CodePage",
201 if (rc
!= ERROR_SUCCESS
) {
203 strcpy(szErrorOut
, "Couldn't open CodePage registry key");
207 /* get ANSI codepage */
209 rc
= RegQueryValue(hKey
, "ACP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
210 if (rc
!= ERROR_SUCCESS
) {
212 strcpy(szErrorOut
, "Couldn't get ACP NLS setting");
217 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
218 if (rc
!= ERROR_SUCCESS
) {
220 strcpy(szErrorOut
, "ACP NLS Setting exists, but isn't readable");
224 /* load ANSI codepage table */
225 strcpy(szFileName
, szSystemRoot
);
226 strcat(szFileName
, "system32\\");
227 strcat(szFileName
, szNameBuffer
);
228 DbgPrint((DPRINT_REACTOS
, "ANSI file: %s\n", szFileName
));
229 if (!FrLdrLoadNlsFile(szFileName
, "ansi.nls")) {
231 strcpy(szErrorOut
, "Couldn't load ansi.nls");
235 /* get OEM codepage */
237 rc
= RegQueryValue(hKey
, "OEMCP", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
238 if (rc
!= ERROR_SUCCESS
) {
240 strcpy(szErrorOut
, "Couldn't get OEMCP NLS setting");
245 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
246 if (rc
!= ERROR_SUCCESS
) {
248 strcpy(szErrorOut
, "OEMCP NLS setting exists, but isn't readable");
252 /* load OEM codepage table */
253 strcpy(szFileName
, szSystemRoot
);
254 strcat(szFileName
, "system32\\");
255 strcat(szFileName
, szNameBuffer
);
256 DbgPrint((DPRINT_REACTOS
, "Oem file: %s\n", szFileName
));
257 if (!FrLdrLoadNlsFile(szFileName
, "oem.nls")) {
259 strcpy(szErrorOut
, "Couldn't load oem.nls");
263 /* open the language key */
264 rc
= RegOpenKey(NULL
,
265 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\NLS\\Language",
267 if (rc
!= ERROR_SUCCESS
) {
269 strcpy(szErrorOut
, "Couldn't open Language registry key");
273 /* get the Unicode case table */
275 rc
= RegQueryValue(hKey
, "Default", NULL
, (PUCHAR
)szIdBuffer
, &BufferSize
);
276 if (rc
!= ERROR_SUCCESS
) {
278 strcpy(szErrorOut
, "Couldn't get Language Default setting");
283 rc
= RegQueryValue(hKey
, szIdBuffer
, NULL
, (PUCHAR
)szNameBuffer
, &BufferSize
);
284 if (rc
!= ERROR_SUCCESS
) {
286 strcpy(szErrorOut
, "Language Default setting exists, but isn't readable");
290 /* load Unicode case table */
291 strcpy(szFileName
, szSystemRoot
);
292 strcat(szFileName
, "system32\\");
293 strcat(szFileName
, szNameBuffer
);
294 DbgPrint((DPRINT_REACTOS
, "Casemap file: %s\n", szFileName
));
295 if (!FrLdrLoadNlsFile(szFileName
, "casemap.nls")) {
297 strcpy(szErrorOut
, "casemap.nls");
305 FrLdrLoadDriver(PCHAR szFileName
,
312 /* Open the Driver */
313 FilePointer
= FsOpenFile(szFileName
);
315 /* Make sure we did */
316 if (FilePointer
== NULL
) {
318 /* Fail if file wasn't opened */
319 strcpy(value
, szFileName
);
320 strcat(value
, " not found.");
325 /* Update the status bar with the current file */
326 strcpy(value
, "Reading ");
327 p
= strrchr(szFileName
, '\\');
330 strcat(value
, szFileName
);
334 strcat(value
, p
+ 1);
337 UiDrawStatusText(value
);
339 /* Load the driver */
340 FrLdrLoadModule(FilePointer
, szFileName
, NULL
);
342 /* Update status and return */
343 UiDrawProgressBarCenter(nPos
, 100, "Loading ReactOS...");
348 FrLdrLoadBootDrivers(PCHAR szSystemRoot
,
352 FRLDRHKEY hGroupKey
, hOrderKey
, hServiceKey
, hDriverKey
;
353 CHAR GroupNameBuffer
[512];
354 CHAR ServiceName
[256];
355 ULONG OrderList
[128];
365 CHAR DriverGroup
[256];
366 ULONG DriverGroupSize
;
369 CHAR TempImagePath
[256];
371 /* get 'service group order' key */
372 rc
= RegOpenKey(NULL
,
373 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\ServiceGroupOrder",
375 if (rc
!= ERROR_SUCCESS
) {
377 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'ServiceGroupOrder' key (rc %d)\n", (int)rc
));
381 /* get 'group order list' key */
382 rc
= RegOpenKey(NULL
,
383 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\GroupOrderList",
385 if (rc
!= ERROR_SUCCESS
) {
387 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'GroupOrderList' key (rc %d)\n", (int)rc
));
391 /* enumerate drivers */
392 rc
= RegOpenKey(NULL
,
393 "\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Services",
395 if (rc
!= ERROR_SUCCESS
) {
397 DbgPrint((DPRINT_REACTOS
, "Failed to open the 'Services' key (rc %d)\n", (int)rc
));
401 /* Get the Name Group */
402 BufferSize
= sizeof(GroupNameBuffer
);
403 rc
= RegQueryValue(hGroupKey
, "List", NULL
, (PUCHAR
)GroupNameBuffer
, &BufferSize
);
404 DbgPrint((DPRINT_REACTOS
, "RegQueryValue(): rc %d\n", (int)rc
));
405 if (rc
!= ERROR_SUCCESS
) return;
406 DbgPrint((DPRINT_REACTOS
, "BufferSize: %d \n", (int)BufferSize
));
407 DbgPrint((DPRINT_REACTOS
, "GroupNameBuffer: '%s' \n", GroupNameBuffer
));
409 /* Loop through each group */
410 GroupName
= GroupNameBuffer
;
412 DbgPrint((DPRINT_REACTOS
, "Driver group: '%s'\n", GroupName
));
414 /* Query the Order */
415 BufferSize
= sizeof(OrderList
);
416 rc
= RegQueryValue(hOrderKey
, GroupName
, NULL
, (PUCHAR
)OrderList
, &BufferSize
);
417 if (rc
!= ERROR_SUCCESS
) OrderList
[0] = 0;
419 /* enumerate all drivers */
420 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
426 /* Get the Driver's Name */
427 ValueSize
= sizeof(ServiceName
);
428 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
429 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
431 /* Makre sure it's valid, and check if we're done */
432 if (rc
== ERROR_NO_MORE_ITEMS
) break;
433 if (rc
!= ERROR_SUCCESS
) return;
434 DbgPrint((DPRINT_REACTOS
, "Service %d: '%s'\n", (int)Index
, ServiceName
));
436 /* open driver Key */
437 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
439 /* Read the Start Value */
440 ValueSize
= sizeof(ULONG
);
441 rc
= RegQueryValue(hDriverKey
, "Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
442 if (rc
!= ERROR_SUCCESS
) StartValue
= (ULONG
)-1;
443 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
446 ValueSize
= sizeof(ULONG
);
447 rc
= RegQueryValue(hDriverKey
, "Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
448 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
449 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
451 /* Read the driver's group */
452 DriverGroupSize
= 256;
453 rc
= RegQueryValue(hDriverKey
, "Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
454 DbgPrint((DPRINT_REACTOS
, " Group: '%s' \n", DriverGroup
));
456 /* Make sure it should be started */
457 if ((StartValue
== 0) &&
458 (TagValue
== OrderList
[TagIndex
]) &&
459 (stricmp(DriverGroup
, GroupName
) == 0)) {
461 /* Get the Driver's Location */
463 rc
= RegQueryValue(hDriverKey
, "ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
465 /* Write the whole path if it suceeded, else prepare to fail */
466 if (rc
!= ERROR_SUCCESS
) {
467 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
468 strcpy(ImagePath
, szSystemRoot
);
469 strcat(ImagePath
, "system32\\drivers\\");
470 strcat(ImagePath
, ServiceName
);
471 strcat(ImagePath
, ".sys");
472 } else if (TempImagePath
[0] != '\\') {
473 strcpy(ImagePath
, szSystemRoot
);
474 strcat(ImagePath
, TempImagePath
);
476 strcpy(ImagePath
, TempImagePath
);
477 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
480 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
482 /* Update the position if needed */
483 if (nPos
< 100) nPos
+= 5;
485 FrLdrLoadDriver(ImagePath
, nPos
);
489 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current Tag %d, current group '%s')\n",
490 ServiceName
, StartValue
, TagValue
, DriverGroup
, OrderList
[TagIndex
], GroupName
));
500 /* Get the Driver's Name */
501 ValueSize
= sizeof(ServiceName
);
502 rc
= RegEnumKey(hServiceKey
, Index
, ServiceName
, &ValueSize
);
504 DbgPrint((DPRINT_REACTOS
, "RegEnumKey(): rc %d\n", (int)rc
));
505 if (rc
== ERROR_NO_MORE_ITEMS
) break;
506 if (rc
!= ERROR_SUCCESS
) return;
507 DbgPrint((DPRINT_REACTOS
, "Service %d: '%s'\n", (int)Index
, ServiceName
));
509 /* open driver Key */
510 rc
= RegOpenKey(hServiceKey
, ServiceName
, &hDriverKey
);
512 /* Read the Start Value */
513 ValueSize
= sizeof(ULONG
);
514 rc
= RegQueryValue(hDriverKey
, "Start", &ValueType
, (PUCHAR
)&StartValue
, &ValueSize
);
515 if (rc
!= ERROR_SUCCESS
) StartValue
= (ULONG
)-1;
516 DbgPrint((DPRINT_REACTOS
, " Start: %x \n", (int)StartValue
));
519 ValueSize
= sizeof(ULONG
);
520 rc
= RegQueryValue(hDriverKey
, "Tag", &ValueType
, (PUCHAR
)&TagValue
, &ValueSize
);
521 if (rc
!= ERROR_SUCCESS
) TagValue
= (ULONG
)-1;
522 DbgPrint((DPRINT_REACTOS
, " Tag: %x \n", (int)TagValue
));
524 /* Read the driver's group */
525 DriverGroupSize
= 256;
526 rc
= RegQueryValue(hDriverKey
, "Group", NULL
, (PUCHAR
)DriverGroup
, &DriverGroupSize
);
527 DbgPrint((DPRINT_REACTOS
, " Group: '%s' \n", DriverGroup
));
529 for (TagIndex
= 1; TagIndex
<= OrderList
[0]; TagIndex
++) {
530 if (TagValue
== OrderList
[TagIndex
]) break;
533 if ((StartValue
== 0) &&
534 (TagIndex
> OrderList
[0]) &&
535 (stricmp(DriverGroup
, GroupName
) == 0)) {
538 rc
= RegQueryValue(hDriverKey
, "ImagePath", NULL
, (PUCHAR
)TempImagePath
, &ValueSize
);
539 if (rc
!= ERROR_SUCCESS
) {
540 DbgPrint((DPRINT_REACTOS
, " ImagePath: not found\n"));
541 strcpy(ImagePath
, szSystemRoot
);
542 strcat(ImagePath
, "system32\\drivers\\");
543 strcat(ImagePath
, ServiceName
);
544 strcat(ImagePath
, ".sys");
545 } else if (TempImagePath
[0] != '\\') {
546 strcpy(ImagePath
, szSystemRoot
);
547 strcat(ImagePath
, TempImagePath
);
549 strcpy(ImagePath
, TempImagePath
);
550 DbgPrint((DPRINT_REACTOS
, " ImagePath: '%s'\n", ImagePath
));
552 DbgPrint((DPRINT_REACTOS
, " Loading driver: '%s'\n", ImagePath
));
554 if (nPos
< 100) nPos
+= 5;
556 FrLdrLoadDriver(ImagePath
, nPos
);
560 DbgPrint((DPRINT_REACTOS
, " Skipping driver '%s' with Start %d, Tag %d and Group '%s' (Current group '%s')\n",
561 ServiceName
, StartValue
, TagValue
, DriverGroup
, GroupName
));
567 /* Move to the next group name */
568 GroupName
= GroupName
+ strlen(GroupName
) + 1;
573 LoadAndBootReactOS(PCHAR OperatingSystemName
)
578 CHAR SystemPath
[1024];
579 CHAR szKernelName
[1024];
580 CHAR szHalName
[1024];
581 CHAR szFileName
[1024];
582 CHAR szBootPath
[256];
590 extern ULONG PageDirectoryStart
;
591 extern ULONG PageDirectoryEnd
;
592 extern BOOLEAN AcpiPresent
;
595 // Open the operating system section
596 // specified in the .ini file
598 if (!IniOpenSection(OperatingSystemName
, &SectionId
))
600 sprintf(MsgBuffer
,"Operating System section '%s' not found in freeldr.ini", OperatingSystemName
);
601 UiMessageBox(MsgBuffer
);
606 * Setup multiboot information structure
608 LoaderBlock
.Flags
= MB_FLAGS_BOOT_DEVICE
| MB_FLAGS_COMMAND_LINE
| MB_FLAGS_MODULE_INFO
;
609 LoaderBlock
.PageDirectoryStart
= (ULONG
)&PageDirectoryStart
;
610 LoaderBlock
.PageDirectoryEnd
= (ULONG
)&PageDirectoryEnd
;
611 LoaderBlock
.BootDevice
= 0xffffffff;
612 LoaderBlock
.CommandLine
= (unsigned long)reactos_kernel_cmdline
;
613 LoaderBlock
.ModsCount
= 0;
614 LoaderBlock
.ModsAddr
= (unsigned long)reactos_modules
;
615 LoaderBlock
.MmapLength
= (unsigned long)MachGetMemoryMap((PBIOS_MEMORY_MAP
)(PVOID
)&reactos_memory_map
, 32) * sizeof(memory_map_t
);
616 if (LoaderBlock
.MmapLength
)
618 LoaderBlock
.MmapAddr
= (unsigned long)&reactos_memory_map
;
619 LoaderBlock
.Flags
|= MB_FLAGS_MEM_INFO
| MB_FLAGS_MMAP_INFO
;
620 reactos_memory_map_descriptor_size
= sizeof(memory_map_t
); // GetBiosMemoryMap uses a fixed value of 24
621 DbgPrint((DPRINT_REACTOS
, "memory map length: %d\n", LoaderBlock
.MmapLength
));
622 DbgPrint((DPRINT_REACTOS
, "dumping memory map:\n"));
623 for (i
=0; i
<(LoaderBlock
.MmapLength
/sizeof(memory_map_t
)); i
++)
625 if (MEMTYPE_USABLE
== reactos_memory_map
[i
].type
&&
626 0 == reactos_memory_map
[i
].base_addr_low
)
628 LoaderBlock
.MemLower
= (reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
) / 1024;
629 if (640 < LoaderBlock
.MemLower
)
631 LoaderBlock
.MemLower
= 640;
634 if (MEMTYPE_USABLE
== reactos_memory_map
[i
].type
&&
635 reactos_memory_map
[i
].base_addr_low
<= 1024 * 1024 &&
636 1024 * 1024 <= reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
)
638 LoaderBlock
.MemHigher
= (reactos_memory_map
[i
].base_addr_low
+ reactos_memory_map
[i
].length_low
) / 1024 - 1024;
640 DbgPrint((DPRINT_REACTOS
, "start: %x\t size: %x\t type %d\n",
641 reactos_memory_map
[i
].base_addr_low
,
642 reactos_memory_map
[i
].length_low
,
643 reactos_memory_map
[i
].type
));
646 DbgPrint((DPRINT_REACTOS
, "low_mem = %d\n", LoaderBlock
.MemLower
));
647 DbgPrint((DPRINT_REACTOS
, "high_mem = %d\n", LoaderBlock
.MemHigher
));
650 * Initialize the registry
652 RegInitializeRegistry();
655 * Make sure the system path is set in the .ini file
657 if (!IniReadSettingByName(SectionId
, "SystemPath", SystemPath
, sizeof(SystemPath
)))
659 UiMessageBox("System path not specified for selected operating system.");
664 * Special case for Live CD.
666 if (!stricmp(SystemPath
, "LiveCD"))
669 MachDiskGetBootPath(SystemPath
, sizeof(SystemPath
));
670 strcat(SystemPath
, "\\reactos");
671 strcat(strcpy(reactos_kernel_cmdline
, SystemPath
),
676 if (! MachDiskNormalizeSystemPath(SystemPath
,
679 UiMessageBox("Invalid system path");
682 /* copy system path into kernel command line */
683 strcpy(reactos_kernel_cmdline
, SystemPath
);
687 * Read the optional kernel parameters (if any)
689 if (IniReadSettingByName(SectionId
, "Options", value
, 1024))
691 strcat(reactos_kernel_cmdline
, " ");
692 strcat(reactos_kernel_cmdline
, value
);
697 UiDrawStatusText("Detecting Hardware...");
704 if (AcpiPresent
) LoaderBlock
.Flags
|= MB_FLAGS_ACPI_TABLE
;
706 UiDrawStatusText("Loading...");
707 UiDrawProgressBarCenter(0, 100, "Loading ReactOS...");
710 * Try to open system drive
712 if (!FsOpenSystemVolume(SystemPath
, szBootPath
, &LoaderBlock
.BootDevice
))
714 UiMessageBox("Failed to open boot drive.");
718 /* append a backslash */
719 if ((strlen(szBootPath
)==0) ||
720 szBootPath
[strlen(szBootPath
)] != '\\')
721 strcat(szBootPath
, "\\");
723 DbgPrint((DPRINT_REACTOS
,"SystemRoot: '%s'\n", szBootPath
));
726 * Find the kernel image name
727 * and try to load the kernel off the disk
729 if(IniReadSettingByName(SectionId
, "Kernel", value
, 1024))
734 if (value
[0] == '\\')
736 strcpy(szKernelName
, value
);
740 strcpy(szKernelName
, szBootPath
);
741 strcat(szKernelName
, "SYSTEM32\\");
742 strcat(szKernelName
, value
);
747 strcpy(value
, "NTOSKRNL.EXE");
748 strcpy(szKernelName
, szBootPath
);
749 strcat(szKernelName
, "SYSTEM32\\");
750 strcat(szKernelName
, value
);
753 if (!FrLdrLoadKernel(szKernelName
, 5)) return;
756 * Find the HAL image name
757 * and try to load the kernel off the disk
759 if(IniReadSettingByName(SectionId
, "Hal", value
, 1024))
764 if (value
[0] == '\\')
766 strcpy(szHalName
, value
);
770 strcpy(szHalName
, szBootPath
);
771 strcat(szHalName
, "SYSTEM32\\");
772 strcat(szHalName
, value
);
777 strcpy(value
, "HAL.DLL");
778 strcpy(szHalName
, szBootPath
);
779 strcat(szHalName
, "SYSTEM32\\");
780 strcat(szHalName
, value
);
783 if (!FrLdrLoadDriver(szHalName
, 10))
788 strcpy(value
, "INBV.DLL");
789 strcpy(szHalName
, szBootPath
);
790 strcat(szHalName
, "SYSTEM32\\");
791 strcat(szHalName
, value
);
793 if (!FrLdrLoadDriver(szHalName
, 10))
797 * Load the System hive from disk
799 strcpy(szFileName
, szBootPath
);
800 strcat(szFileName
, "SYSTEM32\\CONFIG\\SYSTEM");
802 DbgPrint((DPRINT_REACTOS
, "SystemHive: '%s'", szFileName
));
804 FilePointer
= FsOpenFile(szFileName
);
805 if (FilePointer
== NULL
)
807 UiMessageBox("Could not find the System hive!");
812 * Update the status bar with the current file
814 strcpy(name
, "Reading ");
816 while (strlen(name
) < 80)
818 UiDrawStatusText(name
);
821 * Load the System hive
823 Base
= FrLdrLoadModule(FilePointer
, szFileName
, &Size
);
824 if (Base
== 0 || Size
== 0)
826 UiMessageBox("Could not load the System hive!\n");
829 DbgPrint((DPRINT_REACTOS
, "SystemHive loaded at 0x%x size %u", (unsigned)Base
, (unsigned)Size
));
832 * Import the loaded system hive
834 RegImportBinaryHive((PCHAR
)Base
, Size
);
837 * Initialize the 'CurrentControlSet' link
839 RegInitCurrentControlSet(FALSE
);
841 UiDrawProgressBarCenter(15, 100, "Loading ReactOS...");
844 * Export the hardware hive
846 Base
= FrLdrCreateModule ("HARDWARE");
847 RegExportBinaryHive ("\\Registry\\Machine\\HARDWARE", (PCHAR
)Base
, &Size
);
848 FrLdrCloseModule (Base
, Size
);
850 UiDrawProgressBarCenter(20, 100, "Loading ReactOS...");
855 if (!FrLdrLoadNlsFiles(szBootPath
, MsgBuffer
))
857 UiMessageBox(MsgBuffer
);
860 UiDrawProgressBarCenter(30, 100, "Loading ReactOS...");
863 * Load kernel symbols
865 LoadKernelSymbols(szKernelName
, 30);
866 UiDrawProgressBarCenter(40, 100, "Loading ReactOS...");
871 FrLdrLoadBootDrivers(szBootPath
, 40);
872 UiUnInitialize("Booting ReactOS...");
875 * Now boot the kernel
877 DiskStopFloppyMotor();
878 MachVideoPrepareForReactOS();
879 FrLdrStartup(0x2badb002);
884 DbgPrint(char *Fmt
, ...)