ReactOS  0.4.15-dev-2714-g4864c87
winldr.c File Reference
#include <freeldr.h>
#include <ndk/ldrtypes.h>
#include "winldr.h"
#include "ntldropts.h"
#include "registry.h"
#include <debug.h>
Include dependency graph for winldr.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (WINDOWS)
 
VOID WinLdrSetupEms (IN PCSTR BootOptions)
 
VOID DumpMemoryAllocMap (VOID)
 
VOID AllocateAndInitLPB (IN USHORT VersionToBoot, OUT PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
 
VOID WinLdrInitializePhase1 (PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR Options, PCSTR SystemRoot, PCSTR BootPath, USHORT VersionToBoot)
 
static BOOLEAN WinLdrLoadDeviceDriver (PLIST_ENTRY LoadOrderListHead, PCSTR BootPath, PUNICODE_STRING FilePath, ULONG Flags, PLDR_DATA_TABLE_ENTRY *DriverDTE)
 
BOOLEAN WinLdrLoadBootDrivers (PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootPath)
 
PVOID WinLdrLoadModule (PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
 
USHORT WinLdrDetectVersion (VOID)
 
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)
 
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)
 
static BOOLEAN WinLdrInitErrataInf (IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN USHORT OperatingSystemVersion, IN PCSTR SystemRoot)
 
ARC_STATUS LoadAndBootWindows (IN ULONG Argc, IN PCHAR Argv[], IN PCHAR Envp[])
 
ARC_STATUS LoadAndBootWindowsCommon (IN USHORT OperatingSystemVersion, IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR BootOptions, IN PCSTR BootPath)
 
VOID WinLdrpDumpMemoryDescriptors (PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID WinLdrpDumpBootDriver (PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID WinLdrpDumpArcDisks (PLOADER_PARAMETER_BLOCK LoaderBlock)
 

Variables

ULONG reactos_disk_count
 
ARC_DISK_SIGNATURE_EX reactos_arc_disk_info []
 
ULONG LoaderPagesSpanned
 
BOOLEAN AcpiPresent
 
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
 
BOOLEAN WinLdrTerminalConnected
 
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
 
BOOLEAN VirtualBias = FALSE
 
BOOLEAN SosEnabled = FALSE
 
BOOLEAN PaeEnabled = FALSE
 
BOOLEAN PaeDisabled = FALSE
 
BOOLEAN SafeBoot = FALSE
 
BOOLEAN BootLogo = FALSE
 
BOOLEAN NoexecuteDisabled = FALSE
 
BOOLEAN NoexecuteEnabled = FALSE
 

Function Documentation

◆ AllocateAndInitLPB()

VOID AllocateAndInitLPB ( IN USHORT  VersionToBoot,
OUT PLOADER_PARAMETER_BLOCK OutLoaderBlock 
)

Definition at line 44 of file winldr.c.

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 }
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
LOADER_PARAMETER_BLOCK LoaderBlock
Definition: winldr.h:48
NLS_DATA_BLOCK NlsDataBlock
Definition: winldr.h:54
LIST_ENTRY BootDriverListHead
Definition: arc.h:495
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
LOADER_PARAMETER_EXTENSION Extension
Definition: winldr.h:49
LIST_ENTRY MemoryDescriptorListHead
Definition: arc.h:494
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define NULL
Definition: types.h:112
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PNLS_DATA_BLOCK NlsData
Definition: arc.h:508
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
struct _LOADER_PARAMETER_EXTENSION LOADER_PARAMETER_EXTENSION
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
Definition: winldr.c:28

Referenced by LoadAndBootWindows(), and LoadReactOSSetup().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( WINDOWS  )

◆ DumpMemoryAllocMap()

VOID DumpMemoryAllocMap ( VOID  )

◆ LoadAndBootWindows()

ARC_STATUS LoadAndBootWindows ( IN ULONG  Argc,
IN PCHAR  Argv[],
IN PCHAR  Envp[] 
)

Definition at line 759 of file winldr.c.

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 }
VOID AppendBootTimeOptions(PCHAR BootOptions)
Definition: options.c:252
ARC_STATUS RamDiskInitialize(IN BOOLEAN InitRamDisk, IN PCSTR LoadOptions OPTIONAL, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:205
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
Definition: arc.h:32
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot)
Definition: wlregistry.c:173
Definition: arc.h:39
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
char CHAR
Definition: xmlstorage.h:175
ULONG ARC_STATUS
Definition: arc.h:4
static BOOLEAN WinLdrInitErrataInf(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN USHORT OperatingSystemVersion, IN PCSTR SystemRoot)
Definition: winldr.c:698
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define _stricmp
Definition: cat.c:22
PCWSTR FilePath
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 FALSE
Definition: types.h:117
#define ANSI_NULL
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
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
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_PATH
Definition: compat.h:34
static PPARTENTRY SystemPartition
Definition: usetup.c:61
VOID UiDrawBackdrop(VOID)
Definition: ui.c:214
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ HANDLE _In_ ULONG FileNameLength
Definition: fltkernel.h:1129
VOID AllocateAndInitLPB(IN USHORT VersionToBoot, OUT PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
Definition: winldr.c:44
#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
unsigned short USHORT
Definition: pedump.c:61
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
Definition: arc.h:47
const char * PCSTR
Definition: typedefs.h:52
PCHAR GetArgumentValue(IN ULONG Argc, IN PCHAR Argv[], IN PCHAR ArgumentName)
Definition: arcsupp.c:41
BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot, IN BOOLEAN Setup)
Definition: wlregistry.c:123
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
Definition: ui.c:346
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625

◆ LoadAndBootWindowsCommon()

ARC_STATUS LoadAndBootWindowsCommon ( IN USHORT  OperatingSystemVersion,
IN PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN PCSTR  BootOptions,
IN PCSTR  BootPath 
)

Definition at line 945 of file winldr.c.

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 }
#define MachHwDetect()
Definition: machine.h:136
VOID(NTAPI * KERNEL_ENTRY_POINT)(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.h:13
BOOLEAN WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootPath)
Definition: winldr.c:313
VOID WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1081
VOID WinLdrSetProcessorContext(void)
Definition: winldr.c:348
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
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
BOOLEAN WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: wlmemory.c:181
PVOID EntryPoint
Definition: ntddk_ex.h:203
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:379
VOID WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1062
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
static const WCHAR SystemRoot[]
Definition: reg.c:38
ULONG LoaderPagesSpanned
Definition: mm.c:29
VOID IniCleanup(VOID)
Definition: inifile.c:235
#define KI_USER_SHARED_DATA
#define MachPrepareForReactOS()
Definition: machine.h:120
Definition: btrfs_drv.h:1922
VOID UiDrawBackdrop(VOID)
Definition: ui.c:214
VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1043
VOID WinLdrSetupEms(IN PCSTR BootOptions)
Definition: headless.c:302
VOID WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR Options, PCSTR SystemRoot, PCSTR BootPath, USHORT VersionToBoot)
Definition: winldr.c:82
DECLSPEC_NORETURN VOID NTAPI KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kiinit.c:372
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
#define UNREACHABLE
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
Definition: arc.h:47
const char * PCSTR
Definition: typedefs.h:52
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
Definition: ui.c:346

Referenced by LoadAndBootWindows(), and LoadReactOSSetup().

◆ LoadModule()

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 
)
static

Definition at line 449 of file winldr.c.

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 }
BOOLEAN PeLdrLoadImage(IN PCHAR FileName, IN TYPE_OF_MEMORY MemoryType, OUT PVOID *ImageBasePA)
Definition: peloader.c:701
char CHAR
Definition: xmlstorage.h:175
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 FALSE
Definition: types.h:117
unsigned char BOOLEAN
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
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_PATH
Definition: compat.h:34
VOID UiDrawBackdrop(VOID)
Definition: ui.c:214
PRTL_UNICODE_STRING_BUFFER Path
#define NULL
Definition: types.h:112
Definition: File.h:15
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
VOID UiDrawProgressBarCenter(ULONG Position, ULONG Range, PCHAR ProgressText)
Definition: ui.c:346
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625

Referenced by DECLARE_INTERFACE_(), and LoadWindowsCore().

◆ LoadWindowsCore()

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 
)
static

