#include <freeldr.h>
#include <ndk/asm.h>
#include <internal/amd64/intrin_i.h>
#include "../../winldr.h"
#include <debug.h>
Go to the source code of this file.
◆ Amd64SetupGdt()
Definition at line 270 of file winldr.c.
271{
274 TRACE(
"Amd64SetupGdt(GdtBase = %p, TssBase = %p)\n", GdtBase, TssBase);
275
276
279
280
283
284
287
288
291
292
295
296
299
300
303
304
307
308
309 GdtDesc.
Base = GdtBase;
311
312
313 __lgdt(&GdtDesc.
Limit);
314 TRACE(
"Leave Amd64SetupGdt()\n");
315}
FORCEINLINE PKGDTENTRY64 KiGetGdtEntry(PVOID pGdt, USHORT Selector)
FORCEINLINE VOID KiInitGdtEntry(PKGDTENTRY64 Entry, ULONG64 Base, ULONG Size, UCHAR Type, UCHAR Dpl)
unsigned __int64 * PULONG64
Referenced by WinLdrSetProcessorContext().
◆ Amd64SetupIdt()
Definition at line 319 of file winldr.c.
320{
322
323 TRACE(
"Amd64SetupIdt(IdtBase = %p)\n", IdtBase);
324
325
327
328
329
330
331
332
333 IdtDesc.
Base = IdtBase;
335
336
338 TRACE(
"Leave Amd64SetupIdt()\n");
339}
__INTRIN_INLINE void __lidt(void *Source)
__INTRIN_INLINE void __sidt(void *Destination)
Referenced by WinLdrSetProcessorContext().
◆ DBG_DEFAULT_CHANNEL()
◆ MempAllocatePageTables()
Definition at line 34 of file winldr.c.
35{
36 TRACE(
">>> MempAllocatePageTables\n");
37
38
41 {
42 ERR(
"failed to allocate PML4\n");
44 }
45
46
47
48
50
51
52
53
57
58
59
60 TRACE(
">>> leave MempAllocatePageTables\n");
61
63}
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
#define RtlZeroMemory(Destination, Length)
Referenced by WinLdrSetupMachineDependent().
◆ MempDump()
◆ MempGetOrCreatePageDir()
◆ MempIsPageMapped()
Definition at line 123 of file winldr.c.
124{
127
131
134 if (!PpeBase[
Index].Valid)
136
139 if (!PdeBase[
Index].Valid)
141
144 if (!PteBase[
Index].Valid)
146
148}
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
◆ MempMapRangeOfPages()
Definition at line 152 of file winldr.c.
153{
155
156 for (
i = 0;
i < cPages;
i++)
157 {
159 {
160 ERR(
"Failed to map page %ld from %p to %p\n",
163 }
166 }
168}
static BOOLEAN MempMapSinglePage(ULONG64 VirtualAddress, ULONG64 PhysicalAddress)
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
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Referenced by MempSetupPaging().
◆ MempMapSinglePage()
Definition at line 93 of file winldr.c.
94{
97
101
102 if (!PteBase)
103 {
104 ERR(
"!!!No Dir %p, %p, %p, %p\n",
PxeBase, PpeBase, PdeBase, PteBase);
106 }
107
109 if (PteBase[
Index].Valid)
110 {
111 ERR(
"!!!Already mapped %ld\n",
Index);
113 }
114
118
120}
static PHARDWARE_PTE MempGetOrCreatePageDir(PHARDWARE_PTE PdeBase, ULONG Index)
Referenced by MempMapRangeOfPages(), WinLdrMapSpecialPages(), and WinLdrpMapApic().
◆ MempSetupPaging()
Definition at line 171 of file winldr.c.
174{
175 TRACE(
">>> MempSetupPaging(0x%lx, %ld, %p)\n",
177
178
181 NumberOfPages) != NumberOfPages)
182 {
183 ERR(
"Failed to map pages %ld, %ld\n",
186 }
187
188
189 if (KernelMapping)
190 {
193 NumberOfPages) != NumberOfPages)
194 {
195 ERR(
"Failed to map pages %ld, %ld\n",
198 }
199 }
200
202}
static PFN_NUMBER MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, PFN_NUMBER cPages)
int WINAPI StartPage(_In_ HDC)
Referenced by MempSetupPagingForRegion(), and WinLdrSetupMemoryLayout().
◆ MempUnmapPage()
◆ WinLdrMapSpecialPages()
Definition at line 245 of file winldr.c.
246{
248
249
251 {
252 ERR(
"Could not map KI_USER_SHARED_DATA\n");
254 }
255
256
258
259
264
266}
PFN_NUMBER SharedUserDataPfn
static VOID WinLdrpMapApic(VOID)
#define KI_USER_SHARED_DATA
◆ WinLdrpMapApic()
Definition at line 212 of file winldr.c.
213{
218
219 TRACE(
">>> WinLdrpMapApic\n");
220
221
223 LocalAPIC = (((CpuInfo[3] >> 9) & 1) != 0);
224
225
226 if (!LocalAPIC)
227 {
228 WARN(
"No APIC found.\n");
229 return;
230 }
231
232
234 APICAddress = (MsrValue.
LowPart & 0xFFFFF000);
235
236 TRACE(
"Local APIC detected at address 0x%x\n",
237 APICAddress);
238
239
241}
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
PPC_QUAL unsigned long long __readmsr()
Referenced by WinLdrMapSpecialPages().
◆ WinLdrSetProcessorContext()
Definition at line 342 of file winldr.c.
344{
345 TRACE(
"WinLdrSetProcessorContext\n");
346
347
349
350
352
353
355
356
358
359
361
362
364
365
366
367
368
370
371 TRACE(
"leave WinLdrSetProcessorContext\n");
372}
static VOID Amd64SetupGdt(PVOID GdtBase, ULONG64 TssBase)
static VOID Amd64SetupIdt(PVOID IdtBase)
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
__INTRIN_INLINE void __writecr3(unsigned int Data)
void __cdecl _disable(void)
Referenced by LoadAndBootWindowsCommon().
◆ WinLdrSetupMachineDependent()
Definition at line 374 of file winldr.c.
375{
378 ULONG BlockSize, NumPages;
379
382
383
386 if (SharedUserDataAddress ==
NULL)
387 {
389 return;
390 }
392
393
394 BlockSize = (
sizeof(
KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
397
398
400 NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
403 {
405 return;
406 }
407
408
410
411
412
414 {
415
416 }
417
418
420}
static BOOLEAN MempAllocatePageTables(VOID)
static BOOLEAN WinLdrMapSpecialPages(void)
VOID UiMessageBox(_In_ PCSTR Format,...)
union _LOADER_PARAMETER_BLOCK::@3639 u
Referenced by LoadAndBootWindowsCommon().
◆ GdtIdt
◆ PxeBase
◆ SharedUserDataPfn
◆ TssBasePage