ReactOS 0.4.16-dev-981-g80eb313
winldr.c File Reference
#include <freeldr.h>
#include <ndk/ldrtypes.h>
#include "winldr.h"
#include "ntldropts.h"
#include "registry.h"
#include <internal/cmboot.h>
#include <debug.h>
Include dependency graph for winldr.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (WINDOWS)
 
ULONG ArcGetDiskCount (VOID)
 
PARC_DISK_SIGNATURE_EX ArcGetDiskInfo (ULONG Index)
 
BOOLEAN IsAcpiPresent (VOID)
 
VOID WinLdrSetupEms (IN PCSTR BootOptions)
 
VOID DumpMemoryAllocMap (VOID)
 
static VOID NTAPI NtLdrImportDllLoadCallback (_In_ PCSTR FileName)
 
VOID NtLdrOutputLoadMsg (_In_ PCSTR FileName, _In_opt_ PCSTR Description)
 
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 PVOID 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

HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
 
BOOLEAN WinLdrTerminalConnected
 
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
 
PCWSTR BootFileSystem = NULL
 
BOOLEAN VirtualBias = FALSE
 
BOOLEAN SosEnabled = FALSE
 
BOOLEAN SafeBoot = FALSE
 
BOOLEAN BootLogo = FALSE
 
BOOLEAN NoExecuteEnabled = FALSE
 

Function Documentation

◆ AllocateAndInitLPB()

VOID AllocateAndInitLPB ( IN USHORT  VersionToBoot,
OUT PLOADER_PARAMETER_BLOCK OutLoaderBlock 
)

Definition at line 77 of file winldr.c.

80{
81 PLOADER_PARAMETER_BLOCK LoaderBlock;
83
84 /* Allocate and zero-init the Loader Parameter Block */
88 {
89 UiMessageBox("Failed to allocate memory for system block!");
90 return;
91 }
92
94
95 LoaderBlock = &WinLdrSystemBlock->LoaderBlock;
96 LoaderBlock->NlsData = &WinLdrSystemBlock->NlsDataBlock;
97
98 /* Initialize the Loader Block Extension */
100 LoaderBlock->Extension = Extension;
102 Extension->MajorVersion = (VersionToBoot & 0xFF00) >> 8;
103 Extension->MinorVersion = (VersionToBoot & 0xFF);
104
105 /* Init three critical lists, used right away */
109
110 *OutLoaderBlock = LoaderBlock;
111}
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
VOID UiMessageBox(_In_ PCSTR Format,...)
Definition: ui.c:359
#define NULL
Definition: types.h:112
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
@ LoaderSystemBlock
Definition: arc.h:175
struct _LOADER_PARAMETER_EXTENSION LOADER_PARAMETER_EXTENSION
LIST_ENTRY BootDriverListHead
Definition: arc.h:542
LIST_ENTRY LoadOrderListHead
Definition: arc.h:540
PNLS_DATA_BLOCK NlsData
Definition: arc.h:555
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:559
LIST_ENTRY MemoryDescriptorListHead
Definition: arc.h:541
NLS_DATA_BLOCK NlsDataBlock
Definition: winldr.h:54
LOADER_PARAMETER_EXTENSION Extension
Definition: winldr.h:49
LOADER_PARAMETER_BLOCK LoaderBlock
Definition: winldr.h:48
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
Definition: winldr.c:27

Referenced by LoadAndBootWindows(), and LoadReactOSSetup().

◆ ArcGetDiskCount()

ULONG ArcGetDiskCount ( VOID  )

Definition at line 247 of file archwsup.c.

248{
249 return reactos_disk_count;
250}
ULONG reactos_disk_count
Definition: archwsup.c:68

Referenced by WinLdrInitializePhase1().

◆ ArcGetDiskInfo()

PARC_DISK_SIGNATURE_EX ArcGetDiskInfo ( ULONG  Index)

Definition at line 252 of file archwsup.c.

253{
255 {
256 return NULL;
257 }
258
260}
ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[32]
Definition: archwsup.c:69
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by WinLdrInitializePhase1().

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( WINDOWS  )

◆ DumpMemoryAllocMap()

VOID DumpMemoryAllocMap ( VOID  )

◆ IsAcpiPresent()

BOOLEAN IsAcpiPresent ( VOID  )

Definition at line 28 of file hwacpi.c.

29{
30 return AcpiPresent;
31}
BOOLEAN AcpiPresent
Definition: hwacpi.c:26

Referenced by WinLdrInitializePhase1().

◆ LoadAndBootWindows()

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

Definition at line 979 of file winldr.c.

