ReactOS 0.4.16-dev-2610-ge2c92c0
winldr.c
Go to the documentation of this file.
1/*
2 * PROJECT: FreeLoader
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Windows-compatible NT OS Loader.
5 * COPYRIGHT: Copyright 2006-2019 Aleksey Bragin <aleksey@reactos.org>
6 */
7
8#include <freeldr.h>
9#include <ndk/kefuncs.h> // For KeFindConfiguration*Entry()
10#include <ndk/ldrtypes.h>
11#include "winldr.h"
12#include "ntldropts.h"
13#include "registry.h"
14#include <internal/cmboot.h>
15
16#include <drivers/bootvid/framebuf.h> // For CM_FRAMEBUF_DEVICE_DATA
17
18#include <debug.h>
20
23
25
28extern VOID WinLdrSetupEms(_In_ PCSTR BootOptions);
29
32
37#ifdef _M_IX86
38BOOLEAN PaeModeOn = FALSE;
39#endif
41
42// debug stuff
44
45/* PE loader import-DLL loading callback */
46static VOID
50{
52}
53
54VOID
58{
59 if (SosEnabled)
60 {
61 printf(" %s\n", FileName);
62 TRACE("Loading: %s\n", FileName);
63 }
64 else
65 {
66 /* Inform the user we load a file */
67 CHAR ProgressString[256];
68
69 RtlStringCbPrintfA(ProgressString, sizeof(ProgressString),
70 "Loading %s...",
72 // UiSetProgressBarText(ProgressString);
73 // UiIndicateProgress();
74 UiDrawStatusText(ProgressString);
75 }
76}
77
78// Init "phase 0"
79VOID
81 IN USHORT VersionToBoot,
82 OUT PLOADER_PARAMETER_BLOCK* OutLoaderBlock)
83{
84 PLOADER_PARAMETER_BLOCK LoaderBlock;
86
87 /* Allocate and zero-init the Loader Parameter Block */
91 {
92 UiMessageBox("Failed to allocate memory for system block!");
93 return;
94 }
95
97
98 LoaderBlock = &WinLdrSystemBlock->LoaderBlock;
99 LoaderBlock->NlsData = &WinLdrSystemBlock->NlsDataBlock;
100
101 /* Initialize the Loader Block Extension */
103 LoaderBlock->Extension = Extension;
105 Extension->MajorVersion = (VersionToBoot & 0xFF00) >> 8;
106 Extension->MinorVersion = (VersionToBoot & 0xFF);
107
108#ifdef UEFIBOOT
109 Extension->BootViaEFI = 1;
110#if (NTDDI_VERSION >= NTDDI_LONGHORN)
111 LoaderBlock->FirmwareInformation.FirmwareTypeEfi = 1;
112#endif
113#endif
114
115 /* Init three critical lists, used right away */
119
120 *OutLoaderBlock = LoaderBlock;
121}
122
123// Init "phase 1"
124static VOID
126 _In_ USHORT OperatingSystemVersion,
127 _In_ PLOADER_PARAMETER_BLOCK LoaderBlock,
128 _In_ PCSTR BootOptions,
130 _In_ PCSTR BootPath)
131{
132 /*
133 * Examples of correct options and paths:
134 * CHAR BootOptions[] = "DEBUGPORT=COM1 BAUDRATE=115200";
135 * CHAR SystemPartition[] = "multi(0)disk(0)rdisk(0)partition(1)";
136 * CHAR BootPath[] = "multi(0)disk(0)rdisk(0)partition(2)\\ReactOS\\";
137 * --> ArcBootDevice = "multi(0)disk(0)rdisk(0)partition(2)"
138 * SystemRoot = "\\ReactOS\\"
139 */
140 CHAR HalPath[] = "\\";
142 ULONG i;
144
145 /* Convert BootPath to SystemRoot. Attempt to handle paths like:
146 * "multi(0)disk(0)rdisk(0)partition(2)ReactOS\\weird)name"
147 * where SystemRoot would be: "ReactOS\\weird)name" */
148 PCSTR SystemRoot = BootPath + strcspn(BootPath, "\\");
149 PCSTR LastParen;
150
151 CHAR Sep = *SystemRoot;
153 LastParen = strrchr(BootPath, ')');
154 *(PSTR)SystemRoot = Sep;
155 if (LastParen && (LastParen < SystemRoot))
156 SystemRoot = (LastParen + 1);
157
158 TRACE("SystemPartition: '%s'\n", SystemPartition);
159 TRACE("ArcBootDevice: '%.*s'\n", (SystemRoot - BootPath), BootPath);
160 TRACE("SystemRoot: '%s'\n", SystemRoot);
161 TRACE("BootOptions: '%s'\n", BootOptions);
162
163 /* Fill the OS boot partition ARC device path */
164 LoaderBlock->ArcBootDeviceName = WinLdrSystemBlock->ArcBootDeviceName;
165 RtlStringCbCopyNA(LoaderBlock->ArcBootDeviceName, sizeof(WinLdrSystemBlock->ArcBootDeviceName),
166 BootPath, (SystemRoot - BootPath) * sizeof(CHAR));
167 LoaderBlock->ArcBootDeviceName = PaToVa(LoaderBlock->ArcBootDeviceName);
168
169//
170// IMPROVE!!
171// SetupBlock->ArcSetupDeviceName must be the path to the setup **SOURCE**,
172// and not the setup boot path. Indeed they may differ!!
173//
174 if (LoaderBlock->SetupLdrBlock)
175 {
176 PSETUP_LOADER_BLOCK SetupBlock = LoaderBlock->SetupLdrBlock;
177
178 /* Adjust the ARC path in the setup block - Matches ArcBootDeviceName */
180 SetupBlock->ArcSetupDeviceName = PaToVa(SetupBlock->ArcSetupDeviceName);
181
182 /* Convert the setup block pointer */
183 LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
184 }
185
186 /* Fill the firmware system loader / "HAL" partition ARC device path */
187 LoaderBlock->ArcHalDeviceName = WinLdrSystemBlock->ArcHalDeviceName;
188 RtlStringCbCopyA(LoaderBlock->ArcHalDeviceName, sizeof(WinLdrSystemBlock->ArcHalDeviceName), SystemPartition);
189 LoaderBlock->ArcHalDeviceName = PaToVa(LoaderBlock->ArcHalDeviceName);
190
191 /* Fill SystemRoot */
192 LoaderBlock->NtBootPathName = WinLdrSystemBlock->NtBootPathName;
193 RtlStringCbCopyA(LoaderBlock->NtBootPathName, sizeof(WinLdrSystemBlock->NtBootPathName), SystemRoot);
194 LoaderBlock->NtBootPathName = PaToVa(LoaderBlock->NtBootPathName);
195
196 /* Fill NtHalPathName */
197 LoaderBlock->NtHalPathName = WinLdrSystemBlock->NtHalPathName;
198 RtlStringCbCopyA(LoaderBlock->NtHalPathName, sizeof(WinLdrSystemBlock->NtHalPathName), HalPath);
199 LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName);
200
201 /* Fill LoadOptions */
202 LoaderBlock->LoadOptions = WinLdrSystemBlock->LoadOptions;
203 RtlStringCbCopyA(LoaderBlock->LoadOptions, sizeof(WinLdrSystemBlock->LoadOptions), BootOptions);
204 LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions);
205
206 /* ARC devices */
207 LoaderBlock->ArcDiskInformation = &WinLdrSystemBlock->ArcDiskInformation;
208 InitializeListHead(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead);
209
210 /* Convert ARC disk information from freeldr to a correct format */
211 ULONG DiscCount = ArcGetDiskCount();
212 for (i = 0; i < DiscCount; i++)
213 {
214 PARC_DISK_SIGNATURE_EX ArcDiskSig;
215
216 /* Allocate the ARC structure */
217 ArcDiskSig = FrLdrHeapAlloc(sizeof(ARC_DISK_SIGNATURE_EX), 'giSD');
218 if (!ArcDiskSig)
219 {
220 ERR("Failed to allocate ARC structure! Ignoring remaining ARC disks. (i = %lu, DiskCount = %lu)\n",
221 i, DiscCount);
222 break;
223 }
224
225 /* Copy the data over */
227
228 /* Set the ARC Name pointer */
229 ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName);
230
231 /* Insert into the list */
232 InsertTailList(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead,
233 &ArcDiskSig->DiskSignature.ListEntry);
234 }
235
236 /* Convert all lists to Virtual address */
237
238 /* Convert the ArcDisks list to virtual address */
239 List_PaToVa(&LoaderBlock->ArcDiskInformation->DiskSignatureListHead);
240 LoaderBlock->ArcDiskInformation = PaToVa(LoaderBlock->ArcDiskInformation);
241
242 /* Convert configuration entries to VA */
243 ConvertConfigToVA(LoaderBlock->ConfigurationRoot);
244 LoaderBlock->ConfigurationRoot = PaToVa(LoaderBlock->ConfigurationRoot);
245
246 /* Convert all DTE into virtual addresses */
247 List_PaToVa(&LoaderBlock->LoadOrderListHead);
248
249 /* This one will be converted right before switching to virtual paging mode */
250 //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
251
252 /* Convert list of boot drivers */
253 List_PaToVa(&LoaderBlock->BootDriverListHead);
254
255 Extension = LoaderBlock->Extension;
256
257 /* FIXME! HACK value for docking profile */
258 Extension->Profile.Status = 2;
259
260 /* Check if FreeLdr detected a ACPI table */
261 if (IsAcpiPresent())
262 {
263 /* Set the pointer to something for compatibility */
264 Extension->AcpiTable = (PVOID)1;
265 // FIXME: Extension->AcpiTableSize;
266 }
267
268 if (OperatingSystemVersion >= _WIN32_WINNT_VISTA)
269 {
270 Extension->BootViaWinload = 1;
271 Extension->LoaderPerformanceData = PaToVa(&WinLdrSystemBlock->LoaderPerformanceData);
272
273 InitializeListHead(&Extension->BootApplicationPersistentData);
274 List_PaToVa(&Extension->BootApplicationPersistentData);
275 }
276
277 /* Set the headless block pointer */
279 {
280 Extension->HeadlessLoaderBlock = &WinLdrSystemBlock->HeadlessLoaderBlock;
281 RtlCopyMemory(Extension->HeadlessLoaderBlock,
284 Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
285 }
286
287 /* Load drivers database */
288 RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
289 RtlStringCbCatA(FilePath, sizeof(FilePath), "AppPatch\\drvmain.sdb");
291 &Extension->DrvDBSize,
293
294 /* Convert the extension block pointer */
295 LoaderBlock->Extension = PaToVa(LoaderBlock->Extension);
296
297 TRACE("WinLdrInitializePhase1() completed\n");
298}
299
300static BOOLEAN
302 PCSTR BootPath,
304 ULONG Flags,
305 PLDR_DATA_TABLE_ENTRY *DriverDTE)
306{
307 CHAR FullPath[1024];
308 CHAR DriverPath[1024];
309 CHAR DllName[1024];
310 PCHAR DriverNamePos;
312 PVOID DriverBase = NULL;
313
314 // Separate the path to file name and directory path
315 RtlStringCbPrintfA(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
316 DriverNamePos = strrchr(DriverPath, '\\');
317 if (DriverNamePos != NULL)
318 {
319 // Copy the name
320 RtlStringCbCopyA(DllName, sizeof(DllName), DriverNamePos+1);
321
322 // Cut out the name from the path
323 *(DriverNamePos+1) = ANSI_NULL;
324 }
325 else
326 {
327 // There is no directory in the path
328 RtlStringCbCopyA(DllName, sizeof(DllName), DriverPath);
329 *DriverPath = ANSI_NULL;
330 }
331
332 TRACE("DriverPath: '%s', DllName: '%s', LPB\n", DriverPath, DllName);
333
334 // Check if driver is already loaded
335 Success = PeLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
336 if (Success)
337 {
338 // We've got the pointer to its DTE, just return success
339 return TRUE;
340 }
341
342 // It's not loaded, we have to load it
343 RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
344
345 NtLdrOutputLoadMsg(FullPath, NULL);
346 Success = PeLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
347 if (!Success)
348 {
349 ERR("PeLdrLoadImage('%s') failed\n", DllName);
350 return FALSE;
351 }
352
353 // Allocate a DTE for it
354 Success = PeLdrAllocateDataTableEntry(LoadOrderListHead,
355 DllName,
356 DllName,
357 PaToVa(DriverBase),
358 DriverDTE);
359 if (!Success)
360 {
361 /* Cleanup and bail out */
362 ERR("PeLdrAllocateDataTableEntry('%s') failed\n", DllName);
363 MmFreeMemory(DriverBase);
364 return FALSE;
365 }
366
367 /* Init security cookie */
368 PeLdrInitSecurityCookie(*DriverDTE);
369
370 // Modify any flags, if needed
371 (*DriverDTE)->Flags |= Flags;
372
373 // Look for any dependencies it may have, and load them too
374 RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%s", BootPath, DriverPath);
375 Success = PeLdrScanImportDescriptorTable(LoadOrderListHead, FullPath, *DriverDTE);
376 if (!Success)
377 {
378 /* Cleanup and bail out */
379 ERR("PeLdrScanImportDescriptorTable('%s') failed\n", FullPath);
380 PeLdrFreeDataTableEntry(*DriverDTE);
381 MmFreeMemory(DriverBase);
382 return FALSE;
383 }
384
385 return TRUE;
386}
387
390 PCSTR BootPath)
391{
392 PLIST_ENTRY NextBd;
393 PBOOT_DRIVER_NODE DriverNode;
394 PBOOT_DRIVER_LIST_ENTRY BootDriver;
396 BOOLEAN ret = TRUE;
397
398 /* Walk through the boot drivers list */
399 NextBd = LoaderBlock->BootDriverListHead.Flink;
400 while (NextBd != &LoaderBlock->BootDriverListHead)
401 {
402 DriverNode = CONTAINING_RECORD(NextBd,
404 ListEntry.Link);
405 BootDriver = &DriverNode->ListEntry;
406
407 /* Get the next list entry as we may remove the current one on failure */
408 NextBd = BootDriver->Link.Flink;
409
410 TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n",
411 &BootDriver->FilePath, BootDriver->LdrEntry,
412 &BootDriver->RegistryPath);
413
414 // Paths are relative (FIXME: Are they always relative?)
415
416 /* Load it */
419 BootPath,
420 &BootDriver->FilePath,
421 0,
422 &BootDriver->LdrEntry);
423 if (Success)
424 {
425 /* Convert the addresses to VA since we are not going to use them anymore */
426 BootDriver->RegistryPath.Buffer = PaToVa(BootDriver->RegistryPath.Buffer);
427 BootDriver->FilePath.Buffer = PaToVa(BootDriver->FilePath.Buffer);
428 BootDriver->LdrEntry = PaToVa(BootDriver->LdrEntry);
429
430 if (DriverNode->Group.Buffer)
431 DriverNode->Group.Buffer = PaToVa(DriverNode->Group.Buffer);
432 DriverNode->Name.Buffer = PaToVa(DriverNode->Name.Buffer);
433 }
434 else
435 {
436 /* Loading failed: cry loudly */
437 ERR("Cannot load boot driver '%wZ'!\n", &BootDriver->FilePath);
438 UiMessageBox("Cannot load boot driver '%wZ'!", &BootDriver->FilePath);
439 ret = FALSE;
440
441 /* Remove it from the list and try to continue */
442 RemoveEntryList(&BootDriver->Link);
443 }
444 }
445
446 return ret;
447}
448
449PVOID
451 PULONG Size,
452 TYPE_OF_MEMORY MemoryType)
453{
454 ULONG FileId;
455 PVOID PhysicalBase;
460
461 *Size = 0;
462
463 /* Open the image file */
466 if (Status != ESUCCESS)
467 {
468 /* In case of errors, we just return, without complaining to the user */
469 WARN("Error while opening '%s', Status: %u\n", ModuleName, Status);
470 return NULL;
471 }
472
473 /* Retrieve its size */
475 if (Status != ESUCCESS)
476 {
477 ArcClose(FileId);
478 return NULL;
479 }
480 FileSize = FileInfo.EndingAddress.LowPart;
481 *Size = FileSize;
482
483 /* Allocate memory */
484 PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);
485 if (PhysicalBase == NULL)
486 {
487 ERR("Could not allocate memory for '%s'\n", ModuleName);
488 ArcClose(FileId);
489 return NULL;
490 }
491
492 /* Load the whole file */
493 Status = ArcRead(FileId, PhysicalBase, FileSize, &BytesRead);
494 ArcClose(FileId);
495 if (Status != ESUCCESS)
496 {
497 WARN("Error while reading '%s', Status: %u\n", ModuleName, Status);
498 return NULL;
499 }
500
501 TRACE("Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize);
502
503 return PhysicalBase;
504}
505
506USHORT
508{
509 LONG rc;
510 HKEY hKey;
511
512 rc = RegOpenKey(CurrentControlSetKey, L"Control\\Terminal Server", &hKey);
513 if (rc != ERROR_SUCCESS)
514 {
515 /* Key doesn't exist; assume NT 4.0 */
516 return _WIN32_WINNT_NT4;
517 }
519
520 /* We may here want to read the value of ProductVersion */
521 return _WIN32_WINNT_WS03;
522}
523
524static
525PVOID
527 _Inout_ PLIST_ENTRY LoadOrderListHead,
530 _In_ PCSTR ImportName, // BaseDllName
531 _In_ TYPE_OF_MEMORY MemoryType,
533 _In_ ULONG Percentage)
534{
536 CHAR FullFileName[MAX_PATH];
537 CHAR ProgressString[256];
539
540 RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", File);
541 UiUpdateProgressBar(Percentage, ProgressString);
542
543 RtlStringCbCopyA(FullFileName, sizeof(FullFileName), Path);
544 RtlStringCbCatA(FullFileName, sizeof(FullFileName), File);
545
546 NtLdrOutputLoadMsg(FullFileName, NULL);
547 Success = PeLdrLoadImage(FullFileName, MemoryType, &BaseAddress);
548 if (!Success)
549 {
550 ERR("PeLdrLoadImage('%s') failed\n", File);
551 return NULL;
552 }
553 TRACE("%s loaded successfully at %p\n", File, BaseAddress);
554
555 Success = PeLdrAllocateDataTableEntry(LoadOrderListHead,
556 ImportName,
557 FullFileName,
559 Dte);
560 if (!Success)
561 {
562 /* Cleanup and bail out */
563 ERR("PeLdrAllocateDataTableEntry('%s') failed\n", FullFileName);
565 return NULL;
566 }
567
568 /* Init security cookie */
570
571 return BaseAddress;
572}
573
574#ifdef _M_IX86
575static
577WinLdrIsPaeSupported(
578 _In_ USHORT OperatingSystemVersion,
579 _In_ PLOADER_PARAMETER_BLOCK LoaderBlock,
580 _In_ PCSTR BootOptions,
581 _In_ PCSTR HalFileName,
582 _Inout_updates_bytes_(KernelFileNameSize) _Always_(_Post_z_)
583 PSTR KernelFileName,
584 _In_ SIZE_T KernelFileNameSize)
585{
586 BOOLEAN PaeEnabled = FALSE;
587 BOOLEAN PaeDisabled = FALSE;
589
590 if ((OperatingSystemVersion > _WIN32_WINNT_NT4) &&
591 NtLdrGetOption(BootOptions, "PAE"))
592 {
593 /* We found the PAE option */
594 PaeEnabled = TRUE;
595 }
596
597 Result = PaeEnabled;
598
599 if ((OperatingSystemVersion > _WIN32_WINNT_WIN2K) &&
600 NtLdrGetOption(BootOptions, "NOPAE"))
601 {
602 PaeDisabled = TRUE;
603 }
604
605 if (SafeBoot)
606 PaeDisabled = TRUE;
607
608 TRACE("PaeEnabled %X, PaeDisabled %X\n", PaeEnabled, PaeDisabled);
609
610 if (PaeDisabled)
611 Result = FALSE;
612
613 /* Enable PAE if DEP is enabled */
615 Result = TRUE;
616
617 // TODO: checks for CPU support, hotplug memory support ... other tests
618 // TODO: select kernel name ("ntkrnlpa.exe" or "ntoskrnl.exe"), or,
619 // if KernelFileName is a user-specified kernel file, check whether it
620 // has, if PAE needs to be enabled, the IMAGE_FILE_LARGE_ADDRESS_AWARE
621 // Characteristics bit set, and that the HAL image has a similar support.
622
624
625 return Result;
626}
627#endif /* _M_IX86 */
628
629static VOID
632 _Out_writes_bytes_(BootVidNameSize) _Always_(_Post_z_)
633 PSTR BootVidName,
634 _In_ SIZE_T BootVidNameSize)
635{
636 /* NOTE: The following array should instead be read from txtsetup.sif */
637 static const struct
638 {
639 PCSTR SystemSubId;
641 } BootVidNames[] =
642 {
643#if defined(_M_IX86) && !defined(UEFIBOOT)
644 {"PC-98", "pc98bvid.dll"},
645 {"Xbox", "xboxbvid.dll"},
646#endif
647 {"EFI", "lfbbvid.dll"},
648 };
649
650 /* Default BootVid file name */
651 RtlStringCbCopyA(BootVidName, BootVidNameSize, "bootvid.dll");
652
653 /* Attempt auto-detection by System ID */
655 Entry = KeFindConfigurationEntry(ConfigTree,
657 ArcSystem,
658 NULL);
659 if (!Entry)
660 {
661 /* No SystemClass ArcSystem entry, retry with hack */
662 Entry = KeFindConfigurationEntry(ConfigTree,
664 MaximumType, // HACK for non-ARC machines
665 NULL);
666 }
667 if (Entry)
668 {
669 // Entry->ComponentEntry.IdentifierLength;
670 TRACE("ARC System ID: '%s'\n", Entry->ComponentEntry.Identifier);
671
672 /* Look up the name */
673 for (ULONG i = 0; i < RTL_NUMBER_OF(BootVidNames); ++i)
674 {
675 if (strstr(Entry->ComponentEntry.Identifier, BootVidNames[i].SystemSubId))
676 {
677 RtlStringCbCopyA(BootVidName, BootVidNameSize, BootVidNames[i].ModuleName);
678 break;
679 }
680 }
681 }
682 /* Special-case detection if the display controller contains
683 * a DeviceSpecific CM_FRAMEBUF_DEVICE_DATA resource */
684 Entry = KeFindConfigurationEntry(ConfigTree,
687 NULL);
688 if (Entry)
689 {
690 /* Cast to PCM_PARTIAL_RESOURCE_LIST to access
691 * the common Version and Revision fields */
693 (PCM_PARTIAL_RESOURCE_LIST)Entry->ConfigurationData;
694 ULONG ConfigurationDataLength =
695 Entry->ComponentEntry.ConfigurationDataLength;
696
697 // Entry->ComponentEntry.IdentifierLength;
698 TRACE("Display: '%s'\n", Entry->ComponentEntry.Identifier);
699
700 /* The configuration data length must be valid.
701 * The Version/Revision must be greater than or equal to 1.2
702 * in order to describe a valid new configuration data. */
703 if (Entry->ConfigurationData &&
704 (ConfigurationDataLength >= sizeof(CM_PARTIAL_RESOURCE_LIST)) &&
705 ( (ResourceList->Version > 1) ||
706 ((ResourceList->Version == 1) && (ResourceList->Revision > 1)) ))
707 {
708 /* Try to find the DeviceSpecific resource */
709 PCM_PARTIAL_RESOURCE_DESCRIPTOR DeviceSpecific = NULL;
710 for (ULONG i = 0; i < ResourceList->Count; ++i)
711 {
713 &ResourceList->PartialDescriptors[i];
715 {
716 /* NOTE: This descriptor *MUST* be the last one.
717 * The actual device data follows the descriptor. */
718 ASSERT(i == ResourceList->Count - 1);
719 DeviceSpecific = Descriptor;
720 break;
721 }
722 }
723
724 /* Check whether the resource describes framebuffer information */
725 if (DeviceSpecific &&
726 (DeviceSpecific->u.DeviceSpecificData.DataSize >= sizeof(CM_FRAMEBUF_DEVICE_DATA)))
727 {
728 /* It does, use the Linear FrameBuffer Boot Video Driver instead */
729 RtlStringCbCopyA(BootVidName, BootVidNameSize, "lfbbvid.dll");
730 }
731 }
732 }
733}
734
735static
737LoadWindowsCore(IN USHORT OperatingSystemVersion,
738 IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
739 IN PCSTR BootOptions,
740 IN PCSTR BootPath,
741 IN OUT PLDR_DATA_TABLE_ENTRY* KernelDTE)
742{
744 PCSTR Option;
745 ULONG OptionLength;
746 PVOID KernelBase, HalBase, KdDllBase = NULL, BootVidBase = NULL;
747 PLDR_DATA_TABLE_ENTRY HalDTE, KdDllDTE = NULL, BootVidDTE = NULL;
749 CHAR DirPath[MAX_PATH];
750 CHAR HalFileName[MAX_PATH];
751 CHAR KernelFileName[MAX_PATH];
752 CHAR KdDllName[MAX_PATH];
753 CHAR BootVidName[MAX_PATH];
754
755 /* Initialize SystemRoot\System32 path */
756 RtlStringCbCopyA(DirPath, sizeof(DirPath), BootPath);
757 RtlStringCbCatA(DirPath, sizeof(DirPath), "system32\\");
758
759 /* Parse the boot options */
760 TRACE("LoadWindowsCore: BootOptions '%s'\n", BootOptions);
761
762#ifdef _M_IX86
763 if (NtLdrGetOption(BootOptions, "3GB"))
764 {
765 /* We found the 3GB option. */
766 FIXME("LoadWindowsCore: 3GB - TRUE (not implemented)\n");
768 }
769 // TODO: "USERVA=" for XP/2k3
770#endif
771
772 if ((OperatingSystemVersion > _WIN32_WINNT_NT4) &&
773 (NtLdrGetOption(BootOptions, "SAFEBOOT") ||
774 NtLdrGetOption(BootOptions, "SAFEBOOT:")))
775 {
776 /* We found the SAFEBOOT option. */
777 FIXME("LoadWindowsCore: SAFEBOOT - TRUE (not implemented)\n");
778 SafeBoot = TRUE;
779 }
780
781 if ((OperatingSystemVersion > _WIN32_WINNT_WIN2K) &&
782 NtLdrGetOption(BootOptions, "BOOTLOGO"))
783 {
784 /* We found the BOOTLOGO option. */
785 FIXME("LoadWindowsCore: BOOTLOGO - TRUE (not implemented)\n");
786 BootLogo = TRUE;
787 }
788
789 /* Check the (NO)EXECUTE options */
790 if ((OperatingSystemVersion > _WIN32_WINNT_WIN2K) &&
791 !LoaderBlock->SetupLdrBlock)
792 {
793 /* Disable NX by default on x86, otherwise enable it */
794#ifdef _M_IX86
796#else
798#endif
799
800#ifdef _M_IX86
801 /* Check the options in decreasing order of precedence */
802 if (NtLdrGetOption(BootOptions, "NOEXECUTE=OPTIN") ||
803 NtLdrGetOption(BootOptions, "NOEXECUTE=OPTOUT") ||
804 NtLdrGetOption(BootOptions, "NOEXECUTE=ALWAYSON"))
805 {
807 }
808 else if (NtLdrGetOption(BootOptions, "NOEXECUTE=ALWAYSOFF"))
810 else
811#else
812 /* Only the following two options really apply for x64 and other platforms */
813#endif
814 if (NtLdrGetOption(BootOptions, "NOEXECUTE"))
816 else if (NtLdrGetOption(BootOptions, "EXECUTE"))
818
819#ifdef _M_IX86
820 /* Disable DEP in SafeBoot mode for x86 only */
821 if (SafeBoot)
823#endif
824 }
825 TRACE("NoExecuteEnabled %X\n", NoExecuteEnabled);
826
827 /*
828 * Select the HAL and KERNEL file names.
829 * Check for any "/HAL=" or "/KERNEL=" override option.
830 *
831 * See the following links to know how the file names are actually chosen:
832 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/detecthal.htm
833 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/hal.htm
834 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/kernel.htm
835 */
836 /* Default HAL and KERNEL file names */
837 RtlStringCbCopyA(HalFileName , sizeof(HalFileName) , "hal.dll");
838 RtlStringCbCopyA(KernelFileName, sizeof(KernelFileName), "ntoskrnl.exe");
839
840 Option = NtLdrGetOptionEx(BootOptions, "HAL=", &OptionLength);
841 if (Option && (OptionLength > 4))
842 {
843 /* Retrieve the HAL file name */
844 Option += 4; OptionLength -= 4;
845 RtlStringCbCopyNA(HalFileName, sizeof(HalFileName), Option, OptionLength);
846 _strlwr(HalFileName);
847 }
848
849 Option = NtLdrGetOptionEx(BootOptions, "KERNEL=", &OptionLength);
850 if (Option && (OptionLength > 7))
851 {
852 /* Retrieve the KERNEL file name */
853 Option += 7; OptionLength -= 7;
854 RtlStringCbCopyNA(KernelFileName, sizeof(KernelFileName), Option, OptionLength);
855 _strlwr(KernelFileName);
856 }
857
858#ifdef _M_IX86
859 /* Check for PAE support and select the adequate kernel image */
860 PaeModeOn = WinLdrIsPaeSupported(OperatingSystemVersion,
861 LoaderBlock,
862 BootOptions,
863 HalFileName,
864 KernelFileName,
865 sizeof(KernelFileName));
866 if (PaeModeOn) FIXME("WinLdrIsPaeSupported: PaeModeOn\n");
867#endif
868
869 TRACE("HAL file = '%s' ; Kernel file = '%s'\n", HalFileName, KernelFileName);
870
871 /*
872 * Load the core NT files: Kernel, HAL and KD transport DLL.
873 * Cheat about their base DLL name so as to satisfy the imports/exports,
874 * even if the corresponding underlying files do not have the same names
875 * -- this happens e.g. with UP vs. MP kernel, standard vs. ACPI hal, or
876 * different KD transport DLLs.
877 */
878
879 /* Load the Kernel */
880 KernelBase = LoadModule(&LoaderBlock->LoadOrderListHead,
881 DirPath, KernelFileName,
882 "ntoskrnl.exe", LoaderSystemCode,
883 KernelDTE, 30);
884 if (!KernelBase)
885 {
886 ERR("LoadModule('%s') failed\n", KernelFileName);
887 UiMessageBox("Could not load %s", KernelFileName);
888 return FALSE;
889 }
890
891 /* Load the HAL */
892 HalBase = LoadModule(&LoaderBlock->LoadOrderListHead,
893 DirPath, HalFileName,
894 "hal.dll", LoaderHalCode,
895 &HalDTE, 35);
896 if (!HalBase)
897 {
898 ERR("LoadModule('%s') failed\n", HalFileName);
899 UiMessageBox("Could not load %s", HalFileName);
900 PeLdrFreeDataTableEntry(*KernelDTE);
902 return FALSE;
903 }
904
905 /* Load the Kernel Debugger Transport DLL */
906 if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
907 {
908 /*
909 * According to http://www.nynaeve.net/?p=173 :
910 * "[...] Another enhancement that could be done Microsoft-side would be
911 * a better interface for replacing KD transport modules. Right now, due
912 * to the fact that ntoskrnl is static linked to KDCOM.DLL, the OS loader
913 * has a hardcoded hack that interprets the KD type in the OS loader options,
914 * loads one of the (hardcoded filenames) "kdcom.dll", "kd1394.dll", or
915 * "kdusb2.dll" modules, and inserts them into the loaded module list under
916 * the name "kdcom.dll". [...]"
917 */
918
919 /*
920 * A Kernel Debugger Transport DLL is always loaded for Windows XP+ :
921 * either the standard KDCOM.DLL (by default): IsCustomKdDll == FALSE
922 * or an alternative user-provided one via the /DEBUGPORT= option:
923 * IsCustomKdDll == TRUE if it does not specify the default KDCOM.
924 */
925 BOOLEAN IsCustomKdDll = FALSE;
926
927 /* Check whether there is a DEBUGPORT option */
928 Option = NtLdrGetOptionEx(BootOptions, "DEBUGPORT=", &OptionLength);
929 if (Option && (OptionLength > 10))
930 {
931 /* Move to the debug port name */
932 Option += 10; OptionLength -= 10;
933
934 /*
935 * Parse the port name.
936 * Format: /DEBUGPORT=COM[0-9]
937 * or: /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log
938 * or: /DEBUGPORT=FOO
939 * If we only have /DEBUGPORT= (i.e. without any port name),
940 * default to "COM".
941 */
942
943 /* Get the actual length of the debug port
944 * until the next whitespace or colon. */
945 OptionLength = (ULONG)strcspn(Option, " \t:");
946
947 if ((OptionLength == 0) ||
948 ( (OptionLength >= 3) && (_strnicmp(Option, "COM", 3) == 0) &&
949 ((OptionLength == 3) || ('0' <= Option[3] && Option[3] <= '9')) ))
950 {
951 /* The standard KDCOM.DLL is used */
952 }
953 else
954 {
955 /* A custom KD DLL is used */
956 IsCustomKdDll = TRUE;
957 }
958 }
959 if (!IsCustomKdDll)
960 {
961 Option = "COM"; OptionLength = 3;
962 }
963
964 RtlStringCbPrintfA(KdDllName, sizeof(KdDllName), "kd%.*s.dll",
965 OptionLength, Option);
966 _strlwr(KdDllName);
967
968 /* Load the KD DLL. Override its base DLL name to the default "KDCOM.DLL". */
969 KdDllBase = LoadModule(&LoaderBlock->LoadOrderListHead,
970 DirPath, KdDllName,
971 "kdcom.dll", LoaderSystemCode,
972 &KdDllDTE, 40);
973 if (!KdDllBase)
974 {
975 /* If we failed to load a custom KD DLL, fall back to the standard one */
976 if (IsCustomKdDll)
977 {
978 /* The custom KD DLL being optional, just ignore the failure */
979 WARN("LoadModule('%s') failed\n", KdDllName);
980
981 IsCustomKdDll = FALSE;
982 RtlStringCbCopyA(KdDllName, sizeof(KdDllName), "kdcom.dll");
983
984 KdDllBase = LoadModule(&LoaderBlock->LoadOrderListHead,
985 DirPath, KdDllName,
986 "kdcom.dll", LoaderSystemCode,
987 &KdDllDTE, 40);
988 }
989
990 if (!KdDllBase)
991 {
992 /* Ignore the failure; we will fail later when scanning the
993 * kernel import tables, if it really needs the KD DLL. */
994 ERR("LoadModule('%s') failed\n", KdDllName);
995 }
996 }
997 }
998
999 /* Load the correct Boot Video Driver */
1000 if (OperatingSystemVersion >= _WIN32_WINNT_WIN2K)
1001 {
1002 /* Check whether there is a BOOTVID option */
1003 Option = NtLdrGetOptionEx(BootOptions, "BOOTVID=", &OptionLength);
1004 if (Option && (OptionLength > 8))
1005 {
1006 /* Retrieve the BootVid file name */
1007 Option += 8; OptionLength -= 8;
1008 RtlStringCbCopyNA(BootVidName, sizeof(BootVidName), Option, OptionLength);
1009 _strlwr(BootVidName);
1010 TRACE("User-specified BootVid file: '%s'\n", BootVidName);
1011 }
1012 else
1013 {
1014 /* No option given, attempt auto-detection */
1015 NtLdrDetectBootVid(LoaderBlock->ConfigurationRoot,
1016 BootVidName, sizeof(BootVidName));
1017 TRACE("Auto-detected BootVid file: '%s'\n", BootVidName);
1018 }
1019
1020 /* Load the BootVid */
1021 BootVidBase = LoadModule(&LoaderBlock->LoadOrderListHead,
1022 DirPath, BootVidName,
1023 "bootvid.dll", LoaderSystemCode,
1024 &BootVidDTE, 45);
1025 if (!BootVidBase)
1026 {
1027 /* Ignore the failure; we will fail later when scanning the
1028 * kernel import tables, if it really needs the BootVid. */
1029 ERR("LoadModule('%s') failed\n", BootVidName);
1030 }
1031 }
1032
1033 /* Load all referenced DLLs for Kernel, HAL, Kernel Debugger Transport and BootVid */
1034 ModuleName = KernelFileName;
1035 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, *KernelDTE);
1036 if (!Success)
1037 goto Quit;
1038 ModuleName = HalFileName;
1039 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, HalDTE);
1040 if (!Success)
1041 goto Quit;
1042 if (KdDllDTE)
1043 {
1044 ModuleName = KdDllName;
1045 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, KdDllDTE);
1046 if (!Success)
1047 goto Quit;
1048 }
1049 if (BootVidDTE)
1050 {
1051 ModuleName = BootVidName;
1052 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, BootVidDTE);
1053 if (!Success)
1054 goto Quit;
1055 }
1056
1057Quit:
1058 if (!Success)
1059 {
1060 ERR("PeLdrScanImportDescriptorTable('%s') failed\n", ModuleName);
1061 UiMessageBox("Could not load %s", ModuleName);
1062
1063 /* Cleanup and bail out */
1064 if (BootVidDTE)
1065 PeLdrFreeDataTableEntry(BootVidDTE);
1066 if (BootVidBase) // Optional
1067 MmFreeMemory(BootVidBase);
1068
1069 if (KdDllDTE)
1070 PeLdrFreeDataTableEntry(KdDllDTE);
1071 if (KdDllBase) // Optional
1072 MmFreeMemory(KdDllBase);
1073
1075 MmFreeMemory(HalBase);
1076
1077 PeLdrFreeDataTableEntry(*KernelDTE);
1079 }
1080
1081 return Success;
1082}
1083
1084static
1085BOOLEAN
1087 IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
1088 IN USHORT OperatingSystemVersion,
1090{
1091 LONG rc;
1092 HKEY hKey;
1095 PVOID PhysicalBase;
1096 WCHAR szFileName[80];
1097 CHAR ErrataFilePath[MAX_PATH];
1098
1099 /* Open either the 'BiosInfo' (Windows <= 2003) or the 'Errata' (Vista+) key */
1100 if (OperatingSystemVersion >= _WIN32_WINNT_VISTA)
1101 {
1102 rc = RegOpenKey(CurrentControlSetKey, L"Control\\Errata", &hKey);
1103 }
1104 else // (OperatingSystemVersion <= _WIN32_WINNT_WS03)
1105 {
1106 rc = RegOpenKey(CurrentControlSetKey, L"Control\\BiosInfo", &hKey);
1107 }
1108 if (rc != ERROR_SUCCESS)
1109 {
1110 WARN("Could not open the BiosInfo/Errata registry key (Error %u)\n", (int)rc);
1111 return FALSE;
1112 }
1113
1114 /* Retrieve the INF file name value */
1115 BufferSize = sizeof(szFileName);
1116 rc = RegQueryValue(hKey, L"InfName", NULL, (PUCHAR)szFileName, &BufferSize);
1117 if (rc != ERROR_SUCCESS)
1118 {
1119 WARN("Could not retrieve the InfName value (Error %u)\n", (int)rc);
1121 return FALSE;
1122 }
1123
1124 // TODO: "SystemBiosDate"
1125
1127
1128 RtlStringCbPrintfA(ErrataFilePath, sizeof(ErrataFilePath), "%s%s%S",
1129 SystemRoot, "inf\\", szFileName);
1130
1131 /* Load the INF file */
1132 PhysicalBase = WinLdrLoadModule(ErrataFilePath, &FileSize, LoaderRegistryData);
1133 if (!PhysicalBase)
1134 {
1135 WARN("Could not load '%s'\n", ErrataFilePath);
1136 return FALSE;
1137 }
1138
1139 LoaderBlock->Extension->EmInfFileImage = PaToVa(PhysicalBase);
1140 LoaderBlock->Extension->EmInfFileSize = FileSize;
1141
1142 return TRUE;
1143}
1144
1150VOID
1152 _Inout_ PSTR LoadOptions)
1153{
1154 PCHAR NewOptions = LoadOptions;
1155 PCSTR Options, Option;
1156 ULONG OptionLength;
1157
1158 /* Normalize the boot options by successively enumerating each and
1159 * copying them back, stripping and replacing any extra separator
1160 * by one single space. */
1161 Options = LoadOptions;
1162 while ((Option = NtLdrGetNextOption(&Options, &OptionLength)))
1163 {
1164 if (NewOptions > LoadOptions)
1165 *NewOptions++ = ' ';
1166
1167 /* If necessary, move the current option back */
1168 ASSERT(NewOptions <= Option);
1169 if (NewOptions < Option)
1170 RtlMoveMemory(NewOptions, Option, OptionLength * sizeof(CHAR));
1171 NewOptions += OptionLength;
1172 }
1173
1174 /* NUL-terminate */
1175 *NewOptions = ANSI_NULL;
1176}
1177
1180 IN ULONG Argc,
1181 IN PCHAR Argv[],
1182 IN PCHAR Envp[])
1183{
1185 PCSTR ArgValue;
1190 USHORT OperatingSystemVersion;
1191 PLOADER_PARAMETER_BLOCK LoaderBlock;
1192 CHAR BootPath[MAX_PATH];
1194 CHAR BootOptions[MAX_OPTIONS_LENGTH+1];
1195
1196 /* Retrieve the (mandatory) boot type */
1197 ArgValue = GetArgumentValue(Argc, Argv, "BootType");
1198 if (!ArgValue || !*ArgValue)
1199 {
1200 ERR("No 'BootType' value, aborting!\n");
1201 return EINVAL;
1202 }
1203
1204 /* Convert it to an OS version */
1205 if (_stricmp(ArgValue, "Windows") == 0 ||
1206 _stricmp(ArgValue, "Windows2003") == 0)
1207 {
1208 OperatingSystemVersion = _WIN32_WINNT_WS03;
1209 }
1210 else if (_stricmp(ArgValue, "WindowsNT40") == 0)
1211 {
1212 OperatingSystemVersion = _WIN32_WINNT_NT4;
1213 }
1214 else if (_stricmp(ArgValue, "WindowsVista") == 0)
1215 {
1216 OperatingSystemVersion = _WIN32_WINNT_VISTA;
1217 }
1218 else
1219 {
1220 ERR("Unknown 'BootType' value '%s', aborting!\n", ArgValue);
1221 return EINVAL;
1222 }
1223
1224 /* Retrieve the (mandatory) system partition */
1225 SystemPartition = GetArgumentValue(Argc, Argv, "SystemPartition");
1227 {
1228 ERR("No 'SystemPartition' specified, aborting!\n");
1229 return EINVAL;
1230 }
1231
1232 /* Let the user know we started loading */
1234 UiDrawStatusText("Loading...");
1235 UiDrawProgressBarCenter("Loading NT...");
1236
1237 /* Retrieve the system path */
1238 *BootPath = ANSI_NULL;
1239 ArgValue = GetArgumentValue(Argc, Argv, "SystemPath");
1240 if (ArgValue)
1241 RtlStringCbCopyA(BootPath, sizeof(BootPath), ArgValue);
1242
1243 /*
1244 * Check whether BootPath is a full path
1245 * and if not, create a full boot path.
1246 *
1247 * See FsOpenFile for the technique used.
1248 */
1249 if (strrchr(BootPath, ')') == NULL)
1250 {
1251 /* Temporarily save the boot path */
1252 RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
1253
1254 /* This is not a full path: prepend the SystemPartition */
1255 RtlStringCbCopyA(BootPath, sizeof(BootPath), SystemPartition);
1256
1257 /* Append a path separator if needed */
1258 if (*FilePath != '\\' && *FilePath != '/')
1259 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
1260
1261 /* Append the remaining path */
1262 RtlStringCbCatA(BootPath, sizeof(BootPath), FilePath);
1263 }
1264
1265 /* Append a path separator if needed */
1266 if (!*BootPath || BootPath[strlen(BootPath) - 1] != '\\')
1267 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
1268
1269 TRACE("BootPath: '%s'\n", BootPath);
1270
1271 /* Retrieve the boot options */
1272 *BootOptions = ANSI_NULL;
1273 ArgValue = GetArgumentValue(Argc, Argv, "Options");
1274 if (ArgValue && *ArgValue)
1275 RtlStringCbCopyA(BootOptions, sizeof(BootOptions), ArgValue);
1276 TRACE("BootOptions(1): '%s'\n", BootOptions);
1277
1278 /*
1279 * Set the "/HAL=" and "/KERNEL=" options if needed.
1280 * If already present on the standard "Options=" option line, they take
1281 * precedence over those passed via the separate "Hal=" and "Kernel="
1282 * options.
1283 */
1284 if (!NtLdrGetOption(BootOptions, "HAL="))
1285 {
1286 /*
1287 * Not found in the options, try to retrieve the
1288 * separate value and append it to the options.
1289 */
1290 ArgValue = GetArgumentValue(Argc, Argv, "Hal");
1291 if (ArgValue && *ArgValue)
1292 {
1293 RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /HAL=");
1294 RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
1295 }
1296 }
1297 if (!NtLdrGetOption(BootOptions, "KERNEL="))
1298 {
1299 /*
1300 * Not found in the options, try to retrieve the
1301 * separate value and append it to the options.
1302 */
1303 ArgValue = GetArgumentValue(Argc, Argv, "Kernel");
1304 if (ArgValue && *ArgValue)
1305 {
1306 RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /KERNEL=");
1307 RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
1308 }
1309 }
1310
1311 /* Append boot-time options */
1312 AppendBootTimeOptions(BootOptions, sizeof(BootOptions));
1313
1314 /* Post-process the boot options */
1315 NtLdrNormalizeOptions(BootOptions);
1316 TRACE("BootOptions(2): '%s'\n", BootOptions);
1317
1318 /* Check if a RAM disk file was given */
1319 FileName = NtLdrGetOptionEx(BootOptions, "RDPATH=", &FileNameLength);
1320 if (FileName && (FileNameLength >= 7))
1321 {
1322 /* Load the RAM disk */
1324 if (Status != ESUCCESS)
1325 {
1326 FileName += 7; FileNameLength -= 7;
1327 UiMessageBox("Failed to load RAM disk file '%.*s'",
1329 return Status;
1330 }
1331 }
1332
1333 /* Handle the SOS option */
1334 SosEnabled = !!NtLdrGetOption(BootOptions, "SOS");
1335 if (SosEnabled)
1336 UiResetForSOS();
1337
1338 /* Allocate and minimally-initialize the Loader Parameter Block */
1339 AllocateAndInitLPB(OperatingSystemVersion, &LoaderBlock);
1340
1341 /* Load the system hive */
1342 UiUpdateProgressBar(15, "Loading system hive...");
1343 Success = WinLdrInitSystemHive(LoaderBlock, BootPath, FALSE);
1344 TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
1345 /* Bail out if failure */
1346 if (!Success)
1347 return ENOEXEC;
1348
1349 /* Fixup the version number using data from the registry */
1350 if (OperatingSystemVersion == 0)
1351 OperatingSystemVersion = WinLdrDetectVersion();
1352 LoaderBlock->Extension->MajorVersion = (OperatingSystemVersion & 0xFF00) >> 8;
1353 LoaderBlock->Extension->MinorVersion = (OperatingSystemVersion & 0xFF);
1354
1355 /* Load NLS data, OEM font, and prepare boot drivers list */
1356 Success = WinLdrScanSystemHive(LoaderBlock, BootPath);
1357 TRACE("SYSTEM hive %s\n", (Success ? "scanned" : "not scanned"));
1358 /* Bail out if failure */
1359 if (!Success)
1360 return ENOEXEC;
1361
1362 /* Load the Firmware Errata file */
1363 Success = WinLdrInitErrataInf(LoaderBlock, OperatingSystemVersion, BootPath);
1364 TRACE("Firmware Errata file %s\n", (Success ? "loaded" : "not loaded"));
1365 /* Not necessarily fatal if not found - carry on going */
1366
1367 /* Finish loading */
1368 return LoadAndBootWindowsCommon(OperatingSystemVersion,
1369 LoaderBlock,
1370 BootOptions,
1372 BootPath);
1373}
1374
1377 _In_ USHORT OperatingSystemVersion,
1378 _In_ PLOADER_PARAMETER_BLOCK LoaderBlock,
1379 _In_ PCSTR BootOptions,
1381 _In_ PCSTR BootPath)
1382{
1383 PLOADER_PARAMETER_BLOCK LoaderBlockVA;
1385 PLDR_DATA_TABLE_ENTRY KernelDTE;
1387
1388 TRACE("LoadAndBootWindowsCommon()\n");
1389
1390 ASSERT(OperatingSystemVersion != 0);
1391
1392 /* Setup redirection support */
1393 WinLdrSetupEms(BootOptions);
1394
1395 /* Detect hardware */
1396 UiUpdateProgressBar(20, "Detecting hardware...");
1397 LoaderBlock->ConfigurationRoot = MachHwDetect(BootOptions);
1398
1399 /* Initialize the PE loader import-DLL callback, so that we can obtain
1400 * feedback (for example during SOS) on the PE images that get loaded. */
1402
1403 /* Load the operating system core: the Kernel, the HAL and the Kernel Debugger Transport DLL */
1404 Success = LoadWindowsCore(OperatingSystemVersion,
1405 LoaderBlock,
1406 BootOptions,
1407 BootPath,
1408 &KernelDTE);
1409 if (!Success)
1410 {
1411 /* Reset the PE loader import-DLL callback */
1413
1414 UiMessageBox("Error loading NTOS core.");
1415 return ENOEXEC;
1416 }
1417
1418 /* Cleanup INI file */
1419 IniCleanup();
1420
1421/****
1422 **** WE HAVE NOW REACHED THE POINT OF NO RETURN !!
1423 ****/
1424
1425 UiSetProgressBarSubset(40, 90); // NTOS goes from 25 to 75%
1426
1427 /* Load boot drivers */
1428 UiSetProgressBarText("Loading boot drivers...");
1429 Success = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
1430 TRACE("Boot drivers loading %s\n", Success ? "successful" : "failed");
1431
1432 UiSetProgressBarSubset(0, 100);
1433
1434 /* Reset the PE loader import-DLL callback */
1436
1437 /* Initialize Phase 1 - no drivers loading anymore */
1438 WinLdrInitializePhase1(OperatingSystemVersion,
1439 LoaderBlock,
1440 BootOptions,
1442 BootPath);
1443
1445
1446 /* Save entry-point pointer and Loader block VAs */
1448 LoaderBlockVA = PaToVa(LoaderBlock);
1449
1450 /* "Stop all motors", change videomode */
1452
1453 /* Show the "debug mode" notice if needed */
1454 /* Match KdInitSystem() conditions */
1455 if (!NtLdrGetOption(BootOptions, "CRASHDEBUG") &&
1456 !NtLdrGetOption(BootOptions, "NODEBUG") &&
1457 !!NtLdrGetOption(BootOptions, "DEBUG"))
1458 {
1459 /* Check whether there is a DEBUGPORT option */
1460 PCSTR DebugPort;
1461 ULONG DebugPortLength = 0;
1462 DebugPort = NtLdrGetOptionEx(BootOptions, "DEBUGPORT=", &DebugPortLength);
1463 if (DebugPort != NULL && DebugPortLength > 10)
1464 {
1465 /* Move to the debug port name */
1466 DebugPort += 10; DebugPortLength -= 10;
1467 }
1468 else
1469 {
1470 /* Default to COM */
1471 DebugPort = "COM"; DebugPortLength = 3;
1472 }
1473
1474 /* It is booting in debug mode, show the banner */
1475 TuiPrintf("You need to connect a debugger on port %.*s\n"
1476 "For more information, visit https://reactos.org/wiki/Debugging.\n",
1477 DebugPortLength, DebugPort);
1478 }
1479
1480 /* Debugging... */
1481 //DumpMemoryAllocMap();
1482
1483 /* Do the machine specific initialization */
1484 WinLdrSetupMachineDependent(LoaderBlock);
1485
1486 /* Map pages and create memory descriptors */
1487 WinLdrSetupMemoryLayout(LoaderBlock);
1488
1489 /* Set processor context */
1490 WinLdrSetProcessorContext(OperatingSystemVersion);
1491
1492 /* Save final value of LoaderPagesSpanned */
1493 LoaderBlock->Extension->LoaderPagesSpanned = MmGetLoaderPagesSpanned();
1494
1495 TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
1496 KiSystemStartup, LoaderBlockVA);
1497
1498 /* Zero KI_USER_SHARED_DATA page */
1499 RtlZeroMemory((PVOID)KI_USER_SHARED_DATA, MM_PAGE_SIZE);
1500
1501 WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
1502 WinLdrpDumpBootDriver(LoaderBlockVA);
1503#ifndef _M_AMD64
1504 WinLdrpDumpArcDisks(LoaderBlockVA);
1505#endif
1506
1507 /* Pass control */
1508 (*KiSystemStartup)(LoaderBlockVA);
1509
1510 UNREACHABLE; // return ESUCCESS;
1511}
1512
1513VOID
1515{
1516 PLIST_ENTRY NextMd;
1518
1519 NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1520
1521 while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1522 {
1524
1525 TRACE("BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage,
1526 MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType);
1527
1528 NextMd = MemoryDescriptor->ListEntry.Flink;
1529 }
1530}
1531
1532VOID
1534{
1535 PLIST_ENTRY NextBd;
1536 PBOOT_DRIVER_LIST_ENTRY BootDriver;
1537
1538 NextBd = LoaderBlock->BootDriverListHead.Flink;
1539
1540 while (NextBd != &LoaderBlock->BootDriverListHead)
1541 {
1542 BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
1543
1544 TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
1545 BootDriver->LdrEntry, &BootDriver->RegistryPath);
1546
1547 NextBd = BootDriver->Link.Flink;
1548 }
1549}
1550
1551VOID
1553{
1554 PLIST_ENTRY NextBd;
1555 PARC_DISK_SIGNATURE ArcDisk;
1556
1557 NextBd = LoaderBlock->ArcDiskInformation->DiskSignatureListHead.Flink;
1558
1559 while (NextBd != &LoaderBlock->ArcDiskInformation->DiskSignatureListHead)
1560 {
1561 ArcDisk = CONTAINING_RECORD(NextBd, ARC_DISK_SIGNATURE, ListEntry);
1562
1563 TRACE("ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
1564 ArcDisk->ArcName, ArcDisk->CheckSum, ArcDisk->Signature);
1565
1566 NextBd = ArcDisk->ListEntry.Flink;
1567 }
1568}
PCWSTR FilePath
PRTL_UNICODE_STRING_BUFFER Path
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1280
unsigned char BOOLEAN
Definition: actypes.h:127
VOID MachPrepareForReactOS(VOID)
Definition: arcemul.c:49
PCONFIGURATION_COMPONENT_DATA MachHwDetect(_In_opt_ PCSTR Options)
Definition: arcemul.c:44
VOID WinLdrSetProcessorContext(_In_ USHORT OperatingSystemVersion)
Definition: winldr.c:342
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:374
PSTR GetArgumentValue(_In_ ULONG Argc, _In_ PCHAR Argv[], _In_ PCSTR ArgumentName)
Definition: arcsupp.c:42
PPARTENTRY SystemPartition
Definition: reactos.c:50
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
#define UNIMPLEMENTED
Definition: ntoskrnl.c:15
ARC_STATUS RamDiskInitialize(IN BOOLEAN InitRamDisk, IN PCSTR LoadOptions OPTIONAL, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:229
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:462
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:219
ARC_STATUS ArcClose(_In_ ULONG FileId)
Definition: fs.c:409
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:448
VOID MmFreeMemory(PVOID MemoryPointer)
Definition: mm.c:215
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
PFN_NUMBER MmGetLoaderPagesSpanned(VOID)
Definition: mm.c:307
VOID UiSetProgressBarText(_In_ PCSTR ProgressText)
Definition: ui.c:476
VOID UiIndicateProgress(VOID)
Definition: ui.c:418
VOID UiDrawBackdrop(ULONG DrawHeight)
Definition: ui.c:233
VOID UiUpdateProgressBar(_In_ ULONG Percentage, _In_opt_ PCSTR ProgressText)
Definition: ui.c:454
VOID UiSetProgressBarSubset(_In_ ULONG Floor, _In_ ULONG Ceiling)
Definition: ui.c:439
ULONG UiGetScreenHeight(VOID)
Definition: ui.c:655
VOID UiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: ui.c:487
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:286
VOID UiResetForSOS(VOID)
Definition: ui.c:639
VOID UiMessageBox(_In_ PCSTR Format,...)
Definition: ui.c:359
HKEY CurrentControlSetKey
Definition: registry.c:34
#define RegCloseKey(hKey)
Definition: registry.h:49
#define _stricmp
Definition: cat.c:22
Definition: File.h:16
VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
Definition: conversion.c:51
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
#define BufferSize
Definition: mmc.h:75
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static const WCHAR SystemRoot[]
Definition: reg.c:38
static const WCHAR Description[]
Definition: oid.c:1266
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
#define MAX_PATH
Definition: compat.h:34
#define EINVAL
Definition: errno.h:44
#define ENOEXEC
Definition: errno.h:31
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
_ACRTIMP size_t __cdecl strcspn(const char *, const char *)
Definition: string.c:3493
_ACRTIMP char *__cdecl strstr(const char *, const char *)
Definition: string.c:3415
_ACRTIMP char *__cdecl strrchr(const char *, int)
Definition: string.c:3298
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
@ Success
Definition: eventcreate.c:712
struct _FileName FileName
Definition: fatprocs.h:897
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ HANDLE _In_ ULONG FileNameLength
Definition: fltkernel.h:1129
#define printf
Definition: freeldr.h:103
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
FxAutoRegKey hKey
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry)
VOID AppendBootTimeOptions(_Inout_z_bytecount_(BootOptionsSize) PSTR BootOptions, _In_ SIZE_T BootOptionsSize)
Definition: advopts.c:185
VOID IniCleanup(VOID)
Definition: inifile.c:243
#define ASSERT(a)
Definition: mode.c:44
ULONG_PTR KernelBase
Definition: halinit_mp.c:20
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define _Inout_
Definition: no_sal2.h:162
#define _Always_(a)
Definition: no_sal2.h:90
#define _Post_z_
Definition: no_sal2.h:508
#define _Out_
Definition: no_sal2.h:160
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define _Inout_updates_bytes_(s)
Definition: no_sal2.h:184
#define _Out_writes_bytes_(s)
Definition: no_sal2.h:178
#define UNREACHABLE
#define ANSI_NULL
#define MAX_OPTIONS_LENGTH
Definition: winldr.h:44
VOID(NTAPI * KERNEL_ENTRY_POINT)(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.h:13
BOOLEAN WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: wlmemory.c:174
BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot, IN BOOLEAN Setup)
Definition: wlregistry.c:125
BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot)
Definition: wlregistry.c:231
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
PCSTR NtLdrGetNextOption(IN OUT PCSTR *Options, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:16
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
DECLSPEC_NORETURN VOID NTAPI KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kiinit.c:485
PCONFIGURATION_COMPONENT_DATA NTAPI KeFindConfigurationEntry(_In_ PCONFIGURATION_COMPONENT_DATA Child, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_opt_ PULONG ComponentKey)
Definition: config.c:108
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
NTSTRSAFEAPI RtlStringCbCopyNA(_Out_writes_bytes_(cbDest) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:395
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
#define WINDOWS(string, interface)
Definition: osi.c:31
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
char CHAR
Definition: pedump.c:57
BOOLEAN PeLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH DirectoryPath, IN PLDR_DATA_TABLE_ENTRY ScanDTE)
Definition: peloader.c:629
VOID PeLdrFreeDataTableEntry(_In_ PLDR_DATA_TABLE_ENTRY Entry)
Definition: peloader.c:826
PVOID PeLdrInitSecurityCookie(_In_ PLDR_DATA_TABLE_ENTRY LdrEntry)
BOOLEAN PeLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH BaseDllName, IN PCCH FullDllName, IN PVOID BaseVA, OUT PLDR_DATA_TABLE_ENTRY *NewEntry)
Definition: peloader.c:709
BOOLEAN PeLdrCheckForLoadedDll(_Inout_ PLIST_ENTRY ModuleListHead, _In_ PCSTR DllName, _Out_ PLDR_DATA_TABLE_ENTRY *LoadedEntry)
Definition: peloader.c:586
FLDRAPI PELDR_IMPORTDLL_LOAD_CALLBACK PeLdrImportDllLoadCallback
Definition: peloader.c:30
BOOLEAN PeLdrLoadImage(_In_ PCSTR FilePath, _In_ TYPE_OF_MEMORY MemoryType, _Out_ PVOID *ImageBasePA)
Definition: peloader.c:1043
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
struct _CM_PARTIAL_RESOURCE_LIST * PCM_PARTIAL_RESOURCE_LIST
@ SystemClass
Definition: arc.h:99
@ ControllerClass
Definition: arc.h:103
@ ESUCCESS
Definition: arc.h:32
@ LoaderBootDriver
Definition: arc.h:304
@ LoaderSystemCode
Definition: arc.h:302
@ LoaderRegistryData
Definition: arc.h:312
@ LoaderHalCode
Definition: arc.h:303
@ LoaderSystemBlock
Definition: arc.h:294
ULONG ARC_STATUS
Definition: arc.h:4
@ ArcSystem
Definition: arc.h:113
@ MaximumType
Definition: arc.h:154
@ DisplayController
Definition: arc.h:132
struct _LOADER_PARAMETER_EXTENSION LOADER_PARAMETER_EXTENSION
@ OpenReadOnly
Definition: arc.h:65
enum _TYPE_OF_MEMORY TYPE_OF_MEMORY
_strlwr
Definition: string.h:231
#define KI_USER_SHARED_DATA
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
#define _WIN32_WINNT_WIN2K
Definition: sdkddkver.h:21
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
Entry
Definition: section.c:5210
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY DiskSignatureListHead
Definition: arc.h:356
CHAR ArcName[MAX_PATH]
Definition: winldr.h:37
ARC_DISK_SIGNATURE DiskSignature
Definition: winldr.h:36
ULONG CheckSum
Definition: arc.h:346
LIST_ENTRY ListEntry
Definition: arc.h:343
PCHAR ArcName
Definition: arc.h:345
ULONG Signature
Definition: arc.h:344
Definition: arc.h:334
LIST_ENTRY Link
Definition: arc.h:335
UNICODE_STRING RegistryPath
Definition: arc.h:337
UNICODE_STRING FilePath
Definition: arc.h:336
struct _LDR_DATA_TABLE_ENTRY * LdrEntry
Definition: arc.h:338
UNICODE_STRING Group
Definition: cmboot.h:16
BOOT_DRIVER_LIST_ENTRY ListEntry
Definition: cmboot.h:15
UNICODE_STRING Name
Definition: cmboot.h:17
ReactOS Framebuffer-specific video device configuration data.
Definition: framebuf.h:35
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384::@393 DeviceSpecificData
Definition: btrfs_drv.h:1876
PVOID EntryPoint
Definition: ntddk_ex.h:203
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY BootDriverListHead
Definition: arc.h:822
FIRMWARE_INFORMATION_LOADER_BLOCK FirmwareInformation
Definition: arc.h:868
LIST_ENTRY LoadOrderListHead
Definition: arc.h:820
PARC_DISK_INFORMATION ArcDiskInformation
Definition: arc.h:847
PNLS_DATA_BLOCK NlsData
Definition: arc.h:846
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:857
LIST_ENTRY MemoryDescriptorListHead
Definition: arc.h:821
CHAR NtHalPathName[MAX_PATH+1]
Definition: winldr.h:57
ARC_DISK_INFORMATION ArcDiskInformation
Definition: winldr.h:58
CHAR NtBootPathName[MAX_PATH+1]
Definition: winldr.h:56
NLS_DATA_BLOCK NlsDataBlock
Definition: winldr.h:52
LOADER_PARAMETER_EXTENSION Extension
Definition: winldr.h:49
CHAR ArcBootDeviceName[MAX_PATH+1]
Definition: winldr.h:54
HEADLESS_LOADER_BLOCK HeadlessLoaderBlock
Definition: winldr.h:51
LOADER_PARAMETER_BLOCK LoaderBlock
Definition: winldr.h:48
LOADER_PERFORMANCE_DATA LoaderPerformanceData
Definition: winldr.h:59
CHAR ArcHalDeviceName[MAX_PATH+1]
Definition: winldr.h:55
CHAR LoadOptions[MAX_OPTIONS_LENGTH+1]
Definition: winldr.h:53
PCHAR ArcSetupDeviceName
Definition: setupblk.h:112
INT TuiPrintf(_In_ PCSTR Format,...)
Definition: tui.c:39
uint32_t * PULONG
Definition: typedefs.h:59
char * PSTR
Definition: typedefs.h:51
const uint16_t * PCWSTR
Definition: typedefs.h:57
#define NTAPI
Definition: typedefs.h:36
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
const char * PCSTR
Definition: typedefs.h:52
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define IN
Definition: typedefs.h:39
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
static int Link(const char **args)
Definition: vfdcmd.c:2414
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3540
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
Definition: wdfresource.h:309
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR MemoryDescriptor
Definition: wdfusb.h:1339
BOOLEAN VirtualBias
Definition: winldr.c:33
VOID WinLdrSetupEms(_In_ PCSTR BootOptions)
Definition: headless.c:232
static BOOLEAN LoadWindowsCore(IN USHORT OperatingSystemVersion, IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR BootOptions, IN PCSTR BootPath, IN OUT PLDR_DATA_TABLE_ENTRY *KernelDTE)
Definition: winldr.c:737
VOID NtLdrNormalizeOptions(_Inout_ PSTR LoadOptions)
Normalize in-place the NT boot options by removing any leading '/', normalizing TABs to spaces,...
Definition: winldr.c:1151
BOOLEAN WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootPath)
Definition: winldr.c:389
VOID WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1552
BOOLEAN IsAcpiPresent(VOID)
Definition: hwacpi.c:28
ARC_STATUS LoadAndBootWindows(IN ULONG Argc, IN PCHAR Argv[], IN PCHAR Envp[])
Definition: winldr.c:1179
BOOLEAN BootLogo
Definition: winldr.c:36
BOOLEAN NoExecuteEnabled
Definition: winldr.c:40
ULONG ArcGetDiskCount(VOID)
Definition: archwsup.c:111
VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1514
VOID WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1533
VOID NtLdrOutputLoadMsg(_In_ PCSTR FileName, _In_opt_ PCSTR Description)
Definition: winldr.c:55
static PVOID LoadModule(_Inout_ PLIST_ENTRY LoadOrderListHead, _In_ PCSTR Path, _In_ PCSTR File, _In_ PCSTR ImportName, _In_ TYPE_OF_MEMORY MemoryType, _Out_ PLDR_DATA_TABLE_ENTRY *Dte, _In_ ULONG Percentage)
Definition: winldr.c:526
static VOID NtLdrDetectBootVid(_In_ PCONFIGURATION_COMPONENT_DATA ConfigTree, _Out_writes_bytes_(BootVidNameSize) _Always_(_Post_z_) PSTR BootVidName, _In_ SIZE_T BootVidNameSize)
Definition: winldr.c:630
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:450
USHORT WinLdrDetectVersion(VOID)
Definition: winldr.c:507
static BOOLEAN WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead, PCSTR BootPath, PUNICODE_STRING FilePath, ULONG Flags, PLDR_DATA_TABLE_ENTRY *DriverDTE)
Definition: winldr.c:301
BOOLEAN SafeBoot
Definition: winldr.c:35
PARC_DISK_SIGNATURE_EX ArcGetDiskInfo(ULONG Index)
Definition: archwsup.c:116
static VOID WinLdrInitializePhase1(_In_ USHORT OperatingSystemVersion, _In_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ PCSTR BootOptions, _In_ PCSTR SystemPartition, _In_ PCSTR BootPath)
Definition: winldr.c:125
static BOOLEAN WinLdrInitErrataInf(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN USHORT OperatingSystemVersion, IN PCSTR SystemRoot)
Definition: winldr.c:1086
PCWSTR BootFileSystem
Definition: winldr.c:31
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:33
VOID DumpMemoryAllocMap(VOID)
ARC_STATUS LoadAndBootWindowsCommon(_In_ USHORT OperatingSystemVersion, _In_ PLOADER_PARAMETER_BLOCK LoaderBlock, _In_ PCSTR BootOptions, _In_ PCSTR SystemPartition, _In_ PCSTR BootPath)
Definition: winldr.c:1376
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
Definition: winldr.c:30
static VOID NTAPI NtLdrImportDllLoadCallback(_In_ PCSTR FileName)
Definition: winldr.c:48
BOOLEAN SosEnabled
Definition: winldr.c:34
VOID AllocateAndInitLPB(IN USHORT VersionToBoot, OUT PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
Definition: winldr.c:80
BOOLEAN WinLdrTerminalConnected
Definition: headless.c:34
#define RegOpenKey
Definition: winreg.h:551
#define RegQueryValue
Definition: winreg.h:555
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170