mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Kernel base address and system space start can be distinct addresses, so use KERNEL_BASE and MmSystemRangeStart accordingly in the code.
svn path=/trunk/; revision=16447
This commit is contained in:
parent
d64e8b4096
commit
2773203033
12 changed files with 83 additions and 92 deletions
|
@ -22,8 +22,6 @@
|
|||
#define PA_SYSTEM (0)
|
||||
#endif
|
||||
|
||||
#define KERNEL_BASE (ULONG)MmSystemRangeStart
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
||||
#define FLUSH_TLB { \
|
||||
|
|
|
@ -308,6 +308,8 @@ extern LARGE_INTEGER SystemBootTime;
|
|||
|
||||
/* INITIALIZATION FUNCTIONS *************************************************/
|
||||
|
||||
extern ULONG_PTR KERNEL_BASE;
|
||||
|
||||
VOID KeInitExceptions(VOID);
|
||||
VOID KeInitInterrupts(VOID);
|
||||
VOID KeInitTimer(VOID);
|
||||
|
|
|
@ -135,7 +135,7 @@ KiRosPrintAddress(PVOID address)
|
|||
current_entry = current_entry->Flink;
|
||||
}
|
||||
|
||||
address = (PVOID)((ULONG_PTR)address & ~KERNEL_BASE);
|
||||
address = (PVOID)((ULONG_PTR)address & ~(ULONG_PTR)MmSystemRangeStart);
|
||||
} while(++i <= 1);
|
||||
|
||||
return(FALSE);
|
||||
|
|
|
@ -22,18 +22,6 @@
|
|||
ULONG NtMajorVersion = 5;
|
||||
ULONG NtMinorVersion = 0;
|
||||
ULONG NtOSCSDVersion = BUILD_OSCSDVERSION(6, 0);
|
||||
#ifdef __GNUC__
|
||||
ULONG EXPORTED NtBuildNumber = KERNEL_VERSION_BUILD;
|
||||
ULONG EXPORTED NtGlobalFlag = 0;
|
||||
CHAR EXPORTED KeNumberProcessors;
|
||||
KAFFINITY EXPORTED KeActiveProcessors;
|
||||
LOADER_PARAMETER_BLOCK EXPORTED KeLoaderBlock;
|
||||
ULONG EXPORTED KeDcacheFlushCount = 0;
|
||||
ULONG EXPORTED KeIcacheFlushCount = 0;
|
||||
ULONG EXPORTED KiDmaIoCoherency = 0; /* RISC Architectures only */
|
||||
ULONG EXPORTED InitSafeBootMode = 0; /* KB83764 */
|
||||
#else
|
||||
/* Microsoft-style declarations */
|
||||
EXPORTED ULONG NtBuildNumber = KERNEL_VERSION_BUILD;
|
||||
EXPORTED ULONG NtGlobalFlag = 0;
|
||||
EXPORTED CHAR KeNumberProcessors;
|
||||
|
@ -43,7 +31,6 @@ EXPORTED ULONG KeDcacheFlushCount = 0;
|
|||
EXPORTED ULONG KeIcacheFlushCount = 0;
|
||||
EXPORTED ULONG KiDmaIoCoherency = 0; /* RISC Architectures only */
|
||||
EXPORTED ULONG InitSafeBootMode = 0; /* KB83764 */
|
||||
#endif /* __GNUC__ */
|
||||
|
||||
LOADER_MODULE KeLoaderModules[64];
|
||||
static CHAR KeLoaderModuleStrings[64][256];
|
||||
|
@ -69,6 +56,9 @@ ULONG trap_stack_top;
|
|||
/* Cached modules from the loader block */
|
||||
PLOADER_MODULE CachedModules[MaximumCachedModuleType];
|
||||
|
||||
extern unsigned int _image_base__;
|
||||
ULONG_PTR KERNEL_BASE = (ULONG_PTR)&_image_base__;
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
/*
|
||||
|
|
|
@ -73,7 +73,7 @@ MmInitializeAddressSpace(PEPROCESS Process,
|
|||
}
|
||||
else
|
||||
{
|
||||
AddressSpace->LowestAddress = (PVOID)KERNEL_BASE;
|
||||
AddressSpace->LowestAddress = MmSystemRangeStart;
|
||||
}
|
||||
AddressSpace->Process = Process;
|
||||
if (Process != NULL)
|
||||
|
|
|
@ -105,7 +105,7 @@ MiFlushTlb(PULONG Pt, PVOID Address)
|
|||
MiFlushTlbIpiRoutine(Address);
|
||||
}
|
||||
#else
|
||||
if ((Pt && MmUnmapPageTable(Pt)) || Address >= (PVOID)KERNEL_BASE)
|
||||
if ((Pt && MmUnmapPageTable(Pt)) || Address >= MmSystemRangeStart)
|
||||
{
|
||||
FLUSH_TLB_ONE(Address);
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process)
|
|||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
PageDir = (PULONGLONG)MmCreateHyperspaceMapping(PAE_PTE_TO_PFN(PageDirTable[i]));
|
||||
if (i < PAE_ADDR_TO_PDTE_OFFSET(KERNEL_BASE))
|
||||
if (i < PAE_ADDR_TO_PDTE_OFFSET(MmSystemRangeStart))
|
||||
{
|
||||
for (j = 0; j < 512; j++)
|
||||
{
|
||||
|
@ -274,7 +274,7 @@ NTSTATUS Mmi386ReleaseMmInfo(PEPROCESS Process)
|
|||
PULONG Pde;
|
||||
PULONG PageDir;
|
||||
PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.u.LowPart));
|
||||
for (i = 0; i < ADDR_TO_PDE_OFFSET(KERNEL_BASE); i++)
|
||||
for (i = 0; i < ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i++)
|
||||
{
|
||||
if (PageDir[i] != 0)
|
||||
{
|
||||
|
@ -358,7 +358,7 @@ MmCopyMmInfo(PEPROCESS Src,
|
|||
PageDirTable[i] = PAE_PFN_TO_PTE(Pfn[1+i]) | PA_PRESENT;
|
||||
}
|
||||
MmDeleteHyperspaceMapping(PageDirTable);
|
||||
for (i = PAE_ADDR_TO_PDTE_OFFSET(KERNEL_BASE); i < 4; i++)
|
||||
for (i = PAE_ADDR_TO_PDTE_OFFSET(MmSystemRangeStart); i < 4; i++)
|
||||
{
|
||||
PageDir = (PULONGLONG)MmCreateHyperspaceMapping(Pfn[i+1]);
|
||||
memcpy(PageDir, &MmGlobalKernelPageDirectoryForPAE[i * 512], 512 * sizeof(ULONGLONG));
|
||||
|
@ -382,9 +382,9 @@ MmCopyMmInfo(PEPROCESS Src,
|
|||
PULONG PageDirectory;
|
||||
PageDirectory = MmCreateHyperspaceMapping(Pfn[0]);
|
||||
|
||||
memcpy(PageDirectory + ADDR_TO_PDE_OFFSET(KERNEL_BASE),
|
||||
MmGlobalKernelPageDirectory + ADDR_TO_PDE_OFFSET(KERNEL_BASE),
|
||||
(1024 - ADDR_TO_PDE_OFFSET(KERNEL_BASE)) * sizeof(ULONG));
|
||||
memcpy(PageDirectory + ADDR_TO_PDE_OFFSET(MmSystemRangeStart),
|
||||
MmGlobalKernelPageDirectory + ADDR_TO_PDE_OFFSET(MmSystemRangeStart),
|
||||
(1024 - ADDR_TO_PDE_OFFSET(MmSystemRangeStart)) * sizeof(ULONG));
|
||||
|
||||
DPRINT("Addr %x\n",ADDR_TO_PDE_OFFSET(PAGETABLE_MAP));
|
||||
PageDirectory[ADDR_TO_PDE_OFFSET(PAGETABLE_MAP)] = PFN_TO_PTE(Pfn[0]) | PA_PRESENT | PA_READWRITE;
|
||||
|
@ -416,7 +416,7 @@ VOID MmDeletePageTable(PEPROCESS Process, PVOID Address)
|
|||
{
|
||||
*(ADDR_TO_PDE(Address)) = 0;
|
||||
}
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
KEBUGCHECK(0);
|
||||
// MmGlobalKernelPageDirectory[ADDR_TO_PDE_OFFSET(Address)] = 0;
|
||||
|
@ -474,7 +474,7 @@ VOID MmFreePageTable(PEPROCESS Process, PVOID Address)
|
|||
}
|
||||
MiFlushTlb(NULL, Address);
|
||||
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
// MmGlobalKernelPageDirectory[ADDR_TO_PDE_OFFSET(Address)] = 0;
|
||||
KEBUGCHECK(0);
|
||||
|
@ -506,7 +506,7 @@ MmGetPageTableForProcessForPAE(PEPROCESS Process, PVOID Address, BOOLEAN Create)
|
|||
{
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
if (Address < (PVOID)KERNEL_BASE && Process && Process != PsGetCurrentProcess())
|
||||
if (Address < MmSystemRangeStart && Process && Process != PsGetCurrentProcess())
|
||||
{
|
||||
PageDirTable = MmCreateHyperspaceMapping(PAE_PTE_TO_PFN(Process->Pcb.DirectoryTableBase.QuadPart));
|
||||
if (PageDirTable == NULL)
|
||||
|
@ -556,7 +556,7 @@ MmGetPageTableForProcessForPAE(PEPROCESS Process, PVOID Address, BOOLEAN Create)
|
|||
PageDir = PAE_ADDR_TO_PDE(Address);
|
||||
if (0LL == ExfInterlockedCompareExchange64UL(PageDir, &ZeroEntry, &ZeroEntry))
|
||||
{
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
if (MmGlobalKernelPageDirectoryForPAE[PAE_ADDR_TO_PDE_OFFSET(Address)] == 0LL)
|
||||
{
|
||||
|
@ -612,7 +612,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
|
|||
ULONG Entry;
|
||||
PULONG Pt, PageDir;
|
||||
|
||||
if (Address < (PVOID)KERNEL_BASE && Process && Process != PsGetCurrentProcess())
|
||||
if (Address < MmSystemRangeStart && Process && Process != PsGetCurrentProcess())
|
||||
{
|
||||
PageDir = MmCreateHyperspaceMapping(PTE_TO_PFN(Process->Pcb.DirectoryTableBase.QuadPart));
|
||||
if (PageDir == NULL)
|
||||
|
@ -653,7 +653,7 @@ MmGetPageTableForProcess(PEPROCESS Process, PVOID Address, BOOLEAN Create)
|
|||
PageDir = ADDR_TO_PDE(Address);
|
||||
if (0 == InterlockedCompareExchangeUL(PageDir, 0, 0))
|
||||
{
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
if (0 == InterlockedCompareExchangeUL(&MmGlobalKernelPageDirectory[PdeOffset], 0, 0))
|
||||
{
|
||||
|
@ -1024,7 +1024,7 @@ MmDeleteVirtualMapping(PEPROCESS Process, PVOID Address, BOOL FreePage,
|
|||
*/
|
||||
if (Process != NULL && WasValid &&
|
||||
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
||||
Address < (PVOID)KERNEL_BASE)
|
||||
Address < MmSystemRangeStart)
|
||||
{
|
||||
PUSHORT Ptrc;
|
||||
ULONG Idx;
|
||||
|
@ -1072,7 +1072,7 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address,
|
|||
*/
|
||||
if (Process != NULL && Pte &&
|
||||
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
||||
Address < (PVOID)KERNEL_BASE)
|
||||
Address < MmSystemRangeStart)
|
||||
{
|
||||
PUSHORT Ptrc;
|
||||
|
||||
|
@ -1116,7 +1116,7 @@ MmDeletePageFileMapping(PEPROCESS Process, PVOID Address,
|
|||
*/
|
||||
if (Process != NULL && Pte &&
|
||||
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
||||
Address < (PVOID)KERNEL_BASE)
|
||||
Address < MmSystemRangeStart)
|
||||
{
|
||||
PUSHORT Ptrc;
|
||||
|
||||
|
@ -1193,7 +1193,7 @@ BOOLEAN MmIsDirtyPage(PEPROCESS Process, PVOID Address)
|
|||
BOOLEAN
|
||||
MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
if (Address < (PVOID)KERNEL_BASE && Process == NULL)
|
||||
if (Address < MmSystemRangeStart && Process == NULL)
|
||||
{
|
||||
DPRINT1("MmIsAccessedAndResetAccessPage is called for user space without a process.\n");
|
||||
KEBUGCHECK(0);
|
||||
|
@ -1258,7 +1258,7 @@ MmIsAccessedAndResetAccessPage(PEPROCESS Process, PVOID Address)
|
|||
|
||||
VOID MmSetCleanPage(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
if (Address < (PVOID)KERNEL_BASE && Process == NULL)
|
||||
if (Address < MmSystemRangeStart && Process == NULL)
|
||||
{
|
||||
DPRINT1("MmSetCleanPage is called for user space without a process.\n");
|
||||
KEBUGCHECK(0);
|
||||
|
@ -1321,7 +1321,7 @@ VOID MmSetCleanPage(PEPROCESS Process, PVOID Address)
|
|||
|
||||
VOID MmSetDirtyPage(PEPROCESS Process, PVOID Address)
|
||||
{
|
||||
if (Address < (PVOID)KERNEL_BASE && Process == NULL)
|
||||
if (Address < MmSystemRangeStart && Process == NULL)
|
||||
{
|
||||
DPRINT1("MmSetDirtyPage is called for user space without a process.\n");
|
||||
KEBUGCHECK(0);
|
||||
|
@ -1475,7 +1475,7 @@ MmCreateVirtualMappingForKernel(PVOID Address,
|
|||
DPRINT("MmCreateVirtualMappingForKernel(%x, %x, %x, %d)\n",
|
||||
Address, flProtect, Pages, PageCount);
|
||||
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
DPRINT1("MmCreateVirtualMappingForKernel is called for user space\n");
|
||||
KEBUGCHECK(0);
|
||||
|
@ -1592,12 +1592,12 @@ MmCreatePageFileMapping(PEPROCESS Process,
|
|||
PVOID Address,
|
||||
SWAPENTRY SwapEntry)
|
||||
{
|
||||
if (Process == NULL && Address < (PVOID)KERNEL_BASE)
|
||||
if (Process == NULL && Address < MmSystemRangeStart)
|
||||
{
|
||||
DPRINT1("No process\n");
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
if (Process != NULL && Address >= (PVOID)KERNEL_BASE)
|
||||
if (Process != NULL && Address >= MmSystemRangeStart)
|
||||
{
|
||||
DPRINT1("Setting kernel address with process context\n");
|
||||
KEBUGCHECK(0);
|
||||
|
@ -1661,7 +1661,7 @@ MmCreatePageFileMapping(PEPROCESS Process,
|
|||
}
|
||||
if (Process != NULL &&
|
||||
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
||||
Address < (PVOID)KERNEL_BASE)
|
||||
Address < MmSystemRangeStart)
|
||||
{
|
||||
PUSHORT Ptrc;
|
||||
ULONG Idx;
|
||||
|
@ -1692,7 +1692,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
|
|||
|
||||
if (Process == NULL)
|
||||
{
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
DPRINT1("No process\n");
|
||||
KEBUGCHECK(0);
|
||||
|
@ -1706,13 +1706,14 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
|
|||
}
|
||||
else
|
||||
{
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
DPRINT1("Setting kernel address with process context\n");
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
if (PageCount > KERNEL_BASE / PAGE_SIZE ||
|
||||
(ULONG_PTR) Address / PAGE_SIZE + PageCount > KERNEL_BASE / PAGE_SIZE)
|
||||
if (PageCount > (ULONG_PTR)MmSystemRangeStart / PAGE_SIZE ||
|
||||
(ULONG_PTR) Address / PAGE_SIZE + PageCount >
|
||||
(ULONG_PTR)MmSystemRangeStart / PAGE_SIZE)
|
||||
{
|
||||
DPRINT1("Page Count to large\n");
|
||||
KEBUGCHECK(0);
|
||||
|
@ -1725,7 +1726,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
|
|||
NoExecute = TRUE;
|
||||
}
|
||||
Attributes &= 0xfff;
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
Attributes &= ~PA_USER;
|
||||
if (Ke386GlobalPagesEnabled)
|
||||
|
@ -1786,7 +1787,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
|
|||
{
|
||||
MmMarkPageUnmapped(PAE_PTE_TO_PFN((Pte)));
|
||||
}
|
||||
if (Address < (PVOID)KERNEL_BASE &&
|
||||
if (Address < MmSystemRangeStart &&
|
||||
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
||||
Attributes & PA_PRESENT)
|
||||
{
|
||||
|
@ -1798,7 +1799,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
|
|||
}
|
||||
if (Pte != 0LL)
|
||||
{
|
||||
if (Address > (PVOID)KERNEL_BASE ||
|
||||
if (Address > MmSystemRangeStart ||
|
||||
(Pt >= (PULONGLONG)PAGETABLE_MAP && Pt < (PULONGLONG)PAGETABLE_MAP + 4*512*512))
|
||||
{
|
||||
MiFlushTlb((PULONG)Pt, Address);
|
||||
|
@ -1851,7 +1852,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
|
|||
MmMarkPageUnmapped(PTE_TO_PFN((Pte)));
|
||||
}
|
||||
InterlockedExchangeUL(Pt, PFN_TO_PTE(Pages[i]) | Attributes);
|
||||
if (Address < (PVOID)KERNEL_BASE &&
|
||||
if (Address < MmSystemRangeStart &&
|
||||
Process->AddressSpace.PageTableRefCountTable != NULL &&
|
||||
Attributes & PA_PRESENT)
|
||||
{
|
||||
|
@ -1863,7 +1864,7 @@ MmCreateVirtualMappingUnsafe(PEPROCESS Process,
|
|||
}
|
||||
if (Pte != 0)
|
||||
{
|
||||
if (Address > (PVOID)KERNEL_BASE ||
|
||||
if (Address > MmSystemRangeStart ||
|
||||
(Pt >= (PULONG)PAGETABLE_MAP && Pt < (PULONG)PAGETABLE_MAP + 1024*1024))
|
||||
{
|
||||
MiFlushTlb(Pt, Address);
|
||||
|
@ -1963,7 +1964,7 @@ MmSetPageProtect(PEPROCESS Process, PVOID Address, ULONG flProtect)
|
|||
NoExecute = TRUE;
|
||||
}
|
||||
Attributes &= 0xfff;
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
Attributes &= ~PA_USER;
|
||||
if (Ke386GlobalPagesEnabled)
|
||||
|
@ -2233,7 +2234,7 @@ VOID MmUpdatePageDir(PEPROCESS Process, PVOID Address, ULONG Size)
|
|||
{
|
||||
ULONG StartOffset, EndOffset, Offset;
|
||||
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
|
@ -2322,7 +2323,7 @@ MmInitGlobalKernelPageDirectory(VOID)
|
|||
if (Ke386Pae)
|
||||
{
|
||||
PULONGLONG CurrentPageDirectory = (PULONGLONG)PAE_PAGEDIRECTORY_MAP;
|
||||
for (i = PAE_ADDR_TO_PDE_OFFSET(KERNEL_BASE); i < 4 * 512; i++)
|
||||
for (i = PAE_ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i < 4 * 512; i++)
|
||||
{
|
||||
if (!(i >= PAE_ADDR_TO_PDE_OFFSET(PAGETABLE_MAP) && i < PAE_ADDR_TO_PDE_OFFSET(PAGETABLE_MAP) + 4) &&
|
||||
!(i >= PAE_ADDR_TO_PDE_OFFSET(HYPERSPACE) && i < PAE_ADDR_TO_PDE_OFFSET(HYPERSPACE) + 2) &&
|
||||
|
@ -2340,7 +2341,7 @@ MmInitGlobalKernelPageDirectory(VOID)
|
|||
else
|
||||
{
|
||||
PULONG CurrentPageDirectory = (PULONG)PAGEDIRECTORY_MAP;
|
||||
for (i = ADDR_TO_PDE_OFFSET(KERNEL_BASE); i < 1024; i++)
|
||||
for (i = ADDR_TO_PDE_OFFSET(MmSystemRangeStart); i < 1024; i++)
|
||||
{
|
||||
if (i != ADDR_TO_PDE_OFFSET(PAGETABLE_MAP) &&
|
||||
i != ADDR_TO_PDE_OFFSET(HYPERSPACE) &&
|
||||
|
@ -2360,7 +2361,7 @@ MmInitGlobalKernelPageDirectory(VOID)
|
|||
ULONG
|
||||
MiGetUserPageDirectoryCount(VOID)
|
||||
{
|
||||
return Ke386Pae ? PAE_ADDR_TO_PDE_OFFSET(KERNEL_BASE) : ADDR_TO_PDE_OFFSET(KERNEL_BASE);
|
||||
return Ke386Pae ? PAE_ADDR_TO_PDE_OFFSET(MmSystemRangeStart) : ADDR_TO_PDE_OFFSET(MmSystemRangeStart);
|
||||
}
|
||||
|
||||
VOID INIT_FUNCTION
|
||||
|
|
|
@ -51,7 +51,7 @@ NTSTATUS MmPageFault(ULONG Cs,
|
|||
Mode = KernelMode;
|
||||
}
|
||||
|
||||
if (Mode == KernelMode && Cr2 >= KERNEL_BASE &&
|
||||
if (Mode == KernelMode && Cr2 >= (ULONG_PTR)MmSystemRangeStart &&
|
||||
Mmi386MakeKernelPageTableGlobal((PVOID)Cr2))
|
||||
{
|
||||
return(STATUS_SUCCESS);
|
||||
|
|
|
@ -469,8 +469,8 @@ MmFindGapBottomUp(
|
|||
ULONG_PTR Length,
|
||||
ULONG_PTR Granularity)
|
||||
{
|
||||
PVOID HighestAddress = AddressSpace->LowestAddress < (PVOID)KERNEL_BASE ?
|
||||
(PVOID)(KERNEL_BASE - 1) : (PVOID)MAXULONG_PTR;
|
||||
PVOID HighestAddress = AddressSpace->LowestAddress < MmSystemRangeStart ?
|
||||
(PVOID)((ULONG_PTR)MmSystemRangeStart - 1) : (PVOID)MAXULONG_PTR;
|
||||
PVOID AlignedAddress;
|
||||
PMEMORY_AREA Node;
|
||||
PMEMORY_AREA FirstNode;
|
||||
|
@ -546,8 +546,8 @@ MmFindGapTopDown(
|
|||
ULONG_PTR Length,
|
||||
ULONG_PTR Granularity)
|
||||
{
|
||||
PVOID HighestAddress = AddressSpace->LowestAddress < (PVOID)KERNEL_BASE ?
|
||||
(PVOID)(KERNEL_BASE - 1) : (PVOID)MAXULONG_PTR;
|
||||
PVOID HighestAddress = AddressSpace->LowestAddress < MmSystemRangeStart ?
|
||||
(PVOID)((ULONG_PTR)MmSystemRangeStart - 1) : (PVOID)MAXULONG_PTR;
|
||||
PVOID AlignedAddress;
|
||||
PMEMORY_AREA Node;
|
||||
PMEMORY_AREA PreviousNode;
|
||||
|
@ -645,16 +645,16 @@ MmFindGapAtAddress(
|
|||
{
|
||||
PMEMORY_AREA Node = AddressSpace->MemoryAreaRoot;
|
||||
PMEMORY_AREA RightNeighbour = NULL;
|
||||
PVOID HighestAddress = AddressSpace->LowestAddress < (PVOID)KERNEL_BASE ?
|
||||
(PVOID)(KERNEL_BASE - 1) : (PVOID)MAXULONG_PTR;
|
||||
PVOID HighestAddress = AddressSpace->LowestAddress < MmSystemRangeStart ?
|
||||
(PVOID)((ULONG_PTR)MmSystemRangeStart - 1) : (PVOID)MAXULONG_PTR;
|
||||
|
||||
MmVerifyMemoryAreas(AddressSpace);
|
||||
|
||||
Address = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
||||
|
||||
if (AddressSpace->LowestAddress < (PVOID)KERNEL_BASE)
|
||||
if (AddressSpace->LowestAddress < MmSystemRangeStart)
|
||||
{
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
@ -970,15 +970,15 @@ MmCreateMemoryArea(PEPROCESS Process,
|
|||
- (ULONG_PTR) MM_ROUND_DOWN(*BaseAddress, Granularity));
|
||||
*BaseAddress = MM_ROUND_DOWN(*BaseAddress, Granularity);
|
||||
|
||||
if (AddressSpace->LowestAddress == (PVOID)KERNEL_BASE &&
|
||||
if (AddressSpace->LowestAddress == MmSystemRangeStart &&
|
||||
*BaseAddress < (PVOID)KERNEL_BASE)
|
||||
{
|
||||
CHECKPOINT;
|
||||
return STATUS_ACCESS_VIOLATION;
|
||||
}
|
||||
|
||||
if (AddressSpace->LowestAddress < (PVOID)KERNEL_BASE &&
|
||||
(ULONG_PTR)(*BaseAddress) + tmpLength > KERNEL_BASE)
|
||||
if (AddressSpace->LowestAddress < MmSystemRangeStart &&
|
||||
(ULONG_PTR)(*BaseAddress) + tmpLength > (ULONG_PTR)MmSystemRangeStart)
|
||||
{
|
||||
CHECKPOINT;
|
||||
return STATUS_ACCESS_VIOLATION;
|
||||
|
|
|
@ -217,7 +217,7 @@ MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
|
|||
* so there is no need to free it
|
||||
*/
|
||||
if ((Mdl->MdlFlags & MDL_SOURCE_IS_NONPAGED_POOL) &&
|
||||
((ULONG_PTR)BaseAddress >= KERNEL_BASE))
|
||||
(BaseAddress >= MmSystemRangeStart))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -242,7 +242,7 @@ MmUnmapLockedPages(PVOID BaseAddress, PMDL Mdl)
|
|||
NULL);
|
||||
}
|
||||
|
||||
if ((ULONG_PTR)BaseAddress >= KERNEL_BASE)
|
||||
if (BaseAddress >= MmSystemRangeStart)
|
||||
{
|
||||
ASSERT(Mdl->MdlFlags & MDL_MAPPED_TO_SYSTEM_VA);
|
||||
|
||||
|
@ -377,7 +377,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
|
|||
ASSERT(NrPages <= (Mdl->Size - sizeof(MDL))/sizeof(PFN_TYPE));
|
||||
|
||||
|
||||
if (Mdl->StartVa >= (PVOID)KERNEL_BASE &&
|
||||
if (Mdl->StartVa >= MmSystemRangeStart &&
|
||||
MmGetPfnForProcess(NULL, Mdl->StartVa) >= MmPageArraySize)
|
||||
{
|
||||
/* phys addr is not phys memory so this must be io memory */
|
||||
|
@ -392,7 +392,7 @@ VOID STDCALL MmProbeAndLockPages (PMDL Mdl,
|
|||
}
|
||||
|
||||
|
||||
if (Mdl->StartVa >= (PVOID)KERNEL_BASE)
|
||||
if (Mdl->StartVa >= MmSystemRangeStart)
|
||||
{
|
||||
/* FIXME: why isn't AccessMode used? */
|
||||
Mode = KernelMode;
|
||||
|
@ -556,7 +556,7 @@ MmBuildMdlForNonPagedPool (PMDL Mdl)
|
|||
* mdl buffer must (at least) be in kernel space, thou this doesn't
|
||||
* necesarely mean that the buffer in within _nonpaged_ kernel space...
|
||||
*/
|
||||
ASSERT((ULONG_PTR)Mdl->StartVa >= KERNEL_BASE);
|
||||
ASSERT(Mdl->StartVa >= MmSystemRangeStart);
|
||||
|
||||
PageCount = PAGE_ROUND_UP(Mdl->ByteOffset + Mdl->ByteCount) / PAGE_SIZE;
|
||||
MdlPages = (PPFN_TYPE)(Mdl + 1);
|
||||
|
|
|
@ -35,7 +35,7 @@ MmCopyToCaller(PVOID Dest, const VOID *Src, ULONG NumberOfBytes)
|
|||
|
||||
if (ExGetPreviousMode() == UserMode)
|
||||
{
|
||||
if ((ULONG_PTR)Dest >= KERNEL_BASE)
|
||||
if (Dest >= MmSystemRangeStart)
|
||||
{
|
||||
return(STATUS_ACCESS_VIOLATION);
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ MmCopyFromCaller(PVOID Dest, const VOID *Src, ULONG NumberOfBytes)
|
|||
|
||||
if (ExGetPreviousMode() == UserMode)
|
||||
{
|
||||
if ((ULONG_PTR)Src >= KERNEL_BASE)
|
||||
if (Src >= MmSystemRangeStart)
|
||||
{
|
||||
return(STATUS_ACCESS_VIOLATION);
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ BOOLEAN STDCALL MmIsAddressValid(PVOID VirtualAddress)
|
|||
MEMORY_AREA* MemoryArea;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
if ((ULONG_PTR)VirtualAddress >= KERNEL_BASE)
|
||||
if (VirtualAddress >= MmSystemRangeStart)
|
||||
{
|
||||
AddressSpace = MmGetKernelAddressSpace();
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ NTSTATUS MmAccessFault(KPROCESSOR_MODE Mode,
|
|||
/*
|
||||
* Find the memory area for the faulting address
|
||||
*/
|
||||
if (Address >= KERNEL_BASE)
|
||||
if (Address >= (ULONG_PTR)MmSystemRangeStart)
|
||||
{
|
||||
/*
|
||||
* Check permissions
|
||||
|
@ -325,7 +325,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
|
|||
* after my init patch anyways
|
||||
*/
|
||||
CPRINT("No current process\n");
|
||||
if (Address < KERNEL_BASE)
|
||||
if (Address < (ULONG_PTR)MmSystemRangeStart)
|
||||
{
|
||||
return(STATUS_UNSUCCESSFUL);
|
||||
}
|
||||
|
@ -334,7 +334,7 @@ NTSTATUS MmNotPresentFault(KPROCESSOR_MODE Mode,
|
|||
/*
|
||||
* Find the memory area for the faulting address
|
||||
*/
|
||||
if (Address >= KERNEL_BASE)
|
||||
if (Address >= (ULONG_PTR)MmSystemRangeStart)
|
||||
{
|
||||
/*
|
||||
* Check permissions
|
||||
|
|
|
@ -74,7 +74,7 @@ MmWritePagePhysicalAddress(PFN_TYPE Page)
|
|||
{
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
Status = ObReferenceObjectByPointer(Process, PROCESS_ALL_ACCESS, NULL, KernelMode);
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
|
@ -100,7 +100,7 @@ MmWritePagePhysicalAddress(PFN_TYPE Page)
|
|||
if (MemoryArea == NULL || MemoryArea->DeleteInProgress)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ MmWritePagePhysicalAddress(PFN_TYPE Page)
|
|||
if (PageOp == NULL)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
@ -142,13 +142,13 @@ MmWritePagePhysicalAddress(PFN_TYPE Page)
|
|||
}
|
||||
else if ((Type == MEMORY_AREA_VIRTUAL_MEMORY) || (Type == MEMORY_AREA_PEB_OR_TEB))
|
||||
{
|
||||
PageOp = MmGetPageOp(MemoryArea, Address < (PVOID)KERNEL_BASE ? Process->UniqueProcessId : NULL,
|
||||
PageOp = MmGetPageOp(MemoryArea, Address < MmSystemRangeStart ? Process->UniqueProcessId : NULL,
|
||||
Address, NULL, 0, MM_PAGEOP_PAGEOUT, TRUE);
|
||||
|
||||
if (PageOp == NULL)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
@ -170,7 +170,7 @@ MmWritePagePhysicalAddress(PFN_TYPE Page)
|
|||
{
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ MmPageOutPhysicalAddress(PFN_TYPE Page)
|
|||
KEBUGCHECK(0);
|
||||
}
|
||||
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
Status = ObReferenceObjectByPointer(Process, PROCESS_ALL_ACCESS, NULL, KernelMode);
|
||||
ExReleaseFastMutex(&RmapListLock);
|
||||
|
@ -225,7 +225,7 @@ MmPageOutPhysicalAddress(PFN_TYPE Page)
|
|||
if (MemoryArea == NULL || MemoryArea->DeleteInProgress)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ MmPageOutPhysicalAddress(PFN_TYPE Page)
|
|||
if (PageOp == NULL)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
@ -265,12 +265,12 @@ MmPageOutPhysicalAddress(PFN_TYPE Page)
|
|||
}
|
||||
else if ((Type == MEMORY_AREA_VIRTUAL_MEMORY) || (Type == MEMORY_AREA_PEB_OR_TEB))
|
||||
{
|
||||
PageOp = MmGetPageOp(MemoryArea, Address < (PVOID)KERNEL_BASE ? Process->UniqueProcessId : NULL,
|
||||
PageOp = MmGetPageOp(MemoryArea, Address < MmSystemRangeStart ? Process->UniqueProcessId : NULL,
|
||||
Address, NULL, 0, MM_PAGEOP_PAGEOUT, TRUE);
|
||||
if (PageOp == NULL)
|
||||
{
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
@ -292,7 +292,7 @@ MmPageOutPhysicalAddress(PFN_TYPE Page)
|
|||
{
|
||||
KEBUGCHECK(0);
|
||||
}
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ MiQueryVirtualMemory (IN HANDLE ProcessHandle,
|
|||
MEMORY_AREA* MemoryArea;
|
||||
PMADDRESS_SPACE AddressSpace;
|
||||
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
Status = ObReferenceObjectByHandle(ProcessHandle,
|
||||
PROCESS_QUERY_INFORMATION,
|
||||
|
@ -248,7 +248,7 @@ MiQueryVirtualMemory (IN HANDLE ProcessHandle,
|
|||
}
|
||||
|
||||
MmUnlockAddressSpace(AddressSpace);
|
||||
if (Address < (PVOID)KERNEL_BASE)
|
||||
if (Address < MmSystemRangeStart)
|
||||
{
|
||||
ObDereferenceObject(Process);
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ NtQueryVirtualMemory (IN HANDLE ProcessHandle,
|
|||
|
||||
PrevMode = ExGetPreviousMode();
|
||||
|
||||
if (Address >= (PVOID)KERNEL_BASE)
|
||||
if (Address >= MmSystemRangeStart)
|
||||
{
|
||||
DPRINT1("Invalid parameter\n");
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
|
Loading…
Reference in a new issue