983{
985 PCSTR ArgValue;
990 USHORT OperatingSystemVersion;
991 PLOADER_PARAMETER_BLOCK LoaderBlock;
992 CHAR BootPath[MAX_PATH];
994 CHAR BootOptions[256];
995
996 /* Retrieve the (mandatory) boot type */
997 ArgValue = GetArgumentValue(Argc, Argv, "BootType");
998 if (!ArgValue || !*ArgValue)
999 {
1000 ERR("No 'BootType' value, aborting!\n");
1001 return EINVAL;
1002 }
1003
1004 /* Convert it to an OS version */
1005 if (_stricmp(ArgValue, "Windows") == 0 ||
1006 _stricmp(ArgValue, "Windows2003") == 0)
1007 {
1008 OperatingSystemVersion = _WIN32_WINNT_WS03;
1009 }
1010 else if (_stricmp(ArgValue, "WindowsNT40") == 0)
1011 {
1012 OperatingSystemVersion = _WIN32_WINNT_NT4;
1013 }
1014 else if (_stricmp(ArgValue, "WindowsVista") == 0)
1015 {
1016 OperatingSystemVersion = _WIN32_WINNT_VISTA;
1017 }
1018 else
1019 {
1020 ERR("Unknown 'BootType' value '%s', aborting!\n", ArgValue);
1021 return EINVAL;
1022 }
1023
1024 /* Retrieve the (mandatory) system partition */
1025 SystemPartition = GetArgumentValue(Argc, Argv, "SystemPartition");
1027 {
1028 ERR("No 'SystemPartition' specified, aborting!\n");
1029 return EINVAL;
1030 }
1031
1032 /* Let the user know we started loading */
1034 UiDrawStatusText("Loading...");
1035 UiDrawProgressBarCenter("Loading NT...");
1036
1037 /* Retrieve the system path */
1038 *BootPath = ANSI_NULL;
1039 ArgValue = GetArgumentValue(Argc, Argv, "SystemPath");
1040 if (ArgValue)
1041 RtlStringCbCopyA(BootPath, sizeof(BootPath), ArgValue);
1042
1043 /*
1044 * Check whether BootPath is a full path
1045 * and if not, create a full boot path.
1046 *
1047 * See FsOpenFile for the technique used.
1048 */
1049 if (strrchr(BootPath, ')') == NULL)
1050 {
1051 /* Temporarily save the boot path */
1052 RtlStringCbCopyA(FilePath, sizeof(FilePath), BootPath);
1053
1054 /* This is not a full path: prepend the SystemPartition */
1055 RtlStringCbCopyA(BootPath, sizeof(BootPath), SystemPartition);
1056
1057 /* Append a path separator if needed */
1058 if (*FilePath != '\\' && *FilePath != '/')
1059 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
1060
1061 /* Append the remaining path */
1062 RtlStringCbCatA(BootPath, sizeof(BootPath), FilePath);
1063 }
1064
1065 /* Append a path separator if needed */
1066 if (!*BootPath || BootPath[strlen(BootPath) - 1] != '\\')
1067 RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
1068
1069 TRACE("BootPath: '%s'\n", BootPath);
1070
1071 /* Retrieve the boot options */
1073 ArgValue = GetArgumentValue(Argc, Argv, "Options");
1074 if (ArgValue && *ArgValue)
1075 RtlStringCbCopyA(BootOptions, sizeof(BootOptions), ArgValue);
1076
1077 /* Append boot-time options */
1079
1080 /*
1081 * Set the "/HAL=" and "/KERNEL=" options if needed.
1082 * If already present on the standard "Options=" option line, they take
1083 * precedence over those passed via the separate "Hal=" and "Kernel="
1084 * options.
1085 */
1086 if (!NtLdrGetOption(BootOptions, "HAL="))
1087 {
1088 /*
1089 * Not found in the options, try to retrieve the
1090 * separate value and append it to the options.
1091 */
1092 ArgValue = GetArgumentValue(Argc, Argv, "Hal");
1093 if (ArgValue && *ArgValue)
1094 {
1095 RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /HAL=");
1096 RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
1097 }
1098 }
1099 if (!NtLdrGetOption(BootOptions, "KERNEL="))
1100 {
1101 /*
1102 * Not found in the options, try to retrieve the
1103 * separate value and append it to the options.
1104 */
1105 ArgValue = GetArgumentValue(Argc, Argv, "Kernel");
1106 if (ArgValue && *ArgValue)
1107 {
1108 RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /KERNEL=");
1109 RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
1110 }
1111 }
1112
1113 TRACE("BootOptions: '%s'\n", BootOptions);
1114
1115 /* Check if a RAM disk file was given */
1117 if (FileName && (FileNameLength > 7))
1118 {
1119 /* Load the RAM disk */
1121 if (Status != ESUCCESS)
1122 {
1123 FileName += 7; FileNameLength -= 7;
1124 UiMessageBox("Failed to load RAM disk file '%.*s'",
1126 return Status;
1127 }
1128 }
1129
1130 /* Handle the SOS option */
1132 if (SosEnabled)
1133 UiResetForSOS();
1134
1135 /* Allocate and minimally-initialize the Loader Parameter Block */
1136 AllocateAndInitLPB(OperatingSystemVersion, &LoaderBlock);
1137
1138 /* Load the system hive */
1139 UiUpdateProgressBar(15, "Loading system hive...");
1140 Success = WinLdrInitSystemHive(LoaderBlock, BootPath, FALSE);
1141 TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
1142 /* Bail out if failure */
1143 if (!Success)
1144 return ENOEXEC;
1145
1146 /* Fixup the version number using data from the registry */
1147 if (OperatingSystemVersion == 0)
1148 OperatingSystemVersion = WinLdrDetectVersion();
1149 LoaderBlock->Extension->MajorVersion = (OperatingSystemVersion & 0xFF00) >> 8;
1150 LoaderBlock->Extension->MinorVersion = (OperatingSystemVersion & 0xFF);
1151
1152 /* Load NLS data, OEM font, and prepare boot drivers list */
1153 Success = WinLdrScanSystemHive(LoaderBlock, BootPath);
1154 TRACE("SYSTEM hive %s\n", (Success ? "scanned" : "not scanned"));
1155 /* Bail out if failure */
1156 if (!Success)
1157 return ENOEXEC;
1158
1159 /* Load the Firmware Errata file */
1160 Success = WinLdrInitErrataInf(LoaderBlock, OperatingSystemVersion, BootPath);
1161 TRACE("Firmware Errata file %s\n", (Success ? "loaded" : "not loaded"));
1162 /* Not necessarily fatal if not found - carry on going */
1163
1164 /* Finish loading */
1165 return LoadAndBootWindowsCommon(OperatingSystemVersion,
1166 LoaderBlock,
1168 BootPath);
1169}
PCWSTR FilePath
unsigned char BOOLEAN
#define EINVAL
Definition: acclib.h:90
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
PSTR GetArgumentValue(_In_ ULONG Argc, _In_ PCHAR Argv[], _In_ PCSTR ArgumentName)
Definition: arcsupp.c:42
PPARTENTRY SystemPartition
Definition: reactos.c:50
#define ERR(fmt,...)
Definition: precomp.h:57
@ BootOptions
Definition: bl.h:898
ARC_STATUS RamDiskInitialize(IN BOOLEAN InitRamDisk, IN PCSTR LoadOptions OPTIONAL, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:206
VOID AppendBootTimeOptions(PCHAR BootOptions)
Definition: options.c:244
VOID UiDrawBackdrop(ULONG DrawHeight)
Definition: ui.c:233
VOID UiUpdateProgressBar(_In_ ULONG Percentage, _In_opt_ PCSTR ProgressText)
Definition: ui.c:454
ULONG UiGetScreenHeight(VOID)
Definition: ui.c:655
VOID UiDrawProgressBarCenter(_In_ PCSTR ProgressText)
Definition: ui.c:487
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:286
VOID UiResetForSOS(VOID)
Definition: ui.c:639
#define _stricmp
Definition: cat.c:22
#define FALSE
Definition: types.h:117
#define MAX_PATH
Definition: compat.h:34
#define ENOEXEC
Definition: errno.h:14
@ Success
Definition: eventcreate.c:712
struct _FileName FileName
Definition: fatprocs.h:897
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ HANDLE _In_ ULONG FileNameLength
Definition: fltkernel.h:1129
Status
Definition: gdiplustypes.h:25
#define ANSI_NULL
BOOLEAN WinLdrInitSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot, IN BOOLEAN Setup)
Definition: wlregistry.c:125
BOOLEAN WinLdrScanSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot)
Definition: wlregistry.c:231
PCSTR NtLdrGetOption(IN PCSTR Options, IN PCSTR OptionName)
Definition: ntldropts.c:128
PCSTR NtLdrGetOptionEx(IN PCSTR Options, IN PCSTR OptionName, OUT PULONG OptionLength OPTIONAL)
Definition: ntldropts.c:117
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
unsigned short USHORT
Definition: pedump.c:61
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
#define _WIN32_WINNT_VISTA
Definition: sdkddkver.h:25
#define TRACE(s)
Definition: solgame.cpp:4
const char * PCSTR
Definition: typedefs.h:52
uint32_t ULONG
Definition: typedefs.h:59
ARC_STATUS LoadAndBootWindowsCommon(IN USHORT OperatingSystemVersion, IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR BootOptions, IN PCSTR BootPath)
Definition: winldr.c:1172
USHORT WinLdrDetectVersion(VOID)
Definition: winldr.c:497
static BOOLEAN WinLdrInitErrataInf(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN USHORT OperatingSystemVersion, IN PCSTR SystemRoot)
Definition: winldr.c:919
BOOLEAN SosEnabled
Definition: winldr.c:31
VOID AllocateAndInitLPB(IN USHORT VersionToBoot, OUT PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
Definition: winldr.c:77
char CHAR
Definition: xmlstorage.h:175

◆ LoadAndBootWindowsCommon()

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

Definition at line 1172 of file winldr.c.

1177{
1178 PLOADER_PARAMETER_BLOCK LoaderBlockVA;
1180 PLDR_DATA_TABLE_ENTRY KernelDTE;
1183
1184 TRACE("LoadAndBootWindowsCommon()\n");
1185
1186 ASSERT(OperatingSystemVersion != 0);
1187
1188#ifdef _M_IX86
1189 /* Setup redirection support */
1191#endif
1192
1193 /* Convert BootPath to SystemRoot */
1194 SystemRoot = strstr(BootPath, "\\");
1195
1196 /* Detect hardware */
1197 UiUpdateProgressBar(20, "Detecting hardware...");
1198 LoaderBlock->ConfigurationRoot = MachHwDetect(BootOptions);
1199
1200 /* Initialize the PE loader import-DLL callback, so that we can obtain
1201 * feedback (for example during SOS) on the PE images that get loaded. */
1203
1204 /* Load the operating system core: the Kernel, the HAL and the Kernel Debugger Transport DLL */
1205 Success = LoadWindowsCore(OperatingSystemVersion,
1206 LoaderBlock,
1208 BootPath,
1209 &KernelDTE);
1210 if (!Success)
1211 {
1212 /* Reset the PE loader import-DLL callback */
1214
1215 UiMessageBox("Error loading NTOS core.");
1216 return ENOEXEC;
1217 }
1218
1219 /* Cleanup INI file */
1220 IniCleanup();
1221
1222/****
1223 **** WE HAVE NOW REACHED THE POINT OF NO RETURN !!
1224 ****/
1225
1226 UiSetProgressBarSubset(40, 90); // NTOS goes from 25 to 75%
1227
1228 /* Load boot drivers */
1229 UiSetProgressBarText("Loading boot drivers...");
1230 Success = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
1231 TRACE("Boot drivers loading %s\n", Success ? "successful" : "failed");
1232
1233 UiSetProgressBarSubset(0, 100);
1234
1235 /* Reset the PE loader import-DLL callback */
1237
1238 /* Initialize Phase 1 - no drivers loading anymore */
1239 WinLdrInitializePhase1(LoaderBlock,
1241 SystemRoot,
1242 BootPath,
1243 OperatingSystemVersion);
1244
1246
1247 /* Save entry-point pointer and Loader block VAs */
1249 LoaderBlockVA = PaToVa(LoaderBlock);
1250
1251 /* "Stop all motors", change videomode */
1253
1254 /* Debugging... */
1255 //DumpMemoryAllocMap();
1256
1257 /* Do the machine specific initialization */
1258 WinLdrSetupMachineDependent(LoaderBlock);
1259
1260 /* Map pages and create memory descriptors */
1261 WinLdrSetupMemoryLayout(LoaderBlock);
1262
1263 /* Set processor context */
1264 WinLdrSetProcessorContext(OperatingSystemVersion);
1265
1266 /* Save final value of LoaderPagesSpanned */
1267 LoaderBlock->Extension->LoaderPagesSpanned = MmGetLoaderPagesSpanned();
1268
1269 TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
1270 KiSystemStartup, LoaderBlockVA);
1271
1272 /* Zero KI_USER_SHARED_DATA page */
1273 RtlZeroMemory((PVOID)KI_USER_SHARED_DATA, MM_PAGE_SIZE);
1274
1275 WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
1276 WinLdrpDumpBootDriver(LoaderBlockVA);
1277#ifndef _M_AMD64
1278 WinLdrpDumpArcDisks(LoaderBlockVA);
1279#endif
1280
1281 /* Pass control */
1282 (*KiSystemStartup)(LoaderBlockVA);
1283
1284 UNREACHABLE; // return ESUCCESS;
1285}
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
VOID MachPrepareForReactOS(VOID)
Definition: arcemul.c:49
PCONFIGURATION_COMPONENT_DATA MachHwDetect(_In_opt_ PCSTR Options)
Definition: arcemul.c:44
VOID WinLdrSetProcessorContext(_In_ USHORT OperatingSystemVersion)
Definition: winldr.c:342
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:374
PFN_NUMBER MmGetLoaderPagesSpanned(VOID)
Definition: mm.c:307
VOID UiSetProgressBarText(_In_ PCSTR ProgressText)
Definition: ui.c:476
VOID UiSetProgressBarSubset(_In_ ULONG Floor, _In_ ULONG Ceiling)
Definition: ui.c:439
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
static const WCHAR SystemRoot[]
Definition: reg.c:38
VOID IniCleanup(VOID)
Definition: inifile.c:243
#define ASSERT(a)
Definition: mode.c:44
#define UNREACHABLE
VOID(NTAPI * KERNEL_ENTRY_POINT)(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.h:13
BOOLEAN WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: wlmemory.c:174
DECLSPEC_NORETURN VOID NTAPI KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kiinit.c:476
PELDR_IMPORTDLL_LOAD_CALLBACK PeLdrImportDllLoadCallback
Definition: peloader.c:30
#define KI_USER_SHARED_DATA
Definition: btrfs_drv.h:1876
PVOID EntryPoint
Definition: ntddk_ex.h:203
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:621
BOOLEAN WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootPath)
Definition: winldr.c:379
VOID WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1326
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:115
VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1288
VOID WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1307
static VOID NTAPI NtLdrImportDllLoadCallback(_In_ PCSTR FileName)
Definition: winldr.c:45

