ReactOS  0.4.15-dev-1201-gb2cf5a4
winldr.c File Reference
#include <freeldr.h>
#include <ndk/ldrtypes.h>
#include "winldr.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 PCHAR 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 (USHORT OperatingSystemVersion, PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootOptions, PCSTR BootPath, BOOLEAN Setup)
 
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 43 of file winldr.c.

46 {
47  PLOADER_PARAMETER_BLOCK LoaderBlock;
49 
50  /* Allocate and zero-init the Loader Parameter Block */
53  if (WinLdrSystemBlock == NULL)
54  {
55  UiMessageBox("Failed to allocate memory for system block!");
56  return;
57  }
58 
60 
61  LoaderBlock = &WinLdrSystemBlock->LoaderBlock;
62  LoaderBlock->NlsData = &WinLdrSystemBlock->NlsDataBlock;
63 
64  /* Initialize the Loader Block Extension */
66  LoaderBlock->Extension = Extension;
67  Extension->Size = sizeof(LOADER_PARAMETER_EXTENSION);
68  Extension->MajorVersion = (VersionToBoot & 0xFF00) >> 8;
69  Extension->MinorVersion = (VersionToBoot & 0xFF);
70 
71  /* Init three critical lists, used right away */
75 
76  *OutLoaderBlock = LoaderBlock;
77 }
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
smooth NULL
Definition: ftsmooth.c:416
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 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:27

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

824 {
826  PCSTR ArgValue;
828  PCHAR File;
830  USHORT OperatingSystemVersion;
831  PLOADER_PARAMETER_BLOCK LoaderBlock;
832  CHAR BootPath[MAX_PATH];
834  CHAR BootOptions[256];
835 
836  /* Retrieve the (mandatory) boot type */
837  ArgValue = GetArgumentValue(Argc, Argv, "BootType");
838  if (!ArgValue || !*ArgValue)
839  {
840  ERR("No 'BootType' value, aborting!\n");
841  return EINVAL;
842  }
843 
844  /* Convert it to an OS version */
845  if (_stricmp(ArgValue, "Windows") == 0 ||
846  _stricmp(ArgValue, "Windows2003") == 0)
847  {
848  OperatingSystemVersion = _WIN32_WINNT_WS03;
849  }
850  else if (_stricmp(ArgValue, "WindowsNT40") == 0)
851  {
852  OperatingSystemVersion = _WIN32_WINNT_NT4;
853  }
854  else
855  {
856  ERR("Unknown 'BootType' value '%s', aborting!\n", ArgValue);
857  return EINVAL;
858  }
859 
860  /* Retrieve the (mandatory) system partition */
861  SystemPartition = GetArgumentValue(Argc, Argv, "SystemPartition");
863  {
864  ERR("No 'SystemPartition' specified, aborting!\n");
865  return EINVAL;
866  }
867 
868  UiDrawBackdrop();
869  UiDrawProgressBarCenter(1, 100, "Loading NT...");
870 
871  /* Retrieve the system path */
872  *BootPath = ANSI_NULL;
873  ArgValue = GetArgumentValue(Argc, Argv, "SystemPath");
874  if (ArgValue)
875  RtlStringCbCopyA(BootPath, sizeof(BootPath), ArgValue);
876 
877  /*
878  * Check whether BootPath is a full path
879  * and if not, create a full boot path.
880  *
881  * See FsOpenFile for the technique used.
882  */
883  if (strrchr(BootPath, ')') == NULL)
884  {
885  /* Temporarily save the boot path */
886  RtlStringCbCopyA(FileName, sizeof(FileName), BootPath);
887 
888  /* This is not a full path: prepend the SystemPartition */
889  RtlStringCbCopyA(BootPath, sizeof(BootPath), SystemPartition);
890 
891  /* Append a path separator if needed */
892  if (*FileName != '\\' && *FileName != '/')
893  RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
894 
895  /* Append the remaining path */
896  RtlStringCbCatA(BootPath, sizeof(BootPath), FileName);
897  }
898 
899  /* Append a path separator if needed */
900  if (!*BootPath || BootPath[strlen(BootPath) - 1] != '\\')
901  RtlStringCbCatA(BootPath, sizeof(BootPath), "\\");
902 
903  TRACE("BootPath: '%s'\n", BootPath);
904 
905  /* Retrieve the boot options */
907  ArgValue = GetArgumentValue(Argc, Argv, "Options");
908  if (ArgValue && *ArgValue)
909  RtlStringCbCopyA(BootOptions, sizeof(BootOptions), ArgValue);
910 
911  /* Append boot-time options */
913 
914  /*
915  * Set "/HAL=" and "/KERNEL=" options if needed.
916  * If already present on the standard "Options=" option line, they take
917  * precedence over those passed via the separate "Hal=" and "Kernel="
918  * options.
919  */
920  if (strstr(BootOptions, "/HAL=") != 0)
921  {
922  /*
923  * Not found in the options, try to retrieve the
924  * separate value and append it to the options.
925  */
926  ArgValue = GetArgumentValue(Argc, Argv, "Hal");
927  if (ArgValue && *ArgValue)
928  {
929  RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /HAL=");
930  RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
931  }
932  }
933  if (strstr(BootOptions, "/KERNEL=") != 0)
934  {
935  /*
936  * Not found in the options, try to retrieve the
937  * separate value and append it to the options.
938  */
939  ArgValue = GetArgumentValue(Argc, Argv, "Kernel");
940  if (ArgValue && *ArgValue)
941  {
942  RtlStringCbCatA(BootOptions, sizeof(BootOptions), " /KERNEL=");
943  RtlStringCbCatA(BootOptions, sizeof(BootOptions), ArgValue);
944  }
945  }
946 
947  TRACE("BootOptions: '%s'\n", BootOptions);
948 
949  /* Check if a ramdisk file was given */
950  File = strstr(BootOptions, "/RDPATH=");
951  if (File)
952  {
953  /* Load the ramdisk */
955  if (Status != ESUCCESS)
956  {
957  File += 8;
958  UiMessageBox("Failed to load RAM disk file '%.*s'",
959  strcspn(File, " \t"), File);
960  return Status;
961  }
962  }
963 
964  /* Let user know we started loading */
965  //UiDrawStatusText("Loading...");
966 
967  /* Allocate and minimally-initialize the Loader Parameter Block */
968  AllocateAndInitLPB(OperatingSystemVersion, &LoaderBlock);
969 
970  /* Load the system hive */
971  UiDrawBackdrop();
972  UiDrawProgressBarCenter(15, 100, "Loading system hive...");
973  Success = WinLdrInitSystemHive(LoaderBlock, BootPath, FALSE);
974  TRACE("SYSTEM hive %s\n", (Success ? "loaded" : "not loaded"));
975  /* Bail out if failure */
976  if (!Success)
977  return ENOEXEC;
978 
979  /* Fixup the version number using data from the registry */
980  if (OperatingSystemVersion == 0)
981  OperatingSystemVersion = WinLdrDetectVersion();
982  LoaderBlock->Extension->MajorVersion = (OperatingSystemVersion & 0xFF00) >> 8;
983  LoaderBlock->Extension->MinorVersion = (OperatingSystemVersion & 0xFF);
984 
985  /* Load NLS data, OEM font, and prepare boot drivers list */
986  Success = WinLdrScanSystemHive(LoaderBlock, BootPath);
987  TRACE("SYSTEM hive %s\n", (Success ? "scanned" : "not scanned"));
988  /* Bail out if failure */
989  if (!Success)
990  return ENOEXEC;
991 
992  /* Load the Firmware Errata file */
993  Success = WinLdrInitErrataInf(LoaderBlock, OperatingSystemVersion, BootPath);
994  TRACE("Firmware Errata file %s\n", (Success ? "loaded" : "not loaded"));
995  /* Not necessarily fatal if not found - carry on going */
996 
997  /* Finish loading */
998  return LoadAndBootWindowsCommon(OperatingSystemVersion,
999  LoaderBlock,
1000  BootOptions,
1001  BootPath,
1002  FALSE);
1003 }
VOID AppendBootTimeOptions(PCHAR BootOptions)
Definition: options.c:252
signed char * PCHAR
Definition: retypes.h:7
ARC_STATUS RamDiskInitialize(IN BOOLEAN InitRamDisk, IN PCSTR LoadOptions OPTIONAL, IN PCSTR DefaultPath OPTIONAL)
Definition: ramdisk.c:204
#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
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
Definition: arc.h:39
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
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:759
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
#define _stricmp
Definition: cat.c:22
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
_In_opt_ PVOID _In_ PCSTR File
Definition: iofuncs.h:615
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
USHORT WinLdrDetectVersion(VOID)
Definition: winldr.c:428
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_PATH
Definition: compat.h:34
static PPARTENTRY SystemPartition
Definition: usetup.c:61
Status
Definition: gdiplustypes.h:24
VOID UiDrawBackdrop(VOID)
Definition: ui.c:214
VOID AllocateAndInitLPB(IN USHORT VersionToBoot, OUT PLOADER_PARAMETER_BLOCK *OutLoaderBlock)
Definition: winldr.c:43
#define ERR(fmt,...)
Definition: debug.h:110
unsigned short USHORT
Definition: pedump.c:61
ARC_STATUS LoadAndBootWindowsCommon(USHORT OperatingSystemVersion, PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootOptions, PCSTR BootPath, BOOLEAN Setup)
Definition: winldr.c:1006
Definition: arc.h:47
const char * PCSTR
Definition: typedefs.h:52
Definition: File.h:15
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
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 ( USHORT  OperatingSystemVersion,
PLOADER_PARAMETER_BLOCK  LoaderBlock,
PCSTR  BootOptions,
PCSTR  BootPath,
BOOLEAN  Setup 
)