Definition at line 494 of file winldr.c.

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 }
BOOLEAN PeLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH DirectoryPath, IN PLDR_DATA_TABLE_ENTRY ScanDTE)
Definition: peloader.c:509
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
BOOLEAN VirtualBias
Definition: winldr.c:30
BOOLEAN SosEnabled
Definition: winldr.c:31
#define TRUE
Definition: types.h:120
BOOLEAN NoexecuteEnabled
Definition: winldr.c:37
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
char CHAR
Definition: xmlstorage.h:175
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
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
BOOLEAN BootLogo
Definition: winldr.c:35
#define _WIN32_WINNT_WIN2K
Definition: sdkddkver.h:21
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
unsigned char BOOLEAN
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
BOOLEAN PaeEnabled
Definition: winldr.c:32
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:44
#define MAX_PATH
Definition: compat.h:34
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
BOOLEAN PaeDisabled
Definition: winldr.c:33
Definition: btrfs_drv.h:1922
BOOLEAN SafeBoot
Definition: winldr.c:34
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
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
BOOLEAN NoexecuteDisabled
Definition: winldr.c:36
const char * PCSTR
Definition: typedefs.h:52
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrDetectVersion()

USHORT WinLdrDetectVersion ( VOID  )

Definition at line 429 of file winldr.c.

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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
long LONG
Definition: pedump.c:60
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
static const WCHAR L[]
Definition: oid.c:1250
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
#define RegOpenKey
Definition: winreg.h:519

Referenced by LoadAndBootWindows().

◆ WinLdrInitErrataInf()

static BOOLEAN WinLdrInitErrataInf ( IN OUT PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN USHORT  OperatingSystemVersion,
IN PCSTR  SystemRoot 
)
static

Definition at line 698 of file winldr.c.

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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
char CHAR
Definition: xmlstorage.h:175
#define WARN(fmt,...)
Definition: debug.h:112
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
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
static const WCHAR SystemRoot[]
Definition: reg.c:38
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
FxAutoRegKey hKey
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:365
#define NULL
Definition: types.h:112
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
#define RegQueryValue
Definition: winreg.h:523
unsigned int ULONG
Definition: retypes.h:1
#define RegOpenKey
Definition: winreg.h:519
#define BufferSize
Definition: mmc.h:75
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251

Referenced by LoadAndBootWindows().

◆ WinLdrInitializePhase1()

VOID WinLdrInitializePhase1 ( PLOADER_PARAMETER_BLOCK  LoaderBlock,
PCSTR  Options,
PCSTR  SystemRoot,
PCSTR  BootPath,
USHORT  VersionToBoot 
)

Definition at line 82 of file winldr.c.

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 }
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
PSTR ArcBootDeviceName
Definition: arc.h:503
ARC_DISK_INFORMATION ArcDiskInformation
Definition: winldr.h:60
ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[]
Definition: archwsup.c:21
PCHAR ArcName
Definition: arc.h:210
VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry)
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
PCONFIGURATION_COMPONENT_DATA ConfigurationRoot
Definition: arc.h:502
char CHAR
Definition: xmlstorage.h:175
BOOLEAN WinLdrTerminalConnected
Definition: headless.c:31
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:30
#define InsertTailList(ListHead, Entry)
CHAR ArcBootDeviceName[MAX_PATH+1]
Definition: winldr.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
struct _SETUP_LOADER_BLOCK * SetupLdrBlock
Definition: arc.h:511
void * PVOID
Definition: retypes.h:9
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:168
#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
static const WCHAR SystemRoot[]
Definition: reg.c:38
CHAR ArcName[MAX_PATH]
Definition: winldr.h:37
#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
ARC_DISK_SIGNATURE DiskSignature
Definition: winldr.h:36
BOOLEAN AcpiPresent
Definition: macharm.c:21
CHAR LoadOptions[MAX_OPTIONS_LENGTH+1]
Definition: winldr.h:55
CHAR NtHalPathName[MAX_PATH+1]
Definition: winldr.h:59
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
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
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:365
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
signed char * PSTR
Definition: retypes.h:7
VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
Definition: conversion.c:51
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
LIST_ENTRY DiskSignatureListHead
Definition: arc.h:221
PCHAR ArcSetupDeviceName
Definition: setupblk.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
CHAR NtBootPathName[MAX_PATH+1]
Definition: winldr.h:58
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
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

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrLoadBootDrivers()

BOOLEAN WinLdrLoadBootDrivers ( PLOADER_PARAMETER_BLOCK  LoaderBlock,
PCSTR  BootPath 
)

