ReactOS 0.4.16-dev-2473-gb34a1f1
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 /* Init three critical lists, used right away */
112
113 *OutLoaderBlock = LoaderBlock;
114}
115
116// Init "phase 1"
117VOID
121 PCSTR BootPath,
122 USHORT VersionToBoot)
123{
124 /*
125 * Examples of correct options and paths:
126 * CHAR Options[] = "/DEBUGPORT=COM1 /BAUDRATE=115200";
127 * CHAR Options[] = "/NODEBUG";
128 * CHAR SystemRoot[] = "\\WINNT\\";
129 * CHAR ArcBoot[] = "multi(0)disk(0)rdisk(0)partition(1)";
130 */
131
132 PSTR LoadOptions, NewLoadOptions;
133 CHAR HalPath[] = "\\";
134 CHAR ArcBoot[MAX_PATH+1];
135 CHAR MiscFiles[MAX_PATH+1];
136 ULONG i;
137 ULONG_PTR PathSeparator;
139
140 /* Construct SystemRoot and ArcBoot from SystemPath */
141 PathSeparator = strstr(BootPath, "\\") - BootPath;
142 RtlStringCbCopyNA(ArcBoot, sizeof(ArcBoot), BootPath, PathSeparator);
143
144 TRACE("ArcBoot: '%s'\n", ArcBoot);
145 TRACE("SystemRoot: '%s'\n", SystemRoot);
146 TRACE("Options: '%s'\n", Options);
147
148 /* Fill ARC BootDevice */
151 LoaderBlock->ArcBootDeviceName = PaToVa(LoaderBlock->ArcBootDeviceName);
152
153//
154// IMPROVE!!
155// SetupBlock->ArcSetupDeviceName must be the path to the setup **SOURCE**,
156// and not the setup boot path. Indeed they may differ!!
157//
158 if (LoaderBlock->SetupLdrBlock)
159 {
160 PSETUP_LOADER_BLOCK SetupBlock = LoaderBlock->SetupLdrBlock;
161
162 /* Adjust the ARC path in the setup block - Matches ArcBoot path */
164 SetupBlock->ArcSetupDeviceName = PaToVa(SetupBlock->ArcSetupDeviceName);
165
166 /* Convert the setup block pointer */
167 LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
168 }
169
170 /* Fill ARC HalDevice, it matches ArcBoot path */
172 LoaderBlock->ArcHalDeviceName = PaToVa(LoaderBlock->ArcHalDeviceName);
173
174 /* Fill SystemRoot */
177 LoaderBlock->NtBootPathName = PaToVa(LoaderBlock->NtBootPathName);
178
179 /* Fill NtHalPathName */
181 RtlStringCbCopyA(LoaderBlock->NtHalPathName, sizeof(WinLdrSystemBlock->NtHalPathName), HalPath);
182 LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName);
183
184 /* Fill LoadOptions and strip the '/' switch symbol in front of each option */
185 NewLoadOptions = LoadOptions = LoaderBlock->LoadOptions = WinLdrSystemBlock->LoadOptions;
187
188 do
189 {
190 while (*LoadOptions == '/')
191 ++LoadOptions;
192
193 *NewLoadOptions++ = *LoadOptions;
194 } while (*LoadOptions++);
195
196 LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions);
197
198 /* ARC devices */
201
202 /* Convert ARC disk information from freeldr to a correct format */
203 ULONG DiscCount = ArcGetDiskCount();
204 for (i = 0; i < DiscCount; i++)
205 {
206 PARC_DISK_SIGNATURE_EX ArcDiskSig;
207
208 /* Allocate the ARC structure */
209 ArcDiskSig = FrLdrHeapAlloc(sizeof(ARC_DISK_SIGNATURE_EX), 'giSD');
210 if (!ArcDiskSig)
211 {
212 ERR("Failed to allocate ARC structure! Ignoring remaining ARC disks. (i = %lu, DiskCount = %lu)\n",
213 i, DiscCount);
214 break;
215 }
216
217 /* Copy the data over */
219
220 /* Set the ARC Name pointer */
221 ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName);
222
223 /* Insert into the list */
225 &ArcDiskSig->DiskSignature.ListEntry);
226 }
227
228 /* Convert all lists to Virtual address */
229
230 /* Convert the ArcDisks list to virtual address */
232 LoaderBlock->ArcDiskInformation = PaToVa(LoaderBlock->ArcDiskInformation);
233
234 /* Convert configuration entries to VA */
236 LoaderBlock->ConfigurationRoot = PaToVa(LoaderBlock->ConfigurationRoot);
237
238 /* Convert all DTE into virtual addresses */
239 List_PaToVa(&LoaderBlock->LoadOrderListHead);
240
241 /* This one will be converted right before switching to virtual paging mode */
242 //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
243
244 /* Convert list of boot drivers */
245 List_PaToVa(&LoaderBlock->BootDriverListHead);
246
247 Extension = LoaderBlock->Extension;
248
249 /* FIXME! HACK value for docking profile */
250 Extension->Profile.Status = 2;
251
252 /* Check if FreeLdr detected a ACPI table */
253 if (IsAcpiPresent())
254 {
255 /* Set the pointer to something for compatibility */
256 Extension->AcpiTable = (PVOID)1;
257 // FIXME: Extension->AcpiTableSize;
258 }
259
260 if (VersionToBoot >= _WIN32_WINNT_VISTA)
261 {
262 Extension->BootViaWinload = 1;
263 Extension->LoaderPerformanceData = PaToVa(&WinLdrSystemBlock->LoaderPerformanceData);
264
265 InitializeListHead(&Extension->BootApplicationPersistentData);
266 List_PaToVa(&Extension->BootApplicationPersistentData);
267 }
268
269#ifdef _M_IX86
270 /* Set headless block pointer */
272 {
273 Extension->HeadlessLoaderBlock = &WinLdrSystemBlock->HeadlessLoaderBlock;
274 RtlCopyMemory(Extension->HeadlessLoaderBlock,
276 sizeof(HEADLESS_LOADER_BLOCK));
277 Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
278 }
279#endif
280 /* Load drivers database */
281 RtlStringCbCopyA(MiscFiles, sizeof(MiscFiles), BootPath);
282 RtlStringCbCatA(MiscFiles, sizeof(MiscFiles), "AppPatch\\drvmain.sdb");
283 Extension->DrvDBImage = PaToVa(WinLdrLoadModule(MiscFiles,
284 &Extension->DrvDBSize,
286
287 /* Convert the extension block pointer */
288 LoaderBlock->Extension = PaToVa(LoaderBlock->Extension);
289
290 TRACE("WinLdrInitializePhase1() completed\n");
291}
292
293static BOOLEAN
295 PCSTR BootPath,
297 ULONG Flags,
298 PLDR_DATA_TABLE_ENTRY *DriverDTE)
299{
300 CHAR FullPath[1024];
301 CHAR DriverPath[1024];
302 CHAR DllName[1024];
303 PCHAR DriverNamePos;
305 PVOID DriverBase = NULL;
306
307 // Separate the path to file name and directory path
308 RtlStringCbPrintfA(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
309 DriverNamePos = strrchr(DriverPath, '\\');
310 if (DriverNamePos != NULL)
311 {
312 // Copy the name
313 RtlStringCbCopyA(DllName, sizeof(DllName), DriverNamePos+1);
314
315 // Cut out the name from the path
316 *(DriverNamePos+1) = ANSI_NULL;
317 }
318 else
319 {
320 // There is no directory in the path
321 RtlStringCbCopyA(DllName, sizeof(DllName), DriverPath);
322 *DriverPath = ANSI_NULL;
323 }
324
325 TRACE("DriverPath: '%s', DllName: '%s', LPB\n", DriverPath, DllName);
326
327 // Check if driver is already loaded
328 Success = PeLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
329 if (Success)
330 {
331 // We've got the pointer to its DTE, just return success
332 return TRUE;
333 }
334
335 // It's not loaded, we have to load it
336 RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
337
338 NtLdrOutputLoadMsg(FullPath, NULL);
339 Success = PeLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
340 if (!Success)
341 {
342 ERR("PeLdrLoadImage('%s') failed\n", DllName);
343 return FALSE;
344 }
345
346 // Allocate a DTE for it
347 Success = PeLdrAllocateDataTableEntry(LoadOrderListHead,
348 DllName,
349 DllName,
350 PaToVa(DriverBase),
351 DriverDTE);
352 if (!Success)
353 {
354 /* Cleanup and bail out */
355 ERR("PeLdrAllocateDataTableEntry('%s') failed\n", DllName);
356 MmFreeMemory(DriverBase);
357 return FALSE;
358 }
359
360 /* Init security cookie */
361 PeLdrInitSecurityCookie(*DriverDTE);
362
363 // Modify any flags, if needed
364 (*DriverDTE)->Flags |= Flags;
365
366 // Look for any dependencies it may have, and load them too
367 RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%s", BootPath, DriverPath);
368 Success = PeLdrScanImportDescriptorTable(LoadOrderListHead, FullPath, *DriverDTE);
369 if (!Success)
370 {
371 /* Cleanup and bail out */
372 ERR("PeLdrScanImportDescriptorTable('%s') failed\n", FullPath);
373 PeLdrFreeDataTableEntry(*DriverDTE);
374 MmFreeMemory(DriverBase);
375 return FALSE;
376 }
377
378 return TRUE;
379}
380
383 PCSTR BootPath)
384{
385 PLIST_ENTRY NextBd;
386 PBOOT_DRIVER_NODE DriverNode;
387 PBOOT_DRIVER_LIST_ENTRY BootDriver;
389 BOOLEAN ret = TRUE;
390
391 /* Walk through the boot drivers list */
392 NextBd = LoaderBlock->BootDriverListHead.Flink;
393 while (NextBd != &LoaderBlock->BootDriverListHead)
394 {
395 DriverNode = CONTAINING_RECORD(NextBd,
397 ListEntry.Link);
398 BootDriver = &DriverNode->ListEntry;
399
400 /* Get the next list entry as we may remove the current one on failure */
401 NextBd = BootDriver->Link.Flink;
402
403 TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n",
404 &BootDriver->FilePath, BootDriver->LdrEntry,
405 &BootDriver->RegistryPath);
406
407 // Paths are relative (FIXME: Are they always relative?)
408
409 /* Load it */
412 BootPath,
413 &BootDriver->FilePath,
414 0,
415 &BootDriver->LdrEntry);
416 if (Success)
417 {
418 /* Convert the addresses to VA since we are not going to use them anymore */
419 BootDriver->RegistryPath.Buffer = PaToVa(BootDriver->RegistryPath.Buffer);
420 BootDriver->FilePath.Buffer = PaToVa(BootDriver->FilePath.Buffer);
421 BootDriver->LdrEntry = PaToVa(BootDriver->LdrEntry);
422
423 if (DriverNode->Group.Buffer)
424 DriverNode->Group.Buffer = PaToVa(DriverNode->Group.Buffer);
425 DriverNode->Name.Buffer = PaToVa(DriverNode->Name.Buffer);
426 }
427 else
428 {
429 /* Loading failed: cry loudly */
430 ERR("Cannot load boot driver '%wZ'!\n", &BootDriver->FilePath);
431 UiMessageBox("Cannot load boot driver '%wZ'!", &BootDriver->FilePath);
432 ret = FALSE;
433
434 /* Remove it from the list and try to continue */
435 RemoveEntryList(&BootDriver->Link);
436 }
437 }
438
439 return ret;
440}
441
442PVOID
444 PULONG Size,
445 TYPE_OF_MEMORY MemoryType)
446{
447 ULONG FileId;
448 PVOID PhysicalBase;
453
454 *Size = 0;
455
456 /* Open the image file */
459 if (Status != ESUCCESS)
460 {
461 /* In case of errors, we just return, without complaining to the user */
462 WARN("Error while opening '%s', Status: %u\n", ModuleName, Status);
463 return NULL;
464 }
465
466 /* Retrieve its size */
468 if (Status != ESUCCESS)
469 {
470 ArcClose(FileId);
471 return NULL;
472 }
473 FileSize = FileInfo.EndingAddress.LowPart;
474 *Size = FileSize;
475
476 /* Allocate memory */
477 PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);
478 if (PhysicalBase == NULL)
479 {
480 ERR("Could not allocate memory for '%s'\n", ModuleName);
481 ArcClose(FileId);
482 return NULL;
483 }
484
485 /* Load the whole file */
486 Status = ArcRead(FileId, PhysicalBase, FileSize, &BytesRead);
487 ArcClose(FileId);
488 if (Status != ESUCCESS)
489 {
490 WARN("Error while reading '%s', Status: %u\n", ModuleName, Status);
491 return NULL;
492 }
493
494 TRACE("Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize);
495
496 return PhysicalBase;
497}
498
499USHORT
501{
502 LONG rc;
503 HKEY hKey;
504
505 rc = RegOpenKey(CurrentControlSetKey, L"Control\\Terminal Server", &hKey);
506 if (rc != ERROR_SUCCESS)
507 {
508 /* Key doesn't exist; assume NT 4.0 */
509 return _WIN32_WINNT_NT4;
510 }
512
513 /* We may here want to read the value of ProductVersion */
514 return _WIN32_WINNT_WS03;
515}
516
517static
518PVOID
520 _Inout_ PLIST_ENTRY LoadOrderListHead,
523 _In_ PCSTR ImportName, // BaseDllName
524 _In_ TYPE_OF_MEMORY MemoryType,
526 _In_ ULONG Percentage)
527{
529 CHAR FullFileName[MAX_PATH];
530 CHAR ProgressString[256];
532
533 RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", File);
534 UiUpdateProgressBar(Percentage, ProgressString);
535
536 RtlStringCbCopyA(FullFileName, sizeof(FullFileName), Path);
537 RtlStringCbCatA(FullFileName, sizeof(FullFileName), File);
538
539 NtLdrOutputLoadMsg(FullFileName, NULL);
540 Success = PeLdrLoadImage(FullFileName, MemoryType, &BaseAddress);
541 if (!Success)
542 {
543 ERR("PeLdrLoadImage('%s') failed\n", File);
544 return NULL;
545 }
546 TRACE("%s loaded successfully at %p\n", File, BaseAddress);
547
548 Success = PeLdrAllocateDataTableEntry(LoadOrderListHead,
549 ImportName,
550 FullFileName,
552 Dte);
553 if (!Success)
554 {
555 /* Cleanup and bail out */
556 ERR("PeLdrAllocateDataTableEntry('%s') failed\n", FullFileName);
558 return NULL;
559 }
560
561 /* Init security cookie */
563
564 return BaseAddress;
565}
566
567#ifdef _M_IX86
568static
570WinLdrIsPaeSupported(
571 _In_ USHORT OperatingSystemVersion,
572 _In_ PLOADER_PARAMETER_BLOCK LoaderBlock,
573 _In_ PCSTR BootOptions,
574 _In_ PCSTR HalFileName,
575 _Inout_updates_bytes_(KernelFileNameSize) _Always_(_Post_z_)
576 PSTR KernelFileName,
577 _In_ SIZE_T KernelFileNameSize)
578{
579 BOOLEAN PaeEnabled = FALSE;
580 BOOLEAN PaeDisabled = FALSE;
582
583 if ((OperatingSystemVersion > _WIN32_WINNT_NT4) &&
584 NtLdrGetOption(BootOptions, "PAE"))
585 {
586 /* We found the PAE option */
587 PaeEnabled = TRUE;
588 }
589
590 Result = PaeEnabled;
591
592 if ((OperatingSystemVersion > _WIN32_WINNT_WIN2K) &&
593 NtLdrGetOption(BootOptions, "NOPAE"))
594 {
595 PaeDisabled = TRUE;
596 }
597
598 if (SafeBoot)
599 PaeDisabled = TRUE;
600
601 TRACE("PaeEnabled %X, PaeDisabled %X\n", PaeEnabled, PaeDisabled);
602
603 if (PaeDisabled)
604 Result = FALSE;
605
606 /* Enable PAE if DEP is enabled */
608 Result = TRUE;
609
610 // TODO: checks for CPU support, hotplug memory support ... other tests
611 // TODO: select kernel name ("ntkrnlpa.exe" or "ntoskrnl.exe"), or,
612 // if KernelFileName is a user-specified kernel file, check whether it
613 // has, if PAE needs to be enabled, the IMAGE_FILE_LARGE_ADDRESS_AWARE
614 // Characteristics bit set, and that the HAL image has a similar support.
615
617
618 return Result;
619}
620#endif /* _M_IX86 */
621
622static VOID
625 _Out_writes_bytes_(BootVidNameSize) _Always_(_Post_z_)
626 PSTR BootVidName,
627 _In_ SIZE_T BootVidNameSize)
628{
629 /* NOTE: The following array should instead be read from txtsetup.sif */
630 static const struct
631 {
632 PCSTR SystemSubId;
634 } BootVidNames[] =
635 {
636#if defined(_M_IX86) && !defined(UEFIBOOT)
637 {"PC-98", "pc98bvid.dll"},
638 {"Xbox", "xboxbvid.dll"},
639#endif
640 {"EFI", "lfbbvid.dll"},
641 };
642
643 /* Default BootVid file name */
644 RtlStringCbCopyA(BootVidName, BootVidNameSize, "bootvid.dll");
645
646 /* Attempt auto-detection by System ID */
648 Entry = KeFindConfigurationEntry(ConfigTree,
650 ArcSystem,
651 NULL);
652 if (!Entry)
653 {
654 /* No SystemClass ArcSystem entry, retry with hack */
655 Entry = KeFindConfigurationEntry(ConfigTree,
657 MaximumType, // HACK for non-ARC machines
658 NULL);
659 }
660 if (Entry)
661 {
662 // Entry->ComponentEntry.IdentifierLength;
663 TRACE("ARC System ID: '%s'\n", Entry->ComponentEntry.Identifier);
664
665 /* Look up the name */
666 for (ULONG i = 0; i < RTL_NUMBER_OF(BootVidNames); ++i)
667 {
668 if (strstr(Entry->ComponentEntry.Identifier, BootVidNames[i].SystemSubId))
669 {
670 RtlStringCbCopyA(BootVidName, BootVidNameSize, BootVidNames[i].ModuleName);
671 break;
672 }
673 }
674 }
675 /* Special-case detection if the display controller contains
676 * a DeviceSpecific CM_FRAMEBUF_DEVICE_DATA resource */
677 Entry = KeFindConfigurationEntry(ConfigTree,
680 NULL);
681 if (Entry)
682 {
683 /* Cast to PCM_PARTIAL_RESOURCE_LIST to access
684 * the common Version and Revision fields */
686 (PCM_PARTIAL_RESOURCE_LIST)Entry->ConfigurationData;
687 ULONG ConfigurationDataLength =
688 Entry->ComponentEntry.ConfigurationDataLength;
689
690 // Entry->ComponentEntry.IdentifierLength;
691 TRACE("Display: '%s'\n", Entry->ComponentEntry.Identifier);
692
693 /* The configuration data length must be valid.
694 * The Version/Revision must be greater than or equal to 1.2
695 * in order to describe a valid new configuration data. */
696 if (Entry->ConfigurationData &&
697 (ConfigurationDataLength >= sizeof(CM_PARTIAL_RESOURCE_LIST)) &&
698 ( (ResourceList->Version > 1) ||
699 ((ResourceList->Version == 1) && (ResourceList->Revision > 1)) ))
700 {
701 /* Try to find the DeviceSpecific resource */
702 PCM_PARTIAL_RESOURCE_DESCRIPTOR DeviceSpecific = NULL;
703 for (ULONG i = 0; i < ResourceList->Count; ++i)
704 {
706 &ResourceList->PartialDescriptors[i];
708 {
709 /* NOTE: This descriptor *MUST* be the last one.
710 * The actual device data follows the descriptor. */
711 ASSERT(i == ResourceList->Count - 1);
712 DeviceSpecific = Descriptor;
713 break;
714 }
715 }
716
717 /* Check whether the resource describes framebuffer information */
718 if (DeviceSpecific &&
719 (DeviceSpecific->u.DeviceSpecificData.DataSize >= sizeof(CM_FRAMEBUF_DEVICE_DATA)))
720 {
721 /* It does, use the Linear FrameBuffer Boot Video Driver instead */
722 RtlStringCbCopyA(BootVidName, BootVidNameSize, "lfbbvid.dll");
723 }
724 }
725 }
726}
727
728static
730LoadWindowsCore(IN USHORT OperatingSystemVersion,
731 IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
732 IN PCSTR BootOptions,
733 IN PCSTR BootPath,
734 IN OUT PLDR_DATA_TABLE_ENTRY* KernelDTE)
735{
737 PCSTR Option;
738 ULONG OptionLength;
739 PVOID KernelBase, HalBase, KdDllBase = NULL, BootVidBase = NULL;
740 PLDR_DATA_TABLE_ENTRY HalDTE, KdDllDTE = NULL, BootVidDTE = NULL;
742 CHAR DirPath[MAX_PATH];
743 CHAR HalFileName[MAX_PATH];
744 CHAR KernelFileName[MAX_PATH];
745 CHAR KdDllName[MAX_PATH];
746 CHAR BootVidName[MAX_PATH];
747
748 /* Initialize SystemRoot\System32 path */
749 RtlStringCbCopyA(DirPath, sizeof(DirPath), BootPath);
750 RtlStringCbCatA(DirPath, sizeof(DirPath), "system32\\");
751
752 /* Parse the boot options */
753 TRACE("LoadWindowsCore: BootOptions '%s'\n", BootOptions);
754
755#ifdef _M_IX86
756 if (NtLdrGetOption(BootOptions, "3GB"))
757 {
758 /* We found the 3GB option. */
759 FIXME("LoadWindowsCore: 3GB - TRUE (not implemented)\n");
761 }
762 // TODO: "USERVA=" for XP/2k3
763#endif
764
765 if ((OperatingSystemVersion > _WIN32_WINNT_NT4) &&
766 (NtLdrGetOption(BootOptions, "SAFEBOOT") ||
767 NtLdrGetOption(BootOptions, "SAFEBOOT:")))
768 {
769 /* We found the SAFEBOOT option. */
770 FIXME("LoadWindowsCore: SAFEBOOT - TRUE (not implemented)\n");
771 SafeBoot = TRUE;
772 }
773
774 if ((OperatingSystemVersion > _WIN32_WINNT_WIN2K) &&
775 NtLdrGetOption(BootOptions, "BOOTLOGO"))
776 {
777 /* We found the BOOTLOGO option. */
778 FIXME("LoadWindowsCore: BOOTLOGO - TRUE (not implemented)\n");
779 BootLogo = TRUE;
780 }
781
782 /* Check the (NO)EXECUTE options */
783 if ((OperatingSystemVersion > _WIN32_WINNT_WIN2K) &&
784 !LoaderBlock->SetupLdrBlock)
785 {
786 /* Disable NX by default on x86, otherwise enable it */
787#ifdef _M_IX86
789#else
791#endif
792
793#ifdef _M_IX86
794 /* Check the options in decreasing order of precedence */
795 if (NtLdrGetOption(BootOptions, "NOEXECUTE=OPTIN") ||
796 NtLdrGetOption(BootOptions, "NOEXECUTE=OPTOUT") ||
797 NtLdrGetOption(BootOptions, "NOEXECUTE=ALWAYSON"))
798 {
800 }
801 else if (NtLdrGetOption(BootOptions, "NOEXECUTE=ALWAYSOFF"))
803 else
804#else
805 /* Only the following two options really apply for x64 and other platforms */
806#endif
807 if (NtLdrGetOption(BootOptions, "NOEXECUTE"))
809 else if (NtLdrGetOption(BootOptions, "EXECUTE"))
811
812#ifdef _M_IX86
813 /* Disable DEP in SafeBoot mode for x86 only */
814 if (SafeBoot)
816#endif
817 }
818 TRACE("NoExecuteEnabled %X\n", NoExecuteEnabled);
819
820 /*
821 * Select the HAL and KERNEL file names.
822 * Check for any "/HAL=" or "/KERNEL=" override option.
823 *
824 * See the following links to know how the file names are actually chosen:
825 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/detecthal.htm
826 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/hal.htm
827 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/kernel.htm
828 */
829 /* Default HAL and KERNEL file names */
830 RtlStringCbCopyA(HalFileName , sizeof(HalFileName) , "hal.dll");
831 RtlStringCbCopyA(KernelFileName, sizeof(KernelFileName), "ntoskrnl.exe");
832
833 Option = NtLdrGetOptionEx(BootOptions, "HAL=", &OptionLength);
834 if (Option && (OptionLength > 4))
835 {
836 /* Retrieve the HAL file name */
837 Option += 4; OptionLength -= 4;
838 RtlStringCbCopyNA(HalFileName, sizeof(HalFileName), Option, OptionLength);
839 _strlwr(HalFileName);
840 }
841
842 Option = NtLdrGetOptionEx(BootOptions, "KERNEL=", &OptionLength);
843 if (Option && (OptionLength > 7))
844 {
845 /* Retrieve the KERNEL file name */
846 Option += 7; OptionLength -= 7;
847 RtlStringCbCopyNA(KernelFileName, sizeof(KernelFileName), Option, OptionLength);
848 _strlwr(KernelFileName);
849 }
850
851#ifdef _M_IX86
852 /* Check for PAE support and select the adequate kernel image */
853 PaeModeOn = WinLdrIsPaeSupported(OperatingSystemVersion,
854 LoaderBlock,
855 BootOptions,
856 HalFileName,
857 KernelFileName,
858 sizeof(KernelFileName));
859 if (PaeModeOn) FIXME("WinLdrIsPaeSupported: PaeModeOn\n");
860#endif
861
862 TRACE("HAL file = '%s' ; Kernel file = '%s'\n", HalFileName, KernelFileName);
863
864 /*
865 * Load the core NT files: Kernel, HAL and KD transport DLL.
866 * Cheat about their base DLL name so as to satisfy the imports/exports,
867 * even if the corresponding underlying files do not have the same names
868 * -- this happens e.g. with UP vs. MP kernel, standard vs. ACPI hal, or
869 * different KD transport DLLs.
870 */
871
872 /* Load the Kernel */
873 KernelBase = LoadModule(&LoaderBlock->LoadOrderListHead,
874 DirPath, KernelFileName,
875 "ntoskrnl.exe", LoaderSystemCode,
876 KernelDTE, 30);
877 if (!KernelBase)
878 {
879 ERR("LoadModule('%s') failed\n", KernelFileName);
880 UiMessageBox("Could not load %s", KernelFileName);
881 return FALSE;
882 }
883
884 /* Load the HAL */
885 HalBase = LoadModule(&LoaderBlock->LoadOrderListHead,
886 DirPath, HalFileName,
887 "hal.dll", LoaderHalCode,
888 &HalDTE, 35);
889 if (!HalBase)
890 {
891 ERR("LoadModule('%s') failed\n", HalFileName);
892 UiMessageBox("Could not load %s", HalFileName);
893 PeLdrFreeDataTableEntry(*KernelDTE);
895 return FALSE;
896 }
897
898 /* Load the Kernel Debugger Transport DLL */
899 if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
900 {
901 /*
902 * According to http://www.nynaeve.net/?p=173 :
903 * "[...] Another enhancement that could be done Microsoft-side would be
904 * a better interface for replacing KD transport modules. Right now, due
905 * to the fact that ntoskrnl is static linked to KDCOM.DLL, the OS loader
906 * has a hardcoded hack that interprets the KD type in the OS loader options,
907 * loads one of the (hardcoded filenames) "kdcom.dll", "kd1394.dll", or
908 * "kdusb2.dll" modules, and inserts them into the loaded module list under
909 * the name "kdcom.dll". [...]"
910 */
911
912 /*
913 * A Kernel Debugger Transport DLL is always loaded for Windows XP+ :
914 * either the standard KDCOM.DLL (by default): IsCustomKdDll == FALSE
915 * or an alternative user-provided one via the /DEBUGPORT= option:
916 * IsCustomKdDll == TRUE if it does not specify the default KDCOM.
917 */
918 BOOLEAN IsCustomKdDll = FALSE;
919
920 /* Check whether there is a DEBUGPORT option */
921 Option = NtLdrGetOptionEx(BootOptions, "DEBUGPORT=", &OptionLength);
922 if (Option && (OptionLength > 10))
923 {
924 /* Move to the debug port name */
925 Option += 10; OptionLength -= 10;
926
927 /*
928 * Parse the port name.
929 * Format: /DEBUGPORT=COM[0-9]
930 * or: /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log
931 * or: /DEBUGPORT=FOO
932 * If we only have /DEBUGPORT= (i.e. without any port name),
933 * default to "COM".
934 */
935
936 /* Get the actual length of the debug port
937 * until the next whitespace or colon. */
938 OptionLength = (ULONG)strcspn(Option, " \t:");
939
940 if ((OptionLength == 0) ||
941 ( (OptionLength >= 3) && (_strnicmp(Option, "COM", 3) == 0) &&
942 ((OptionLength == 3) || ('0' <= Option[3] && Option[3] <= '9')) ))
943 {
944 /* The standard KDCOM.DLL is used */
945 }
946 else
947 {
948 /* A custom KD DLL is used */
949 IsCustomKdDll = TRUE;
950 }
951 }
952 if (!IsCustomKdDll)
953 {
954 Option = "COM"; OptionLength = 3;
955 }
956
957 RtlStringCbPrintfA(KdDllName, sizeof(KdDllName), "kd%.*s.dll",
958 OptionLength, Option);
959 _strlwr(KdDllName);
960
961 /* Load the KD DLL. Override its base DLL name to the default "KDCOM.DLL". */
962 KdDllBase = LoadModule(&LoaderBlock->LoadOrderListHead,
963 DirPath, KdDllName,
964 "kdcom.dll", LoaderSystemCode,
965 &KdDllDTE, 40);
966 if (!KdDllBase)
967 {
968 /* If we failed to load a custom KD DLL, fall back to the standard one */
969 if (IsCustomKdDll)
970 {
971 /* The custom KD DLL being optional, just ignore the failure */
972 WARN("LoadModule('%s') failed\n", KdDllName);
973
974 IsCustomKdDll = FALSE;
975 RtlStringCbCopyA(KdDllName, sizeof(KdDllName), "kdcom.dll");
976
977 KdDllBase = LoadModule(&LoaderBlock->LoadOrderListHead,
978 DirPath, KdDllName,
979 "kdcom.dll", LoaderSystemCode,
980 &KdDllDTE, 40);
981 }
982
983 if (!KdDllBase)
984 {
985 /* Ignore the failure; we will fail later when scanning the
986 * kernel import tables, if it really needs the KD DLL. */
987 ERR("LoadModule('%s') failed\n", KdDllName);
988 }
989 }
990 }
991
992 /* Load the correct Boot Video Driver */
993 if (OperatingSystemVersion >= _WIN32_WINNT_WIN2K)
994 {
995 /* Check whether there is a BOOTVID option */
996 Option = NtLdrGetOptionEx(BootOptions, "BOOTVID=", &OptionLength);
997 if (Option && (OptionLength > 8))
998 {
999 /* Retrieve the BootVid file name */
1000 Option += 8; OptionLength -= 8;
1001 RtlStringCbCopyNA(BootVidName, sizeof(BootVidName), Option, OptionLength);
1002 _strlwr(BootVidName);
1003 TRACE("User-specified BootVid file: '%s'\n", BootVidName);
1004 }
1005 else
1006 {
1007 /* No option given, attempt auto-detection */
1008 NtLdrDetectBootVid(LoaderBlock->ConfigurationRoot,
1009 BootVidName, sizeof(BootVidName));
1010 TRACE("Auto-detected BootVid file: '%s'\n", BootVidName);
1011 }
1012
1013 /* Load the BootVid */
1014 BootVidBase = LoadModule(&LoaderBlock->LoadOrderListHead,
1015 DirPath, BootVidName,
1016 "bootvid.dll", LoaderSystemCode,
1017 &BootVidDTE, 45);
1018 if (!BootVidBase)
1019 {
1020 /* Ignore the failure; we will fail later when scanning the
1021 * kernel import tables, if it really needs the BootVid. */
1022 ERR("LoadModule('%s') failed\n", BootVidName);
1023 }
1024 }
1025
1026 /* Load all referenced DLLs for Kernel, HAL, Kernel Debugger Transport and BootVid */
1027 ModuleName = KernelFileName;
1028 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, *KernelDTE);
1029 if (!Success)
1030 goto Quit;
1031 ModuleName = HalFileName;
1032 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, HalDTE);
1033 if (!Success)
1034 goto Quit;
1035 if (KdDllDTE)
1036 {
1037 ModuleName = KdDllName;
1038 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, KdDllDTE);
1039 if (!Success)
1040 goto Quit;
1041 }
1042 if (BootVidDTE)
1043 {
1044 ModuleName = BootVidName;
1045 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, BootVidDTE);
1046 if (!Success)
1047 goto Quit;
1048 }
1049
1050Quit:
1051 if (!Success)
1052 {
1053 ERR("PeLdrScanImportDescriptorTable('%s') failed\n", ModuleName);
1054 UiMessageBox("Could not load %s", ModuleName);
1055
1056 /* Cleanup and bail out */
1057 if (BootVidDTE)
1058 PeLdrFreeDataTableEntry(BootVidDTE);
1059 if (BootVidBase) // Optional
1060 MmFreeMemory(BootVidBase);
1061
1062 if (KdDllDTE)
1063 PeLdrFreeDataTableEntry(KdDllDTE);
1064 if (KdDllBase) // Optional
1065 MmFreeMemory(KdDllBase);
1066
1068 MmFreeMemory(HalBase);
1069
1070 PeLdrFreeDataTableEntry(*KernelDTE);
1072 }
1073
1074 return Success;
1075}
1076
1077static
1078BOOLEAN
1080 IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
1081 IN USHORT OperatingSystemVersion,
1083{
1084 LONG rc;
1085 HKEY hKey;
1088 PVOID PhysicalBase;
1089 WCHAR szFileName[80];
1090 CHAR ErrataFilePath[MAX_PATH];
1091
1092 /* Open either the 'BiosInfo' (Windows <= 2003) or the 'Errata' (Vista+) key */
1093 if (OperatingSystemVersion >= _WIN32_WINNT_VISTA)
1094 {
1095 rc = RegOpenKey(CurrentControlSetKey, L"Control\\Errata", &hKey);
1096 }
1097 else // (OperatingSystemVersion <= _WIN32_WINNT_WS03)
1098 {
1099 rc = RegOpenKey(CurrentControlSetKey, L"Control\\BiosInfo", &hKey);
1100 }
1101 if (rc != ERROR_SUCCESS)
1102 {
1103 WARN("Could not open the BiosInfo/Errata registry key (Error %u)\n", (int)rc);
1104 return FALSE;
1105 }
1106
1107 /* Retrieve the INF file name value */
1108 BufferSize = sizeof(szFileName);
1109 rc = RegQueryValue(hKey, L"InfName", NULL, (PUCHAR)szFileName, &BufferSize);
1110 if (rc != ERROR_SUCCESS)
1111 {
1112 WARN("Could not retrieve the InfName value (Error %u)\n", (int)rc);
1114 return FALSE;
1115 }
1116
1117 // TODO: "SystemBiosDate"
1118
1120
1121 RtlStringCbPrintfA(ErrataFilePath, sizeof(ErrataFilePath), "%s%s%S",
1122 SystemRoot, "inf\\", szFileName);
1123
1124 /* Load the INF file */
1125 PhysicalBase = WinLdrLoadModule(ErrataFilePath, &FileSize, LoaderRegistryData);
1126 if (!PhysicalBase)
1127 {
1128 WARN("Could not load '%s'\n", ErrataFilePath);
1129 return FALSE;
1130 }
1131
1132 LoaderBlock->Extension->EmInfFileImage = PaToVa(PhysicalBase);
1133 LoaderBlock->Extension->EmInfFileSize = FileSize;
1134
1135 return TRUE;
1136}
1137
1140 IN ULONG Argc,
1141 IN PCHAR Argv[],
1142 IN PCHAR Envp[])
1143{
1145 PCSTR ArgValue;
1150 USHORT OperatingSystemVersion;
1151 PLOADER_PARAMETER_BLOCK LoaderBlock;
1152 CHAR BootPath[MAX_PATH];
1154 CHAR BootOptions[256];
1155
1156 /* Retrieve the (mandatory) boot type */
1157 ArgValue = GetArgumentValue(Argc, Argv, "BootType");
1158 if (!ArgValue || !*ArgValue)
1159 {
1160 ERR("No 'BootType' value, aborting!\n");
1161 return EINVAL;
1162 }
1163
1164 /* Convert it to an OS version */
1165 if (_stricmp(ArgValue, "Windows") == 0 ||
1166 _stricmp(ArgValue, "Windows2003") == 0)
1167 {
1168 OperatingSystemVersion = _WIN32_WINNT_WS03;
1169 }
1170 else if (_stricmp(ArgValue, "WindowsNT40") == 0)
1171 {
1172 OperatingSystemVersion = _WIN32_WINNT_NT4;
1173 }
1174 else if (_stricmp(ArgValue, "WindowsVista") == 0)
1175 {
1176 OperatingSystemVersion = _WIN32_WINNT_VISTA;
1177 }
1178 else
1179 {
1180 ERR("Unknown 'BootType' value '%s', aborting!\n", ArgValue);
1181 return EINVAL;
1182 }
1183
1184 /* Retrieve the (mandatory) system partition */
1185 SystemPartition = GetArgumentValue(Argc, Argv, "SystemPartition");
1187 {
1188 ERR("No 'SystemPartition' specified, aborting!\n");
1189 return EINVAL;
1190 }
1191
1192 /* Let the user know we started loading */
1194 UiDrawStatusText("Loading...");
1195 UiDrawProgressBarCenter("Loading NT...");
1196
1197 /* Retrieve the system path */
1198 *BootPath = ANSI_NULL;
1199 ArgValue = GetArgumentValue(Argc, Argv, "SystemPath");
1200 if (ArgValue)
1201 RtlStringCbCopyA(BootPath, sizeof(BootPath), ArgValue);
1202
1203 /*
1204 * Check whether BootPath is a full path
1205 * and if not, create a full boot path.
1206 *
1207 * See FsOpenFile for the technique used.
1208 */
1209 if (strrchr(BootPath, ')') == NULL)
1210 {
1211 /* Temporarily save the boot path */
1212 RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
1213
1214 /* This is not a full path: prepend the SystemPartition */
1215 RtlStringCbCopyA(BootPath, sizeof(BootPath), SystemPartition);
1216
1217 /* Append a path separator if needed */
1218 if (*FilePath != '\\' && *FilePath != '/')
1219 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
1220
1221 /* Append the remaining path */
1222 RtlStringCbCatA(BootPath, sizeof(BootPath), FilePath);
1223 }
1224
1225 /* Append a path separator if needed */
1226 if (!*BootPath || BootPath[strlen(BootPath) - 1] != '\\')
1227 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
1228
1229 TRACE("BootPath: '%s'\n", BootPath);
1230
1231 /* Retrieve the boot options */
1232 *BootOptions = ANSI_NULL;
1233 ArgValue = GetArgumentValue(Argc, Argv, "Options");
1234 if (ArgValue && *ArgValue)
1235 RtlStringCbCopyA(BootOptions, sizeof(BootOptions), ArgValue);
1236
1237 /* Append boot-time options */
1238 AppendBootTimeOptions(BootOptions);
1239
1240 /*
1241 * Set the "/HAL=" and "/KERNEL=" options if needed.
1242 * If already present on the standard "Options=" option line, they take
1243 * precedence over those passed via the separate "Hal=" and "Kernel="
1244 * options.
1245 */
1246 if (!NtLdrGetOption(BootOptions, "HAL="))
1247 {
1248 /*
1249 * Not found in the options, try to retrieve the
1250 * separate value and append it to the options.
1251 */
1252 ArgValue = GetArgumentValue(Argc, Argv, "Hal");
1253 if (ArgValue && *ArgValue)
1254 {
1255 RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /HAL=");
1256 RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
1257 }
1258 }
1259 if (!NtLdrGetOption(BootOptions, "KERNEL="))
1260 {
1261 /*
1262 * Not found in the options, try to retrieve the
1263 * separate value and append it to the options.
1264 */
1265 ArgValue = GetArgumentValue(Argc, Argv, "Kernel");
1266 if (ArgValue && *ArgValue)
1267 {
1268 RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /KERNEL=");
1269 RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
1270 }
1271 }
1272
1273 TRACE("BootOptions: '%s'\n", BootOptions);
1274
1275 /* Check if a RAM disk file was given */
1276 FileName = NtLdrGetOptionEx(BootOptions, "RDPATH=", &FileNameLength);
1277 if (FileName && (FileNameLength >= 7))
1278 {
1279 /* Load the RAM disk */
1281 if (Status != ESUCCESS)
1282 {
1283 FileName += 7; FileNameLength -= 7;
1284 UiMessageBox("Failed to load RAM disk file '%.*s'",
1286 return Status;
1287 }
1288 }
1289
1290 /* Handle the SOS option */
1291 SosEnabled = !!NtLdrGetOption(BootOptions, "SOS");
1292 if (SosEnabled)
1293 UiResetForSOS();
1294
1295 /* Allocate and minimally-initialize the Loader Parameter Block */
1296 AllocateAndInitLPB(OperatingSystemVersion, &LoaderBlock);
1297
1298 /* Load the system hive */
1299 UiUpdateProgressBar(15, "Loading system hive...");
1300 Success = WinLdrInitSystemHive(LoaderBlock, BootPath, FALSE);
1301 TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
1302 /* Bail out if failure */
1303 if (!Success)
1304 return ENOEXEC;
1305
1306 /* Fixup the version number using data from the registry */
1307 if (OperatingSystemVersion == 0)
1308 OperatingSystemVersion = WinLdrDetectVersion();
1309 LoaderBlock->Extension->MajorVersion = (OperatingSystemVersion & 0xFF00) >> 8;
1310 LoaderBlock->Extension->MinorVersion = (OperatingSystemVersion & 0xFF);
1311
1312 /* Load NLS data, OEM font, and prepare boot drivers list */
1313 Success = WinLdrScanSystemHive(LoaderBlock, BootPath);
1314 TRACE("SYSTEM hive %s\n", (Success ? "scanned" : "not scanned"));
1315 /* Bail out if failure */
1316 if (!Success)
1317 return ENOEXEC;
1318
1319 /* Load the Firmware Errata file */
1320 Success = WinLdrInitErrataInf(LoaderBlock, OperatingSystemVersion, BootPath);
1321 TRACE("Firmware Errata file %s\n", (Success ? "loaded" : "not loaded"));
1322 /* Not necessarily fatal if not found - carry on going */
1323
1324 /* Finish loading */
1325 return LoadAndBootWindowsCommon(OperatingSystemVersion,
1326 LoaderBlock,
1327 BootOptions,
1328 BootPath);
1329}
1330
1333 IN USHORT OperatingSystemVersion,
1334 IN PLOADER_PARAMETER_BLOCK LoaderBlock,
1335 IN PCSTR BootOptions,
1336 IN PCSTR BootPath)
1337{
1338 PLOADER_PARAMETER_BLOCK LoaderBlockVA;
1340 PLDR_DATA_TABLE_ENTRY KernelDTE;
1343
1344 TRACE("LoadAndBootWindowsCommon()\n");
1345
1346 ASSERT(OperatingSystemVersion != 0);
1347
1348 /* Setup redirection support */
1349 WinLdrSetupEms(BootOptions);
1350
1351 /* Convert BootPath to SystemRoot */
1352 SystemRoot = strstr(BootPath, "\\");
1353
1354 /* Detect hardware */
1355 UiUpdateProgressBar(20, "Detecting hardware...");
1356 LoaderBlock->ConfigurationRoot = MachHwDetect(BootOptions);
1357
1358 /* Initialize the PE loader import-DLL callback, so that we can obtain
1359 * feedback (for example during SOS) on the PE images that get loaded. */
1361
1362 /* Load the operating system core: the Kernel, the HAL and the Kernel Debugger Transport DLL */
1363 Success = LoadWindowsCore(OperatingSystemVersion,
1364 LoaderBlock,
1365 BootOptions,
1366 BootPath,
1367 &KernelDTE);
1368 if (!Success)
1369 {
1370 /* Reset the PE loader import-DLL callback */
1372
1373 UiMessageBox("Error loading NTOS core.");
1374 return ENOEXEC;
1375 }
1376
1377 /* Cleanup INI file */
1378 IniCleanup();
1379
1380/****
1381 **** WE HAVE NOW REACHED THE POINT OF NO RETURN !!
1382 ****/
1383
1384 UiSetProgressBarSubset(40, 90); // NTOS goes from 25 to 75%
1385
1386 /* Load boot drivers */
1387 UiSetProgressBarText("Loading boot drivers...");
1388 Success = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
1389 TRACE("Boot drivers loading %s\n", Success ? "successful" : "failed");
1390
1391 UiSetProgressBarSubset(0, 100);
1392
1393 /* Reset the PE loader import-DLL callback */
1395
1396 /* Initialize Phase 1 - no drivers loading anymore */
1397 WinLdrInitializePhase1(LoaderBlock,
1398 BootOptions,
1399 SystemRoot,
1400 BootPath,
1401 OperatingSystemVersion);
1402
1404
1405 /* Save entry-point pointer and Loader block VAs */
1407 LoaderBlockVA = PaToVa(LoaderBlock);
1408
1409 /* "Stop all motors", change videomode */
1411
1412 /* Show the "debug mode" notice if needed */
1413 /* Match KdInitSystem() conditions */
1414 if (!NtLdrGetOption(BootOptions, "CRASHDEBUG") &&
1415 !NtLdrGetOption(BootOptions, "NODEBUG") &&
1416 !!NtLdrGetOption(BootOptions, "DEBUG"))
1417 {
1418 /* Check whether there is a DEBUGPORT option */
1419 PCSTR DebugPort;
1420 ULONG DebugPortLength = 0;
1421 DebugPort = NtLdrGetOptionEx(BootOptions, "DEBUGPORT=", &DebugPortLength);
1422 if (DebugPort != NULL && DebugPortLength > 10)
1423 {
1424 /* Move to the debug port name */
1425 DebugPort += 10; DebugPortLength -= 10;
1426 }
1427 else
1428 {
1429 /* Default to COM */
1430 DebugPort = "COM"; DebugPortLength = 3;
1431 }
1432
1433 /* It is booting in debug mode, show the banner */
1434 TuiPrintf("You need to connect a debugger on port %.*s\n"
1435 "For more information, visit https://reactos.org/wiki/Debugging.\n",
1436 DebugPortLength, DebugPort);
1437 }
1438
1439 /* Debugging... */
1440 //DumpMemoryAllocMap();
1441
1442 /* Do the machine specific initialization */
1443 WinLdrSetupMachineDependent(LoaderBlock);
1444
1445 /* Map pages and create memory descriptors */
1446 WinLdrSetupMemoryLayout(LoaderBlock);
1447
1448 /* Set processor context */
1449 WinLdrSetProcessorContext(OperatingSystemVersion);
1450
1451 /* Save final value of LoaderPagesSpanned */
1452 LoaderBlock->Extension->LoaderPagesSpanned = MmGetLoaderPagesSpanned();
1453
1454 TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
1455 KiSystemStartup, LoaderBlockVA);
1456
1457 /* Zero KI_USER_SHARED_DATA page */
1458 RtlZeroMemory((PVOID)KI_USER_SHARED_DATA, MM_PAGE_SIZE);
1459
1460 WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
1461 WinLdrpDumpBootDriver(LoaderBlockVA);
1462#ifndef _M_AMD64
1463 WinLdrpDumpArcDisks(LoaderBlockVA);
1464#endif
1465
1466 /* Pass control */
1467 (*KiSystemStartup)(LoaderBlockVA);
1468
1469 UNREACHABLE; // return ESUCCESS;
1470}
1471
1472VOID
1474{
1475 PLIST_ENTRY NextMd;
1477
1478 NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1479
1480 while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1481 {
1483
1484 TRACE("BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage,
1485 MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType);
1486
1487 NextMd = MemoryDescriptor->ListEntry.Flink;
1488 }
1489}
1490
1491VOID
1493{
1494 PLIST_ENTRY NextBd;
1495 PBOOT_DRIVER_LIST_ENTRY BootDriver;
1496
1497 NextBd = LoaderBlock->BootDriverListHead.Flink;
1498
1499 while (NextBd != &LoaderBlock->BootDriverListHead)
1500 {
1501 BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
1502
1503 TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
1504 BootDriver->LdrEntry, &BootDriver->RegistryPath);
1505
1506 NextBd = BootDriver->Link.Flink;
1507 }
1508}
1509
1510VOID
1512{
1513 PLIST_ENTRY NextBd;
1514 PARC_DISK_SIGNATURE ArcDisk;
1515
1516 NextBd = LoaderBlock->ArcDiskInformation->DiskSignatureListHead.Flink;
1517
1518 while (NextBd != &LoaderBlock->ArcDiskInformation->DiskSignatureListHead)
1519 {
1520 ArcDisk = CONTAINING_RECORD(NextBd, ARC_DISK_SIGNATURE, ListEntry);
1521
1522 TRACE("ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
1523 ArcDisk->ArcName, ArcDisk->CheckSum, ArcDisk->Signature);
1524
1525 NextBd = ArcDisk->ListEntry.Flink;
1526 }
1527}
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 AppendBootTimeOptions(PCHAR BootOptions)
Definition: options.c:244
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:104
_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 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
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 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
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
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
#define TRACE(s)
Definition: solgame.cpp:4
base of all file and directory entries
Definition: entries.h:83
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
PCONFIGURATION_COMPONENT_DATA ConfigurationRoot
Definition: arc.h:840
LIST_ENTRY LoadOrderListHead
Definition: arc.h:820
PARC_DISK_INFORMATION ArcDiskInformation
Definition: arc.h:847
PNLS_DATA_BLOCK NlsData
Definition: arc.h:846
PSTR ArcBootDeviceName
Definition: arc.h:841
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:857
LIST_ENTRY MemoryDescriptorListHead
Definition: arc.h:821
CHAR NtHalPathName[MAX_PATH+1]
Definition: winldr.h:59
ARC_DISK_INFORMATION ArcDiskInformation
Definition: winldr.h:60
CHAR NtBootPathName[MAX_PATH+1]
Definition: winldr.h:58
NLS_DATA_BLOCK NlsDataBlock
Definition: winldr.h:54
LOADER_PARAMETER_EXTENSION Extension
Definition: winldr.h:49
CHAR ArcBootDeviceName[MAX_PATH+1]
Definition: winldr.h:56
LOADER_PARAMETER_BLOCK LoaderBlock
Definition: winldr.h:48
LOADER_PERFORMANCE_DATA LoaderPerformanceData
Definition: winldr.h:61
CHAR LoadOptions[MAX_OPTIONS_LENGTH+1]
Definition: winldr.h:55
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
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#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:730
BOOLEAN WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootPath)
Definition: winldr.c:382
VOID WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1511
BOOLEAN IsAcpiPresent(VOID)
Definition: hwacpi.c:28
ARC_STATUS LoadAndBootWindows(IN ULONG Argc, IN PCHAR Argv[], IN PCHAR Envp[])
Definition: winldr.c:1139
BOOLEAN BootLogo
Definition: winldr.c:36
BOOLEAN NoExecuteEnabled
Definition: winldr.c:40
VOID WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR Options, PCSTR SystemRoot, PCSTR BootPath, USHORT VersionToBoot)
Definition: winldr.c:118
ULONG ArcGetDiskCount(VOID)
Definition: archwsup.c:247
VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1473
VOID WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1492
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:519
static VOID NtLdrDetectBootVid(_In_ PCONFIGURATION_COMPONENT_DATA ConfigTree, _Out_writes_bytes_(BootVidNameSize) _Always_(_Post_z_) PSTR BootVidName, _In_ SIZE_T BootVidNameSize)
Definition: winldr.c:623
ARC_STATUS LoadAndBootWindowsCommon(IN USHORT OperatingSystemVersion, IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR BootOptions, IN PCSTR BootPath)
Definition: winldr.c:1332
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:443
USHORT WinLdrDetectVersion(VOID)
Definition: winldr.c:500
static BOOLEAN WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead, PCSTR BootPath, PUNICODE_STRING FilePath, ULONG Flags, PLDR_DATA_TABLE_ENTRY *DriverDTE)
Definition: winldr.c:294
BOOLEAN SafeBoot
Definition: winldr.c:35
PARC_DISK_SIGNATURE_EX ArcGetDiskInfo(ULONG Index)
Definition: archwsup.c:252
static BOOLEAN WinLdrInitErrataInf(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN USHORT OperatingSystemVersion, IN PCSTR SystemRoot)
Definition: winldr.c:1079
PCWSTR BootFileSystem
Definition: winldr.c:31
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:33
VOID DumpMemoryAllocMap(VOID)
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
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175