Definition at line 1006 of file winldr.c.

1012 {
1013  PLOADER_PARAMETER_BLOCK LoaderBlockVA;
1014  BOOLEAN Success;
1015  PLDR_DATA_TABLE_ENTRY KernelDTE;
1017  PCSTR SystemRoot;
1018 
1019  TRACE("LoadAndBootWindowsCommon()\n");
1020 
1021  ASSERT(OperatingSystemVersion != 0);
1022 
1023 #ifdef _M_IX86
1024  /* Setup redirection support */
1026 #endif
1027 
1028  /* Convert BootPath to SystemRoot */
1029  SystemRoot = strstr(BootPath, "\\");
1030 
1031  /* Detect hardware */
1032  UiDrawBackdrop();
1033  UiDrawProgressBarCenter(20, 100, "Detecting hardware...");
1034  LoaderBlock->ConfigurationRoot = MachHwDetect();
1035 
1036  /* Load the operating system core: the Kernel, the HAL and the Kernel Debugger Transport DLL */
1037  Success = LoadWindowsCore(OperatingSystemVersion,
1038  LoaderBlock,
1039  BootOptions,
1040  BootPath,
1041  &KernelDTE);
1042  if (!Success)
1043  {
1044  UiMessageBox("Error loading NTOS core.");
1045  return ENOEXEC;
1046  }
1047 
1048  /* Load boot drivers */
1049  UiDrawBackdrop();
1050  UiDrawProgressBarCenter(100, 100, "Loading boot drivers...");
1051  Success = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
1052  TRACE("Boot drivers loading %s\n", Success ? "successful" : "failed");
1053 
1054  /* Cleanup ini file */
1055  IniCleanup();
1056 
1057  /* Initialize Phase 1 - no drivers loading anymore */
1058  WinLdrInitializePhase1(LoaderBlock,
1059  BootOptions,
1060  SystemRoot,
1061  BootPath,
1062  OperatingSystemVersion);
1063 
1064  /* Save entry-point pointer and Loader block VAs */
1066  LoaderBlockVA = PaToVa(LoaderBlock);
1067 
1068  /* "Stop all motors", change videomode */
1070 
1071  /* Debugging... */
1072  //DumpMemoryAllocMap();
1073 
1074  /* Do the machine specific initialization */
1075  WinLdrSetupMachineDependent(LoaderBlock);
1076 
1077  /* Map pages and create memory descriptors */
1078  WinLdrSetupMemoryLayout(LoaderBlock);
1079 
1080  /* Set processor context */
1082 
1083  /* Save final value of LoaderPagesSpanned */
1085 
1086  TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
1087  KiSystemStartup, LoaderBlockVA);
1088 
1089  /* Zero KI_USER_SHARED_DATA page */
1090  RtlZeroMemory((PVOID)KI_USER_SHARED_DATA, MM_PAGE_SIZE);
1091 
1092  WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
1093  WinLdrpDumpBootDriver(LoaderBlockVA);
1094 #ifndef _M_AMD64
1095  WinLdrpDumpArcDisks(LoaderBlockVA);
1096 #endif
1097 
1098  /* Pass control */
1099  (*KiSystemStartup)(LoaderBlockVA);
1100  return ESUCCESS;
1101 }
signed char * PCHAR
Definition: retypes.h:7
#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:312
VOID WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1142
Definition: arc.h:32
VOID WinLdrSetProcessorContext(void)
Definition: winldr.c:348
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
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:493
void WinLdrSetupEms(IN PCHAR BootOptions)
Definition: headless.c:303
BOOLEAN WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: wlmemory.c:181
PVOID EntryPoint
Definition: ntddk_ex.h:203
INIT_FUNCTION VOID NTAPI KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kiinit.c:371
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:1123
ULONG_PTR LoaderPagesSpanned
Definition: arc.h:356
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR SystemRoot[]
Definition: reg.c:38
ULONG LoaderPagesSpanned
Definition: mm.c:29
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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:1104
VOID WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR Options, PCSTR SystemRoot, PCSTR BootPath, USHORT VersionToBoot)
Definition: winldr.c:81
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
#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 448 of file winldr.c.