Definition at line 313 of file winldr.c.

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 }
static BOOLEAN WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead, PCSTR BootPath, PUNICODE_STRING FilePath, ULONG Flags, PLDR_DATA_TABLE_ENTRY *DriverDTE)
Definition: winldr.c:242
#define TRUE
Definition: types.h:120
UNICODE_STRING FilePath
Definition: arc.h:201
static int Link(const char **args)
Definition: vfdcmd.c:2414
Definition: arc.h:198
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
#define FALSE
Definition: types.h:117
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY BootDriverListHead
Definition: arc.h:495
int ret
Definition: typedefs.h:119
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
#define ERR(fmt,...)
Definition: debug.h:110
UNICODE_STRING RegistryPath
Definition: arc.h:202
struct _LDR_DATA_TABLE_ENTRY * LdrEntry
Definition: arc.h:203
LIST_ENTRY Link
Definition: arc.h:200
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrLoadDeviceDriver()

static BOOLEAN WinLdrLoadDeviceDriver ( PLIST_ENTRY  LoadOrderListHead,
PCSTR  BootPath,
PUNICODE_STRING  FilePath,
ULONG  Flags,
PLDR_DATA_TABLE_ENTRY DriverDTE 
)
static

Definition at line 242 of file winldr.c.

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 }
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
BOOLEAN PeLdrLoadImage(IN PCHAR FileName, IN TYPE_OF_MEMORY MemoryType, OUT PVOID *ImageBasePA)
Definition: peloader.c:701
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
PCWSTR FilePath
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 FALSE
Definition: types.h:117
#define ANSI_NULL
unsigned char BOOLEAN
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
#define TRACE(s)
Definition: solgame.cpp:4
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define ERR(fmt,...)
Definition: debug.h:110
#define NULL
Definition: types.h:112
BOOLEAN PeLdrCheckForLoadedDll(IN OUT PLIST_ENTRY ModuleListHead, IN PCH DllName, OUT PLDR_DATA_TABLE_ENTRY *LoadedEntry)
Definition: peloader.c:465
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

Referenced by WinLdrLoadBootDrivers().

◆ WinLdrLoadModule()

PVOID WinLdrLoadModule ( PCSTR  ModuleName,
PULONG  Size,
TYPE_OF_MEMORY  MemoryType 
)

Definition at line 365 of file winldr.c.

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 }
Definition: arc.h:32
#define WARN(fmt,...)
Definition: debug.h:112
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
ULONG ARC_STATUS
Definition: arc.h:4
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
_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
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
#define ERR(fmt,...)
Definition: debug.h:110
signed char * PSTR
Definition: retypes.h:7
#define NULL
Definition: types.h:112
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:218
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:250
struct FileInfo FileInfo
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:56
unsigned int ULONG
Definition: retypes.h:1

Referenced by SetupLdrInitErrataInf(), WinLdrInitErrataInf(), and WinLdrInitializePhase1().

◆ WinLdrpDumpArcDisks()

VOID WinLdrpDumpArcDisks ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1081 of file winldr.c.

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 }
PCHAR ArcName
Definition: arc.h:210
ULONG Signature
Definition: arc.h:209
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY ListEntry
Definition: arc.h:208
PARC_DISK_INFORMATION ArcDiskInformation
Definition: arc.h:509
Definition: typedefs.h:119
LIST_ENTRY DiskSignatureListHead
Definition: arc.h:221
ULONG CheckSum
Definition: arc.h:211

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrpDumpBootDriver()

VOID WinLdrpDumpBootDriver ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1062 of file winldr.c.

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 }
UNICODE_STRING FilePath
Definition: arc.h:201
static int Link(const char **args)
Definition: vfdcmd.c:2414
Definition: arc.h:198
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
LIST_ENTRY BootDriverListHead
Definition: arc.h:495
Definition: typedefs.h:119
UNICODE_STRING RegistryPath
Definition: arc.h:202
struct _LDR_DATA_TABLE_ENTRY * LdrEntry
Definition: arc.h:203
LIST_ENTRY Link
Definition: arc.h:200

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrpDumpMemoryDescriptors()

VOID WinLdrpDumpMemoryDescriptors ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1043 of file winldr.c.

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 }
_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
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
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:119
LIST_ENTRY MemoryDescriptorListHead
Definition: arc.h:494

Referenced by LoadAndBootWindowsCommon(), and WinLdrSetupMemoryLayout().

◆ WinLdrSetupEms()

VOID WinLdrSetupEms ( IN PCSTR  BootOptions)

Definition at line 302 of file headless.c.

