ReactOS  0.4.15-dev-2964-ge2a8585
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/ldrtypes.h>
10 #include "winldr.h"
11 #include "ntldropts.h"
12 #include "registry.h"
13 
14 #include <debug.h>
15 DBG_DEFAULT_CHANNEL(WINDOWS);
16 
17 // FIXME: Find a better way to retrieve ARC disk information
20 
22 extern BOOLEAN AcpiPresent;
23 
27 
29 
38 
39 // debug stuff
41 
42 // Init "phase 0"
43 VOID
45  IN USHORT VersionToBoot,
46  OUT PLOADER_PARAMETER_BLOCK* OutLoaderBlock)
47 {
48  PLOADER_PARAMETER_BLOCK LoaderBlock;
50 
51  /* Allocate and zero-init the Loader Parameter Block */
54  if (WinLdrSystemBlock == NULL)
55  {
56  UiMessageBox("Failed to allocate memory for system block!");
57  return;
58  }
59 
61 
62  LoaderBlock = &WinLdrSystemBlock->LoaderBlock;
63  LoaderBlock->NlsData = &WinLdrSystemBlock->NlsDataBlock;
64 
65  /* Initialize the Loader Block Extension */
67  LoaderBlock->Extension = Extension;
68  Extension->Size = sizeof(LOADER_PARAMETER_EXTENSION);
69  Extension->MajorVersion = (VersionToBoot & 0xFF00) >> 8;
70  Extension->MinorVersion = (VersionToBoot & 0xFF);
71 
72  /* Init three critical lists, used right away */
76 
77  *OutLoaderBlock = LoaderBlock;
78 }
79 
80 // Init "phase 1"
81 VOID
83  PCSTR Options,
85  PCSTR BootPath,
86  USHORT VersionToBoot)
87 {
88  /*
89  * Examples of correct options and paths:
90  * CHAR Options[] = "/DEBUGPORT=COM1 /BAUDRATE=115200";
91  * CHAR Options[] = "/NODEBUG";
92  * CHAR SystemRoot[] = "\\WINNT\\";
93  * CHAR ArcBoot[] = "multi(0)disk(0)rdisk(0)partition(1)";
94  */
95 
96  PSTR LoadOptions, NewLoadOptions;
97  CHAR HalPath[] = "\\";
98  CHAR ArcBoot[MAX_PATH+1];
99  CHAR MiscFiles[MAX_PATH+1];
100  ULONG i;
101  ULONG_PTR PathSeparator;
103 
104  /* Construct SystemRoot and ArcBoot from SystemPath */
105  PathSeparator = strstr(BootPath, "\\") - BootPath;
106  RtlStringCbCopyNA(ArcBoot, sizeof(ArcBoot), BootPath, PathSeparator);
107 
108  TRACE("ArcBoot: '%s'\n", ArcBoot);
109  TRACE("SystemRoot: '%s'\n", SystemRoot);
110  TRACE("Options: '%s'\n", Options);
111 
112  /* Fill ARC BootDevice */
115  LoaderBlock->ArcBootDeviceName = PaToVa(LoaderBlock->ArcBootDeviceName);
116 
117 //
118 // IMPROVE!!
119 // SetupBlock->ArcSetupDeviceName must be the path to the setup **SOURCE**,
120 // and not the setup boot path. Indeed they may differ!!
121 //
122  if (LoaderBlock->SetupLdrBlock)
123  {
124  PSETUP_LOADER_BLOCK SetupBlock = LoaderBlock->SetupLdrBlock;
125 
126  /* Adjust the ARC path in the setup block - Matches ArcBoot path */
128  SetupBlock->ArcSetupDeviceName = PaToVa(SetupBlock->ArcSetupDeviceName);
129 
130  /* Convert the setup block pointer */
131  LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
132  }
133 
134  /* Fill ARC HalDevice, it matches ArcBoot path */
136  LoaderBlock->ArcHalDeviceName = PaToVa(LoaderBlock->ArcHalDeviceName);
137 
138  /* Fill SystemRoot */
141  LoaderBlock->NtBootPathName = PaToVa(LoaderBlock->NtBootPathName);
142 
143  /* Fill NtHalPathName */
145  RtlStringCbCopyA(LoaderBlock->NtHalPathName, sizeof(WinLdrSystemBlock->NtHalPathName), HalPath);
146  LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName);
147 
148  /* Fill LoadOptions and strip the '/' switch symbol in front of each option */
149  NewLoadOptions = LoadOptions = LoaderBlock->LoadOptions = WinLdrSystemBlock->LoadOptions;
151 
152  do
153  {
154  while (*LoadOptions == '/')
155  ++LoadOptions;
156 
157  *NewLoadOptions++ = *LoadOptions;
158  } while (*LoadOptions++);
159 
160  LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions);
161 
162  /* ARC devices */
165 
166  /* Convert ARC disk information from freeldr to a correct format */
167  for (i = 0; i < reactos_disk_count; i++)
168  {
169  PARC_DISK_SIGNATURE_EX ArcDiskSig;
170 
171  /* Allocate the ARC structure */
172  ArcDiskSig = FrLdrHeapAlloc(sizeof(ARC_DISK_SIGNATURE_EX), 'giSD');
173 
174  /* Copy the data over */
176 
177  /* Set the ARC Name pointer */
178  ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName);
179 
180  /* Insert into the list */
182  &ArcDiskSig->DiskSignature.ListEntry);
183  }
184 
185  /* Convert all lists to Virtual address */
186 
187  /* Convert the ArcDisks list to virtual address */
189  LoaderBlock->ArcDiskInformation = PaToVa(LoaderBlock->ArcDiskInformation);
190 
191  /* Convert configuration entries to VA */
192  ConvertConfigToVA(LoaderBlock->ConfigurationRoot);
193  LoaderBlock->ConfigurationRoot = PaToVa(LoaderBlock->ConfigurationRoot);
194 
195  /* Convert all DTE into virtual addresses */
196  List_PaToVa(&LoaderBlock->LoadOrderListHead);
197 
198  /* This one will be converted right before switching to virtual paging mode */
199  //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
200 
201  /* Convert list of boot drivers */
202  List_PaToVa(&LoaderBlock->BootDriverListHead);
203 
204  Extension = LoaderBlock->Extension;
205 
206  /* FIXME! HACK value for docking profile */
207  Extension->Profile.Status = 2;
208 
209  /* Check if FreeLdr detected a ACPI table */
210  if (AcpiPresent)
211  {
212  /* Set the pointer to something for compatibility */
213  Extension->AcpiTable = (PVOID)1;
214  // FIXME: Extension->AcpiTableSize;
215  }
216 
217 #ifdef _M_IX86
218  /* Set headless block pointer */
220  {
221  Extension->HeadlessLoaderBlock = &WinLdrSystemBlock->HeadlessLoaderBlock;
222  RtlCopyMemory(Extension->HeadlessLoaderBlock,
224  sizeof(HEADLESS_LOADER_BLOCK));
225  Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
226  }
227 #endif
228  /* Load drivers database */
229  RtlStringCbCopyA(MiscFiles, sizeof(MiscFiles), BootPath);
230  RtlStringCbCatA(MiscFiles, sizeof(MiscFiles), "AppPatch\\drvmain.sdb");
231  Extension->DrvDBImage = PaToVa(WinLdrLoadModule(MiscFiles,
232  &Extension->DrvDBSize,
234 
235  /* Convert the extension block pointer */
236  LoaderBlock->Extension = PaToVa(LoaderBlock->Extension);
237 
238  TRACE("WinLdrInitializePhase1() completed\n");
239 }
240 
241 static BOOLEAN
243  PCSTR BootPath,
245  ULONG Flags,
246  PLDR_DATA_TABLE_ENTRY *DriverDTE)
247 {
248  CHAR FullPath[1024];
249  CHAR DriverPath[1024];
250  CHAR DllName[1024];
251  PCHAR DriverNamePos;
253  PVOID DriverBase = NULL;
254 
255  // Separate the path to file name and directory path
256  RtlStringCbPrintfA(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
257  DriverNamePos = strrchr(DriverPath, '\\');
258  if (DriverNamePos != NULL)
259  {
260  // Copy the name
261  RtlStringCbCopyA(DllName, sizeof(DllName), DriverNamePos+1);
262 
263  // Cut out the name from the path
264  *(DriverNamePos+1) = ANSI_NULL;
265  }
266  else
267  {
268  // There is no directory in the path
269  RtlStringCbCopyA(DllName, sizeof(DllName), DriverPath);
270  *DriverPath = ANSI_NULL;
271  }
272 
273  TRACE("DriverPath: '%s', DllName: '%s', LPB\n", DriverPath, DllName);
274 
275  // Check if driver is already loaded
276  Success = PeLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
277  if (Success)
278  {
279  // We've got the pointer to its DTE, just return success
280  return TRUE;
281  }
282 
283  // It's not loaded, we have to load it
284  RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
285  Success = PeLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
286  if (!Success)
287  return FALSE;
288 
289  // Allocate a DTE for it
290  Success = PeLdrAllocateDataTableEntry(LoadOrderListHead, DllName, DllName, DriverBase, DriverDTE);
291  if (!Success)
292  {
293  ERR("PeLdrAllocateDataTableEntry() failed\n");
294  return FALSE;
295  }
296 
297  // Modify any flags, if needed
298  (*DriverDTE)->Flags |= Flags;
299 
300  // Look for any dependencies it may have, and load them too
301  RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%s", BootPath, DriverPath);
302  Success = PeLdrScanImportDescriptorTable(LoadOrderListHead, FullPath, *DriverDTE);
303  if (!Success)
304  {
305  ERR("PeLdrScanImportDescriptorTable() failed for %s\n", FullPath);
306  return FALSE;
307  }
308 
309  return TRUE;
310 }
311 
312 BOOLEAN
314  PCSTR BootPath)
315 {
316  PLIST_ENTRY NextBd;
317  PBOOT_DRIVER_LIST_ENTRY BootDriver;
319  BOOLEAN ret = TRUE;
320 
321  // Walk through the boot drivers list
322  NextBd = LoaderBlock->BootDriverListHead.Flink;
323 
324  while (NextBd != &LoaderBlock->BootDriverListHead)
325  {
326  BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
327 
328  TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
329  BootDriver->LdrEntry, &BootDriver->RegistryPath);
330 
331  // Paths are relative (FIXME: Are they always relative?)
332 
333  // Load it
335  BootPath,
336  &BootDriver->FilePath,
337  0,
338  &BootDriver->LdrEntry);
339 
340  if (Success)
341  {
342  // Convert the RegistryPath and DTE addresses to VA since we are not going to use it anymore
343  BootDriver->RegistryPath.Buffer = PaToVa(BootDriver->RegistryPath.Buffer);
344  BootDriver->FilePath.Buffer = PaToVa(BootDriver->FilePath.Buffer);
345  BootDriver->LdrEntry = PaToVa(BootDriver->LdrEntry);
346  }
347  else
348  {
349  // Loading failed - cry loudly
350  ERR("Can't load boot driver '%wZ'!\n", &BootDriver->FilePath);
351  UiMessageBox("Can't load boot driver '%wZ'!", &BootDriver->FilePath);
352  ret = FALSE;
353 
354  // Remove it from the list and try to continue
355  RemoveEntryList(NextBd);
356  }
357 
358  NextBd = BootDriver->Link.Flink;
359  }
360 
361  return ret;
362 }
363 
364 PVOID
366  PULONG Size,
367  TYPE_OF_MEMORY MemoryType)
368 {
369  ULONG FileId;
370  PVOID PhysicalBase;
372  ULONG FileSize;
375 
376  //CHAR ProgressString[256];
377 
378  /* Inform user we are loading files */
379  //UiDrawBackdrop();
380  //RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", FileName);
381  //UiDrawProgressBarCenter(1, 100, ProgressString);
382 
383  TRACE("Loading module %s\n", ModuleName);
384  *Size = 0;
385 
386  /* Open the image file */
387  Status = ArcOpen((PSTR)ModuleName, OpenReadOnly, &FileId);
388  if (Status != ESUCCESS)
389  {
390  /* In case of errors, we just return, without complaining to the user */
391  WARN("Error while opening '%s', Status: %u\n", ModuleName, Status);
392  return NULL;
393  }
394 
395  /* Retrieve its size */
397  if (Status != ESUCCESS)
398  {
399  ArcClose(FileId);
400  return NULL;
401  }
402  FileSize = FileInfo.EndingAddress.LowPart;
403  *Size = FileSize;
404 
405  /* Allocate memory */
406  PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);
407  if (PhysicalBase == NULL)
408  {
409  ERR("Could not allocate memory for '%s'\n", ModuleName);
410  ArcClose(FileId);
411  return NULL;
412  }
413 
414  /* Load the whole file */
415  Status = ArcRead(FileId, PhysicalBase, FileSize, &BytesRead);
416  ArcClose(FileId);
417  if (Status != ESUCCESS)
418  {
419  WARN("Error while reading '%s', Status: %u\n", ModuleName, Status);
420  return NULL;
421  }
422 
423  TRACE("Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize);
424 
425  return PhysicalBase;
426 }
427 
428 USHORT
430 {
431  LONG rc;
432  HKEY hKey;
433 
434  rc = RegOpenKey(NULL,
435  L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server",
436  &hKey);
437  if (rc != ERROR_SUCCESS)
438  {
439  /* Key doesn't exist; assume NT 4.0 */
440  return _WIN32_WINNT_NT4;
441  }
442 
443  /* We may here want to read the value of ProductVersion */
444  return _WIN32_WINNT_WS03;
445 }
446 
447 static
448 BOOLEAN
450  IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
451  IN PCCH Path,
452  IN PCCH File,
453  IN PCCH ImportName, // BaseDllName
454  IN TYPE_OF_MEMORY MemoryType,
456  IN ULONG Percentage)
457 {
459  CHAR FullFileName[MAX_PATH];
460  CHAR ProgressString[256];
462 
463  UiDrawBackdrop();
464  RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", File);
465  UiDrawProgressBarCenter(Percentage, 100, ProgressString);
466 
467  RtlStringCbCopyA(FullFileName, sizeof(FullFileName), Path);
468  RtlStringCbCatA(FullFileName, sizeof(FullFileName), File);
469 
470  Success = PeLdrLoadImage(FullFileName, MemoryType, &BaseAddress);
471  if (!Success)
472  {
473  TRACE("Loading %s failed\n", File);
474  return FALSE;
475  }
476  TRACE("%s loaded successfully at %p\n", File, BaseAddress);
477 
478  /*
479  * Cheat about the base DLL name if we are loading
480  * the Kernel Debugger Transport DLL, to make the
481  * PE loader happy.
482  */
483  Success = PeLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
484  ImportName,
485  FullFileName,
486  BaseAddress,
487  Dte);
488 
489  return Success;
490 }
491 
492 static
493 BOOLEAN
494 LoadWindowsCore(IN USHORT OperatingSystemVersion,
495  IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
497  IN PCSTR BootPath,
498  IN OUT PLDR_DATA_TABLE_ENTRY* KernelDTE)
499 {
501  PCSTR Option;
502  ULONG OptionLength;
503  PLDR_DATA_TABLE_ENTRY HalDTE, KdComDTE = NULL;
504  CHAR DirPath[MAX_PATH];
505  CHAR HalFileName[MAX_PATH];
506  CHAR KernelFileName[MAX_PATH];
507  CHAR KdTransportDllName[MAX_PATH];
508 
509  if (!KernelDTE) return FALSE;
510 
511  /* Initialize SystemRoot\System32 path */
512  RtlStringCbCopyA(DirPath, sizeof(DirPath), BootPath);
513  RtlStringCbCatA(DirPath, sizeof(DirPath), "system32\\");
514 
515  /*
516  * Default HAL and KERNEL file names.
517  * See the following links to know how the file names are actually chosen:
518  * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/detecthal.htm
519  * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/hal.htm
520  * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/kernel.htm
521  */
522  RtlStringCbCopyA(HalFileName , sizeof(HalFileName) , "hal.dll");
523  RtlStringCbCopyA(KernelFileName, sizeof(KernelFileName), "ntoskrnl.exe");
524 
525  /* Check for any "/HAL=" or "/KERNEL=" override option */
526 
527  Option = NtLdrGetOptionEx(BootOptions, "HAL=", &OptionLength);
528  if (Option && (OptionLength > 4))
529  {
530  /* Retrieve the HAL file name */
531  Option += 4; OptionLength -= 4;
532  RtlStringCbCopyNA(HalFileName, sizeof(HalFileName), Option, OptionLength);
533  _strupr(HalFileName);
534  }
535 
536  Option = NtLdrGetOptionEx(BootOptions, "KERNEL=", &OptionLength);
537  if (Option && (OptionLength > 7))
538  {
539  /* Retrieve the KERNEL file name */
540  Option += 7; OptionLength -= 7;
541  RtlStringCbCopyNA(KernelFileName, sizeof(KernelFileName), Option, OptionLength);
542  _strupr(KernelFileName);
543  }
544 
545  TRACE("HAL file = '%s' ; Kernel file = '%s'\n", HalFileName, KernelFileName);
546 
547  /* Load the Kernel */
548  LoadModule(LoaderBlock, DirPath, KernelFileName, "ntoskrnl.exe", LoaderSystemCode, KernelDTE, 30);
549 
550  /* Load the HAL */
551  LoadModule(LoaderBlock, DirPath, HalFileName, "hal.dll", LoaderHalCode, &HalDTE, 45);
552 
553  /* Load the Kernel Debugger Transport DLL */
554  if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
555  {
556  /*
557  * According to http://www.nynaeve.net/?p=173 :
558  * "[...] Another enhancement that could be done Microsoft-side would be
559  * a better interface for replacing KD transport modules. Right now, due
560  * to the fact that ntoskrnl is static linked to KDCOM.DLL, the OS loader
561  * has a hardcoded hack that interprets the KD type in the OS loader options,
562  * loads one of the (hardcoded filenames) "kdcom.dll", "kd1394.dll", or
563  * "kdusb2.dll" modules, and inserts them into the loaded module list under
564  * the name "kdcom.dll". [...]"
565  */
566 
567  /* Check whether there is a DEBUGPORT option */
568  Option = NtLdrGetOptionEx(BootOptions, "DEBUGPORT=", &OptionLength);
569  if (Option && (OptionLength > 10))
570  {
571  /* Move to the debug port name */
572  Option += 10; OptionLength -= 10;
573  ASSERT(OptionLength > 0);
574 
575  /*
576  * Parse the port name.
577  * Format: /DEBUGPORT=COM[1-9]
578  * or: /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log
579  * or: /DEBUGPORT=FOO
580  * If we only have /DEBUGPORT= (i.e. without any port name),
581  * defaults it to "COM".
582  */
583  RtlStringCbCopyA(KdTransportDllName, sizeof(KdTransportDllName), "KD");
584  if (_strnicmp(Option, "COM", 3) == 0 && '0' <= Option[3] && Option[3] <= '9')
585  {
586  RtlStringCbCatNA(KdTransportDllName, sizeof(KdTransportDllName), Option, 3);
587  }
588  else
589  {
590  /* Get the actual length of the debug port
591  * until the next whitespace or colon. */
592  OptionLength = (ULONG)strcspn(Option, " \t:");
593  if (OptionLength == 0)
594  RtlStringCbCatA(KdTransportDllName, sizeof(KdTransportDllName), "COM");
595  else
596  RtlStringCbCatNA(KdTransportDllName, sizeof(KdTransportDllName), Option, OptionLength);
597  }
598  RtlStringCbCatA(KdTransportDllName, sizeof(KdTransportDllName), ".DLL");
599  _strupr(KdTransportDllName);
600 
601  /*
602  * Load the transport DLL. Override the base DLL name of the
603  * loaded transport DLL to the default "KDCOM.DLL" name.
604  */
605  LoadModule(LoaderBlock, DirPath, KdTransportDllName, "kdcom.dll", LoaderSystemCode, &KdComDTE, 60);
606  }
607  }
608 
609  /* Parse the boot options */
610  TRACE("LoadWindowsCore: BootOptions '%s'\n", BootOptions);
611 
612  if (NtLdrGetOption(BootOptions, "3GB"))
613  {
614  /* We found the 3GB option. */
615  FIXME("LoadWindowsCore: 3GB - TRUE (not implemented)\n");
616  VirtualBias = TRUE;
617  }
618  if (NtLdrGetOption(BootOptions, "SOS"))
619  {
620  /* We found the SOS option. */
621  FIXME("LoadWindowsCore: SOS - TRUE (not implemented)\n");
622  SosEnabled = TRUE;
623  }
624 
625  if (OperatingSystemVersion > _WIN32_WINNT_NT4)
626  {
627  if (NtLdrGetOption(BootOptions, "SAFEBOOT"))
628  {
629  /* We found the SAFEBOOT option. */
630  FIXME("LoadWindowsCore: SAFEBOOT - TRUE (not implemented)\n");
631  SafeBoot = TRUE;
632  }
633  if (NtLdrGetOption(BootOptions, "PAE"))
634  {
635  /* We found the PAE option. */
636  FIXME("LoadWindowsCore: PAE - TRUE (not implemented)\n");
637  PaeEnabled = TRUE;
638  }
639  }
640 
641  if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
642  {
643  if (NtLdrGetOption(BootOptions, "NOPAE"))
644  {
645  /* We found the NOPAE option. */
646  FIXME("LoadWindowsCore: NOPAE - TRUE (not implemented)\n");
647  PaeDisabled = TRUE;
648  }
649  if (NtLdrGetOption(BootOptions, "BOOTLOGO"))
650  {
651  /* We found the BOOTLOGO option. */
652  FIXME("LoadWindowsCore: BOOTLOGO - TRUE (not implemented)\n");
653  BootLogo = TRUE;
654  }
655 
656  if (!LoaderBlock->SetupLdrBlock)
657  {
658  if (NtLdrGetOption(BootOptions, "EXECUTE"))
659  {
660  /* We found the EXECUTE option. */
661  FIXME("LoadWindowsCore: EXECUTE - TRUE (not implemented)\n");
663  }
664  if (NtLdrGetOption(BootOptions, "NOEXECUTE=ALWAYSOFF"))
665  {
666  /* We found the NOEXECUTE=ALWAYSOFF option. */
667  FIXME("LoadWindowsCore: NOEXECUTE=ALWAYSOFF - TRUE (not implemented)\n");
669  }
670  if (NtLdrGetOption(BootOptions, "NOEXECUTE"))
671  {
672  /* We found the NOEXECUTE option. */
673  FIXME("LoadWindowsCore: NOEXECUTE - TRUE (not implemented)\n");
675  }
676  }
677  }
678 
679  if (SafeBoot)
680  {
681  PaeDisabled = TRUE;
683  }
684 
685  /* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
686  Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, *KernelDTE);
687  Success &= PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, HalDTE);
688  if (KdComDTE)
689  {
690  Success &= PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, KdComDTE);
691  }
692 
693  return Success;
694 }
695 
696 static
697 BOOLEAN
699  IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock,
700  IN USHORT OperatingSystemVersion,
702 {
703  LONG rc;
704  HKEY hKey;
706  ULONG FileSize;
707  PVOID PhysicalBase;
708  WCHAR szFileName[80];
709  CHAR ErrataFilePath[MAX_PATH];
710 
711  /* Open either the 'BiosInfo' (Windows <= 2003) or the 'Errata' (Vista+) key */
712  if (OperatingSystemVersion >= _WIN32_WINNT_VISTA)
713  {
714  rc = RegOpenKey(NULL,
715  L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Errata",
716  &hKey);
717  }
718  else // (OperatingSystemVersion <= _WIN32_WINNT_WS03)
719  {
720  rc = RegOpenKey(NULL,
721  L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\BiosInfo",
722  &hKey);
723  }
724  if (rc != ERROR_SUCCESS)
725  {
726  WARN("Could not open the BiosInfo/Errata registry key (Error %u)\n", (int)rc);
727  return FALSE;
728  }
729 
730  /* Retrieve the INF file name value */
731  BufferSize = sizeof(szFileName);
732  rc = RegQueryValue(hKey, L"InfName", NULL, (PUCHAR)szFileName, &BufferSize);
733  if (rc != ERROR_SUCCESS)
734  {
735  WARN("Could not retrieve the InfName value (Error %u)\n", (int)rc);
736  return FALSE;
737  }
738 
739  // TODO: "SystemBiosDate"
740 
741  RtlStringCbPrintfA(ErrataFilePath, sizeof(ErrataFilePath), "%s%s%S",
742  SystemRoot, "inf\\", szFileName);
743 
744  /* Load the INF file */
745  PhysicalBase = WinLdrLoadModule(ErrataFilePath, &FileSize, LoaderRegistryData);
746  if (!PhysicalBase)
747  {
748  WARN("Could not load '%s'\n", ErrataFilePath);
749  return FALSE;
750  }
751 
752  LoaderBlock->Extension->EmInfFileImage = PaToVa(PhysicalBase);
753  LoaderBlock->Extension->EmInfFileSize = FileSize;
754 
755  return TRUE;
756 }
757 
760  IN ULONG Argc,
761  IN PCHAR Argv[],
762  IN PCHAR Envp[])
763 {
765  PCSTR ArgValue;
767  PCSTR FileName;
770  USHORT OperatingSystemVersion;
771  PLOADER_PARAMETER_BLOCK LoaderBlock;
772  CHAR BootPath[MAX_PATH];
774  CHAR BootOptions[256];
775 
776  /* Retrieve the (mandatory) boot type */
777  ArgValue = GetArgumentValue(Argc, Argv, "BootType");
778  if (!ArgValue || !*ArgValue)
779  {
780  ERR("No 'BootType' value, aborting!\n");
781  return EINVAL;
782  }
783 
784  /* Convert it to an OS version */
785  if (_stricmp(ArgValue, "Windows") == 0 ||
786  _stricmp(ArgValue, "Windows2003") == 0)
787  {
788  OperatingSystemVersion = _WIN32_WINNT_WS03;
789  }
790  else if (_stricmp(ArgValue, "WindowsNT40") == 0)
791  {
792  OperatingSystemVersion = _WIN32_WINNT_NT4;
793  }
794  else
795  {
796  ERR("Unknown 'BootType' value '%s', aborting!\n", ArgValue);
797  return EINVAL;
798  }
799 
800  /* Retrieve the (mandatory) system partition */
801  SystemPartition = GetArgumentValue(Argc, Argv, "SystemPartition");
803  {
804  ERR("No 'SystemPartition' specified, aborting!\n");
805  return EINVAL;
806  }
807 
808  UiDrawBackdrop();
809  UiDrawProgressBarCenter(1, 100, "Loading NT...");
810 
811  /* Retrieve the system path */
812  *BootPath = ANSI_NULL;
813  ArgValue = GetArgumentValue(Argc, Argv, "SystemPath");
814  if (ArgValue)
815  RtlStringCbCopyA(BootPath, sizeof(BootPath), ArgValue);
816 
817  /*
818  * Check whether BootPath is a full path
819  * and if not, create a full boot path.
820  *
821  * See FsOpenFile for the technique used.
822  */
823  if (strrchr(BootPath, ')') == NULL)
824  {
825  /* Temporarily save the boot path */
826  RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
827 
828  /* This is not a full path: prepend the SystemPartition */
829  RtlStringCbCopyA(BootPath, sizeof(BootPath), SystemPartition);
830 
831  /* Append a path separator if needed */
832  if (*FilePath != '\\' && *FilePath != '/')
833  RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
834 
835  /* Append the remaining path */
836  RtlStringCbCatA(BootPath, sizeof(BootPath), FilePath);
837  }
838 
839  /* Append a path separator if needed */
840  if (!*BootPath || BootPath[strlen(BootPath) - 1] != '\\')
841  RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
842 
843  TRACE("BootPath: '%s'\n", BootPath);
844 
845  /* Retrieve the boot options */
847  ArgValue = GetArgumentValue(Argc, Argv, "Options");
848  if (ArgValue && *ArgValue)
849  RtlStringCbCopyA(BootOptions, sizeof(BootOptions), ArgValue);
850 
851  /* Append boot-time options */
853 
854  /*
855  * Set the "/HAL=" and "/KERNEL=" options if needed.
856  * If already present on the standard "Options=" option line, they take
857  * precedence over those passed via the separate "Hal=" and "Kernel="
858  * options.
859  */
860  if (!NtLdrGetOption(BootOptions, "HAL="))
861  {
862  /*
863  * Not found in the options, try to retrieve the
864  * separate value and append it to the options.
865  */
866  ArgValue = GetArgumentValue(Argc, Argv, "Hal");
867  if (ArgValue && *ArgValue)
868  {
869  RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /HAL=");
870  RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
871  }
872  }
873  if (!NtLdrGetOption(BootOptions, "KERNEL="))
874  {
875  /*
876  * Not found in the options, try to retrieve the
877  * separate value and append it to the options.
878  */
879  ArgValue = GetArgumentValue(Argc, Argv, "Kernel");
880  if (ArgValue && *ArgValue)
881  {
882  RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /KERNEL=");
883  RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
884  }
885  }
886 
887  TRACE("BootOptions: '%s'\n", BootOptions);
888 
889  /* Check if a RAM disk file was given */
891  if (FileName && (FileNameLength > 7))
892  {
893  /* Load the RAM disk */
895  if (Status != ESUCCESS)
896  {
897  FileName += 7; FileNameLength -= 7;
898  UiMessageBox("Failed to load RAM disk file '%.*s'",
900  return Status;
901  }
902  }
903 
904  /* Let user know we started loading */
905  //UiDrawStatusText("Loading...");
906 
907  /* Allocate and minimally-initialize the Loader Parameter Block */
908  AllocateAndInitLPB(OperatingSystemVersion, &LoaderBlock);
909 
910  /* Load the system hive */
911  UiDrawBackdrop();
912  UiDrawProgressBarCenter(15, 100, "Loading system hive...");
913  Success = WinLdrInitSystemHive(LoaderBlock, BootPath, FALSE);
914  TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
915  /* Bail out if failure */
916  if (!Success)
917  return ENOEXEC;
918 
919  /* Fixup the version number using data from the registry */
920  if (OperatingSystemVersion == 0)
921  OperatingSystemVersion = WinLdrDetectVersion();
922  LoaderBlock->Extension->MajorVersion = (OperatingSystemVersion & 0xFF00) >> 8;
923  LoaderBlock->Extension->MinorVersion = (OperatingSystemVersion & 0xFF);
924 
925  /* Load NLS data, OEM font, and prepare boot drivers list */
926  Success = WinLdrScanSystemHive(LoaderBlock, BootPath);
927  TRACE("SYSTEM hive %s\n", (Success ? "scanned" : "not scanned"));
928  /* Bail out if failure */
929  if (!Success)
930  return ENOEXEC;
931 
932  /* Load the Firmware Errata file */
933  Success = WinLdrInitErrataInf(LoaderBlock, OperatingSystemVersion, BootPath);
934  TRACE("Firmware Errata file %s\n", (Success ? "loaded" : "not loaded"));
935  /* Not necessarily fatal if not found - carry on going */
936 
937  /* Finish loading */
938  return LoadAndBootWindowsCommon(OperatingSystemVersion,
939  LoaderBlock,
940  BootOptions,
941  BootPath);
942 }
943 
946  IN USHORT OperatingSystemVersion,
947  IN PLOADER_PARAMETER_BLOCK LoaderBlock,
949  IN PCSTR BootPath)
950 {
951  PLOADER_PARAMETER_BLOCK LoaderBlockVA;
953  PLDR_DATA_TABLE_ENTRY KernelDTE;
956 
957  TRACE("LoadAndBootWindowsCommon()\n");
958 
959  ASSERT(OperatingSystemVersion != 0);
960 
961 #ifdef _M_IX86
962  /* Setup redirection support */
964 #endif
965 
966  /* Convert BootPath to SystemRoot */
967  SystemRoot = strstr(BootPath, "\\");
968 
969  /* Detect hardware */
970  UiDrawBackdrop();
971  UiDrawProgressBarCenter(20, 100, "Detecting hardware...");
972  LoaderBlock->ConfigurationRoot = MachHwDetect();
973 
974  /* Load the operating system core: the Kernel, the HAL and the Kernel Debugger Transport DLL */
975  Success = LoadWindowsCore(OperatingSystemVersion,
976  LoaderBlock,
977  BootOptions,
978  BootPath,
979  &KernelDTE);
980  if (!Success)
981  {
982  UiMessageBox("Error loading NTOS core.");
983  return ENOEXEC;
984  }
985 
986  /* Load boot drivers */
987  UiDrawBackdrop();
988  UiDrawProgressBarCenter(100, 100, "Loading boot drivers...");
989  Success = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
990  TRACE("Boot drivers loading %s\n", Success ? "successful" : "failed");
991 
992  /* Cleanup ini file */
993  IniCleanup();
994 
995  /* Initialize Phase 1 - no drivers loading anymore */
996  WinLdrInitializePhase1(LoaderBlock,
997  BootOptions,
998  SystemRoot,
999  BootPath,
1000  OperatingSystemVersion);
1001 
1002  /* Save entry-point pointer and Loader block VAs */
1004  LoaderBlockVA = PaToVa(LoaderBlock);
1005 
1006  /* "Stop all motors", change videomode */
1008 
1009  /* Debugging... */
1010  //DumpMemoryAllocMap();
1011 
1012  /* Do the machine specific initialization */
1013  WinLdrSetupMachineDependent(LoaderBlock);
1014 
1015  /* Map pages and create memory descriptors */
1016  WinLdrSetupMemoryLayout(LoaderBlock);
1017 
1018  /* Set processor context */
1020 
1021  /* Save final value of LoaderPagesSpanned */
1022  LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
1023 
1024  TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
1025  KiSystemStartup, LoaderBlockVA);
1026 
1027  /* Zero KI_USER_SHARED_DATA page */
1028  RtlZeroMemory((PVOID)KI_USER_SHARED_DATA, MM_PAGE_SIZE);
1029 
1030  WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
1031  WinLdrpDumpBootDriver(LoaderBlockVA);
1032 #ifndef _M_AMD64
1033  WinLdrpDumpArcDisks(LoaderBlockVA);
1034 #endif
1035 
1036  /* Pass control */
1037  (*KiSystemStartup)(LoaderBlockVA);
1038 
1039  UNREACHABLE; // return ESUCCESS;
1040 }
1041 
1042 VOID
1044 {
1045  PLIST_ENTRY NextMd;
1047 
1048  NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1049 
1050  while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1051  {
1053 
1054  TRACE("BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage,
1055  MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType);
1056 
1057  NextMd = MemoryDescriptor->ListEntry.Flink;
1058  }
1059 }
1060 
1061 VOID
1063 {
1064  PLIST_ENTRY NextBd;
1065  PBOOT_DRIVER_LIST_ENTRY BootDriver;
1066 
1067  NextBd = LoaderBlock->BootDriverListHead.Flink;
1068 
1069  while (NextBd != &LoaderBlock->BootDriverListHead)
1070  {
1071  BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
1072 
1073  TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
1074  BootDriver->LdrEntry, &BootDriver->RegistryPath);
1075 
1076  NextBd = BootDriver->Link.Flink;
1077  }
1078 }
1079 
1080 VOID
1082 {
1083  PLIST_ENTRY NextBd;
1084  PARC_DISK_SIGNATURE ArcDisk;
1085 
1086  NextBd = LoaderBlock->ArcDiskInformation->DiskSignatureListHead.Flink;
1087 
1088  while (NextBd != &LoaderBlock->ArcDiskInformation->DiskSignatureListHead)
1089  {
1090  ArcDisk = CONTAINING_RECORD(NextBd, ARC_DISK_SIGNATURE, ListEntry);
1091 
1092  TRACE("ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
1093  ArcDisk->ArcName, ArcDisk->CheckSum, ArcDisk->Signature);
1094 
1095  NextBd = ArcDisk->ListEntry.Flink;
1096  }
1097 }
static BOOLEAN WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead, PCSTR BootPath, PUNICODE_STRING FilePath, ULONG Flags, PLDR_DATA_TABLE_ENTRY *DriverDTE)
Definition: winldr.c:242
VOID AppendBootTimeOptions(PCHAR BootOptions)
Definition: options.c:252
signed char * PCHAR
Definition: retypes.h:7
BOOLEAN PeLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH DirectoryPath, IN PLDR_DATA_TABLE_ENTRY ScanDTE)
Definition: peloader.c:509
#define MachHwDetect()
Definition: machine.h:136
#define IN
Definition: typedefs.h:39
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
ARC_STATUS RamDiskInitialize(IN BOOLEAN InitRamDisk, IN PCSTR LoadOptions OPTIONAL, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:205
VOID(NTAPI * KERNEL_ENTRY_POINT)(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.h:13
BOOLEAN PeLdrLoadImage(IN PCHAR FileName, IN TYPE_OF_MEMORY MemoryType, OUT PVOID *ImageBasePA)
Definition: peloader.c:701
PSTR ArcBootDeviceName
Definition: arc.h:503
ARC_DISK_INFORMATION ArcDiskInformation
Definition: winldr.h:60
BOOLEAN WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootPath)
Definition: winldr.c:313
ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[]
Definition: archwsup.c:21
BOOLEAN VirtualBias
Definition: winldr.c:30
#define ERROR_SUCCESS
Definition: deptool.c:10
VOID WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1081
BOOLEAN SosEnabled
Definition: winldr.c:31
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
Definition: arc.h:32
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
#define TRUE
Definition: types.h:120
VOID WinLdrSetProcessorContext(void)
Definition: winldr.c:348
PCHAR ArcName
Definition: arc.h:210
BOOLEAN NoexecuteEnabled
Definition: winldr.c:37
VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry)
BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot)
Definition: wlregistry.c:173
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
Definition: arc.h:39
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
unsigned char * PUCHAR
Definition: retypes.h:3
PCONFIGURATION_COMPONENT_DATA ConfigurationRoot
Definition: arc.h:502
char CHAR
Definition: xmlstorage.h:175
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:494
#define WARN(fmt,...)
Definition: debug.h:112
BOOLEAN WinLdrTerminalConnected
Definition: headless.c:31
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
ULONG Signature
Definition: arc.h:209
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:30
ULONG ARC_STATUS
Definition: arc.h:4
_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:1331
static BOOLEAN WinLdrInitErrataInf(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN USHORT OperatingSystemVersion, IN PCSTR SystemRoot)
Definition: winldr.c:698
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:1274
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
NTSTRSAFEAPI RtlStringCbCatNA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToAppend) STRSAFE_LPCSTR pszSrc, _In_ size_t cbToAppend)
Definition: ntstrsafe.h:819
#define InsertTailList(ListHead, Entry)
UNICODE_STRING FilePath
Definition: arc.h:201
#define _stricmp
Definition: cat.c:22
static int Link(const char **args)
Definition: vfdcmd.c:2414
BOOLEAN WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: wlmemory.c:181
_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:859
CHAR ArcBootDeviceName[MAX_PATH+1]
Definition: winldr.h:56
PCWSTR FilePath
enum _TYPE_OF_MEMORY TYPE_OF_MEMORY
uint32_t ULONG_PTR
Definition: typedefs.h:65
Definition: arc.h:198
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
BOOLEAN BootLogo
Definition: winldr.c:35
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
#define _WIN32_WINNT_WIN2K
Definition: sdkddkver.h:21
VOID DumpMemoryAllocMap(VOID)
struct _SETUP_LOADER_BLOCK * SetupLdrBlock
Definition: arc.h:511
#define FALSE
Definition: types.h:117
#define ANSI_NULL
ARC_STATUS LoadAndBootWindows(IN ULONG Argc, IN PCHAR Argv[], IN PCHAR Envp[])
Definition: winldr.c:759
long LONG
Definition: pedump.c:60
DBG_DEFAULT_CHANNEL(WINDOWS)
PVOID EntryPoint
Definition: ntddk_ex.h:203
#define FIXME(fmt,...)
Definition: debug.h:111
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:379
ARC_STATUS LoadAndBootWindowsCommon(IN USHORT OperatingSystemVersion, IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR BootOptions, IN PCSTR BootPath)
Definition: winldr.c:945
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
USHORT WinLdrDetectVersion(VOID)
Definition: winldr.c:429
VOID WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1062
void * PVOID
Definition: retypes.h:9
LOADER_PARAMETER_BLOCK LoaderBlock
Definition: winldr.h:48
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
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
BOOLEAN PaeEnabled
Definition: winldr.c:32
Status
Definition: gdiplustypes.h:24
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
CONST CHAR * PCCH
Definition: ntbasedef.h:392
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3531
LIST_ENTRY ListEntry
Definition: arc.h:208
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ASSERT(a)
Definition: mode.c:44
static const WCHAR SystemRoot[]
Definition: reg.c:38
__wchar_t WCHAR
Definition: xmlstorage.h:180
CHAR ArcName[MAX_PATH]
Definition: winldr.h:37
NLS_DATA_BLOCK NlsDataBlock
Definition: winldr.h:54
#define MAX_PATH
Definition: compat.h:34
PARC_DISK_INFORMATION ArcDiskInformation
Definition: arc.h:509
LIST_ENTRY BootDriverListHead
Definition: arc.h:495
ULONG reactos_disk_count
Definition: archwsup.c:20
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
ULONG LoaderPagesSpanned
Definition: mm.c:29
ARC_DISK_SIGNATURE DiskSignature
Definition: winldr.h:36
BOOLEAN AcpiPresent
Definition: macharm.c:21
BOOLEAN PaeDisabled
Definition: winldr.c:33
static PPARTENTRY SystemPartition
Definition: usetup.c:61
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
CHAR LoadOptions[MAX_OPTIONS_LENGTH+1]
Definition: winldr.h:55
VOID IniCleanup(VOID)
Definition: inifile.c:235
int ret
static const WCHAR L[]
Definition: oid.c:1250
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
#define KI_USER_SHARED_DATA
#define MachPrepareForReactOS()
Definition: machine.h:120
Definition: btrfs_drv.h:1922
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
CHAR NtHalPathName[MAX_PATH+1]
Definition: winldr.h:59
BOOLEAN SafeBoot
Definition: winldr.c:34
Definition: typedefs.h:119
VOID UiDrawBackdrop(VOID)
Definition: ui.c:214
VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1043
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ HANDLE _In_ ULONG FileNameLength
Definition: fltkernel.h:1129
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
LOADER_PARAMETER_EXTENSION Extension
Definition: winldr.h:49
VOID AllocateAndInitLPB(IN USHORT VersionToBoot, OUT PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
Definition: winldr.c:44
static BOOLEAN LoadModule(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCCH Path, IN PCCH File, IN PCCH ImportName, IN TYPE_OF_MEMORY MemoryType, OUT PLDR_DATA_TABLE_ENTRY *Dte, IN ULONG Percentage)
Definition: winldr.c:449
VOID WinLdrSetupEms(IN PCSTR BootOptions)
Definition: headless.c:302
#define ERR(fmt,...)
Definition: debug.h:110
struct _FileName FileName
Definition: fatprocs.h:893
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
UNICODE_STRING RegistryPath
Definition: arc.h:202
PRTL_UNICODE_STRING_BUFFER Path
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
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
unsigned short USHORT
Definition: pedump.c:61
struct _LDR_DATA_TABLE_ENTRY * LdrEntry
Definition: arc.h:203
FxAutoRegKey hKey
VOID WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR Options, PCSTR SystemRoot, PCSTR BootPath, USHORT VersionToBoot)
Definition: winldr.c:82
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:365
LIST_ENTRY MemoryDescriptorListHead
Definition: arc.h:494
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
signed char * PSTR
Definition: retypes.h:7
unsigned int * PULONG
Definition: retypes.h:1
#define NULL
Definition: types.h:112
VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
Definition: conversion.c:51
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:218
DECLSPEC_NORETURN VOID NTAPI KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kiinit.c:372
LIST_ENTRY Link
Definition: arc.h:200
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:250
#define OUT
Definition: typedefs.h:40
struct FileInfo FileInfo
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
#define RegQueryValue
Definition: winreg.h:523
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:56
LIST_ENTRY DiskSignatureListHead
Definition: arc.h:221
PCHAR ArcSetupDeviceName
Definition: setupblk.h:112
unsigned int ULONG
Definition: retypes.h:1
#define UNREACHABLE
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
BOOLEAN NoexecuteDisabled
Definition: winldr.c:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
Definition: arc.h:47
PNLS_DATA_BLOCK NlsData
Definition: arc.h:508
const char * PCSTR
Definition: typedefs.h:52
Definition: File.h:15
ULONG CheckSum
Definition: arc.h:211
CHAR NtBootPathName[MAX_PATH+1]
Definition: winldr.h:58
PCHAR GetArgumentValue(IN ULONG Argc, IN PCHAR Argv[], IN PCHAR ArgumentName)
Definition: arcsupp.c:41
BOOLEAN PeLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead, IN PCH DllName, OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry)
Definition: peloader.c:465
#define RegOpenKey
Definition: winreg.h:519
BOOLEAN PeLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH BaseDllName, IN PCCH FullDllName, IN PVOID BasePA, OUT PLDR_DATA_TABLE_ENTRY *NewEntry)
Definition: peloader.c:585
BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot, IN BOOLEAN Setup)
Definition: wlregistry.c:123
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
#define BufferSize
Definition: mmc.h:75
struct _LOADER_PARAMETER_EXTENSION LOADER_PARAMETER_EXTENSION
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
Definition: ui.c:346
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
Definition: winldr.c:28
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625