456 {
458  CHAR FullFileName[MAX_PATH];
459  CHAR ProgressString[256];
461 
462  UiDrawBackdrop();
463  RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", File);
464  UiDrawProgressBarCenter(Percentage, 100, ProgressString);
465 
466  RtlStringCbCopyA(FullFileName, sizeof(FullFileName), Path);
467  RtlStringCbCatA(FullFileName, sizeof(FullFileName), File);
468 
469  Success = PeLdrLoadImage(FullFileName, MemoryType, &BaseAddress);
470  if (!Success)
471  {
472  TRACE("Loading %s failed\n", File);
473  return FALSE;
474  }
475  TRACE("%s loaded successfully at %p\n", File, BaseAddress);
476 
477  /*
478  * Cheat about the base DLL name if we are loading
479  * the Kernel Debugger Transport DLL, to make the
480  * PE loader happy.
481  */
482  Success = PeLdrAllocateDataTableEntry(&LoaderBlock->LoadOrderListHead,
483  ImportName,
484  FullFileName,
485  BaseAddress,
486  Dte);
487 
488  return Success;
489 }
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
smooth NULL
Definition: ftsmooth.c:416
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
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 493 of file winldr.c.

498 {
500  PCSTR Options;
501  CHAR DirPath[MAX_PATH];
502  CHAR HalFileName[MAX_PATH];
503  CHAR KernelFileName[MAX_PATH];
504  CHAR KdTransportDllName[MAX_PATH];
505  PLDR_DATA_TABLE_ENTRY HalDTE, KdComDTE = NULL;
506 
507  if (!KernelDTE) return FALSE;
508 
509  /* Initialize SystemRoot\System32 path */
510  RtlStringCbCopyA(DirPath, sizeof(DirPath), BootPath);
511  RtlStringCbCatA(DirPath, sizeof(DirPath), "system32\\");
512 
513  /*
514  * Default HAL and KERNEL file names.
515  * See the following links to know how the file names are actually chosen:
516  * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/detecthal.htm
517  * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/hal.htm
518  * https://www.geoffchappell.com/notes/windows/boot/bcd/osloader/kernel.htm
519  */
520  RtlStringCbCopyA(HalFileName , sizeof(HalFileName) , "hal.dll");
521  RtlStringCbCopyA(KernelFileName, sizeof(KernelFileName), "ntoskrnl.exe");
522 
523  /* Find any "/HAL=" or "/KERNEL=" switch in the boot options */
525  while (Options)
526  {
527  /* Skip possible initial whitespace */
528  Options += strspn(Options, " \t");
529 
530  /* Check whether a new option starts and it is either HAL or KERNEL */
531  if (*Options != '/' || (++Options,
532  !(_strnicmp(Options, "HAL=", 4) == 0 ||
533  _strnicmp(Options, "KERNEL=", 7) == 0)) )
534  {
535  /* Search for another whitespace */
536  Options = strpbrk(Options, " \t");
537  continue;
538  }
539  else
540  {
541  size_t i = strcspn(Options, " \t"); /* Skip whitespace */
542  if (i == 0)
543  {
544  /* Use the default values */
545  break;
546  }
547 
548  /* We have found either HAL or KERNEL options */
549  if (_strnicmp(Options, "HAL=", 4) == 0)
550  {
551  Options += 4; i -= 4;
552  RtlStringCbCopyNA(HalFileName, sizeof(HalFileName), Options, i);
553  _strupr(HalFileName);
554  }
555  else if (_strnicmp(Options, "KERNEL=", 7) == 0)
556  {
557  Options += 7; i -= 7;
558  RtlStringCbCopyNA(KernelFileName, sizeof(KernelFileName), Options, i);
559  _strupr(KernelFileName);
560  }
561  }
562  }
563 
564  TRACE("HAL file = '%s' ; Kernel file = '%s'\n", HalFileName, KernelFileName);
565 
566  /* Load the Kernel */
567  LoadModule(LoaderBlock, DirPath, KernelFileName, "ntoskrnl.exe", LoaderSystemCode, KernelDTE, 30);
568 
569  /* Load the HAL */
570  LoadModule(LoaderBlock, DirPath, HalFileName, "hal.dll", LoaderHalCode, &HalDTE, 45);
571 
572  /* Load the Kernel Debugger Transport DLL */
573  if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
574  {
575  /*
576  * According to http://www.nynaeve.net/?p=173 :
577  * "[...] Another enhancement that could be done Microsoft-side would be
578  * a better interface for replacing KD transport modules. Right now, due
579  * to the fact that ntoskrnl is static linked to KDCOM.DLL, the OS loader
580  * has a hardcoded hack that interprets the KD type in the OS loader options,
581  * loads one of the (hardcoded filenames) "kdcom.dll", "kd1394.dll", or
582  * "kdusb2.dll" modules, and inserts them into the loaded module list under
583  * the name "kdcom.dll". [...]"
584  */
585 
586  /*
587  * This loop replaces a dumb call to strstr(..., "DEBUGPORT=").
588  * Indeed I want it to be case-insensitive to allow "debugport="
589  * or "DeBuGpOrT=" or... , and I don't want it to match malformed
590  * command-line options, such as:
591  *
592  * "...foo DEBUGPORT=xxx bar..."
593  * "...foo/DEBUGPORT=xxx bar..."
594  * "...foo/DEBUGPORT=bar..."
595  *
596  * i.e. the "DEBUGPORT=" switch must start with a slash and be separated
597  * from the rest by whitespace, unless it begins the command-line, e.g.:
598  *
599  * "/DEBUGPORT=COM1 foo...bar..."
600  * "...foo /DEBUGPORT=USB bar..."
601  * or:
602  * "...foo /DEBUGPORT= bar..."
603  * (in that case, we default the port to COM).
604  */
606  while (Options)
607  {
608  /* Skip possible initial whitespace */
609  Options += strspn(Options, " \t");
610 
611  /* Check whether a new option starts and it is the DEBUGPORT one */
612  if (*Options != '/' || _strnicmp(++Options, "DEBUGPORT=", 10) != 0)
613  {
614  /* Search for another whitespace */
615  Options = strpbrk(Options, " \t");
616  continue;
617  }
618  else
619  {
620  /* We found the DEBUGPORT option. Move to the port name. */
621  Options += 10;
622  break;
623  }
624  }
625 
626  if (Options)
627  {
628  /*
629  * We have found the DEBUGPORT option. Parse the port name.
630  * Format: /DEBUGPORT=COM1 or /DEBUGPORT=FILE:\Device\HarddiskX\PartitionY\debug.log or /DEBUGPORT=FOO
631  * If we only have /DEBUGPORT= (i.e. without any port name), defaults it to "COM".
632  */
633  RtlStringCbCopyA(KdTransportDllName, sizeof(KdTransportDllName), "KD");
634  if (_strnicmp(Options, "COM", 3) == 0 && '0' <= Options[3] && Options[3] <= '9')
635  {
636  RtlStringCbCatNA(KdTransportDllName, sizeof(KdTransportDllName), Options, 3);
637  }
638  else
639  {
640  size_t i = strcspn(Options, " \t:"); /* Skip valid separators: whitespace or colon */
641  if (i == 0)
642  RtlStringCbCatA(KdTransportDllName, sizeof(KdTransportDllName), "COM");
643  else
644  RtlStringCbCatNA(KdTransportDllName, sizeof(KdTransportDllName), Options, i);
645  }
646  RtlStringCbCatA(KdTransportDllName, sizeof(KdTransportDllName), ".DLL");
647  _strupr(KdTransportDllName);
648 
649  /*
650  * Load the transport DLL. Override the base DLL name of the
651  * loaded transport DLL to the default "KDCOM.DLL" name.
652  */
653  LoadModule(LoaderBlock, DirPath, KdTransportDllName, "kdcom.dll", LoaderSystemCode, &KdComDTE, 60);
654  }
655  }
656 
657  /* Parse the boot options */
659  TRACE("LoadWindowsCore: BootOptions '%s'\n", BootOptions);
660  while (Options)
661  {
662  /* Skip possible initial whitespace */
663  Options += strspn(Options, " \t");
664 
665  /* Check whether a new option starts */
666  if (*Options == '/')
667  {
668  Options++;
669 
670  if (_strnicmp(Options, "3GB", 3) == 0)
671  {
672  /* We found the 3GB option. */
673  FIXME("LoadWindowsCore: 3GB - TRUE (not implemented)\n");
674  VirtualBias = TRUE;
675  }
676  if (_strnicmp(Options, "SOS", 3) == 0)
677  {
678  /* We found the SOS option. */
679  FIXME("LoadWindowsCore: SOS - TRUE (not implemented)\n");
680  SosEnabled = TRUE;
681  }
682  if (OperatingSystemVersion > _WIN32_WINNT_NT4)
683  {
684  if (_strnicmp(Options, "SAFEBOOT", 8) == 0)
685  {
686  /* We found the SAFEBOOT option. */
687  FIXME("LoadWindowsCore: SAFEBOOT - TRUE (not implemented)\n");
688  SafeBoot = TRUE;
689  }
690  if (_strnicmp(Options, "PAE", 3) == 0)
691  {
692  /* We found the PAE option. */
693  FIXME("LoadWindowsCore: PAE - TRUE (not implemented)\n");
694  PaeEnabled = TRUE;
695  }
696  }
697  if (OperatingSystemVersion > _WIN32_WINNT_WIN2K)
698  {
699  if (_strnicmp(Options, "NOPAE", 5) == 0)
700  {
701  /* We found the NOPAE option. */
702  FIXME("LoadWindowsCore: NOPAE - TRUE (not implemented)\n");
703  PaeDisabled = TRUE;
704  }
705  if (_strnicmp(Options, "BOOTLOGO", 8) == 0)
706  {
707  /* We found the BOOTLOGO option. */
708  FIXME("LoadWindowsCore: BOOTLOGO - TRUE (not implemented)\n");
709  BootLogo = TRUE;
710  }
711  if (!LoaderBlock->SetupLdrBlock)
712  {
713  if (_strnicmp(Options, "NOEXECUTE=ALWAYSOFF", 19) == 0)
714  {
715  /* We found the NOEXECUTE=ALWAYSOFF option. */
716  FIXME("LoadWindowsCore: NOEXECUTE=ALWAYSOFF - TRUE (not implemented)\n");
718  }
719  else if (_strnicmp(Options, "NOEXECUTE", 9) == 0)
720  {
721  /* We found the NOEXECUTE option. */
722  FIXME("LoadWindowsCore: NOEXECUTE - TRUE (not implemented)\n");
724  }
725 
726  if (_strnicmp(Options, "EXECUTE", 7) == 0)
727  {
728  /* We found the EXECUTE option. */
729  FIXME("LoadWindowsCore: EXECUTE - TRUE (not implemented)\n");
731  }
732  }
733  }
734  }
735 
736  /* Search for another whitespace */
737  Options = strpbrk(Options, " \t");
738  }
739 
740  if (SafeBoot)
741  {
742  PaeDisabled = TRUE;
744  }
745 
746  /* Load all referenced DLLs for Kernel, HAL and Kernel Debugger Transport DLL */
747  Success = PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, *KernelDTE);
748  Success &= PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, HalDTE);
749  if (KdComDTE)
750  {
751  Success &= PeLdrScanImportDescriptorTable(&LoaderBlock->LoadOrderListHead, DirPath, KdComDTE);
752  }
753 
754  return Success;
755 }
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:29
BOOLEAN SosEnabled
Definition: winldr.c:30
char * strpbrk(const char *String, const char *Delimiters)
Definition: utclib.c:302
#define TRUE
Definition: types.h:120
BOOLEAN NoexecuteEnabled
Definition: winldr.c:36
_Check_return_ _CRTIMP size_t __cdecl strcspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
char CHAR
Definition: xmlstorage.h:175
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
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
enum OPTION_FLAGS Options
Definition: stats.c:44
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:34
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
#define _WIN32_WINNT_WIN2K
Definition: sdkddkver.h:21
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:111
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
BOOLEAN PaeEnabled
Definition: winldr.c:31
#define TRACE(s)
Definition: solgame.cpp:4
#define MAX_PATH
Definition: compat.h:34
#define _strnicmp(_String1, _String2, _MaxCount)
Definition: compat.h:23
BOOLEAN PaeDisabled
Definition: winldr.c:32
Definition: btrfs_drv.h:1922
BOOLEAN SafeBoot
Definition: winldr.c:33
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:448
_CRTIMP char *__cdecl _strupr(_Inout_z_ char *_String)
BOOLEAN NoexecuteDisabled
Definition: winldr.c:35
const char * PCSTR
Definition: typedefs.h:52
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 428 of file winldr.c.

