14#include "../../winldr.h"
36 TRACE(
">>> MempAllocatePageTables\n");
42 ERR(
"failed to allocate PML4\n");
60 TRACE(
">>> leave MempAllocatePageTables\n");
74 if (!PdeBase[
Index].Valid)
104 ERR(
"!!!No Dir %p, %p, %p, %p\n",
PxeBase, PpeBase, PdeBase, PteBase);
109 if (PteBase[
Index].Valid)
111 ERR(
"!!!Already mapped %ld\n",
Index);
134 if (!PpeBase[
Index].Valid)
139 if (!PdeBase[
Index].Valid)
144 if (!PteBase[
Index].Valid)
156 for (
i = 0;
i < cPages;
i++)
160 ERR(
"Failed to map page %ld from %p to %p\n",
175 TRACE(
">>> MempSetupPaging(0x%lx, %ld, %p)\n",
181 NumberOfPages) != NumberOfPages)
183 ERR(
"Failed to map pages %ld, %ld\n",
193 NumberOfPages) != NumberOfPages)
195 ERR(
"Failed to map pages %ld, %ld\n",
219 TRACE(
">>> WinLdrpMapApic\n");
223 LocalAPIC = (((CpuInfo[3] >> 9) & 1) != 0);
228 WARN(
"No APIC found.\n");
234 APICAddress = (MsrValue.
LowPart & 0xFFFFF000);
236 TRACE(
"Local APIC detected at address 0x%x\n",
259 ERR(
"Could not map KI_USER_SHARED_DATA\n");
281 TRACE(
"Amd64SetupGdt(GdtBase = %p, TssBase = %p)\n", GdtBase, TssBase);
316 GdtDesc.
Base = GdtBase;
320 __lgdt(&GdtDesc.
Limit);
321 TRACE(
"Leave Amd64SetupGdt()\n");
330 TRACE(
"Amd64SetupIdt(IdtBase = %p)\n", IdtBase);
340 IdtDesc.
Base = IdtBase;
345 TRACE(
"Leave Amd64SetupIdt()\n");
352 TRACE(
"WinLdrSetProcessorContext\n");
378 TRACE(
"leave WinLdrSetProcessorContext\n");
385 ULONG BlockSize, NumPages;
401 BlockSize = (
sizeof(
KTSS) + MM_PAGE_SIZE) & ~(MM_PAGE_SIZE - 1);
407 NumPages = (BlockSize + MM_PAGE_SIZE - 1) >> MM_PAGE_SHIFT;
FORCEINLINE PKGDTENTRY64 KiGetGdtEntry(PVOID pGdt, USHORT Selector)
FORCEINLINE VOID KiInitGdtEntry(PKGDTENTRY64 Entry, ULONG64 Base, ULONG Size, UCHAR Type, UCHAR Dpl)
VOID WinLdrSetProcessorContext(_In_ USHORT OperatingSystemVersion)
static BOOLEAN MempMapSinglePage(ULONG64 VirtualAddress, ULONG64 PhysicalAddress)
BOOLEAN MempSetupPaging(IN PFN_NUMBER StartPage, IN PFN_NUMBER NumberOfPages, IN BOOLEAN KernelMapping)
static BOOLEAN MempAllocatePageTables(VOID)
static PHARDWARE_PTE MempGetOrCreatePageDir(PHARDWARE_PTE PdeBase, ULONG Index)
static VOID WinLdrpMapApic(VOID)
VOID MempUnmapPage(PFN_NUMBER Page)
static VOID Amd64SetupGdt(PVOID GdtBase, ULONG64 TssBase)
static PFN_NUMBER MempMapRangeOfPages(ULONG64 VirtualAddress, ULONG64 PhysicalAddress, PFN_NUMBER cPages)
static VOID Amd64SetupIdt(PVOID IdtBase)
BOOLEAN MempIsPageMapped(PVOID VirtualAddress)
void WinLdrSetupMachineDependent(PLOADER_PARAMETER_BLOCK LoaderBlock)
static BOOLEAN WinLdrMapSpecialPages(void)
#define DBG_DEFAULT_CHANNEL(ch)
PVOID MmAllocateMemoryWithType(SIZE_T MemorySize, TYPE_OF_MEMORY MemoryType)
VOID UiMessageBox(_In_ PCSTR Format,...)
static const WCHAR SubDir[]
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
void __cdecl _disable(void)
PPC_QUAL void __cpuid(int CPUInfo[], const int InfoType)
PPC_QUAL unsigned long long __readmsr()
__INTRIN_INLINE void __writeeflags(uintptr_t Value)
__INTRIN_INLINE void __lidt(void *Source)
__INTRIN_INLINE void __writecr3(unsigned int Data)
__INTRIN_INLINE void __sidt(void *Destination)
unsigned __int64 * PULONG64
_In_ PVOID _Out_opt_ BOOLEAN _Out_opt_ PPFN_NUMBER Page
#define KI_USER_SHARED_DATA
base of all file and directory entries
union _LOADER_PARAMETER_BLOCK::@3369 u
#define RtlZeroMemory(Destination, Length)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
int WINAPI StartPage(_In_ HDC)
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress