ReactOS  0.4.15-dev-1367-g07cc0b5
winldr.h File Reference
#include <arc/setupblk.h>
Include dependency graph for winldr.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _LOADER_SYSTEM_BLOCK
 

Macros

#define NUM_GDT   128
 
#define NUM_IDT   0x100
 
#define MAX_OPTIONS_LENGTH   255
 

Typedefs

typedef VOID(NTAPIKERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock)
 
typedef struct _LOADER_SYSTEM_BLOCK LOADER_SYSTEM_BLOCK
 
typedef struct _LOADER_SYSTEM_BLOCKPLOADER_SYSTEM_BLOCK
 

Functions

VOID ConvertConfigToVA (PCONFIGURATION_COMPONENT_DATA Start)
 
PVOID WinLdrLoadModule (PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
 
BOOLEAN WinLdrSetupMemoryLayout (IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
 
BOOLEAN WinLdrInitSystemHive (IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot, IN BOOLEAN Setup)
 
BOOLEAN WinLdrScanSystemHive (IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR SystemRoot)
 
VOID WinLdrInitializePhase1 (PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR Options, PCSTR SystemPath, PCSTR BootPath, USHORT VersionToBoot)
 
BOOLEAN WinLdrLoadNLSData (IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR DirectoryPath, IN PCSTR AnsiFileName, IN PCSTR OemFileName, IN PCSTR LanguageFileName)
 
BOOLEAN WinLdrAddDriverToList (LIST_ENTRY *BootDriverListHead, PWSTR RegistryPath, PWSTR ImagePath, PWSTR ServiceName)
 
VOID WinLdrpDumpMemoryDescriptors (PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID WinLdrpDumpBootDriver (PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID WinLdrpDumpArcDisks (PLOADER_PARAMETER_BLOCK LoaderBlock)
 
ARC_STATUS LoadAndBootWindowsCommon (IN USHORT OperatingSystemVersion, IN PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR BootOptions, IN PCSTR BootPath)
 
VOID WinLdrSetupMachineDependent (PLOADER_PARAMETER_BLOCK LoaderBlock)
 
VOID WinLdrSetProcessorContext (VOID)
 
BOOLEAN MempSetupPaging (IN PFN_NUMBER StartPage, IN PFN_NUMBER NumberOfPages, IN BOOLEAN KernelMapping)
 
VOID MempUnmapPage (PFN_NUMBER Page)
 
VOID MempDump (VOID)
 

Variables

PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
 

Macro Definition Documentation

◆ MAX_OPTIONS_LENGTH

#define MAX_OPTIONS_LENGTH   255

Definition at line 44 of file winldr.h.

◆ NUM_GDT

#define NUM_GDT   128

Definition at line 16 of file winldr.h.

◆ NUM_IDT

#define NUM_IDT   0x100

Definition at line 17 of file winldr.h.

Typedef Documentation

◆ KERNEL_ENTRY_POINT

typedef VOID(NTAPI * KERNEL_ENTRY_POINT) (PLOADER_PARAMETER_BLOCK LoaderBlock)

Definition at line 13 of file winldr.h.

◆ LOADER_SYSTEM_BLOCK

◆ PLOADER_SYSTEM_BLOCK

Function Documentation

◆ ConvertConfigToVA()

VOID ConvertConfigToVA ( PCONFIGURATION_COMPONENT_DATA  Start)

Definition at line 51 of file conversion.c.

52 {
55 
56  TRACE("ConvertConfigToVA(Start 0x%X)\n", Start);
57  Child = Start;
58 
59  while (Child != NULL)
60  {
61  if (Child->ConfigurationData)
62  Child->ConfigurationData = PaToVa(Child->ConfigurationData);
63 
64  if (Child->Child)
65  Child->Child = PaToVa(Child->Child);
66 
67  if (Child->Parent)
68  Child->Parent = PaToVa(Child->Parent);
69 
70  if (Child->Sibling)
71  Child->Sibling = PaToVa(Child->Sibling);
72 
73  if (Child->ComponentEntry.Identifier)
74  Child->ComponentEntry.Identifier = PaToVa(Child->ComponentEntry.Identifier);
75 
76  TRACE("Device 0x%X class %d type %d id '%s', parent %p\n", Child,
77  Child->ComponentEntry.Class, Child->ComponentEntry.Type, VaToPa(Child->ComponentEntry.Identifier), Child->Parent);
78 
79  // Go through siblings list
80  Sibling = VaToPa(Child->Sibling);
81  while (Sibling != NULL)
82  {
83  if (Sibling->ConfigurationData)
84  Sibling->ConfigurationData = PaToVa(Sibling->ConfigurationData);
85 
86  if (Sibling->Child)
87  Sibling->Child = PaToVa(Sibling->Child);
88 
89  if (Sibling->Parent)
90  Sibling->Parent = PaToVa(Sibling->Parent);
91 
92  if (Sibling->Sibling)
93  Sibling->Sibling = PaToVa(Sibling->Sibling);
94 
95  if (Sibling->ComponentEntry.Identifier)
97 
98  TRACE("Device 0x%X class %d type %d id '%s', parent %p\n", Sibling,
99  Sibling->ComponentEntry.Class, Sibling->ComponentEntry.Type, VaToPa(Sibling->ComponentEntry.Identifier), Sibling->Parent);
100 
101  // Recurse into the Child tree
102  if (VaToPa(Sibling->Child) != NULL)
103  ConvertConfigToVA(VaToPa(Sibling->Child));
104 
105  Sibling = VaToPa(Sibling->Sibling);
106  }
107 
108  // Go to the next child
109  Child = VaToPa(Child->Child);
110  }
111 }
struct _CONFIGURATION_COMPONENT_DATA * Parent
Definition: arc.h:118
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:533
struct _CONFIGURATION_COMPONENT_DATA * Child
Definition: arc.h:119
CONFIGURATION_TYPE Type
Definition: arc.h:105
#define TRACE(s)
Definition: solgame.cpp:4
CONFIGURATION_CLASS Class
Definition: arc.h:104
Definition: partlist.h:33
CONFIGURATION_COMPONENT ComponentEntry
Definition: arc.h:121
struct _CONFIGURATION_COMPONENT_DATA * Sibling
Definition: arc.h:120
#define NULL
Definition: types.h:112
VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
Definition: conversion.c:51
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
FORCEINLINE PVOID VaToPa(PVOID Va)
Definition: conversion.h:15

Referenced by ConvertConfigToVA(), and WinLdrInitializePhase1().

◆ LoadAndBootWindowsCommon()

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

Definition at line 945 of file winldr.c.

950 {
951  PLOADER_PARAMETER_BLOCK LoaderBlockVA;
953  PLDR_DATA_TABLE_ENTRY KernelDTE;
956 
957  TRACE("LoadAndBootWindowsCommon()\n");
958 
959  ASSERT(OperatingSystemVersion != 0);
960 
961 #ifdef _M_IX86
962  /* Setup redirection support */
964 #endif
965 
966  /* Convert BootPath to SystemRoot */
967  SystemRoot = strstr(BootPath, "\\");
968 
969  /* Detect hardware */
970  UiDrawBackdrop();
971  UiDrawProgressBarCenter(20, 100, "Detecting hardware...");
972  LoaderBlock->ConfigurationRoot = MachHwDetect();
973 
974  /* Load the operating system core: the Kernel, the HAL and the Kernel Debugger Transport DLL */
975  Success = LoadWindowsCore(OperatingSystemVersion,
976  LoaderBlock,
977  BootOptions,
978  BootPath,
979  &KernelDTE);
980  if (!Success)
981  {
982  UiMessageBox("Error loading NTOS core.");
983  return ENOEXEC;
984  }
985 
986  /* Load boot drivers */
987  UiDrawBackdrop();
988  UiDrawProgressBarCenter(100, 100, "Loading boot drivers...");
989  Success = WinLdrLoadBootDrivers(LoaderBlock, BootPath);
990  TRACE("Boot drivers loading %s\n", Success ? "successful" : "failed");
991 
992  /* Cleanup ini file */
993  IniCleanup();
994 
995  /* Initialize Phase 1 - no drivers loading anymore */
996  WinLdrInitializePhase1(LoaderBlock,
997  BootOptions,
998  SystemRoot,
999  BootPath,
1000  OperatingSystemVersion);
1001 
1002  /* Save entry-point pointer and Loader block VAs */
1004  LoaderBlockVA = PaToVa(LoaderBlock);
1005 
1006  /* "Stop all motors", change videomode */
1008 
1009  /* Debugging... */
1010  //DumpMemoryAllocMap();
1011 
1012  /* Do the machine specific initialization */
1013  WinLdrSetupMachineDependent(LoaderBlock);
1014 
1015  /* Map pages and create memory descriptors */
1016  WinLdrSetupMemoryLayout(LoaderBlock);
1017 
1018  /* Set processor context */
1020 
1021  /* Save final value of LoaderPagesSpanned */
1022  LoaderBlock->Extension->LoaderPagesSpanned = LoaderPagesSpanned;
1023 
1024  TRACE("Hello from paged mode, KiSystemStartup %p, LoaderBlockVA %p!\n",
1025  KiSystemStartup, LoaderBlockVA);
1026 
1027  /* Zero KI_USER_SHARED_DATA page */
1028  RtlZeroMemory((PVOID)KI_USER_SHARED_DATA, MM_PAGE_SIZE);
1029 
1030  WinLdrpDumpMemoryDescriptors(LoaderBlockVA);
1031  WinLdrpDumpBootDriver(LoaderBlockVA);
1032 #ifndef _M_AMD64
1033  WinLdrpDumpArcDisks(LoaderBlockVA);
1034 #endif
1035 
1036  /* Pass control */
1037  (*KiSystemStartup)(LoaderBlockVA);
1038  return ESUCCESS;
1039 }
#define MachHwDetect()
Definition: machine.h:136
VOID(NTAPI * KERNEL_ENTRY_POINT)(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.h:13
BOOLEAN WinLdrLoadBootDrivers(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR BootPath)
Definition: winldr.c:313
VOID WinLdrpDumpArcDisks(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1080
VOID NTAPI KiSystemStartup(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: kiinit.c:372
Definition: arc.h:32
VOID WinLdrSetProcessorContext(void)
Definition: winldr.c:348
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
static BOOLEAN LoadWindowsCore(IN USHORT OperatingSystemVersion, IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR BootOptions, IN PCSTR BootPath, IN OUT PLDR_DATA_TABLE_ENTRY *KernelDTE)
Definition: winldr.c:494
BOOLEAN WinLdrSetupMemoryLayout(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: wlmemory.c:181
PVOID EntryPoint
Definition: ntddk_ex.h:203
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:379
VOID WinLdrpDumpBootDriver(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1061
#define TRACE(s)
Definition: solgame.cpp:4
#define ASSERT(a)
Definition: mode.c:45
static const WCHAR SystemRoot[]
Definition: reg.c:38
ULONG LoaderPagesSpanned
Definition: mm.c:29
VOID IniCleanup(VOID)
Definition: inifile.c:235
#define KI_USER_SHARED_DATA
#define MachPrepareForReactOS()
Definition: machine.h:120
Definition: btrfs_drv.h:1922
VOID UiDrawBackdrop(VOID)
Definition: ui.c:214
VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1042
VOID WinLdrSetupEms(IN PCSTR BootOptions)
Definition: headless.c:303
VOID WinLdrInitializePhase1(PLOADER_PARAMETER_BLOCK LoaderBlock, PCSTR Options, PCSTR SystemRoot, PCSTR BootPath, USHORT VersionToBoot)
Definition: winldr.c:82
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().

◆ MempDump()

VOID MempDump ( VOID  )

Definition at line 429 of file winldr.c.

430 {
431 }

Referenced by WinLdrSetupMemoryLayout().

◆ MempSetupPaging()

BOOLEAN MempSetupPaging ( IN PFN_NUMBER  StartPage,
IN PFN_NUMBER  NumberOfPages,
IN BOOLEAN  KernelMapping 
)

Definition at line 170 of file winldr.c.

173 {
174  TRACE(">>> MempSetupPaging(0x%lx, %ld, %p)\n",
175  StartPage, NumberOfPages, StartPage * PAGE_SIZE + KSEG0_BASE);
176 
177  /* Identity mapping */
180  NumberOfPages) != NumberOfPages)
181  {
182  ERR("Failed to map pages %ld, %ld\n",
183  StartPage, NumberOfPages);
184  return FALSE;
185  }
186 
187  /* Kernel mapping */
188  if (KernelMapping)
189  {
192  NumberOfPages) != NumberOfPages)
193  {
194  ERR("Failed to map pages %ld, %ld\n",
195  StartPage, NumberOfPages);
196  return FALSE;
197  }
198  }
199 
200  return TRUE;
201 }
#define TRUE
Definition: types.h:120
int WINAPI StartPage(_In_ HDC)
#define FALSE
Definition: types.h:117
#define KSEG0_BASE
Definition: ketypes.h:273
static PFN_NUMBER MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, PFN_NUMBER cPages)
Definition: winldr.c:151
#define TRACE(s)
Definition: solgame.cpp:4
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define ERR(fmt,...)
Definition: debug.h:110

Referenced by MempSetupPagingForRegion(), and WinLdrSetupMemoryLayout().

◆ MempUnmapPage()

VOID MempUnmapPage ( PFN_NUMBER  Page)

Definition at line 204 of file winldr.c.

205 {
206  // TRACE(">>> MempUnmapPage\n");
207 }

◆ WinLdrAddDriverToList()

BOOLEAN WinLdrAddDriverToList ( LIST_ENTRY BootDriverListHead,
PWSTR  RegistryPath,
PWSTR  ImagePath,
PWSTR  ServiceName 
)

Definition at line 768 of file wlregistry.c.

772 {
773  PBOOT_DRIVER_LIST_ENTRY BootDriverEntry;
776 
777  BootDriverEntry = FrLdrHeapAlloc(sizeof(BOOT_DRIVER_LIST_ENTRY), TAG_WLDR_BDE);
778 
779  if (!BootDriverEntry)
780  return FALSE;
781 
782  // DTE will be filled during actual load of the driver
783  BootDriverEntry->LdrEntry = NULL;
784 
785  // Check - if we have a valid ImagePath, if not - we need to build it
786  // like "System32\\Drivers\\blah.sys"
787  if (ImagePath && (ImagePath[0] != 0))
788  {
789  // Just copy ImagePath to the corresponding field in the structure
790  PathLength = (USHORT)wcslen(ImagePath) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
791 
792  BootDriverEntry->FilePath.Length = 0;
793  BootDriverEntry->FilePath.MaximumLength = PathLength;
795 
796  if (!BootDriverEntry->FilePath.Buffer)
797  {
798  FrLdrHeapFree(BootDriverEntry, TAG_WLDR_BDE);
799  return FALSE;
800  }
801 
802  Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, ImagePath);
803  if (!NT_SUCCESS(Status))
804  {
805  FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
806  FrLdrHeapFree(BootDriverEntry, TAG_WLDR_BDE);
807  return FALSE;
808  }
809  }
810  else
811  {
812  // we have to construct ImagePath ourselves
813  PathLength = (USHORT)wcslen(ServiceName)*sizeof(WCHAR) + sizeof(L"system32\\drivers\\.sys");
814  BootDriverEntry->FilePath.Length = 0;
815  BootDriverEntry->FilePath.MaximumLength = PathLength;
817 
818  if (!BootDriverEntry->FilePath.Buffer)
819  {
820  FrLdrHeapFree(BootDriverEntry, TAG_WLDR_NAME);
821  return FALSE;
822  }
823 
824  Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, L"system32\\drivers\\");
825  if (!NT_SUCCESS(Status))
826  {
827  FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
828  FrLdrHeapFree(BootDriverEntry, TAG_WLDR_NAME);
829  return FALSE;
830  }
831 
832  Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, ServiceName);
833  if (!NT_SUCCESS(Status))
834  {
835  FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
836  FrLdrHeapFree(BootDriverEntry, TAG_WLDR_NAME);
837  return FALSE;
838  }
839 
840  Status = RtlAppendUnicodeToString(&BootDriverEntry->FilePath, L".sys");
841  if (!NT_SUCCESS(Status))
842  {
843  FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
844  FrLdrHeapFree(BootDriverEntry, TAG_WLDR_NAME);
845  return FALSE;
846  }
847  }
848 
849  // Add registry path
851  BootDriverEntry->RegistryPath.Length = 0;
852  BootDriverEntry->RegistryPath.MaximumLength = PathLength;
854  if (!BootDriverEntry->RegistryPath.Buffer)
855  return FALSE;
856 
858  if (!NT_SUCCESS(Status))
859  return FALSE;
860 
862  if (!NT_SUCCESS(Status))
863  return FALSE;
864 
865  // Insert entry into the list
866  if (!InsertInBootDriverList(BootDriverListHead, BootDriverEntry))
867  {
868  // It was already there, so delete our entry
869  if (BootDriverEntry->FilePath.Buffer) FrLdrHeapFree(BootDriverEntry->FilePath.Buffer, TAG_WLDR_NAME);
870  if (BootDriverEntry->RegistryPath.Buffer) FrLdrHeapFree(BootDriverEntry->RegistryPath.Buffer, TAG_WLDR_NAME);
871  FrLdrHeapFree(BootDriverEntry, TAG_WLDR_BDE);
872  }
873 
874  return TRUE;
875 }
FORCEINLINE VOID FrLdrHeapFree(PVOID MemoryPointer, ULONG Tag)
Definition: mm.h:170
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
Definition: wdfdriver.h:213
static USHORT PathLength
UNICODE_STRING FilePath
Definition: arc.h:201
Definition: arc.h:198
#define FALSE
Definition: types.h:117
#define UNICODE_NULL
Status
Definition: gdiplustypes.h:24
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
#define TAG_WLDR_NAME
Definition: winldr.h:15
#define TAG_WLDR_BDE
Definition: winldr.h:14
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
LPTSTR ServiceName
Definition: ServiceMain.c:15
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
UNICODE_STRING RegistryPath
Definition: arc.h:202
unsigned short USHORT
Definition: pedump.c:61
struct _LDR_DATA_TABLE_ENTRY * LdrEntry
Definition: arc.h:203
#define NULL
Definition: types.h:112
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
static BOOLEAN InsertInBootDriverList(PLIST_ENTRY BootDriverListHead, PBOOT_DRIVER_LIST_ENTRY BootDriverEntry)
Definition: wlregistry.c:729

Referenced by SetupLdrScanBootDrivers(), WinLdrLoadSystemHive(), and WinLdrScanRegistry().

◆ WinLdrInitializePhase1()

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

Definition at line 82 of file winldr.c.

87 {
88  /*
89  * Examples of correct options and paths:
90  * CHAR Options[] = "/DEBUGPORT=COM1 /BAUDRATE=115200";
91  * CHAR Options[] = "/NODEBUG";
92  * CHAR SystemRoot[] = "\\WINNT\\";
93  * CHAR ArcBoot[] = "multi(0)disk(0)rdisk(0)partition(1)";
94  */
95 
96  PSTR LoadOptions, NewLoadOptions;
97  CHAR HalPath[] = "\\";
98  CHAR ArcBoot[MAX_PATH+1];
99  CHAR MiscFiles[MAX_PATH+1];
100  ULONG i;
101  ULONG_PTR PathSeparator;
103 
104  /* Construct SystemRoot and ArcBoot from SystemPath */
105  PathSeparator = strstr(BootPath, "\\") - BootPath;
106  RtlStringCbCopyNA(ArcBoot, sizeof(ArcBoot), BootPath, PathSeparator);
107 
108  TRACE("ArcBoot: '%s'\n", ArcBoot);
109  TRACE("SystemRoot: '%s'\n", SystemRoot);
110  TRACE("Options: '%s'\n", Options);
111 
112  /* Fill ARC BootDevice */
115  LoaderBlock->ArcBootDeviceName = PaToVa(LoaderBlock->ArcBootDeviceName);
116 
117 //
118 // IMPROVE!!
119 // SetupBlock->ArcSetupDeviceName must be the path to the setup **SOURCE**,
120 // and not the setup boot path. Indeed they may differ!!
121 //
122  if (LoaderBlock->SetupLdrBlock)
123  {
124  PSETUP_LOADER_BLOCK SetupBlock = LoaderBlock->SetupLdrBlock;
125 
126  /* Adjust the ARC path in the setup block - Matches ArcBoot path */
128  SetupBlock->ArcSetupDeviceName = PaToVa(SetupBlock->ArcSetupDeviceName);
129 
130  /* Convert the setup block pointer */
131  LoaderBlock->SetupLdrBlock = PaToVa(LoaderBlock->SetupLdrBlock);
132  }
133 
134  /* Fill ARC HalDevice, it matches ArcBoot path */
136  LoaderBlock->ArcHalDeviceName = PaToVa(LoaderBlock->ArcHalDeviceName);
137 
138  /* Fill SystemRoot */
141  LoaderBlock->NtBootPathName = PaToVa(LoaderBlock->NtBootPathName);
142 
143  /* Fill NtHalPathName */
145  RtlStringCbCopyA(LoaderBlock->NtHalPathName, sizeof(WinLdrSystemBlock->NtHalPathName), HalPath);
146  LoaderBlock->NtHalPathName = PaToVa(LoaderBlock->NtHalPathName);
147 
148  /* Fill LoadOptions and strip the '/' switch symbol in front of each option */
149  NewLoadOptions = LoadOptions = LoaderBlock->LoadOptions = WinLdrSystemBlock->LoadOptions;
151 
152  do
153  {
154  while (*LoadOptions == '/')
155  ++LoadOptions;
156 
157  *NewLoadOptions++ = *LoadOptions;
158  } while (*LoadOptions++);
159 
160  LoaderBlock->LoadOptions = PaToVa(LoaderBlock->LoadOptions);
161 
162  /* ARC devices */
165 
166  /* Convert ARC disk information from freeldr to a correct format */
167  for (i = 0; i < reactos_disk_count; i++)
168  {
169  PARC_DISK_SIGNATURE_EX ArcDiskSig;
170 
171  /* Allocate the ARC structure */
172  ArcDiskSig = FrLdrHeapAlloc(sizeof(ARC_DISK_SIGNATURE_EX), 'giSD');
173 
174  /* Copy the data over */
176 
177  /* Set the ARC Name pointer */
178  ArcDiskSig->DiskSignature.ArcName = PaToVa(ArcDiskSig->ArcName);
179 
180  /* Insert into the list */
182  &ArcDiskSig->DiskSignature.ListEntry);
183  }
184 
185  /* Convert all lists to Virtual address */
186 
187  /* Convert the ArcDisks list to virtual address */
189  LoaderBlock->ArcDiskInformation = PaToVa(LoaderBlock->ArcDiskInformation);
190 
191  /* Convert configuration entries to VA */
192  ConvertConfigToVA(LoaderBlock->ConfigurationRoot);
193  LoaderBlock->ConfigurationRoot = PaToVa(LoaderBlock->ConfigurationRoot);
194 
195  /* Convert all DTE into virtual addresses */
196  List_PaToVa(&LoaderBlock->LoadOrderListHead);
197 
198  /* This one will be converted right before switching to virtual paging mode */
199  //List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
200 
201  /* Convert list of boot drivers */
202  List_PaToVa(&LoaderBlock->BootDriverListHead);
203 
204  Extension = LoaderBlock->Extension;
205 
206  /* FIXME! HACK value for docking profile */
207  Extension->Profile.Status = 2;
208 
209  /* Check if FreeLdr detected a ACPI table */
210  if (AcpiPresent)
211  {
212  /* Set the pointer to something for compatibility */
213  Extension->AcpiTable = (PVOID)1;
214  // FIXME: Extension->AcpiTableSize;
215  }
216 
217 #ifdef _M_IX86
218  /* Set headless block pointer */
220  {
221  Extension->HeadlessLoaderBlock = &WinLdrSystemBlock->HeadlessLoaderBlock;
222  RtlCopyMemory(Extension->HeadlessLoaderBlock,
224  sizeof(HEADLESS_LOADER_BLOCK));
225  Extension->HeadlessLoaderBlock = PaToVa(Extension->HeadlessLoaderBlock);
226  }
227 #endif
228  /* Load drivers database */
229  RtlStringCbCopyA(MiscFiles, sizeof(MiscFiles), BootPath);
230  RtlStringCbCatA(MiscFiles, sizeof(MiscFiles), "AppPatch\\drvmain.sdb");
231  Extension->DrvDBImage = PaToVa(WinLdrLoadModule(MiscFiles,
232  &Extension->DrvDBSize,
234 
235  /* Convert the extension block pointer */
236  LoaderBlock->Extension = PaToVa(LoaderBlock->Extension);
237 
238  TRACE("WinLdrInitializePhase1() completed\n");
239 }
NTSTRSAFEAPI RtlStringCbCopyNA(_Out_writes_bytes_(cbDest) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:395
PSTR ArcBootDeviceName
Definition: arc.h:503
ARC_DISK_INFORMATION ArcDiskInformation
Definition: winldr.h:60
ARC_DISK_SIGNATURE_EX reactos_arc_disk_info[]
Definition: archwsup.c:21
PCHAR ArcName
Definition: arc.h:210
VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry)
char * strstr(char *String1, char *String2)
Definition: utclib.c:653
PLOADER_PARAMETER_EXTENSION Extension
Definition: arc.h:512
PCONFIGURATION_COMPONENT_DATA ConfigurationRoot
Definition: arc.h:502
char CHAR
Definition: xmlstorage.h:175
BOOLEAN WinLdrTerminalConnected
Definition: headless.c:30
HEADLESS_LOADER_BLOCK LoaderRedirectionInformation
Definition: headless.c:29
#define InsertTailList(ListHead, Entry)
CHAR ArcBootDeviceName[MAX_PATH+1]
Definition: winldr.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTRSAFEAPI RtlStringCbCopyA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:156
struct _SETUP_LOADER_BLOCK * SetupLdrBlock
Definition: arc.h:511
void * PVOID
Definition: retypes.h:9
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
#define TRACE(s)
Definition: solgame.cpp:4
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3531
LIST_ENTRY ListEntry
Definition: arc.h:208
static const WCHAR SystemRoot[]
Definition: reg.c:38
CHAR ArcName[MAX_PATH]
Definition: winldr.h:37
#define MAX_PATH
Definition: compat.h:34
PARC_DISK_INFORMATION ArcDiskInformation
Definition: arc.h:509
LIST_ENTRY BootDriverListHead
Definition: arc.h:495
ULONG reactos_disk_count
Definition: archwsup.c:20
ARC_DISK_SIGNATURE DiskSignature
Definition: winldr.h:36
BOOLEAN AcpiPresent
Definition: macharm.c:21
CHAR LoadOptions[MAX_OPTIONS_LENGTH+1]
Definition: winldr.h:55
CHAR NtHalPathName[MAX_PATH+1]
Definition: winldr.h:59
LIST_ENTRY LoadOrderListHead
Definition: arc.h:493
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PVOID WinLdrLoadModule(PCSTR ModuleName, PULONG Size, TYPE_OF_MEMORY MemoryType)
Definition: winldr.c:365
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
signed char * PSTR
Definition: retypes.h:7
VOID ConvertConfigToVA(PCONFIGURATION_COMPONENT_DATA Start)
Definition: conversion.c:51
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
LIST_ENTRY DiskSignatureListHead
Definition: arc.h:221
PCHAR ArcSetupDeviceName
Definition: setupblk.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
CHAR NtBootPathName[MAX_PATH+1]
Definition: winldr.h:58
_Inout_opt_ PUNICODE_STRING Extension
Definition: fltkernel.h:1092
PLOADER_SYSTEM_BLOCK WinLdrSystemBlock
Definition: winldr.c:28
NTSTRSAFEAPI RtlStringCbCatA(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:625

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrInitSystemHive()

BOOLEAN WinLdrInitSystemHive ( IN OUT PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN PCSTR  SystemRoot,
IN BOOLEAN  Setup 
)

Definition at line 123 of file wlregistry.c.

127 {
128  CHAR SearchPath[1024];
129  PCSTR HiveName;
131 
132  if (Setup)
133  {
135  HiveName = "SETUPREG.HIV";
136  }
137  else
138  {
139  // There is a simple logic here: try to load usual hive (system), if it
140  // fails, then give system.alt a try, and finally try a system.sav
141 
142  // FIXME: For now we only try system
144  RtlStringCbCatA(SearchPath, sizeof(SearchPath), "system32\\config\\");
145  HiveName = "SYSTEM";
146  }
147 
148  TRACE("WinLdrInitSystemHive: loading hive %s%s\n", SearchPath, HiveName);
149  Success = WinLdrLoadSystemHive(LoaderBlock, SearchPath, HiveName);
150 
151  /* Fail if failed... */
152  if (!Success)
153  return FALSE;
154 
155  /* Import what was loaded */
156  Success = RegImportBinaryHive(VaToPa(LoaderBlock->RegistryBase), LoaderBlock->RegistryLength);
157  if (!Success)
158  {
159  UiMessageBox("Importing binary hive failed!");
160  return FALSE;
161  }
162 
163  /* Initialize the 'CurrentControlSet' link */
165  {
166  UiMessageBox("Initializing CurrentControlSet link failed!");
167  return FALSE;
168  }
169 
170  return TRUE;
171 }
#define ERROR_SUCCESS
Definition: deptool.c:10
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE ACPI_ADR_SPACE_HANDLER ACPI_ADR_SPACE_SETUP Setup
Definition: acpixf.h:828
#define TRUE
Definition: types.h:120
BOOLEAN RegImportBinaryHive(_In_ PVOID ChunkBase, _In_ ULONG ChunkSize)
Definition: registry.c:56
char CHAR
Definition: xmlstorage.h:175
LONG RegInitCurrentControlSet(_In_ BOOLEAN LastKnownGood)
Definition: registry.c:93
#define SearchPath
Definition: winbase.h:3740
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
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR SystemRoot[]
Definition: reg.c:38
static BOOLEAN WinLdrLoadSystemHive(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR DirectoryPath, IN PCSTR HiveName)
Definition: wlregistry.c:34
FORCEINLINE PVOID VaToPa(PVOID Va)
Definition: conversion.h:15
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 LoadAndBootWindows(), and LoadReactOSSetup().

◆ WinLdrLoadModule()

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

Definition at line 365 of file winldr.c.

368 {
369  ULONG FileId;
370  PVOID PhysicalBase;
372  ULONG FileSize;
375 
376  //CHAR ProgressString[256];
377 
378  /* Inform user we are loading files */
379  //UiDrawBackdrop();
380  //RtlStringCbPrintfA(ProgressString, sizeof(ProgressString), "Loading %s...", FileName);
381  //UiDrawProgressBarCenter(1, 100, ProgressString);
382 
383  TRACE("Loading module %s\n", ModuleName);
384  *Size = 0;
385 
386  /* Open the image file */
387  Status = ArcOpen((PSTR)ModuleName, OpenReadOnly, &FileId);
388  if (Status != ESUCCESS)
389  {
390  /* In case of errors, we just return, without complaining to the user */
391  WARN("Error while opening '%s', Status: %u\n", ModuleName, Status);
392  return NULL;
393  }
394 
395  /* Retrieve its size */
397  if (Status != ESUCCESS)
398  {
399  ArcClose(FileId);
400  return NULL;
401  }
402  FileSize = FileInfo.EndingAddress.LowPart;
403  *Size = FileSize;
404 
405  /* Allocate memory */
406  PhysicalBase = MmAllocateMemoryWithType(FileSize, MemoryType);
407  if (PhysicalBase == NULL)
408  {
409  ERR("Could not allocate memory for '%s'\n", ModuleName);
410  ArcClose(FileId);
411  return NULL;
412  }
413 
414  /* Load the whole file */
415  Status = ArcRead(FileId, PhysicalBase, FileSize, &BytesRead);
416  ArcClose(FileId);
417  if (Status != ESUCCESS)
418  {
419  WARN("Error while reading '%s', Status: %u\n", ModuleName, Status);
420  return NULL;
421  }
422 
423  TRACE("Loaded %s at 0x%x with size 0x%x\n", ModuleName, PhysicalBase, FileSize);
424 
425  return PhysicalBase;
426 }
Definition: arc.h:32
#define WARN(fmt,...)
Definition: debug.h:112
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
ULONG ARC_STATUS
Definition: arc.h:4
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 ACPI_STATUS const char UINT32 ACPI_STATUS const char UINT32 const char const char * ModuleName
Definition: acpixf.h:1274
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:859
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
#define ERR(fmt,...)
Definition: debug.h:110
signed char * PSTR
Definition: retypes.h:7
#define NULL
Definition: types.h:112
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:218
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:250
struct FileInfo FileInfo
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:56
unsigned int ULONG
Definition: retypes.h:1

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

◆ WinLdrLoadNLSData()

BOOLEAN WinLdrLoadNLSData ( IN OUT PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN PCSTR  DirectoryPath,
IN PCSTR  AnsiFileName,
IN PCSTR  OemFileName,
IN PCSTR  LanguageFileName 
)

Definition at line 301 of file wlregistry.c.

306 {
307  CHAR FileName[255];
308  ULONG FileId;
309  ULONG AnsiFileSize, OemFileSize, LanguageFileSize;
310  ULONG TotalSize;
311  PVOID NlsDataBase;
312  PVOID NlsVirtual;
313  BOOLEAN AnsiEqualsOem = FALSE;
317 
318  /* There may be a case, when OEM and ANSI page coincide */
319  if (!strcmp(AnsiFileName, OemFileName))
320  AnsiEqualsOem = TRUE;
321 
322  /* Open file with ANSI and store its size */
323  RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
324  RtlStringCbCatA(FileName, sizeof(FileName), AnsiFileName);
325  Status = ArcOpen(FileName, OpenReadOnly, &FileId);
326  if (Status != ESUCCESS)
327  {
328  WARN("Error while opening '%s', Status: %u\n", FileName, Status);
329  goto Failure;
330  }
331 
333  ArcClose(FileId);
334  if (Status != ESUCCESS)
335  goto Failure;
336  AnsiFileSize = FileInfo.EndingAddress.LowPart;
337  TRACE("AnsiFileSize: %d\n", AnsiFileSize);
338 
339  /* Open OEM file and store its length */
340  if (AnsiEqualsOem)
341  {
342  OemFileSize = 0;
343  }
344  else
345  {
346  //Print(L"Loading %s...\n", Filename);
347  RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
348  RtlStringCbCatA(FileName, sizeof(FileName), OemFileName);
349  Status = ArcOpen(FileName, OpenReadOnly, &FileId);
350  if (Status != ESUCCESS)
351  {
352  WARN("Error while opening '%s', Status: %u\n", FileName, Status);
353  goto Failure;
354  }
355 
357  ArcClose(FileId);
358  if (Status != ESUCCESS)
359  goto Failure;
360  OemFileSize = FileInfo.EndingAddress.LowPart;
361  }
362  TRACE("OemFileSize: %d\n", OemFileSize);
363 
364  /* And finally open the language codepage file and store its length */
365  //Print(L"Loading %s...\n", Filename);
366  RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
367  RtlStringCbCatA(FileName, sizeof(FileName), LanguageFileName);
368  Status = ArcOpen(FileName, OpenReadOnly, &FileId);
369  if (Status != ESUCCESS)
370  {
371  WARN("Error while opening '%s', Status: %u\n", FileName, Status);
372  goto Failure;
373  }
374 
376  ArcClose(FileId);
377  if (Status != ESUCCESS)
378  goto Failure;
379  LanguageFileSize = FileInfo.EndingAddress.LowPart;
380  TRACE("LanguageFileSize: %d\n", LanguageFileSize);
381 
382  /* Sum up all three length, having in mind that every one of them
383  must start at a page boundary => thus round up each file to a page */
384  TotalSize = MM_SIZE_TO_PAGES(AnsiFileSize) +
385  MM_SIZE_TO_PAGES(OemFileSize) +
386  MM_SIZE_TO_PAGES(LanguageFileSize);
387 
388  /* Store it for later marking the pages as NlsData type */
389  TotalNLSSize = TotalSize;
390 
391  NlsDataBase = MmAllocateMemoryWithType(TotalSize*MM_PAGE_SIZE, LoaderNlsData);
392  if (NlsDataBase == NULL)
393  goto Failure;
394 
395  NlsVirtual = PaToVa(NlsDataBase);
396  LoaderBlock->NlsData->AnsiCodePageData = NlsVirtual;
397  LoaderBlock->NlsData->OemCodePageData = (PVOID)((ULONG_PTR)NlsVirtual +
398  (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT));
399  LoaderBlock->NlsData->UnicodeCodePageData = (PVOID)((ULONG_PTR)NlsVirtual +
400  (MM_SIZE_TO_PAGES(AnsiFileSize) << MM_PAGE_SHIFT) +
401  (MM_SIZE_TO_PAGES(OemFileSize) << MM_PAGE_SHIFT));
402 
403  /* Ansi and OEM data are the same - just set pointers to the same area */
404  if (AnsiEqualsOem)
405  LoaderBlock->NlsData->OemCodePageData = LoaderBlock->NlsData->AnsiCodePageData;
406 
407  /* Now actually read the data into memory, starting with Ansi file */
408  RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
409  RtlStringCbCatA(FileName, sizeof(FileName), AnsiFileName);
410  Status = ArcOpen(FileName, OpenReadOnly, &FileId);
411  if (Status != ESUCCESS)
412  {
413  WARN("Error while opening '%s', Status: %u\n", FileName, Status);
414  goto Failure;
415  }
416 
417  Status = ArcRead(FileId, VaToPa(LoaderBlock->NlsData->AnsiCodePageData), AnsiFileSize, &BytesRead);
418  ArcClose(FileId);
419  if (Status != ESUCCESS)
420  {
421  WARN("Error while reading '%s', Status: %u\n", FileName, Status);
422  goto Failure;
423  }
424 
425  /* OEM now, if it doesn't equal Ansi of course */
426  if (!AnsiEqualsOem)
427  {
428  RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
429  RtlStringCbCatA(FileName, sizeof(FileName), OemFileName);
430  Status = ArcOpen(FileName, OpenReadOnly, &FileId);
431  if (Status != ESUCCESS)
432  {
433  WARN("Error while opening '%s', Status: %u\n", FileName, Status);
434  goto Failure;
435  }
436 
437  Status = ArcRead(FileId, VaToPa(LoaderBlock->NlsData->OemCodePageData), OemFileSize, &BytesRead);
438  ArcClose(FileId);
439  if (Status != ESUCCESS)
440  {
441  WARN("Error while reading '%s', Status: %u\n", FileName, Status);
442  goto Failure;
443  }
444  }
445 
446  /* Finally the language file */
447  RtlStringCbCopyA(FileName, sizeof(FileName), DirectoryPath);
448  RtlStringCbCatA(FileName, sizeof(FileName), LanguageFileName);
449  Status = ArcOpen(FileName, OpenReadOnly, &FileId);
450  if (Status != ESUCCESS)
451  {
452  WARN("Error while opening '%s', Status: %u\n", FileName, Status);
453  goto Failure;
454  }
455 
456  Status = ArcRead(FileId, VaToPa(LoaderBlock->NlsData->UnicodeCodePageData), LanguageFileSize, &BytesRead);
457  ArcClose(FileId);
458  if (Status != ESUCCESS)
459  {
460  WARN("Error while reading '%s', Status: %u\n", FileName, Status);
461  goto Failure;
462  }
463 
464  //
465  // THIS IS HAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACK
466  // Should go to WinLdrLoadOemHalFont(), when it will be implemented
467  //
468  LoaderBlock->OemFontFile = VaToPa(LoaderBlock->NlsData->UnicodeCodePageData);
469 
470  /* Convert NlsTables address to VA */
471  LoaderBlock->NlsData = PaToVa(LoaderBlock->NlsData);
472 
473  return TRUE;
474 
475 Failure:
476  UiMessageBox("Error reading NLS file %s", FileName);
477  return FALSE;
478 }
Definition: arc.h:32
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
#define WARN(fmt,...)
Definition: debug.h:112
ULONG ARC_STATUS
Definition: arc.h:4
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS _Out_opt_ PULONG_PTR BytesRead
Definition: wdfiotarget.h:859
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
#define FALSE
Definition: types.h:117
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
void * PVOID
Definition: retypes.h:9
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:236
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
ULONG TotalNLSSize
Definition: wlregistry.c:19
#define NULL
Definition: types.h:112
ARC_STATUS ArcClose(ULONG FileId)
Definition: fs.c:218
ARC_STATUS ArcGetFileInformation(ULONG FileId, FILEINFORMATION *Information)
Definition: fs.c:250
struct FileInfo FileInfo
FORCEINLINE PVOID PaToVa(PVOID Pa)
Definition: conversion.h:22
ARC_STATUS ArcOpen(CHAR *Path, OPENMODE OpenMode, ULONG *FileId)
Definition: fs.c:56
unsigned int ULONG
Definition: retypes.h:1
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
FORCEINLINE PVOID VaToPa(PVOID Va)
Definition: conversion.h:15
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 SetupLdrLoadNlsData(), and WinLdrScanSystemHive().

◆ WinLdrpDumpArcDisks()

VOID WinLdrpDumpArcDisks ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 1080 of file winldr.c.

1081 {
1082  PLIST_ENTRY NextBd;
1083  PARC_DISK_SIGNATURE ArcDisk;
1084 
1085  NextBd = LoaderBlock->ArcDiskInformation->DiskSignatureListHead.Flink;
1086 
1087  while (NextBd != &LoaderBlock->ArcDiskInformation->DiskSignatureListHead)
1088  {
1089  ArcDisk = CONTAINING_RECORD(NextBd, ARC_DISK_SIGNATURE, ListEntry);
1090 
1091  TRACE("ArcDisk %s checksum: 0x%X, signature: 0x%X\n",
1092  ArcDisk->ArcName, ArcDisk->CheckSum, ArcDisk->Signature);
1093 
1094  NextBd = ArcDisk->ListEntry.Flink;
1095  }
1096 }
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 1061 of file winldr.c.

1062 {
1063  PLIST_ENTRY NextBd;
1064  PBOOT_DRIVER_LIST_ENTRY BootDriver;
1065 
1066  NextBd = LoaderBlock->BootDriverListHead.Flink;
1067 
1068  while (NextBd != &LoaderBlock->BootDriverListHead)
1069  {
1070  BootDriver = CONTAINING_RECORD(NextBd, BOOT_DRIVER_LIST_ENTRY, Link);
1071 
1072  TRACE("BootDriver %wZ DTE %08X RegPath: %wZ\n", &BootDriver->FilePath,
1073  BootDriver->LdrEntry, &BootDriver->RegistryPath);
1074 
1075  NextBd = BootDriver->Link.Flink;
1076  }
1077 }
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 1042 of file winldr.c.

1043 {
1044  PLIST_ENTRY NextMd;
1046 
1047  NextMd = LoaderBlock->MemoryDescriptorListHead.Flink;
1048 
1049  while (NextMd != &LoaderBlock->MemoryDescriptorListHead)
1050  {
1052 
1053  TRACE("BP %08X PC %04X MT %d\n", MemoryDescriptor->BasePage,
1054  MemoryDescriptor->PageCount, MemoryDescriptor->MemoryType);
1055 
1056  NextMd = MemoryDescriptor->ListEntry.Flink;
1057  }
1058 }
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET _In_opt_ PWDF_MEMORY_DESCRIPTOR MemoryDescriptor
Definition: wdfusb.h:1331
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define TRACE(s)
Definition: solgame.cpp:4
Definition: typedefs.h:119
LIST_ENTRY MemoryDescriptorListHead
Definition: arc.h:494

Referenced by LoadAndBootWindowsCommon(), and WinLdrSetupMemoryLayout().

◆ WinLdrScanSystemHive()

BOOLEAN WinLdrScanSystemHive ( IN OUT PLOADER_PARAMETER_BLOCK  LoaderBlock,
IN PCSTR  SystemRoot 
)

Definition at line 173 of file wlregistry.c.

175 {
176  CHAR SearchPath[1024];
177  CHAR AnsiName[256], OemName[256], LangName[256];
179 
180  /* Scan registry and prepare boot drivers list */
181  WinLdrScanRegistry(&LoaderBlock->BootDriverListHead, SystemRoot);
182 
183  /* Get names of NLS files */
184  Success = WinLdrGetNLSNames(AnsiName, OemName, LangName);
185  if (!Success)
186  {
187  UiMessageBox("Getting NLS names from registry failed!");
188  return FALSE;
189  }
190 
191  TRACE("NLS data %s %s %s\n", AnsiName, OemName, LangName);
192 
193  /* Load NLS data */
195  RtlStringCbCatA(SearchPath, sizeof(SearchPath), "system32\\");
196  Success = WinLdrLoadNLSData(LoaderBlock, SearchPath, AnsiName, OemName, LangName);
197  TRACE("NLS data loading %s\n", Success ? "successful" : "failed");
198 
199  /* TODO: Load OEM HAL font */
200  // In HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage,
201  // REG_SZ value "OEMHAL"
202 
203  return TRUE;
204 }
static VOID WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead, IN PCSTR SystemRoot)
Definition: wlregistry.c:481
#define TRUE
Definition: types.h:120
char CHAR
Definition: xmlstorage.h:175
#define SearchPath
Definition: winbase.h:3740
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
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
unsigned char BOOLEAN
static BOOLEAN WinLdrGetNLSNames(PSTR AnsiName, PSTR OemName, PSTR LangName)
Definition: wlregistry.c:211
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR SystemRoot[]
Definition: reg.c:38
BOOLEAN WinLdrLoadNLSData(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PCSTR DirectoryPath, IN PCSTR AnsiFileName, IN PCSTR OemFileName, IN PCSTR LanguageFileName)
Definition: wlregistry.c:301
IN PDCB IN POEM_STRING OemName
Definition: fatprocs.h:1303
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 LoadAndBootWindows().

◆ WinLdrSetProcessorContext()

VOID WinLdrSetProcessorContext ( VOID  )

Definition at line 348 of file winldr.c.

349 {
350  TRACE("WinLdrSetProcessorContext\n");
351 
352  /* Disable Interrupts */
353  _disable();
354 
355  /* Re-initialize EFLAGS */
356  __writeeflags(0);
357 
358  /* Set the new PML4 */
360 
361  /* Get kernel mode address of gdt / idt */
363 
364  /* Create gdt entries and load gdtr */
365  Amd64SetupGdt(GdtIdt, KSEG0_BASE | (TssBasePage << MM_PAGE_SHIFT));
366 
367  /* Copy old Idt and set idtr */
369 
370  /* LDT is unused */
371 // __lldt(0);
372 
373  /* Load TSR */
374  __ltr(KGDT64_SYS_TSS);
375 
376  TRACE("leave WinLdrSetProcessorContext\n");
377 }
static VOID Amd64SetupIdt(PVOID IdtBase)
Definition: winldr.c:325
static VOID Amd64SetupGdt(PVOID GdtBase, ULONG64 TssBase)
Definition: winldr.c:276
PHARDWARE_PTE PxeBase
Definition: winldr.c:22
__INTRIN_INLINE void __writecr3(unsigned int Data)
Definition: intrin_x86.h:1723
#define KSEG0_BASE
Definition: ketypes.h:273
ULONG_PTR TssBasePage
Definition: winldr.c:27
void * PVOID
Definition: retypes.h:9
#define TRACE(s)
Definition: solgame.cpp:4
unsigned __int64 ULONG64
Definition: imports.h:198
#define KGDT64_SYS_TSS
Definition: ketypes.h:77
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
Definition: intrin_x86.h:1598
#define NUM_GDT
Definition: winldr.h:16
void __cdecl _disable(void)
Definition: intrin_arm.h:365
PVOID GdtIdt
Definition: winldr.c:25

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrSetupMachineDependent()

VOID WinLdrSetupMachineDependent ( PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 379 of file winldr.c.

380 {
381  ULONG_PTR Pcr = 0;
382  ULONG_PTR Tss = 0;
383  ULONG BlockSize, NumPages;
384 
385  LoaderBlock->u.I386.CommonDataArea = (PVOID)DbgPrint; // HACK
386  LoaderBlock->u.I386.MachineType = MACHINE_TYPE_ISA;
387 
388  /* Allocate 2 pages for PCR */
389  Pcr = (ULONG_PTR)MmAllocateMemoryWithType(2 * MM_PAGE_SIZE, LoaderStartupPcrPage);
390  PcrBasePage = Pcr >> MM_PAGE_SHIFT;
391  if (Pcr == 0)
392  {
393  UiMessageBox("Can't allocate PCR.");
394  return;
395  }
396  RtlZeroMemory((PVOID)Pcr, 2 * MM_PAGE_SIZE);
397 
398  /* Allocate TSS */
399  BlockSize = (sizeof(KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
401  TssBasePage = Tss >> MM_PAGE_SHIFT;
402 
403  /* Allocate space for new GDT + IDT */
404  BlockSize = NUM_GDT * sizeof(KGDTENTRY) + NUM_IDT * sizeof(KIDTENTRY);
405  NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
406  GdtIdt = (PKGDTENTRY)MmAllocateMemoryWithType(NumPages * MM_PAGE_SIZE, LoaderMemoryData);
407  if (GdtIdt == NULL)
408  {
409  UiMessageBox("Can't allocate pages for GDT+IDT!");
410  return;
411  }
412 
413  /* Zero newly prepared GDT+IDT */
414  RtlZeroMemory(GdtIdt, NumPages << MM_PAGE_SHIFT);
415 
416  // Before we start mapping pages, create a block of memory, which will contain
417  // PDE and PTEs
418  if (MempAllocatePageTables() == FALSE)
419  {
420  // FIXME: bugcheck
421  }
422 
423  /* Map stuff like PCR, KI_USER_SHARED_DATA and Apic */
425 }
union _LOADER_PARAMETER_BLOCK::@3350 u
#define PKGDTENTRY
Definition: ketypes.h:438
#define KTSS
Definition: ketypes.h:920
#define DbgPrint
Definition: loader.c:25
ULONG_PTR PcrBasePage
Definition: winldr.c:26
#define KGDTENTRY
Definition: ketypes.h:437
static BOOLEAN WinLdrMapSpecialPages(VOID)
Definition: winldr.c:244
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
I386_LOADER_BLOCK I386
Definition: arc.h:515
ULONG_PTR TssBasePage
Definition: winldr.c:27
void * PVOID
Definition: retypes.h:9
ULONG MachineType
Definition: arc.h:407
#define MACHINE_TYPE_ISA
Definition: ketypes.h:52
#define NUM_IDT
Definition: winldr.h:17
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
PVOID CommonDataArea
Definition: arc.h:406
#define NUM_GDT
Definition: winldr.h:16
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define ULONG_PTR
Definition: config.h:101
PVOID GdtIdt
Definition: winldr.c:25
static BOOLEAN MempAllocatePageTables(VOID)
Definition: winldr.c:33

Referenced by LoadAndBootWindowsCommon().

◆ WinLdrSetupMemoryLayout()

BOOLEAN WinLdrSetupMemoryLayout ( IN OUT PLOADER_PARAMETER_BLOCK  LoaderBlock)

Definition at line 181 of file wlmemory.c.

182 {
183  PFN_NUMBER i, PagesCount, MemoryMapSizeInPages, NoEntries;
184  PFN_NUMBER LastPageIndex, MemoryMapStartPage;
186  ULONG LastPageType;
187  //PKTSS Tss;
188  //BOOLEAN Status;
189 
190  /* Cleanup heap */
192 
193  //
194  // Creating a suitable memory map for Windows can be tricky, so let's
195  // give a few advices:
196  // 1) One must not map the whole available memory pages to PDE!
197  // Map only what's needed - 16Mb, 24Mb, 32Mb max I think,
198  // thus occupying 4, 6 or 8 PDE entries for identical mapping,
199  // the same quantity for KSEG0_BASE mapping, one more entry for
200  // hyperspace and one more entry for HAL physical pages mapping.
201  // 2) Memory descriptors must map *the whole* physical memory
202  // showing any memory above 16/24/32 as FirmwareTemporary
203  //
204  // 3) Overall memory blocks count must not exceed 30 (?? why?)
205  //
206 
207  //
208  // During MmInitMachineDependent, the kernel zeroes PDE at the following address
209  // 0xC0300000 - 0xC03007FC
210  //
211  // Then it finds the best place for non-paged pool:
212  // StartPde C0300F70, EndPde C0300FF8, NumberOfPages C13, NextPhysPage 3AD
213  //
214 
215  // Allocate memory for memory allocation descriptors
218 
219  // Setup an entry for each descriptor
220  MemoryMap = MmGetMemoryMap(&NoEntries);
221  if (MemoryMap == NULL)
222  {
223  UiMessageBox("Can not retrieve the current memory map.");
224  return FALSE;
225  }
226 
227  // Calculate parameters of the memory map
228  MemoryMapStartPage = (ULONG_PTR)MemoryMap >> MM_PAGE_SHIFT;
229  MemoryMapSizeInPages = (NoEntries * sizeof(PAGE_LOOKUP_TABLE_ITEM) + MM_PAGE_SIZE - 1) / MM_PAGE_SIZE;
230 
231  TRACE("Got memory map with %d entries\n", NoEntries);
232 #if 0
233  // Always contiguously map low 1Mb of memory
234  Status = MempSetupPaging(0, 0x100, FALSE);
235  if (!Status)
236  {
237  ERR("Error during MempSetupPaging of low 1Mb\n");
238  return FALSE;
239  }
240 #endif
241 
242  /* Before creating the map, we need to map pages to kernel mode */
243  LastPageIndex = 1;
244  LastPageType = MemoryMap[1].PageAllocated;
245  for (i = 2; i < NoEntries; i++)
246  {
247  if ((MemoryMap[i].PageAllocated != LastPageType) ||
248  (i == NoEntries - 1))
249  {
250  MempSetupPagingForRegion(LastPageIndex, i - LastPageIndex, LastPageType);
251  LastPageIndex = i;
252  LastPageType = MemoryMap[i].PageAllocated;
253  }
254  }
255 
256  // Construct a good memory map from what we've got,
257  // but mark entries which the memory allocation bitmap takes
258  // as free entries (this is done in order to have the ability
259  // to place mem alloc bitmap outside lower 16Mb zone)
260  PagesCount = 1;
261  LastPageIndex = 0;
262  LastPageType = MemoryMap[0].PageAllocated;
263  for (i = 1; i < NoEntries; i++)
264  {
265  // Check if its memory map itself
266  if (i >= MemoryMapStartPage &&
267  i < (MemoryMapStartPage+MemoryMapSizeInPages))
268  {
269  // Exclude it if current page belongs to the memory map
270  MemoryMap[i].PageAllocated = LoaderFree;
271  }
272 
273  // Process entry
274  if (MemoryMap[i].PageAllocated == LastPageType &&
275  (i != NoEntries-1) )
276  {
277  PagesCount++;
278  }
279  else
280  {
281  // Add the resulting region
282  MempAddMemoryBlock(LoaderBlock, LastPageIndex, PagesCount, LastPageType);
283 
284  // Reset our counter vars
285  LastPageIndex = i;
286  LastPageType = MemoryMap[i].PageAllocated;
287  PagesCount = 1;
288  }
289  }
290 
291  // TEMP, DEBUG!
292  // adding special reserved memory zones for vmware workstation
293 #if 0
294  {
295  Mad[MadCount].BasePage = 0xfec00;
296  Mad[MadCount].PageCount = 0x10;
298  WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]);
299  MadCount++;
300 
301  Mad[MadCount].BasePage = 0xfee00;
302  Mad[MadCount].PageCount = 0x1;
304  WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]);
305  MadCount++;
306 
307  Mad[MadCount].BasePage = 0xfffe0;
308  Mad[MadCount].PageCount = 0x20;
310  WinLdrInsertDescriptor(LoaderBlock, &Mad[MadCount]);
311  MadCount++;
312  }
313 #endif
314 
315  /* Now we need to add high descriptors from the bios memory map */
316  for (i = 0; i < BiosMemoryMapEntryCount; i++)
317  {
318  /* Check if its higher than the lookup table */
320  {
321  /* Copy this descriptor */
322  MempAddMemoryBlock(LoaderBlock,
326  }
327  }
328 
329  TRACE("MadCount: %d\n", MadCount);
330 
331  WinLdrpDumpMemoryDescriptors(LoaderBlock); //FIXME: Delete!
332 
333  // Map our loader image, so we can continue running
334  /*Status = MempSetupPaging(OsLoaderBase >> MM_PAGE_SHIFT, OsLoaderSize >> MM_PAGE_SHIFT);
335  if (!Status)
336  {
337  UiMessageBox("Error during MempSetupPaging.");
338  return;
339  }*/
340 
341  // Fill the memory descriptor list and
342  //PrepareMemoryDescriptorList();
343  TRACE("Memory Descriptor List prepared, printing PDE\n");
344  List_PaToVa(&LoaderBlock->MemoryDescriptorListHead);
345 
346 #if DBG
347  MempDump();
348 #endif
349 
350  return TRUE;
351 }
VOID MempDump(VOID)
Definition: winldr.c:429
PFN_NUMBER MmHighestPhysicalPage
Definition: meminit.c:31
ULONG MadCount
Definition: wlmemory.c:58
#define TRUE
Definition: types.h:120
VOID List_PaToVa(_In_ LIST_ENTRY *ListEntry)
BIOS_MEMORY_MAP MemoryMap[32]
Definition: loader.c:11
TYPE_OF_MEMORY MemoryType
Definition: mm.h:38
VOID MempSetupPagingForRegion(PFN_NUMBER BasePage, PFN_NUMBER PageCount, ULONG Type)
Definition: wlmemory.c:106
BOOLEAN MempSetupPaging(IN PFN_NUMBER StartPage, IN PFN_NUMBER NumberOfPages, IN BOOLEAN KernelMapping)
Definition: winldr.c:170
MEMORY_ALLOCATION_DESCRIPTOR * Mad
Definition: wlmemory.c:57
TYPE_OF_MEMORY MemoryType
Definition: arc.h:193
ULONG PFN_NUMBER
Definition: ke.h:8
#define FALSE
Definition: types.h:117
#define MAX_MAD_COUNT
Definition: wlmemory.c:60
VOID UiMessageBox(PCSTR Format,...)
Definition: ui.c:320
PFN_NUMBER BasePage
Definition: mm.h:39
ULONG BiosMemoryMapEntryCount
Definition: meminit.c:34
Status
Definition: gdiplustypes.h:24
#define TRACE(s)
Definition: solgame.cpp:4
PPAGE_LOOKUP_TABLE_ITEM MmGetMemoryMap(PFN_NUMBER *NoEntries)
Definition: mm.c:297
VOID FrLdrHeapCleanupAll(VOID)
Definition: heap.c:248
PFREELDR_MEMORY_DESCRIPTOR BiosMemoryMap
Definition: meminit.c:33
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
Definition: mm.c:31
VOID WinLdrpDumpMemoryDescriptors(PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: winldr.c:1042
VOID MempAddMemoryBlock(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, PFN_NUMBER BasePage, PFN_NUMBER PageCount, ULONG Type)
Definition: wlmemory.c:65
#define ERR(fmt,...)
Definition: debug.h:110
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 NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
static VOID WinLdrInsertDescriptor(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, IN PMEMORY_ALLOCATION_DESCRIPTOR NewDescriptor)
Definition: wlmemory.c:356
PFN_NUMBER PageCount
Definition: mm.h:40

Referenced by LoadAndBootWindowsCommon().

Variable Documentation

◆ WinLdrSystemBlock

PLOADER_SYSTEM_BLOCK WinLdrSystemBlock

Definition at line 28 of file winldr.c.

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