429 {
430  LONG rc;
431  HKEY hKey;
432 
433  rc = RegOpenKey(NULL,
434  L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Terminal Server",
435  &hKey);
436  if (rc != ERROR_SUCCESS)
437  {
438  /* Key doesn't exist; assume NT 4.0 */
439  return _WIN32_WINNT_NT4;
440  }
441 
442  /* We may here want to read the value of ProductVersion */
443  return _WIN32_WINNT_WS03;
444 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define _WIN32_WINNT_WS03
Definition: sdkddkver.h:23
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
#define _WIN32_WINNT_NT4
Definition: sdkddkver.h:20
static const WCHAR L[]
Definition: oid.c:1250
#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 759 of file winldr.c.

763 {
764  LONG rc;
765  HKEY hKey;
767  ULONG FileSize;
768  PVOID PhysicalBase;
769  WCHAR szFileName[80];
770  CHAR ErrataFilePath[MAX_PATH];
771 
772  /* Open either the 'BiosInfo' (Windows <= 2003) or the 'Errata' (Vista+) key */
773  if (OperatingSystemVersion >= _WIN32_WINNT_VISTA)
774  {
775  rc = RegOpenKey(NULL,
776  L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Errata",
777  &hKey);
778  }
779  else // (OperatingSystemVersion <= _WIN32_WINNT_WS03)
780  {
781  rc = RegOpenKey(NULL,
782  L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\BiosInfo",
783  &hKey);
784  }
785  if (rc != ERROR_SUCCESS)
786  {
787  WARN("Could not open the BiosInfo/Errata registry key (Error %u)\n", (int)rc);
788  return FALSE;
789  }
790 
791  /* Retrieve the INF file name value */
792  BufferSize = sizeof(szFileName);
793  rc = RegQueryValue(hKey, L"InfName", NULL, (PUCHAR)szFileName, &BufferSize);
794  if (rc != ERROR_SUCCESS)
795  {
796  WARN("Could not retrieve the InfName value (Error %u)\n", (int)rc);
797  return FALSE;
798  }
799 
800  // TODO: "SystemBiosDate"
801 
802  RtlStringCbPrintfA(ErrataFilePath, sizeof(ErrataFilePath), "%s%s%S",
803  SystemRoot, "inf\\", szFileName);
804 
805  /* Load the INF file */
806  PhysicalBase = WinLdrLoadModule(ErrataFilePath, &FileSize, LoaderRegistryData);
807  if (!PhysicalBase)
808  {
809  WARN("Could not load '%s'\n", ErrataFilePath);
810  return FALSE;
811  }
812 
813  LoaderBlock->Extension->EmInfFileImage = PaToVa(PhysicalBase);
814  LoaderBlock->Extension->EmInfFileSize = FileSize;
815 
816  return TRUE;
817 }
#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
smooth NULL
Definition: ftsmooth.c:416
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
#define BufferSize
Definition: mmc.h:75
static const WCHAR L[]
Definition: oid.c:1250
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:364
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

Referenced by LoadAndBootWindows().

◆ WinLdrInitializePhase1()

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

Definition at line 81 of file winldr.c.

86 {
87  /*
88  * Examples of correct options and paths:
89  * CHAR Options[] = "/DEBUGPORT=COM1 /BAUDRATE=115200";
90  * CHAR Options[] = "/NODEBUG";
91  * CHAR SystemRoot[] = "\\WINNT\\";
92  * CHAR ArcBoot[] = "multi(0)disk(0)rdisk(0)partition(1)";
93  */
94 
95  PSTR LoadOptions, NewLoadOptions;
96  CHAR HalPath[] = "\\";
97  CHAR ArcBoot[MAX_PATH+1];
98  CHAR MiscFiles[MAX_PATH+1];
99  ULONG i;
100  ULONG_PTR PathSeparator;
102 
103  /* Construct SystemRoot and ArcBoot from SystemPath */
104  PathSeparator = strstr(BootPath, "\\") - BootPath;
105  RtlStringCbCopyNA(ArcBoot, sizeof(ArcBoot), BootPath, PathSeparator);
106 
107  TRACE("ArcBoot: '%s'\n", ArcBoot);
108  TRACE("SystemRoot: '%s'\n", SystemRoot);
109  TRACE("Options: '%s'\n", Options);
110 
111  /* Fill ARC BootDevice */
114  LoaderBlock->ArcBootDeviceName = PaToVa(LoaderBlock->ArcBootDeviceName);
115 
116 //
117 // IMPROVE!!
118 // SetupBlock->ArcSetupDeviceName must be the path to the setup **SOURCE**,
119 // and not the setup boot path. Indeed they may differ!!
120 //
121  if (LoaderBlock->SetupLdrBlock)
122  {
123  PSETUP_LOADER_BLOCK SetupBlock = LoaderBlock->SetupLdrBlock;
124 
125  /* Adjust the ARC path in the setup block - Matches ArcBoot path */
127  SetupBlock->ArcSetupDeviceName = PaToVa(SetupBlock->ArcSetupDeviceName);
128 
129  /* Convert the setup block pointer */
130  LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
131  }
132 
133  /* Fill ARC HalDevice, it matches ArcBoot path */
135  LoaderBlock->ArcHalDeviceName = PaToVa(LoaderBlock->ArcHalDeviceName);
136 
137  /* Fill SystemRoot */
140  LoaderBlock->NtBootPathName = PaToVa(LoaderBlock->NtBootPathName);
141 
142  /* Fill NtHalPathName */
144  RtlStringCbCopyA(LoaderBlock->NtHalPathName, sizeof(WinLdrSystemBlock->NtHalPathName), HalPath);
145  LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName);
146 
147  /* Fill LoadOptions and strip the '/' switch symbol in front of each option */
148  NewLoadOptions = LoadOptions = LoaderBlock->LoadOptions = WinLdrSystemBlock->LoadOptions;
150 
151  do
152  {
153  while (*LoadOptions == '/')
154  ++LoadOptions;
155 
156  *NewLoadOptions++ = *LoadOptions;
157  } while (*LoadOptions++);
158 
159  LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions);
160 
161  /* ARC devices */
164 
165  /* Convert ARC disk information from freeldr to a correct format */
166  for (i = 0; i < reactos_disk_count; i++)
167  {
168  PARC_DISK_SIGNATURE_EX ArcDiskSig;
169 
170  /* Allocate the ARC structure */
171  ArcDiskSig = FrLdrHeapAlloc(sizeof(ARC_DISK_SIGNATURE_EX), 'giSD');
172 
173  /* Copy the data over */
175 
176  /* Set the ARC Name pointer */
177  ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName);
178 
179  /* Insert into the list */
181  &ArcDiskSig->DiskSignature.ListEntry);
182  }
183 
184  /* Convert all lists to Virtual address */
185 
186  /* Convert the ArcDisks list to virtual address */
188  LoaderBlock->ArcDiskInformation = PaToVa(LoaderBlock->ArcDiskInformation);
189 
190  /* Convert configuration entries to VA */
191  ConvertConfigToVA(LoaderBlock->ConfigurationRoot);
192  LoaderBlock->ConfigurationRoot = PaToVa(LoaderBlock->ConfigurationRoot);
193 
194  /* Convert all DTE into virtual addresses */
195  List_PaToVa(&LoaderBlock->LoadOrderListHead);
196 
197  /* This one will be converted right before switching to virtual paging mode */
198  //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
199 
200  /* Convert list of boot drivers */
201  List_PaToVa(&LoaderBlock->BootDriverListHead);
202 
203  Extension = LoaderBlock->Extension;
204 
205  /* FIXME! HACK value for docking profile */
206  Extension->Profile.Status = 2;
207 
208  /* Check if FreeLdr detected a ACPI table */
209  if (AcpiPresent)
210  {
211  /* Set the pointer to something for compatibility */
212  Extension->AcpiTable = (PVOID)1;
213  // FIXME: Extension->AcpiTableSize;
214  }
215 
216 #ifdef _M_IX86
217  /* Set headless block pointer */
219  {
220  Extension->HeadlessLoaderBlock = &WinLdrSystemBlock->HeadlessLoaderBlock;
221  RtlCopyMemory(Extension->HeadlessLoaderBlock,
223  sizeof(HEADLESS_LOADER_BLOCK));
224  Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
225  }
226 #endif
227  /* Load drivers database */
228  RtlStringCbCopyA(MiscFiles, sizeof(MiscFiles), BootPath);
229  RtlStringCbCatA(MiscFiles, sizeof(MiscFiles), "AppPatch\\drvmain.sdb");
230  Extension->DrvDBImage = PaToVa(WinLdrLoadModule(MiscFiles,
231  &Extension->DrvDBSize,
233 
234  /* Convert the extension block pointer */
235  LoaderBlock->Extension = PaToVa(LoaderBlock->Extension);
236 
237  TRACE("WinLdrInitializePhase1() completed\n");
238 }
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
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
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:30
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:29
#define InsertTailList(ListHead, Entry)
enum OPTION_FLAGS Options
Definition: stats.c:44
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
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
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:163
#define TRACE(s)
Definition: solgame.cpp:4
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
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:364
#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
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:27
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 312 of file winldr.c.

314 {
315  PLIST_ENTRY NextBd;
316  PBOOT_DRIVER_LIST_ENTRY BootDriver;
318  BOOLEAN ret = TRUE;
319 
320  // Walk through the boot drivers list
321  NextBd = LoaderBlock->BootDriverListHead.Flink;
322 
323  while (NextBd != &LoaderBlock->BootDriverListHead)
324  {
325  BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
326 
327  TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
328  BootDriver->LdrEntry, &BootDriver->RegistryPath);
329 
330  // Paths are relative (FIXME: Are they always relative?)
331 
332  // Load it
334  BootPath,
335  &BootDriver->FilePath,
336  0,
337  &BootDriver->LdrEntry);
338 
339  if (Success)
340  {
341  // Convert the RegistryPath and DTE addresses to VA since we are not going to use it anymore
342  BootDriver->RegistryPath.Buffer = PaToVa(BootDriver->RegistryPath.Buffer);
343  BootDriver->FilePath.Buffer = PaToVa(BootDriver->FilePath.Buffer);
344  BootDriver->LdrEntry = PaToVa(BootDriver->LdrEntry);
345  }
346  else
347  {
348  // Loading failed - cry loudly
349  ERR("Can't load boot driver '%wZ'!\n", &BootDriver->FilePath);
350  UiMessageBox("Can't load boot driver '%wZ'!", &BootDriver->FilePath);
351  ret = FALSE;
352 
353  // Remove it from the list and try to continue
354  RemoveEntryList(NextBd);
355  }
356 
357  NextBd = BootDriver->Link.Flink;
358  }
359 
360  return ret;
361 }
static BOOLEAN WinLdrLoadDeviceDriver(PLIST_ENTRY LoadOrderListHead, PCSTR BootPath, PUNICODE_STRING FilePath, ULONG Flags, PLDR_DATA_TABLE_ENTRY *DriverDTE)
Definition: winldr.c:241
#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 241 of file winldr.c.