Referenced by LoadAndBootWindows(), and LoadReactOSSetup().

◆ LoadModule()

static PVOID 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 516 of file winldr.c.

524{
526 CHAR FullFileName[MAX_PATH];
527 CHAR ProgressString[256];
529
530 RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", File);
531 UiUpdateProgressBar(Percentage, ProgressString);
532
533 RtlStringCbCopyA(FullFileName, sizeof(FullFileName), Path);
534 RtlStringCbCatA(FullFileName, sizeof(FullFileName), File);
535
536 NtLdrOutputLoadMsg(FullFileName, NULL);
537 Success = PeLdrLoadImage(FullFileName, MemoryType, &BaseAddress);
538 if (!Success)
539 {
540 ERR("PeLdrLoadImage('%s') failed\n", File);
541 return NULL;
542 }
543 TRACE("%s loaded successfully at %p\n", File, BaseAddress);
544
545 Success = PeLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
546 ImportName,
547 FullFileName,
549 Dte);
550 if (!Success)
551 {
552 /* Cleanup and bail out */
553 ERR("PeLdrAllocateDataTableEntry('%s') failed\n", FullFileName);
555 return NULL;
556 }
557
558 /* Init security cookie */
560
561 return BaseAddress;
562}
PRTL_UNICODE_STRING_BUFFER Path
VOID MmFreeMemory(PVOID MemoryPointer)
Definition: mm.c:215
Definition: File.h:16
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID * BaseAddress
Definition: mmfuncs.h:404
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
PVOID PeLdrInitSecurityCookie(_In_ PLDR_DATA_TABLE_ENTRY LdrEntry)
BOOLEAN PeLdrAllocateDataTableEntry(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH BaseDllName, IN PCCH FullDllName, IN PVOID BaseVA, OUT PLDR_DATA_TABLE_ENTRY *NewEntry)
Definition: peloader.c:709
BOOLEAN PeLdrLoadImage(_In_ PCSTR FilePath, _In_ TYPE_OF_MEMORY MemoryType, _Out_ PVOID *ImageBasePA)
Definition: peloader.c:1043
VOID NtLdrOutputLoadMsg(_In_ PCSTR FileName, _In_opt_ PCSTR Description)
Definition: winldr.c:52

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 621 of file winldr.c.