303 {
304  PCSTR Option;
305 
306  /* Start fresh */
309 
310  /* Use a direction port if one was given, or use ACPI to detect one instead */
311  Option = NtLdrGetOption(BootOptions, "redirect=");
312  if (Option)
313  {
314  Option += 9;
315  if (_strnicmp(Option, "com", 3) == 0)
316  {
317  Option += 3;
320  }
321  else if (_strnicmp(Option, "usebiossettings", 15) == 0)
322  {
323  // FIXME: TODO!
324  UiDrawStatusText("ACPI SRT/SPCR Table Not Supported...");
325  return;
326  }
327  else
328  {
331  {
333  }
334  }
335  }
336 
337  /* Use a direction baudrate if one was given */
338  Option = NtLdrGetOption(BootOptions, "redirectbaudrate=");
339  if (Option)
340  {
341  Option += 17;
342  // LoaderRedirectionInformation.BaudRate = atoi(Option);
343  if (strncmp(Option, "115200", 6) == 0)
344  {
346  }
347  else if (strncmp(Option, "57600", 5) == 0)
348  {
350  }
351  else if (strncmp(Option, "19200", 5) == 0)
352  {
354  }
355  else
356  {
358  }
359  }
360 
361  /* Enable headless support if parameters were found */
363  {
365  {
367  }
368 
370  }
371 }
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
unsigned char * PUCHAR
Definition: retypes.h:3
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:30
VOID WinLdrInitializeHeadlessPort(VOID)
Definition: headless.c:206
PUCHAR PortAddress
Definition: arc.h:312
UCHAR TerminalType
Definition: arc.h:321
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
USHORT PciDeviceId
Definition: arc.h:313
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:249
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
const char * PCSTR
Definition: typedefs.h:52

Referenced by LoadAndBootWindowsCommon().

Variable Documentation

◆ AcpiPresent

BOOLEAN AcpiPresent

Definition at line 21 of file macharm.c.

Referenced by DetectAcpiBios(), and WinLdrInitializePhase1().

◆ BootLogo

BOOLEAN BootLogo = FALSE

Definition at line 35 of file winldr.c.

Referenced by DisplayBootBitmap(), and LoadWindowsCore().

◆ LoaderPagesSpanned

ULONG LoaderPagesSpanned

Definition at line 29 of file mm.c.

Referenced by LoadAndBootWindowsCommon().

◆ LoaderRedirectionInformation

HEADLESS_LOADER_BLOCK LoaderRedirectionInformation

◆ NoexecuteDisabled

BOOLEAN NoexecuteDisabled = FALSE

Definition at line 36 of file winldr.c.

Referenced by LoadWindowsCore().

◆ NoexecuteEnabled

BOOLEAN NoexecuteEnabled = FALSE

Definition at line 37 of file winldr.c.

Referenced by LoadWindowsCore().

◆ PaeDisabled

BOOLEAN PaeDisabled = FALSE

Definition at line 33 of file winldr.c.

Referenced by LoadWindowsCore().

◆ PaeEnabled

BOOLEAN PaeEnabled = FALSE

Definition at line 32 of file winldr.c.

Referenced by LoadWindowsCore().

◆ reactos_arc_disk_info

ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[]

Definition at line 21 of file archwsup.c.

Referenced by AddReactOSArcDiskInfo(), and WinLdrInitializePhase1().

◆ reactos_disk_count

ULONG reactos_disk_count

Definition at line 20 of file archwsup.c.

Referenced by AddReactOSArcDiskInfo(), and WinLdrInitializePhase1().

◆ SafeBoot

BOOLEAN SafeBoot = FALSE

Definition at line 34 of file winldr.c.

Referenced by LoadWindowsCore(), and Phase1InitializationDiscard().

◆ SosEnabled

BOOLEAN SosEnabled = FALSE

Definition at line 31 of file winldr.c.

Referenced by LoadWindowsCore(), and Phase1InitializationDiscard().

◆ VirtualBias

BOOLEAN VirtualBias = FALSE

Definition at line 30 of file winldr.c.

Referenced by LoadWindowsCore().

◆ WinLdrSystemBlock

PLOADER_SYSTEM_BLOCK WinLdrSystemBlock

Definition at line 28 of file winldr.c.

Referenced by AllocateAndInitLPB(), LoadReactOSSetup(), and WinLdrInitializePhase1().

◆ WinLdrTerminalConnected

BOOLEAN WinLdrTerminalConnected

Definition at line 31 of file headless.c.

Referenced by WinLdrInitializeHeadlessPort(), and WinLdrInitializePhase1().