246 {
247  CHAR FullPath[1024];
248  CHAR DriverPath[1024];
249  CHAR DllName[1024];
250  PCHAR DriverNamePos;
252  PVOID DriverBase = NULL;
253 
254  // Separate the path to file name and directory path
255  RtlStringCbPrintfA(DriverPath, sizeof(DriverPath), "%wZ", FilePath);
256  DriverNamePos = strrchr(DriverPath, '\\');
257  if (DriverNamePos != NULL)
258  {
259  // Copy the name
260  RtlStringCbCopyA(DllName, sizeof(DllName), DriverNamePos+1);
261 
262  // Cut out the name from the path
263  *(DriverNamePos+1) = ANSI_NULL;
264  }
265  else
266  {
267  // There is no directory in the path
268  RtlStringCbCopyA(DllName, sizeof(DllName), DriverPath);
269  *DriverPath = ANSI_NULL;
270  }
271 
272  TRACE("DriverPath: '%s', DllName: '%s', LPB\n", DriverPath, DllName);
273 
274  // Check if driver is already loaded
275  Success = PeLdrCheckForLoadedDll(LoadOrderListHead, DllName, DriverDTE);
276  if (Success)
277  {
278  // We've got the pointer to its DTE, just return success
279  return TRUE;
280  }
281 
282  // It's not loaded, we have to load it
283  RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%wZ", BootPath, FilePath);
284  Success = PeLdrLoadImage(FullPath, LoaderBootDriver, &DriverBase);
285  if (!Success)
286  return FALSE;
287 
288  // Allocate a DTE for it
289  Success = PeLdrAllocateDataTableEntry(LoadOrderListHead, DllName, DllName, DriverBase, DriverDTE);
290  if (!Success)
291  {
292  ERR("PeLdrAllocateDataTableEntry() failed\n");
293  return FALSE;
294  }
295 
296  // Modify any flags, if needed
297  (*DriverDTE)->Flags |= Flags;
298 
299  // Look for any dependencies it may have, and load them too
300  RtlStringCbPrintfA(FullPath, sizeof(FullPath), "%s%s", BootPath, DriverPath);
301  Success = PeLdrScanImportDescriptorTable(LoadOrderListHead, FullPath, *DriverDTE);
302  if (!Success)
303  {
304  ERR("PeLdrScanImportDescriptorTable() failed for %s\n", FullPath);
305  return FALSE;
306  }
307 
308  return TRUE;
309 }
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
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define FALSE
Definition: types.h:117
#define ANSI_NULL
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
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
#define ERR(fmt,...)
Definition: debug.h:110
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 364 of file winldr.c.