626{
628 PCSTR Option;
629 ULONG OptionLength;
630 PVOID KernelBase, HalBase, KdDllBase = NULL;
631 PLDR_DATA_TABLE_ENTRY HalDTE, KdDllDTE = NULL;
632 CHAR DirPath[MAX_PATH];
633 CHAR HalFileName[MAX_PATH];
634 CHAR KernelFileName[MAX_PATH];
635 CHAR KdDllName[MAX_PATH];
636
637 if (!KernelDTE) return FALSE;
638
639 /* Initialize SystemRoot\System32 path */
640 RtlStringCbCopyA(DirPath, sizeof(DirPath), BootPath);
641 RtlStringCbCatA(DirPath, sizeof(DirPath), "system32\\");
642
643 /* Parse the boot options */
644 TRACE("LoadWindowsCore: BootOptions '%s'\n", BootOptions);
645
646#ifdef _M_IX86
647 if (NtLdrGetOption(BootOptions, "3GB"))
648 {
649 /* We found the 3GB option. */
650 FIXME("LoadWindowsCore: 3GB - TRUE (not implemented)\n");
652 }
653 // TODO: "USERVA=" for XP/2k3
654#endif
655
656 if ((OperatingSystemVersion > _WIN32_WINNT_NT4) &&
657 (NtLdrGetOption(BootOptions, "SAFEBOOT") ||
658 NtLdrGetOption(BootOptions, "SAFEBOOT:")))
659 {
660 /* We found the SAFEBOOT option. */
661 FIXME("LoadWindowsCore: SAFEBOOT - TRUE (not implemented)\n");
662 SafeBoot = TRUE;
663 }
664
665 if ((OperatingSystemVersion > _WIN32_WINNT_WIN2K) &&
666 NtLdrGetOption(BootOptions, "BOOTLOGO"))
667 {
668 /* We found the BOOTLOGO option. */
669 FIXME("LoadWindowsCore: BOOTLOGO - TRUE (not implemented)\n");
670 BootLogo = TRUE;
671 }
672
673 /* Check the (NO)EXECUTE options */
674 if ((OperatingSystemVersion > _WIN32_WINNT_WIN2K) &&
675 !LoaderBlock->SetupLdrBlock)
676 {
677 /* Disable NX by default on x86, otherwise enable it */
678#ifdef _M_IX86
680#else
682#endif
683
684#ifdef _M_IX86
685 /* Check the options in decreasing order of precedence */
686 if (NtLdrGetOption(BootOptions, "NOEXECUTE=OPTIN") ||
687 NtLdrGetOption(BootOptions, "NOEXECUTE=OPTOUT") ||
688 NtLdrGetOption(BootOptions, "NOEXECUTE=ALWAYSON"))
689 {
691 }
692 else if (NtLdrGetOption(BootOptions, "NOEXECUTE=ALWAYSOFF"))
694 else
695#else
696 /* Only the following two options really apply for x64 and other platforms */
697#endif
698 if (NtLdrGetOption(BootOptions, "NOEXECUTE"))
700 else if (NtLdrGetOption(BootOptions, "EXECUTE"))
702
703#ifdef _M_IX86
704 /* Disable DEP in SafeBoot mode for x86 only */
705 if (SafeBoot)
707#endif
708 }
709 TRACE("NoExecuteEnabled %X\n", NoExecuteEnabled);
710
711 /*
712 * Select the HAL and KERNEL file names.
713 * Check for any "/HAL=" or "/KERNEL=" override option.
714 *
715 * See the following links to know how the file names are actually chosen:
716 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/detecthal.htm
717 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/hal.htm
718 * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/kernel.htm
719 */
720 /* Default HAL and KERNEL file names */
721 RtlStringCbCopyA(HalFileName , sizeof(HalFileName) , "hal.dll");
722 RtlStringCbCopyA(KernelFileName, sizeof(KernelFileName), "ntoskrnl.exe");
723
724 Option = NtLdrGetOptionEx(BootOptions, "HAL=", &OptionLength);
725 if (Option && (OptionLength > 4))
726 {
727 /* Retrieve the HAL file name */
728 Option += 4; OptionLength -= 4;
729 RtlStringCbCopyNA(HalFileName, sizeof(HalFileName), Option, OptionLength);
730 _strlwr(HalFileName);
731 }
732
733 Option = NtLdrGetOptionEx(BootOptions, "KERNEL=", &OptionLength);
734 if (Option && (OptionLength > 7))
735 {
736 /* Retrieve the KERNEL file name */
737 Option += 7; OptionLength -= 7;
738 RtlStringCbCopyNA(KernelFileName, sizeof(KernelFileName), Option, OptionLength);
739 _strlwr(KernelFileName);
740 }
741
742#ifdef _M_IX86
743 /* Check for PAE support and select the adequate kernel image */
744 PaeModeOn = WinLdrIsPaeSupported(OperatingSystemVersion,
745 LoaderBlock,
747 HalFileName,
748 KernelFileName,
749 sizeof(KernelFileName));
750 if (PaeModeOn) FIXME("WinLdrIsPaeSupported: PaeModeOn\n");
751#endif
752
753 TRACE("HAL file = '%s' ; Kernel file = '%s'\n", HalFileName, KernelFileName);
754
755 /*
756 * Load the core NT files: Kernel, HAL and KD transport DLL.
757 * Cheat about their base DLL name so as to satisfy the imports/exports,
758 * even if the corresponding underlying files do not have the same names
759 * -- this happens e.g. with UP vs. MP kernel, standard vs. ACPI hal, or
760 * different KD transport DLLs.
761 */
762
763 /* Load the Kernel */
764 KernelBase = LoadModule(LoaderBlock, DirPath, KernelFileName,
765 "ntoskrnl.exe", LoaderSystemCode, KernelDTE, 30);
766 if (!KernelBase)
767 {
768 ERR("LoadModule('%s') failed\n", KernelFileName);
769 UiMessageBox("Could not load %s", KernelFileName);
770 return FALSE;
771 }
772
773 /* Load the HAL */
774 HalBase = LoadModule(LoaderBlock, DirPath, HalFileName,
775 "hal.dll", LoaderHalCode, &HalDTE, 35);
776 if (!HalBase)
777 {
778 ERR("LoadModule('%s') failed\n", HalFileName);
779 UiMessageBox("Could not load %s", HalFileName);
780 PeLdrFreeDataTableEntry(*KernelDTE);
782 return FALSE;
783 }
784
785 /* Load the Kernel Debugger Transport DLL */
786 if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
787 {
788 /*
789 * According to http://www.nynaeve.net/?p=173 :
790 * "[...] Another enhancement that could be done Microsoft-side would be
791 * a better interface for replacing KD transport modules. Right now, due
792 * to the fact that ntoskrnl is static linked to KDCOM.DLL, the OS loader
793 * has a hardcoded hack that interprets the KD type in the OS loader options,
794 * loads one of the (hardcoded filenames) "kdcom.dll", "kd1394.dll", or
795 * "kdusb2.dll" modules, and inserts them into the loaded module list under
796 * the name "kdcom.dll". [...]"
797 */
798
799 /*
800 * A Kernel Debugger Transport DLL is always loaded for Windows XP+ :
801 * either the standard KDCOM.DLL (by default): IsCustomKdDll == FALSE
802 * or an alternative user-provided one via the /DEBUGPORT= option:
803 * IsCustomKdDll == TRUE if it does not specify the default KDCOM.
804 */
805 BOOLEAN IsCustomKdDll = FALSE;
806
807 /* Check whether there is a DEBUGPORT option */
808 Option = NtLdrGetOptionEx(BootOptions, "DEBUGPORT=", &OptionLength);
809 if (Option && (OptionLength > 10))
810 {
811 /* Move to the debug port name */
812 Option += 10; OptionLength -= 10;
813
814 /*
815 * Parse the port name.
816 * Format: /DEBUGPORT=COM[0-9]
817 * or: /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log
818 * or: /DEBUGPORT=FOO
819 * If we only have /DEBUGPORT= (i.e. without any port name),
820 * default to "COM".
821 */
822
823 /* Get the actual length of the debug port
824 * until the next whitespace or colon. */
825 OptionLength = (ULONG)strcspn(Option, " \t:");
826
827 if ((OptionLength == 0) ||
828 ( (OptionLength >= 3) && (_strnicmp(Option, "COM", 3) == 0) &&
829 ((OptionLength == 3) || ('0' <= Option[3] && Option[3] <= '9')) ))
830 {
831 /* The standard KDCOM.DLL is used */
832 }
833 else
834 {
835 /* A custom KD DLL is used */
836 IsCustomKdDll = TRUE;
837 }
838 }
839 if (!IsCustomKdDll)
840 {
841 Option = "COM"; OptionLength = 3;
842 }
843
844 RtlStringCbPrintfA(KdDllName, sizeof(KdDllName), "kd%.*s.dll",
845 OptionLength, Option);
846 _strlwr(KdDllName);
847
848 /* Load the KD DLL. Override its base DLL name to the default "KDCOM.DLL". */
849 KdDllBase = LoadModule(LoaderBlock, DirPath, KdDllName,
850 "kdcom.dll", LoaderSystemCode, &KdDllDTE, 40);
851 if (!KdDllBase)
852 {
853 /* If we failed to load a custom KD DLL, fall back to the standard one */
854 if (IsCustomKdDll)
855 {
856 /* The custom KD DLL being optional, just ignore the failure */
857 WARN("LoadModule('%s') failed\n", KdDllName);
858
859 IsCustomKdDll = FALSE;
860 RtlStringCbCopyA(KdDllName, sizeof(KdDllName), "kdcom.dll");
861
862 KdDllBase = LoadModule(LoaderBlock, DirPath, KdDllName,
863 "kdcom.dll", LoaderSystemCode, &KdDllDTE, 40);
864 }
865
866 if (!KdDllBase)
867 {
868 /* Ignore the failure; we will fail later when scanning the
869 * kernel import tables, if it really needs the KD DLL. */
870 ERR("LoadModule('%s') failed\n", KdDllName);
871 }
872 }
873 }
874
875 /* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
876 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, *KernelDTE);
877 if (!Success)
878 {
879 UiMessageBox("Could not load %s", KernelFileName);
880 goto Quit;
881 }
882 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, HalDTE);
883 if (!Success)
884 {
885 UiMessageBox("Could not load %s", HalFileName);
886 goto Quit;
887 }
888 if (KdDllDTE)
889 {
890 Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, KdDllDTE);
891 if (!Success)
892 {
893 UiMessageBox("Could not load %s", KdDllName);
894 goto Quit;
895 }
896 }
897
898Quit:
899 if (!Success)
900 {
901 /* Cleanup and bail out */
902 if (KdDllDTE)
903 PeLdrFreeDataTableEntry(KdDllDTE);
904 if (KdDllBase) // Optional
905 MmFreeMemory(KdDllBase);
906
908 MmFreeMemory(HalBase);
909
910 PeLdrFreeDataTableEntry(*KernelDTE);
912 }
913
914 return Success;
915}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define TRUE
Definition: types.h:120
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
ULONG_PTR KernelBase
Definition: halinit_mp.c:20
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 PeLdrScanImportDescriptorTable(IN OUT PLIST_ENTRY ModuleListHead, IN PCCH DirectoryPath, IN PLDR_DATA_TABLE_ENTRY ScanDTE)
Definition: peloader.c:629
VOID PeLdrFreeDataTableEntry(_In_ PLDR_DATA_TABLE_ENTRY Entry)
Definition: peloader.c:826
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
@ LoaderSystemCode
Definition: arc.h:183
@ LoaderHalCode
Definition: arc.h:184
_strlwr
Definition: string.h:231
#define _WIN32_WINNT_WIN2K
Definition: sdkddkver.h:21
BOOLEAN VirtualBias
Definition: winldr.c:30
BOOLEAN BootLogo
Definition: winldr.c:33
BOOLEAN NoExecuteEnabled
Definition: winldr.c:37
BOOLEAN SafeBoot
Definition: winldr.c:32
static PVOID 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:516