367 {
368  ULONG FileId;
369  PVOID PhysicalBase;
371  ULONG FileSize;
374 
375  //CHAR ProgressString[256];
376 
377  /* Inform user we are loading files */
378  //UiDrawBackdrop();
379  //RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", FileName);
380  //UiDrawProgressBarCenter(1, 100, ProgressString);
381 
382  TRACE("Loading module %s\n", ModuleName);
383  *Size = 0;
384 
385  /* Open the image file */
386  Status = ArcOpen((PSTR)ModuleName, OpenReadOnly, &FileId);
387  if (Status != ESUCCESS)
388  {
389  /* In case of errors, we just return, without complaining to the user */
390  WARN("Error while opening '%s', Status: %u\n", ModuleName, Status);
391  return NULL;
392  }
393 
394  /* Retrieve its size */
396  if (Status != ESUCCESS)
397  {
398  ArcClose(FileId);
399  return NULL;
400  }
401  FileSize = FileInfo.EndingAddress.LowPart;
402  *Size = FileSize;
403 
404  /* Allocate memory */
405  PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);
406  if (PhysicalBase == NULL)
407  {
408  ERR("Could not allocate memory for '%s'\n", ModuleName);
409  ArcClose(FileId);
410  return NULL;
411  }
412 
413  /* Load the whole file */
414  Status = ArcRead(FileId, PhysicalBase, FileSize, &BytesRead);
415  ArcClose(FileId);
416  if (Status != ESUCCESS)
417  {
418  WARN("Error while reading '%s', Status: %u\n", ModuleName, Status);
419  return NULL;
420  }
421 
422  TRACE("Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize);
423 
424  return PhysicalBase;
425 }
Definition: arc.h:32
#define WARN(fmt,...)
Definition: debug.h:112
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
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
Status
Definition: gdiplustypes.h:24
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
#define ERR(fmt,...)
Definition: debug.h:110
signed char * PSTR
Definition: retypes.h:7
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
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255

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

◆ WinLdrpDumpArcDisks()

VOID WinLdrpDumpArcDisks ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1142 of file winldr.c.

1143 {
1144  PLIST_ENTRY NextBd;
1145  PARC_DISK_SIGNATURE ArcDisk;
1146 
1147  NextBd = LoaderBlock->ArcDiskInformation->DiskSignatureListHead.Flink;
1148 
1149  while (NextBd != &LoaderBlock->ArcDiskInformation->DiskSignatureListHead)
1150  {
1151  ArcDisk = CONTAINING_RECORD(NextBd, ARC_DISK_SIGNATURE, ListEntry);
1152 
1153  TRACE("ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
1154  ArcDisk->ArcName, ArcDisk->CheckSum, ArcDisk->Signature);
1155 
1156  NextBd = ArcDisk->ListEntry.Flink;
1157  }
1158 }
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 1123 of file winldr.c.

1124 {
1125  PLIST_ENTRY NextBd;
1126  PBOOT_DRIVER_LIST_ENTRY BootDriver;
1127 
1128  NextBd = LoaderBlock->BootDriverListHead.Flink;
1129 
1130  while (NextBd != &LoaderBlock->BootDriverListHead)
1131  {
1132  BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
1133 
1134  TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
1135  BootDriver->LdrEntry, &BootDriver->RegistryPath);
1136 
1137  NextBd = BootDriver->Link.Flink;
1138  }
1139 }
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 1104 of file winldr.c.