Referenced by LoadAndBootWindowsCommon().

◆ NtLdrImportDllLoadCallback()

static VOID NTAPI NtLdrImportDllLoadCallback ( _In_ PCSTR  FileName)
static

Definition at line 45 of file winldr.c.

Referenced by LoadAndBootWindowsCommon().

◆ NtLdrOutputLoadMsg()

VOID NtLdrOutputLoadMsg ( _In_ PCSTR  FileName,
_In_opt_ PCSTR  Description 
)

Definition at line 52 of file winldr.c.

55{
56 if (SosEnabled)
57 {
58 printf(" %s\n", FileName);
59 TRACE("Loading: %s\n", FileName);
60 }
61 else
62 {
63 /* Inform the user we load a file */
64 CHAR ProgressString[256];
65
66 RtlStringCbPrintfA(ProgressString, sizeof(ProgressString),
67 "Loading %s...",
69 // UiSetProgressBarText(ProgressString);
70 // UiIndicateProgress();
71 UiDrawStatusText(ProgressString);
72 }
73}
static const WCHAR Description[]
Definition: oid.c:1266
#define printf
Definition: freeldr.h:97

Referenced by LoadModule(), NtLdrImportDllLoadCallback(), WinLdrLoadDeviceDriver(), WinLdrLoadModule(), WinLdrLoadNLSData(), and WinLdrLoadSystemHive().

◆ WinLdrDetectVersion()

USHORT WinLdrDetectVersion ( VOID  )

Definition at line 497 of file winldr.c.

498{
499 LONG rc;
500 HKEY hKey;
501
502 rc = RegOpenKey(CurrentControlSetKey, L"Control\\Terminal Server", &hKey);
503 if (rc != ERROR_SUCCESS)
504 {
505 /* Key doesn't exist; assume NT 4.0 */
506 return _WIN32_WINNT_NT4;
507 }
509
510 /* We may here want to read the value of ProductVersion */
511 return _WIN32_WINNT_WS03;
512}
HKEY CurrentControlSetKey
Definition: registry.c:34
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
FxAutoRegKey hKey
#define L(x)
Definition: ntvdm.h:50
long LONG
Definition: pedump.c:60
#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 919 of file winldr.c.

923{
924 LONG rc;
925 HKEY hKey;
928 PVOID PhysicalBase;
929 WCHAR szFileName[80];
930 CHAR ErrataFilePath[MAX_PATH];
931
932 /* Open either the 'BiosInfo' (Windows <= 2003) or the 'Errata' (Vista+) key */
933 if (OperatingSystemVersion >= _WIN32_WINNT_VISTA)
934 {
935 rc = RegOpenKey(CurrentControlSetKey, L"Control\\Errata", &hKey);
936 }
937 else // (OperatingSystemVersion <= _WIN32_WINNT_WS03)
938 {
939 rc = RegOpenKey(CurrentControlSetKey, L"Control\\BiosInfo", &hKey);
940 }
941 if (rc != ERROR_SUCCESS)
942 {
943 WARN("Could not open the BiosInfo/Errata registry key (Error %u)\n", (int)rc);
944 return FALSE;
945 }
946
947 /* Retrieve the INF file name value */
948 BufferSize = sizeof(szFileName);
949 rc = RegQueryValue(hKey, L"InfName", NULL, (PUCHAR)szFileName, &BufferSize);
950 if (rc != ERROR_SUCCESS)
951 {
952 WARN("Could not retrieve the InfName value (Error %u)\n", (int)rc);
954 return FALSE;
955 }
956
957 // TODO: "SystemBiosDate"
958
960
961 RtlStringCbPrintfA(ErrataFilePath, sizeof(ErrataFilePath), "%s%s%S",
962 SystemRoot, "inf\\", szFileName);
963
964 /* Load the INF file */
965 PhysicalBase = WinLdrLoadModule(ErrataFilePath, &FileSize, LoaderRegistryData);
966 if (!PhysicalBase)
967 {
968 WARN("Could not load '%s'\n", ErrataFilePath);
969 return FALSE;
970 }
971
972 LoaderBlock->Extension->EmInfFileImage = PaToVa(PhysicalBase);
973 LoaderBlock->Extension->EmInfFileSize = FileSize;
974
975 return TRUE;
976}
#define BufferSize
Definition: mmc.h:75
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
@ LoaderRegistryData
Definition: arc.h:193
unsigned char * PUCHAR
Definition: typedefs.h:53
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:440
#define RegQueryValue
Definition: winreg.h:523
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by LoadAndBootWindows().

◆ WinLdrInitializePhase1()

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

Definition at line 115 of file winldr.c.

120{
121 /*
122 * Examples of correct options and paths:
123 * CHAR Options[] = "/DEBUGPORT=COM1 /BAUDRATE=115200";
124 * CHAR Options[] = "/NODEBUG";
125 * CHAR SystemRoot[] = "\\WINNT\\";
126 * CHAR ArcBoot[] = "multi(0)disk(0)rdisk(0)partition(1)";
127 */
128
129 PSTR LoadOptions, NewLoadOptions;
130 CHAR HalPath[] = "\\";
131 CHAR ArcBoot[MAX_PATH+1];
132 CHAR MiscFiles[MAX_PATH+1];
133 ULONG i;
134 ULONG_PTR PathSeparator;
136
137 /* Construct SystemRoot and ArcBoot from SystemPath */
138 PathSeparator = strstr(BootPath, "\\") - BootPath;
139 RtlStringCbCopyNA(ArcBoot, sizeof(ArcBoot), BootPath, PathSeparator);
140
141 TRACE("ArcBoot: '%s'\n", ArcBoot);
142 TRACE("SystemRoot: '%s'\n", SystemRoot);
143 TRACE("Options: '%s'\n", Options);
144
145 /* Fill ARC BootDevice */
148 LoaderBlock->ArcBootDeviceName = PaToVa(LoaderBlock->ArcBootDeviceName);
149
150//
151// IMPROVE!!
152// SetupBlock->ArcSetupDeviceName must be the path to the setup **SOURCE**,
153// and not the setup boot path. Indeed they may differ!!
154//
155 if (LoaderBlock->SetupLdrBlock)
156 {
157 PSETUP_LOADER_BLOCK SetupBlock = LoaderBlock->SetupLdrBlock;
158
159 /* Adjust the ARC path in the setup block - Matches ArcBoot path */
161 SetupBlock->ArcSetupDeviceName = PaToVa(SetupBlock->ArcSetupDeviceName);
162
163 /* Convert the setup block pointer */
164 LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
165 }
166
167 /* Fill ARC HalDevice, it matches ArcBoot path */
169 LoaderBlock->ArcHalDeviceName = PaToVa(LoaderBlock->ArcHalDeviceName);
170
171 /* Fill SystemRoot */
174 LoaderBlock->NtBootPathName = PaToVa(LoaderBlock->NtBootPathName);
175
176 /* Fill NtHalPathName */
178 RtlStringCbCopyA(LoaderBlock->NtHalPathName, sizeof(WinLdrSystemBlock->NtHalPathName), HalPath);
179 LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName);
180
181 /* Fill LoadOptions and strip the '/' switch symbol in front of each option */
182 NewLoadOptions = LoadOptions = LoaderBlock->LoadOptions = WinLdrSystemBlock->LoadOptions;
184
185 do
186 {
187 while (*LoadOptions == '/')
188 ++LoadOptions;
189
190 *NewLoadOptions++ = *LoadOptions;
191 } while (*LoadOptions++);
192
193 LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions);
194
195 /* ARC devices */
198
199 /* Convert ARC disk information from freeldr to a correct format */
200 ULONG DiscCount = ArcGetDiskCount();
201 for (i = 0; i < DiscCount; i++)
202 {
203 PARC_DISK_SIGNATURE_EX ArcDiskSig;
204
205 /* Allocate the ARC structure */
206 ArcDiskSig = FrLdrHeapAlloc(sizeof(ARC_DISK_SIGNATURE_EX), 'giSD');
207 if (!ArcDiskSig)
208 {
209 ERR("Failed to allocate ARC structure! Ignoring remaining ARC disks. (i = %lu, DiskCount = %lu)\n",
210 i, DiscCount);
211 break;
212 }
213
214 /* Copy the data over */
216
217 /* Set the ARC Name pointer */
218 ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName);
219
220 /* Insert into the list */
222 &ArcDiskSig->DiskSignature.ListEntry);
223 }
224
225 /* Convert all lists to Virtual address */
226
227 /* Convert the ArcDisks list to virtual address */
229 LoaderBlock->ArcDiskInformation = PaToVa(LoaderBlock->ArcDiskInformation);
230
231 /* Convert configuration entries to VA */
233 LoaderBlock->ConfigurationRoot = PaToVa(LoaderBlock->ConfigurationRoot);
234
235 /* Convert all DTE into virtual addresses */
236 List_PaToVa(&LoaderBlock->LoadOrderListHead);
237
238 /* This one will be converted right before switching to virtual paging mode */
239 //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
240
241 /* Convert list of boot drivers */
242 List_PaToVa(&LoaderBlock->BootDriverListHead);
243
244 Extension = LoaderBlock->Extension;
245
246 /* FIXME! HACK value for docking profile */
247 Extension->Profile.Status = 2;
248
249 /* Check if FreeLdr detected a ACPI table */
250 if (IsAcpiPresent())
251 {
252 /* Set the pointer to something for compatibility */
253 Extension->AcpiTable = (PVOID)1;
254 // FIXME: Extension->AcpiTableSize;
255 }
256
257 if (VersionToBoot >= _WIN32_WINNT_VISTA)
258 {
259 Extension->BootViaWinload = 1;
260 Extension->LoaderPerformanceData = PaToVa(&WinLdrSystemBlock->LoaderPerformanceData);
261
262 InitializeListHead(&Extension->BootApplicationPersistentData);
263 List_PaToVa(&Extension->BootApplicationPersistentData);
264 }
265
266#ifdef _M_IX86
267 /* Set headless block pointer */
269 {
270 Extension->HeadlessLoaderBlock = &WinLdrSystemBlock->HeadlessLoaderBlock;
271 RtlCopyMemory(Extension->HeadlessLoaderBlock,
273 sizeof(HEADLESS_LOADER_BLOCK));
274 Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
275 }
276#endif
277 /* Load drivers database */
278 RtlStringCbCopyA(MiscFiles, sizeof(MiscFiles), BootPath);
279 RtlStringCbCatA(MiscFiles, sizeof(MiscFiles), "AppPatch\\drvmain.sdb");
280 Extension->DrvDBImage = PaToVa(WinLdrLoadModule(MiscFiles,
281 &Extension->DrvDBSize,
283
284 /* Convert the extension block pointer */
285 LoaderBlock->Extension = PaToVa(LoaderBlock->Extension);
286
287 TRACE("WinLdrInitializePhase1() completed\n");
288}
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
Definition: conversion.c:51
#define InsertTailList(ListHead, Entry)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry)
LIST_ENTRY DiskSignatureListHead
Definition: arc.h:268
CHAR ArcName[MAX_PATH]
Definition: winldr.h:37
ARC_DISK_SIGNATURE DiskSignature
Definition: winldr.h:36
LIST_ENTRY ListEntry
Definition: arc.h:255
PCHAR ArcName
Definition: arc.h:257
PCONFIGURATION_COMPONENT_DATA ConfigurationRoot
Definition: arc.h:549
PARC_DISK_INFORMATION ArcDiskInformation
Definition: arc.h:556
PSTR ArcBootDeviceName
Definition: arc.h:550
struct _SETUP_LOADER_BLOCK * SetupLdrBlock
Definition: arc.h:558
CHAR NtHalPathName[MAX_PATH+1]
Definition: winldr.h:59
ARC_DISK_INFORMATION ArcDiskInformation
Definition: winldr.h:60
CHAR NtBootPathName[MAX_PATH+1]
Definition: winldr.h:58
CHAR ArcBootDeviceName[MAX_PATH+1]
Definition: winldr.h:56
LOADER_PERFORMANCE_DATA LoaderPerformanceData
Definition: winldr.h:61
CHAR LoadOptions[MAX_OPTIONS_LENGTH+1]
Definition: winldr.h:55
PCHAR ArcSetupDeviceName
Definition: setupblk.h:112
char * PSTR
Definition: typedefs.h:51
void * PVOID
Definition: typedefs.h:50
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG_PTR
Definition: typedefs.h:65
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534
BOOLEAN IsAcpiPresent(VOID)
Definition: hwacpi.c:28
ULONG ArcGetDiskCount(VOID)
Definition: archwsup.c:247
PARC_DISK_SIGNATURE_EX ArcGetDiskInfo(ULONG Index)
Definition: archwsup.c:252
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:30
BOOLEAN WinLdrTerminalConnected
Definition: headless.c:31

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrLoadBootDrivers()

BOOLEAN WinLdrLoadBootDrivers ( PLOADER_PARAMETER_BLOCK  LoaderBlock,
PCSTR  BootPath 
)

Definition at line 379 of file winldr.c.

381{
382 PLIST_ENTRY NextBd;
383 PBOOT_DRIVER_NODE DriverNode;
384 PBOOT_DRIVER_LIST_ENTRY BootDriver;
386 BOOLEAN ret = TRUE;
387
388 /* Walk through the boot drivers list */
389 NextBd = LoaderBlock->BootDriverListHead.Flink;
390 while (NextBd != &LoaderBlock->BootDriverListHead)
391 {
392 DriverNode = CONTAINING_RECORD(NextBd,
394 ListEntry.Link);
395 BootDriver = &DriverNode->ListEntry;
396
397 /* Get the next list entry as we may remove the current one on failure */
398 NextBd = BootDriver->Link.Flink;
399
400 TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n",
401 &BootDriver->FilePath, BootDriver->LdrEntry,
402 &BootDriver->RegistryPath);
403
404 // Paths are relative (FIXME: Are they always relative?)
405
406 /* Load it */
409 BootPath,
410 &BootDriver->FilePath,
411 0,
412 &BootDriver->LdrEntry);
413 if (Success)
414 {
415 /* Convert the addresses to VA since we are not going to use them anymore */
416 BootDriver->RegistryPath.Buffer = PaToVa(BootDriver->RegistryPath.Buffer);
417 BootDriver->FilePath.Buffer = PaToVa(BootDriver->FilePath.Buffer);
418 BootDriver->LdrEntry = PaToVa(BootDriver->LdrEntry);
419
420 if (DriverNode->Group.Buffer)
421 DriverNode->Group.Buffer = PaToVa(DriverNode->Group.Buffer);
422 DriverNode->Name.Buffer = PaToVa(DriverNode->Name.Buffer);
423 }
424 else
425 {
426 /* Loading failed: cry loudly */
427 ERR("Cannot load boot driver '%wZ'!\n", &BootDriver->FilePath);
428 UiMessageBox("Cannot load boot driver '%wZ'!", &BootDriver->FilePath);
429 ret = FALSE;
430
431 /* Remove it from the list and try to continue */
432 RemoveEntryList(&BootDriver->Link);
433 }
434 }
435
436 return ret;
437}
VOID UiIndicateProgress(VOID)
Definition: ui.c:418
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
Definition: arc.h:246
LIST_ENTRY Link
Definition: arc.h:247
UNICODE_STRING RegistryPath
Definition: arc.h:249
UNICODE_STRING FilePath
Definition: arc.h:248
struct _LDR_DATA_TABLE_ENTRY * LdrEntry
Definition: arc.h:250
UNICODE_STRING Group
Definition: cmboot.h:16
BOOT_DRIVER_LIST_ENTRY ListEntry
Definition: cmboot.h:15
UNICODE_STRING Name
Definition: cmboot.h:17
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
int ret
static BOOLEAN WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead, PCSTR BootPath, PUNICODE_STRING FilePath, ULONG Flags, PLDR_DATA_TABLE_ENTRY *DriverDTE)
Definition: winldr.c:291

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 291 of file winldr.c.