1105 {
1106  PLIST_ENTRY NextMd;
1108 
1109  NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1110 
1111  while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1112  {
1114 
1115  TRACE("BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage,
1116  MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType);
1117 
1118  NextMd = MemoryDescriptor->ListEntry.Flink;
1119  }
1120 }
_Out_ PNDIS_BUFFER _In_ NDIS_HANDLE _In_ PVOID MemoryDescriptor
Definition: ndis.h:3270
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 PCHAR  BootOptions)

Definition at line 303 of file headless.c.

304 {
305  PCHAR Settings, RedirectPort;
306 
307  /* Start fresh */
310 
311  /* Use a direction port if one was given, or use ACPI to detect one instead */
312  Settings = strstr(BootOptions, "/redirect=");
313  if (Settings)
314  {
315  RedirectPort = strstr(Settings, "com");
316  if (RedirectPort)
317  {
318  RedirectPort += sizeof("com") - 1;
320  LoaderRedirectionInformation.TerminalType = 1; // HeadlessSerialPort
321  }
322  else
323  {
324  RedirectPort = strstr(Settings, "usebiossettings");
325  if (RedirectPort)
326  {
327  UiDrawStatusText("ACPI SRT Table Not Supported...");
328  return;
329  }
330  else
331  {
334  {
336  }
337  }
338  }
339  }
340 
341  /* Use a direction baudrate if one was given */
342  Settings = strstr(BootOptions, "/redirectbaudrate=");
343  if (Settings)
344  {
345  if (strstr(Settings, "115200"))
346  {
348  }
349  else if (strstr(Settings, "57600"))
350  {
352  }
353  else if (strstr(Settings, "19200"))
354  {
356  }
357  else
358  {
360  }
361  }
362 
363  /* Enable headless support if parameters were found */
365  {
367  {
369  }
370 
372  }
373 }
signed char * PCHAR
Definition: retypes.h:7
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
unsigned char * PUCHAR
Definition: retypes.h:3
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:29
VOID WinLdrInitializeHeadlessPort(VOID)
Definition: headless.c:205
PUCHAR PortAddress
Definition: arc.h:312
UCHAR TerminalType
Definition: arc.h:321
#define PCI_INVALID_VENDORID
Definition: iotypes.h:3580
SETTINGS Settings
Definition: charmap.c:26
USHORT PciDeviceId
Definition: arc.h:313
VOID UiDrawStatusText(PCSTR StatusText)
Definition: ui.c:249
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262

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

Referenced by LoadWindowsCore().

◆ NoexecuteEnabled

BOOLEAN NoexecuteEnabled = FALSE

Definition at line 36 of file winldr.c.

Referenced by LoadWindowsCore().

◆ PaeDisabled

BOOLEAN PaeDisabled = FALSE

Definition at line 32 of file winldr.c.

Referenced by LoadWindowsCore().

◆ PaeEnabled

BOOLEAN PaeEnabled = FALSE

Definition at line 31 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 33 of file winldr.c.

Referenced by LoadWindowsCore(), and Phase1InitializationDiscard().

◆ SosEnabled

BOOLEAN SosEnabled = FALSE

Definition at line 30 of file winldr.c.

Referenced by LoadWindowsCore(), and Phase1InitializationDiscard().

◆ VirtualBias

BOOLEAN VirtualBias = FALSE

Definition at line 29 of file winldr.c.

Referenced by LoadWindowsCore().

◆ WinLdrSystemBlock

PLOADER_SYSTEM_BLOCK WinLdrSystemBlock

Definition at line 27 of file winldr.c.

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

◆ WinLdrTerminalConnected

BOOLEAN WinLdrTerminalConnected

Definition at line 30 of file headless.c.

Referenced by WinLdrInitializeHeadlessPort(), and WinLdrInitializePhase1().