296{
297 CHAR FullPath[1024];
298 CHAR DriverPath[1024];
299 CHAR DllName[1024];
300 PCHAR DriverNamePos;
302 PVOID DriverBase = NULL;
303
304 // Separate the path to file name and directory path
305 RtlStringCbPrintfA(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
306 DriverNamePos = strrchr(DriverPath, '\\');
307 if (DriverNamePos != NULL)
308 {
309 // Copy the name
310 RtlStringCbCopyA(DllName, sizeof(DllName), DriverNamePos+1);
311
312 // Cut out the name from the path
313 *(DriverNamePos+1) = ANSI_NULL;
314 }
315 else
316 {
317 // There is no directory in the path
318 RtlStringCbCopyA(DllName, sizeof(DllName), DriverPath);
319 *DriverPath = ANSI_NULL;
320 }
321
322 TRACE("DriverPath: '%s', DllName: '%s', LPB\n", DriverPath, DllName);
323
324 // Check if driver is already loaded
325 Success = PeLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
326 if (Success)
327 {
328 // We've got the pointer to its DTE, just return success
329 return TRUE;
330 }
331
332 // It's not loaded, we have to load it
333 RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
334
335 NtLdrOutputLoadMsg(FullPath, NULL);
336 Success = PeLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
337 if (!Success)
338 {
339 ERR("PeLdrLoadImage('%s') failed\n", DllName);
340 return FALSE;
341 }
342
343 // Allocate a DTE for it
344 Success = PeLdrAllocateDataTableEntry(LoadOrderListHead,
345 DllName,
346 DllName,
347 PaToVa(DriverBase),
348 DriverDTE);
349 if (!Success)
350 {
351 /* Cleanup and bail out */
352 ERR("PeLdrAllocateDataTableEntry('%s') failed\n", DllName);
353 MmFreeMemory(DriverBase);
354 return FALSE;
355 }
356
357 /* Init security cookie */
358 PeLdrInitSecurityCookie(*DriverDTE);
359
360 // Modify any flags, if needed
361 (*DriverDTE)->Flags |= Flags;
362
363 // Look for any dependencies it may have, and load them too
364 RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%s", BootPath, DriverPath);
365 Success = PeLdrScanImportDescriptorTable(LoadOrderListHead, FullPath, *DriverDTE);
366 if (!Success)
367 {
368 /* Cleanup and bail out */
369 ERR("PeLdrScanImportDescriptorTable('%s') failed\n", FullPath);
370 PeLdrFreeDataTableEntry(*DriverDTE);
371 MmFreeMemory(DriverBase);
372 return FALSE;
373 }
374
375 return TRUE;
376}
BOOLEAN PeLdrCheckForLoadedDll(_Inout_ PLIST_ENTRY ModuleListHead, _In_ PCSTR DllName, _Out_ PLDR_DATA_TABLE_ENTRY *LoadedEntry)
Definition: peloader.c:586
@ LoaderBootDriver
Definition: arc.h:185
char * PCHAR
Definition: typedefs.h:51
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by WinLdrLoadBootDrivers().

◆ WinLdrLoadModule()

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

Definition at line 440 of file winldr.c.

443{
444 ULONG FileId;
445 PVOID PhysicalBase;
450
451 *Size = 0;
452
453 /* Open the image file */
456 if (Status != ESUCCESS)
457 {
458 /* In case of errors, we just return, without complaining to the user */
459 WARN("Error while opening '%s', Status: %u\n", ModuleName, Status);
460 return NULL;
461 }
462
463 /* Retrieve its size */
465 if (Status != ESUCCESS)
466 {
467 ArcClose(FileId);
468 return NULL;
469 }
470 FileSize = FileInfo.EndingAddress.LowPart;
471 *Size = FileSize;
472
473 /* Allocate memory */
474 PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);
475 if (PhysicalBase == NULL)
476 {
477 ERR("Could not allocate memory for '%s'\n", ModuleName);
478 ArcClose(FileId);
479 return NULL;
480 }
481
482 /* Load the whole file */
483 Status = ArcRead(FileId, PhysicalBase, FileSize, &BytesRead);
484 ArcClose(FileId);
485 if (Status != ESUCCESS)
486 {
487 WARN("Error while reading '%s', Status: %u\n", ModuleName, Status);
488 return NULL;
489 }
490
491 TRACE("Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize);
492
493 return PhysicalBase;
494}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1280
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:462
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:219
ARC_STATUS ArcClose(_In_ ULONG FileId)
Definition: fs.c:409
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:448
@ OpenReadOnly
Definition: arc.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:870

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

◆ WinLdrpDumpArcDisks()

VOID WinLdrpDumpArcDisks ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1326 of file winldr.c.

1327{
1328 PLIST_ENTRY NextBd;
1329 PARC_DISK_SIGNATURE ArcDisk;
1330
1331 NextBd = LoaderBlock->ArcDiskInformation->DiskSignatureListHead.Flink;
1332
1333 while (NextBd != &LoaderBlock->ArcDiskInformation->DiskSignatureListHead)
1334 {
1335 ArcDisk = CONTAINING_RECORD(NextBd, ARC_DISK_SIGNATURE, ListEntry);
1336
1337 TRACE("ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
1338 ArcDisk->ArcName, ArcDisk->CheckSum, ArcDisk->Signature);
1339
1340 NextBd = ArcDisk->ListEntry.Flink;
1341 }
1342}
ULONG CheckSum
Definition: arc.h:258
ULONG Signature
Definition: arc.h:256

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrpDumpBootDriver()

VOID WinLdrpDumpBootDriver ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1307 of file winldr.c.

1308{
1309 PLIST_ENTRY NextBd;
1310 PBOOT_DRIVER_LIST_ENTRY BootDriver;
1311
1312 NextBd = LoaderBlock->BootDriverListHead.Flink;
1313
1314 while (NextBd != &LoaderBlock->BootDriverListHead)
1315 {
1316 BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
1317
1318 TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
1319 BootDriver->LdrEntry, &BootDriver->RegistryPath);
1320
1321 NextBd = BootDriver->Link.Flink;
1322 }
1323}
static int Link(const char **args)
Definition: vfdcmd.c:2414

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrpDumpMemoryDescriptors()

VOID WinLdrpDumpMemoryDescriptors ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1288 of file winldr.c.

1289{
1290 PLIST_ENTRY NextMd;
1292
1293 NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1294
1295 while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1296 {
1298
1299 TRACE("BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage,
1300 MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType);
1301
1302 NextMd = MemoryDescriptor->ListEntry.Flink;
1303 }
1304}
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR MemoryDescriptor
Definition: wdfusb.h:1339

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
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
VOID WinLdrInitializeHeadlessPort(VOID)
Definition: headless.c:206
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:30
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
PUCHAR PortAddress
Definition: arc.h:359
USHORT PciDeviceId
Definition: arc.h:360
UCHAR TerminalType
Definition: arc.h:368
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3601

Referenced by LoadAndBootWindowsCommon().

Variable Documentation

◆ BootFileSystem

PCWSTR BootFileSystem = NULL

◆ BootLogo

BOOLEAN BootLogo = FALSE

Definition at line 33 of file winldr.c.

Referenced by DisplayBootBitmap(), and LoadWindowsCore().

◆ LoaderRedirectionInformation

HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
extern

◆ NoExecuteEnabled

BOOLEAN NoExecuteEnabled = FALSE

Definition at line 37 of file winldr.c.

Referenced by LoadWindowsCore().

◆ SafeBoot

BOOLEAN SafeBoot = FALSE

Definition at line 32 of file winldr.c.

Referenced by LoadWindowsCore(), and Phase1InitializationDiscard().

◆ SosEnabled

BOOLEAN SosEnabled = FALSE

◆ VirtualBias

BOOLEAN VirtualBias = FALSE

Definition at line 30 of file winldr.c.

Referenced by LoadWindowsCore().

◆ WinLdrSystemBlock

◆ WinLdrTerminalConnected

BOOLEAN WinLdrTerminalConnected
extern

Definition at line 31 of file headless.c.

Referenced by WinLdrInitializeHeadlessPort(), and WinLdrInitializePhase1().