mirror of
https://github.com/reactos/reactos.git
synced 2025-02-25 01:39:30 +00:00
Now that MADDRESS_SPACE became nearly an empty structure pointing only at the root, it can completely go away. Now VadRoot really is a MM_AVL_TABLE structure.
The BalancedRoot.u1.Parent now points to what used to be MemoryAreaRoot. This isn't really the most proper fix out there -- the problem is that React starts with an no root, while Windows starts with an empty balanced root. So for now we keep doing it the React way, which means we have about 10 ugly typecast hacks. On the other hand, we got rid of more than 100 of them. svn path=/trunk/; revision=34881
This commit is contained in:
parent
7c1492c712
commit
a5a0461289
12 changed files with 133 additions and 173 deletions
|
@ -250,11 +250,6 @@ typedef struct _MEMORY_AREA
|
||||||
} Data;
|
} Data;
|
||||||
} MEMORY_AREA, *PMEMORY_AREA;
|
} MEMORY_AREA, *PMEMORY_AREA;
|
||||||
|
|
||||||
typedef struct _MADDRESS_SPACE
|
|
||||||
{
|
|
||||||
PMEMORY_AREA MemoryAreaRoot;
|
|
||||||
} MADDRESS_SPACE, *PMADDRESS_SPACE;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
ULONG NrTotalPages;
|
ULONG NrTotalPages;
|
||||||
|
@ -367,7 +362,7 @@ extern MM_MEMORY_CONSUMER MiMemoryConsumers[MC_MAXIMUM];
|
||||||
|
|
||||||
typedef VOID
|
typedef VOID
|
||||||
(*PMM_ALTER_REGION_FUNC)(
|
(*PMM_ALTER_REGION_FUNC)(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
ULONG OldType,
|
ULONG OldType,
|
||||||
|
@ -386,22 +381,6 @@ typedef VOID
|
||||||
BOOLEAN Dirty
|
BOOLEAN Dirty
|
||||||
);
|
);
|
||||||
|
|
||||||
/* aspace.c ******************************************************************/
|
|
||||||
|
|
||||||
VOID
|
|
||||||
NTAPI
|
|
||||||
MmInitializeKernelAddressSpace(VOID);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
MmInitializeAddressSpace(
|
|
||||||
struct _EPROCESS* Process,
|
|
||||||
PMADDRESS_SPACE AddressSpace);
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace);
|
|
||||||
|
|
||||||
/* marea.c *******************************************************************/
|
/* marea.c *******************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
|
@ -411,7 +390,7 @@ MmInitMemoryAreas(VOID);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmCreateMemoryArea(
|
MmCreateMemoryArea(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
ULONG Type,
|
ULONG Type,
|
||||||
PVOID *BaseAddress,
|
PVOID *BaseAddress,
|
||||||
ULONG_PTR Length,
|
ULONG_PTR Length,
|
||||||
|
@ -425,21 +404,21 @@ MmCreateMemoryArea(
|
||||||
PMEMORY_AREA
|
PMEMORY_AREA
|
||||||
NTAPI
|
NTAPI
|
||||||
MmLocateMemoryAreaByAddress(
|
MmLocateMemoryAreaByAddress(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID Address
|
PVOID Address
|
||||||
);
|
);
|
||||||
|
|
||||||
ULONG_PTR
|
ULONG_PTR
|
||||||
NTAPI
|
NTAPI
|
||||||
MmFindGapAtAddress(
|
MmFindGapAtAddress(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID Address
|
PVOID Address
|
||||||
);
|
);
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmFreeMemoryArea(
|
MmFreeMemoryArea(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PMM_FREE_PAGE_FUNC FreePage,
|
PMM_FREE_PAGE_FUNC FreePage,
|
||||||
PVOID FreePageContext
|
PVOID FreePageContext
|
||||||
|
@ -448,7 +427,7 @@ MmFreeMemoryArea(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmFreeMemoryAreaByPtr(
|
MmFreeMemoryAreaByPtr(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
PMM_FREE_PAGE_FUNC FreePage,
|
PMM_FREE_PAGE_FUNC FreePage,
|
||||||
PVOID FreePageContext
|
PVOID FreePageContext
|
||||||
|
@ -456,12 +435,12 @@ MmFreeMemoryAreaByPtr(
|
||||||
|
|
||||||
VOID
|
VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
MmDumpMemoryAreas(PMADDRESS_SPACE AddressSpace);
|
MmDumpMemoryAreas(PMM_AVL_TABLE AddressSpace);
|
||||||
|
|
||||||
PMEMORY_AREA
|
PMEMORY_AREA
|
||||||
NTAPI
|
NTAPI
|
||||||
MmLocateMemoryAreaByRegion(
|
MmLocateMemoryAreaByRegion(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
ULONG_PTR Length
|
ULONG_PTR Length
|
||||||
);
|
);
|
||||||
|
@ -469,7 +448,7 @@ MmLocateMemoryAreaByRegion(
|
||||||
PVOID
|
PVOID
|
||||||
NTAPI
|
NTAPI
|
||||||
MmFindGap(
|
MmFindGap(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
ULONG_PTR Length,
|
ULONG_PTR Length,
|
||||||
ULONG_PTR Granularity,
|
ULONG_PTR Granularity,
|
||||||
BOOLEAN TopDown
|
BOOLEAN TopDown
|
||||||
|
@ -479,7 +458,7 @@ VOID
|
||||||
NTAPI
|
NTAPI
|
||||||
MmReleaseMemoryAreaIfDecommitted(
|
MmReleaseMemoryAreaIfDecommitted(
|
||||||
struct _EPROCESS *Process,
|
struct _EPROCESS *Process,
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress
|
PVOID BaseAddress
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -745,7 +724,7 @@ MmAccessFault(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmNotPresentFaultVirtualMemory(
|
MmNotPresentFaultVirtualMemory(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
MEMORY_AREA* MemoryArea,
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
BOOLEAN Locked
|
BOOLEAN Locked
|
||||||
|
@ -754,7 +733,7 @@ MmNotPresentFaultVirtualMemory(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmPageOutVirtualMemory(
|
MmPageOutVirtualMemory(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
struct _MM_PAGEOP* PageOp
|
struct _MM_PAGEOP* PageOp
|
||||||
|
@ -779,7 +758,7 @@ MmFreeVirtualMemory(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmProtectAnonMem(
|
MmProtectAnonMem(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
|
@ -790,7 +769,7 @@ MmProtectAnonMem(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmWritePageVirtualMemory(
|
MmWritePageVirtualMemory(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MArea,
|
PMEMORY_AREA MArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
PMM_PAGEOP PageOp
|
PMM_PAGEOP PageOp
|
||||||
|
@ -1360,7 +1339,7 @@ MmTrimUserMemory(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmAlterRegion(
|
MmAlterRegion(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
PLIST_ENTRY RegionListHead,
|
PLIST_ENTRY RegionListHead,
|
||||||
PVOID StartAddress,
|
PVOID StartAddress,
|
||||||
|
@ -1428,7 +1407,7 @@ MmQuerySectionView(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmProtectSectionView(
|
MmProtectSectionView(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
|
@ -1439,7 +1418,7 @@ MmProtectSectionView(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmWritePageSectionView(
|
MmWritePageSectionView(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MArea,
|
PMEMORY_AREA MArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
PMM_PAGEOP PageOp
|
PMM_PAGEOP PageOp
|
||||||
|
@ -1452,7 +1431,7 @@ MmInitSectionImplementation(VOID);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmNotPresentFaultSectionView(
|
MmNotPresentFaultSectionView(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
MEMORY_AREA* MemoryArea,
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
BOOLEAN Locked
|
BOOLEAN Locked
|
||||||
|
@ -1461,7 +1440,7 @@ MmNotPresentFaultSectionView(
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmPageOutSectionView(
|
MmPageOutSectionView(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
struct _MM_PAGEOP *PageOp
|
struct _MM_PAGEOP *PageOp
|
||||||
|
@ -1474,7 +1453,7 @@ MmCreatePhysicalMemorySection(VOID);
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmAccessFaultSectionView(
|
MmAccessFaultSectionView(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
MEMORY_AREA* MemoryArea,
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
BOOLEAN Locked
|
BOOLEAN Locked
|
||||||
|
@ -1568,39 +1547,39 @@ MiSyncThreadProcessViews(IN PVOID Process,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
extern PMADDRESS_SPACE MmKernelAddressSpace;
|
extern PMM_AVL_TABLE MmKernelAddressSpace;
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
VOID
|
VOID
|
||||||
MmLockAddressSpace(PMADDRESS_SPACE AddressSpace)
|
MmLockAddressSpace(PMM_AVL_TABLE AddressSpace)
|
||||||
{
|
{
|
||||||
KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot)->AddressCreationLock);
|
KeAcquireGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot)->AddressCreationLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
VOID
|
VOID
|
||||||
MmUnlockAddressSpace(PMADDRESS_SPACE AddressSpace)
|
MmUnlockAddressSpace(PMM_AVL_TABLE AddressSpace)
|
||||||
{
|
{
|
||||||
KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot)->AddressCreationLock);
|
KeReleaseGuardedMutex(&CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot)->AddressCreationLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
PEPROCESS
|
PEPROCESS
|
||||||
MmGetAddressSpaceOwner(IN PMADDRESS_SPACE AddressSpace)
|
MmGetAddressSpaceOwner(IN PMM_AVL_TABLE AddressSpace)
|
||||||
{
|
{
|
||||||
if (AddressSpace == MmKernelAddressSpace) return NULL;
|
if (AddressSpace == MmKernelAddressSpace) return NULL;
|
||||||
return CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot);
|
return CONTAINING_RECORD(AddressSpace, EPROCESS, VadRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
PMADDRESS_SPACE
|
PMM_AVL_TABLE
|
||||||
MmGetCurrentAddressSpace(VOID)
|
MmGetCurrentAddressSpace(VOID)
|
||||||
{
|
{
|
||||||
return (PMADDRESS_SPACE)&((PEPROCESS)KeGetCurrentThread()->ApcState.Process)->VadRoot;
|
return &((PEPROCESS)KeGetCurrentThread()->ApcState.Process)->VadRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
FORCEINLINE
|
FORCEINLINE
|
||||||
PMADDRESS_SPACE
|
PMM_AVL_TABLE
|
||||||
MmGetKernelAddressSpace(VOID)
|
MmGetKernelAddressSpace(VOID)
|
||||||
{
|
{
|
||||||
return MmKernelAddressSpace;
|
return MmKernelAddressSpace;
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
MmWritePageVirtualMemory(PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
PMM_PAGEOP PageOp)
|
PMM_PAGEOP PageOp)
|
||||||
|
@ -130,7 +130,7 @@ MmWritePageVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
MmPageOutVirtualMemory(PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
PMM_PAGEOP PageOp)
|
PMM_PAGEOP PageOp)
|
||||||
|
@ -239,7 +239,7 @@ MmPageOutVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
MmNotPresentFaultVirtualMemory(PMM_AVL_TABLE AddressSpace,
|
||||||
MEMORY_AREA* MemoryArea,
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
BOOLEAN Locked)
|
BOOLEAN Locked)
|
||||||
|
@ -437,7 +437,7 @@ MmNotPresentFaultVirtualMemory(PMADDRESS_SPACE AddressSpace,
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID static
|
VOID static
|
||||||
MmModifyAttributes(PMADDRESS_SPACE AddressSpace,
|
MmModifyAttributes(PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG RegionSize,
|
ULONG RegionSize,
|
||||||
ULONG OldType,
|
ULONG OldType,
|
||||||
|
@ -553,7 +553,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
ULONG_PTR MemoryAreaLength;
|
ULONG_PTR MemoryAreaLength;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
ULONG RegionSize;
|
ULONG RegionSize;
|
||||||
PVOID PBaseAddress;
|
PVOID PBaseAddress;
|
||||||
|
@ -704,7 +704,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
Type = (AllocationType & MEM_COMMIT) ? MEM_COMMIT : MEM_RESERVE;
|
Type = (AllocationType & MEM_COMMIT) ? MEM_COMMIT : MEM_RESERVE;
|
||||||
DPRINT("Type %x\n", Type);
|
DPRINT("Type %x\n", Type);
|
||||||
|
|
||||||
AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
if (PBaseAddress != 0)
|
if (PBaseAddress != 0)
|
||||||
|
@ -861,7 +861,7 @@ MmFreeVirtualMemory(PEPROCESS Process,
|
||||||
if (PageOp != NULL)
|
if (PageOp != NULL)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
MmUnlockAddressSpace(&Process->VadRoot);
|
||||||
Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
|
Status = KeWaitForSingleObject(&PageOp->CompletionEvent,
|
||||||
0,
|
0,
|
||||||
KernelMode,
|
KernelMode,
|
||||||
|
@ -872,7 +872,7 @@ MmFreeVirtualMemory(PEPROCESS Process,
|
||||||
DPRINT1("Failed to wait for page op\n");
|
DPRINT1("Failed to wait for page op\n");
|
||||||
KEBUGCHECK(0);
|
KEBUGCHECK(0);
|
||||||
}
|
}
|
||||||
MmLockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
MmLockAddressSpace(&Process->VadRoot);
|
||||||
MmReleasePageOp(PageOp);
|
MmReleasePageOp(PageOp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -888,7 +888,7 @@ MmFreeVirtualMemory(PEPROCESS Process,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Actually free the memory area. */
|
/* Actually free the memory area. */
|
||||||
MmFreeMemoryArea((PMADDRESS_SPACE)&Process->VadRoot,
|
MmFreeMemoryArea(&Process->VadRoot,
|
||||||
MemoryArea,
|
MemoryArea,
|
||||||
MmFreeVirtualMemoryPage,
|
MmFreeVirtualMemoryPage,
|
||||||
(PVOID)Process);
|
(PVOID)Process);
|
||||||
|
@ -918,7 +918,7 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
ULONG RegionSize;
|
ULONG RegionSize;
|
||||||
|
|
||||||
|
@ -941,7 +941,7 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
|
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, BaseAddress);
|
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, BaseAddress);
|
||||||
|
@ -991,7 +991,7 @@ unlock_deref_and_return:
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmProtectAnonMem(PMADDRESS_SPACE AddressSpace,
|
MmProtectAnonMem(PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
|
|
|
@ -19,27 +19,9 @@
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
PMADDRESS_SPACE MmKernelAddressSpace;
|
PMM_AVL_TABLE MmKernelAddressSpace;
|
||||||
|
|
||||||
ULONGLONG Cycles;
|
|
||||||
ULONG TimeDelta;
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
MmInitializeAddressSpace(PEPROCESS Process,
|
|
||||||
PMADDRESS_SPACE AddressSpace)
|
|
||||||
{
|
|
||||||
AddressSpace->MemoryAreaRoot = NULL;
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
NTSTATUS
|
|
||||||
NTAPI
|
|
||||||
MmDestroyAddressSpace(PMADDRESS_SPACE AddressSpace)
|
|
||||||
{
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -197,7 +197,7 @@ MmInitializeHandBuiltProcess(IN PEPROCESS Process,
|
||||||
|
|
||||||
/* Initialize the Addresss Space */
|
/* Initialize the Addresss Space */
|
||||||
KeInitializeGuardedMutex(&Process->AddressCreationLock);
|
KeInitializeGuardedMutex(&Process->AddressCreationLock);
|
||||||
MmInitializeAddressSpace(Process, (PMADDRESS_SPACE)&Process->VadRoot);
|
Process->VadRoot.BalancedRoot.u1.Parent = NULL;
|
||||||
|
|
||||||
/* The process now has an address space */
|
/* The process now has an address space */
|
||||||
Process->HasAddressSpace = TRUE;
|
Process->HasAddressSpace = TRUE;
|
||||||
|
|
|
@ -160,18 +160,18 @@ static PMEMORY_AREA MmIteratePrevNode(PMEMORY_AREA Node)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef VALIDATE_MEMORY_AREAS
|
#ifdef VALIDATE_MEMORY_AREAS
|
||||||
static VOID MmVerifyMemoryAreas(PMADDRESS_SPACE AddressSpace)
|
static VOID MmVerifyMemoryAreas(PMM_AVL_TABLE AddressSpace)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA Node;
|
PMEMORY_AREA Node;
|
||||||
|
|
||||||
ASSERT(AddressSpace != NULL);
|
ASSERT(AddressSpace != NULL);
|
||||||
|
|
||||||
/* Special case for empty tree. */
|
/* Special case for empty tree. */
|
||||||
if (AddressSpace->MemoryAreaRoot == NULL)
|
if (AddressSpace->BalancedRoot.u1.Parent == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Traverse the tree from left to right. */
|
/* Traverse the tree from left to right. */
|
||||||
for (Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot);
|
for (Node = MmIterateFirstNode(AddressSpace->BalancedRoot.u1.Parent);
|
||||||
Node != NULL;
|
Node != NULL;
|
||||||
Node = MmIterateNextNode(Node))
|
Node = MmIterateNextNode(Node))
|
||||||
{
|
{
|
||||||
|
@ -186,18 +186,18 @@ static VOID MmVerifyMemoryAreas(PMADDRESS_SPACE AddressSpace)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
MmDumpMemoryAreas(PMADDRESS_SPACE AddressSpace)
|
MmDumpMemoryAreas(PMM_AVL_TABLE AddressSpace)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA Node;
|
PMEMORY_AREA Node;
|
||||||
|
|
||||||
DbgPrint("MmDumpMemoryAreas()\n");
|
DbgPrint("MmDumpMemoryAreas()\n");
|
||||||
|
|
||||||
/* Special case for empty tree. */
|
/* Special case for empty tree. */
|
||||||
if (AddressSpace->MemoryAreaRoot == NULL)
|
if (AddressSpace->BalancedRoot.u1.Parent == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Traverse the tree from left to right. */
|
/* Traverse the tree from left to right. */
|
||||||
for (Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot);
|
for (Node = MmIterateFirstNode((PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent);
|
||||||
Node != NULL;
|
Node != NULL;
|
||||||
Node = MmIterateNextNode(Node))
|
Node = MmIterateNextNode(Node))
|
||||||
{
|
{
|
||||||
|
@ -211,10 +211,10 @@ MmDumpMemoryAreas(PMADDRESS_SPACE AddressSpace)
|
||||||
|
|
||||||
PMEMORY_AREA STDCALL
|
PMEMORY_AREA STDCALL
|
||||||
MmLocateMemoryAreaByAddress(
|
MmLocateMemoryAreaByAddress(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID Address)
|
PVOID Address)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA Node = AddressSpace->MemoryAreaRoot;
|
PMEMORY_AREA Node = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent;
|
||||||
|
|
||||||
DPRINT("MmLocateMemoryAreaByAddress(AddressSpace %p, Address %p)\n",
|
DPRINT("MmLocateMemoryAreaByAddress(AddressSpace %p, Address %p)\n",
|
||||||
AddressSpace, Address);
|
AddressSpace, Address);
|
||||||
|
@ -241,7 +241,7 @@ MmLocateMemoryAreaByAddress(
|
||||||
|
|
||||||
PMEMORY_AREA STDCALL
|
PMEMORY_AREA STDCALL
|
||||||
MmLocateMemoryAreaByRegion(
|
MmLocateMemoryAreaByRegion(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
ULONG_PTR Length)
|
ULONG_PTR Length)
|
||||||
{
|
{
|
||||||
|
@ -251,11 +251,11 @@ MmLocateMemoryAreaByRegion(
|
||||||
MmVerifyMemoryAreas(AddressSpace);
|
MmVerifyMemoryAreas(AddressSpace);
|
||||||
|
|
||||||
/* Special case for empty tree. */
|
/* Special case for empty tree. */
|
||||||
if (AddressSpace->MemoryAreaRoot == NULL)
|
if (AddressSpace->BalancedRoot.u1.Parent == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Traverse the tree from left to right. */
|
/* Traverse the tree from left to right. */
|
||||||
for (Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot);
|
for (Node = MmIterateFirstNode((PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent);
|
||||||
Node != NULL;
|
Node != NULL;
|
||||||
Node = MmIterateNextNode(Node))
|
Node = MmIterateNextNode(Node))
|
||||||
{
|
{
|
||||||
|
@ -302,11 +302,11 @@ MmLocateMemoryAreaByRegion(
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
MmCompressHelper(
|
MmCompressHelper(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
ULONG Count)
|
ULONG Count)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA Root = NULL;
|
PMEMORY_AREA Root = NULL;
|
||||||
PMEMORY_AREA Red = AddressSpace->MemoryAreaRoot;
|
PMEMORY_AREA Red = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent;
|
||||||
PMEMORY_AREA Black = Red->LeftChild;
|
PMEMORY_AREA Black = Red->LeftChild;
|
||||||
|
|
||||||
while (Count--)
|
while (Count--)
|
||||||
|
@ -314,7 +314,7 @@ MmCompressHelper(
|
||||||
if (Root)
|
if (Root)
|
||||||
Root->LeftChild = Black;
|
Root->LeftChild = Black;
|
||||||
else
|
else
|
||||||
AddressSpace->MemoryAreaRoot = Black;
|
AddressSpace->BalancedRoot.u1.Parent = (PVOID)Black;
|
||||||
Black->Parent = Root;
|
Black->Parent = Root;
|
||||||
Red->LeftChild = Black->RightChild;
|
Red->LeftChild = Black->RightChild;
|
||||||
if (Black->RightChild)
|
if (Black->RightChild)
|
||||||
|
@ -341,7 +341,7 @@ MmCompressHelper(
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
MmRebalanceTree(
|
MmRebalanceTree(
|
||||||
PMADDRESS_SPACE AddressSpace)
|
PMM_AVL_TABLE AddressSpace)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA PreviousNode;
|
PMEMORY_AREA PreviousNode;
|
||||||
PMEMORY_AREA CurrentNode;
|
PMEMORY_AREA CurrentNode;
|
||||||
|
@ -354,7 +354,7 @@ MmRebalanceTree(
|
||||||
/* Transform the tree into Vine. */
|
/* Transform the tree into Vine. */
|
||||||
|
|
||||||
PreviousNode = NULL;
|
PreviousNode = NULL;
|
||||||
CurrentNode = AddressSpace->MemoryAreaRoot;
|
CurrentNode = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent;
|
||||||
while (CurrentNode != NULL)
|
while (CurrentNode != NULL)
|
||||||
{
|
{
|
||||||
if (CurrentNode->RightChild == NULL)
|
if (CurrentNode->RightChild == NULL)
|
||||||
|
@ -379,7 +379,7 @@ MmRebalanceTree(
|
||||||
if (PreviousNode != NULL)
|
if (PreviousNode != NULL)
|
||||||
PreviousNode->LeftChild = TempNode;
|
PreviousNode->LeftChild = TempNode;
|
||||||
else
|
else
|
||||||
AddressSpace->MemoryAreaRoot = TempNode;
|
AddressSpace->BalancedRoot.u1.Parent = (PVOID)TempNode;
|
||||||
TempNode->Parent = PreviousNode;
|
TempNode->Parent = PreviousNode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ MmRebalanceTree(
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
MmInsertMemoryArea(
|
MmInsertMemoryArea(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA marea)
|
PMEMORY_AREA marea)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA Node;
|
PMEMORY_AREA Node;
|
||||||
|
@ -419,14 +419,14 @@ MmInsertMemoryArea(
|
||||||
|
|
||||||
MmVerifyMemoryAreas(AddressSpace);
|
MmVerifyMemoryAreas(AddressSpace);
|
||||||
|
|
||||||
if (AddressSpace->MemoryAreaRoot == NULL)
|
if (AddressSpace->BalancedRoot.u1.Parent == NULL)
|
||||||
{
|
{
|
||||||
AddressSpace->MemoryAreaRoot = marea;
|
AddressSpace->BalancedRoot.u1.Parent = (PVOID)marea;
|
||||||
marea->LeftChild = marea->RightChild = marea->Parent = NULL;
|
marea->LeftChild = marea->RightChild = marea->Parent = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Node = AddressSpace->MemoryAreaRoot;
|
Node = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
DPRINT("marea->EndingAddress: %p Node->StartingAddress: %p\n",
|
DPRINT("marea->EndingAddress: %p Node->StartingAddress: %p\n",
|
||||||
|
@ -466,7 +466,7 @@ MmInsertMemoryArea(
|
||||||
|
|
||||||
static PVOID
|
static PVOID
|
||||||
MmFindGapBottomUp(
|
MmFindGapBottomUp(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
ULONG_PTR Length,
|
ULONG_PTR Length,
|
||||||
ULONG_PTR Granularity)
|
ULONG_PTR Granularity)
|
||||||
{
|
{
|
||||||
|
@ -486,7 +486,7 @@ MmFindGapBottomUp(
|
||||||
AlignedAddress = MM_ROUND_UP(LowestAddress, Granularity);
|
AlignedAddress = MM_ROUND_UP(LowestAddress, Granularity);
|
||||||
|
|
||||||
/* Special case for empty tree. */
|
/* Special case for empty tree. */
|
||||||
if (AddressSpace->MemoryAreaRoot == NULL)
|
if (AddressSpace->BalancedRoot.u1.Parent == NULL)
|
||||||
{
|
{
|
||||||
if ((ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length)
|
if ((ULONG_PTR)HighestAddress - (ULONG_PTR)AlignedAddress >= Length)
|
||||||
{
|
{
|
||||||
|
@ -498,7 +498,7 @@ MmFindGapBottomUp(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Go to the node with lowest address in the tree. */
|
/* Go to the node with lowest address in the tree. */
|
||||||
FirstNode = Node = MmIterateFirstNode(AddressSpace->MemoryAreaRoot);
|
FirstNode = Node = MmIterateFirstNode((PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent);
|
||||||
|
|
||||||
/* Traverse the tree from left to right. */
|
/* Traverse the tree from left to right. */
|
||||||
PreviousNode = Node;
|
PreviousNode = Node;
|
||||||
|
@ -544,7 +544,7 @@ MmFindGapBottomUp(
|
||||||
|
|
||||||
static PVOID
|
static PVOID
|
||||||
MmFindGapTopDown(
|
MmFindGapTopDown(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
ULONG_PTR Length,
|
ULONG_PTR Length,
|
||||||
ULONG_PTR Granularity)
|
ULONG_PTR Granularity)
|
||||||
{
|
{
|
||||||
|
@ -567,7 +567,7 @@ MmFindGapTopDown(
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Special case for empty tree. */
|
/* Special case for empty tree. */
|
||||||
if (AddressSpace->MemoryAreaRoot == NULL)
|
if (AddressSpace->BalancedRoot.u1.Parent == NULL)
|
||||||
{
|
{
|
||||||
if (AlignedAddress >= LowestAddress)
|
if (AlignedAddress >= LowestAddress)
|
||||||
{
|
{
|
||||||
|
@ -579,7 +579,7 @@ MmFindGapTopDown(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Go to the node with highest address in the tree. */
|
/* Go to the node with highest address in the tree. */
|
||||||
Node = MmIterateLastNode(AddressSpace->MemoryAreaRoot);
|
Node = MmIterateLastNode((PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent);
|
||||||
|
|
||||||
/* Check if there is enough space after the last memory area. */
|
/* Check if there is enough space after the last memory area. */
|
||||||
if (Node->EndingAddress <= AlignedAddress)
|
if (Node->EndingAddress <= AlignedAddress)
|
||||||
|
@ -630,7 +630,7 @@ MmFindGapTopDown(
|
||||||
|
|
||||||
PVOID STDCALL
|
PVOID STDCALL
|
||||||
MmFindGap(
|
MmFindGap(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
ULONG_PTR Length,
|
ULONG_PTR Length,
|
||||||
ULONG_PTR Granularity,
|
ULONG_PTR Granularity,
|
||||||
BOOLEAN TopDown)
|
BOOLEAN TopDown)
|
||||||
|
@ -643,10 +643,10 @@ MmFindGap(
|
||||||
|
|
||||||
ULONG_PTR STDCALL
|
ULONG_PTR STDCALL
|
||||||
MmFindGapAtAddress(
|
MmFindGapAtAddress(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID Address)
|
PVOID Address)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA Node = AddressSpace->MemoryAreaRoot;
|
PMEMORY_AREA Node = (PMEMORY_AREA)AddressSpace->BalancedRoot.u1.Parent;
|
||||||
PMEMORY_AREA RightNeighbour = NULL;
|
PMEMORY_AREA RightNeighbour = NULL;
|
||||||
PVOID LowestAddress = MmGetAddressSpaceOwner(AddressSpace) ? MM_LOWEST_USER_ADDRESS : MmSystemRangeStart;
|
PVOID LowestAddress = MmGetAddressSpaceOwner(AddressSpace) ? MM_LOWEST_USER_ADDRESS : MmSystemRangeStart;
|
||||||
PVOID HighestAddress = MmGetAddressSpaceOwner(AddressSpace) ?
|
PVOID HighestAddress = MmGetAddressSpaceOwner(AddressSpace) ?
|
||||||
|
@ -740,7 +740,7 @@ MmInitMemoryAreas(VOID)
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
MmFreeMemoryArea(
|
MmFreeMemoryArea(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PMM_FREE_PAGE_FUNC FreePage,
|
PMM_FREE_PAGE_FUNC FreePage,
|
||||||
PVOID FreePageContext)
|
PVOID FreePageContext)
|
||||||
|
@ -804,7 +804,7 @@ MmFreeMemoryArea(
|
||||||
ParentReplace = &MemoryArea->Parent->RightChild;
|
ParentReplace = &MemoryArea->Parent->RightChild;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ParentReplace = &AddressSpace->MemoryAreaRoot;
|
ParentReplace = (PMEMORY_AREA*)&AddressSpace->BalancedRoot.u1.Parent;
|
||||||
|
|
||||||
if (MemoryArea->RightChild == NULL)
|
if (MemoryArea->RightChild == NULL)
|
||||||
{
|
{
|
||||||
|
@ -882,7 +882,7 @@ MmFreeMemoryArea(
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
MmFreeMemoryAreaByPtr(
|
MmFreeMemoryAreaByPtr(
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
PMM_FREE_PAGE_FUNC FreePage,
|
PMM_FREE_PAGE_FUNC FreePage,
|
||||||
PVOID FreePageContext)
|
PVOID FreePageContext)
|
||||||
|
@ -933,7 +933,7 @@ MmFreeMemoryAreaByPtr(
|
||||||
*/
|
*/
|
||||||
|
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
MmCreateMemoryArea(PMADDRESS_SPACE AddressSpace,
|
MmCreateMemoryArea(PMM_AVL_TABLE AddressSpace,
|
||||||
ULONG Type,
|
ULONG Type,
|
||||||
PVOID *BaseAddress,
|
PVOID *BaseAddress,
|
||||||
ULONG_PTR Length,
|
ULONG_PTR Length,
|
||||||
|
@ -1059,7 +1059,7 @@ MmMapMemoryArea(PVOID BaseAddress,
|
||||||
|
|
||||||
VOID STDCALL
|
VOID STDCALL
|
||||||
MmReleaseMemoryAreaIfDecommitted(PEPROCESS Process,
|
MmReleaseMemoryAreaIfDecommitted(PEPROCESS Process,
|
||||||
PMADDRESS_SPACE AddressSpace,
|
PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress)
|
PVOID BaseAddress)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
|
|
|
@ -366,12 +366,12 @@ MmUnmapLockedPages(IN PVOID BaseAddress,
|
||||||
ASSERT(Mdl->Process == PsGetCurrentProcess());
|
ASSERT(Mdl->Process == PsGetCurrentProcess());
|
||||||
|
|
||||||
/* Find the memory area */
|
/* Find the memory area */
|
||||||
MemoryArea = MmLocateMemoryAreaByAddress((PMADDRESS_SPACE)&(Mdl->Process)->VadRoot,
|
MemoryArea = MmLocateMemoryAreaByAddress(&Mdl->Process->VadRoot,
|
||||||
BaseAddress);
|
BaseAddress);
|
||||||
ASSERT(MemoryArea);
|
ASSERT(MemoryArea);
|
||||||
|
|
||||||
/* Free it */
|
/* Free it */
|
||||||
MmFreeMemoryArea((PMADDRESS_SPACE)&(Mdl->Process)->VadRoot,
|
MmFreeMemoryArea(&Mdl->Process->VadRoot,
|
||||||
MemoryArea,
|
MemoryArea,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -395,7 +395,7 @@ MmProbeAndLockPages(IN PMDL Mdl,
|
||||||
PFN_TYPE Page;
|
PFN_TYPE Page;
|
||||||
PEPROCESS CurrentProcess;
|
PEPROCESS CurrentProcess;
|
||||||
PETHREAD Thread;
|
PETHREAD Thread;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
DPRINT("Probing MDL: %p\n", Mdl);
|
DPRINT("Probing MDL: %p\n", Mdl);
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
|
@ -479,7 +479,7 @@ MmProbeAndLockPages(IN PMDL Mdl,
|
||||||
Mdl->Process = CurrentProcess;
|
Mdl->Process = CurrentProcess;
|
||||||
|
|
||||||
/* Use the process lock */
|
/* Use the process lock */
|
||||||
AddressSpace = (PMADDRESS_SPACE)&(CurrentProcess)->VadRoot;
|
AddressSpace = &CurrentProcess->VadRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -732,8 +732,8 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl,
|
||||||
|
|
||||||
CurrentProcess = PsGetCurrentProcess();
|
CurrentProcess = PsGetCurrentProcess();
|
||||||
|
|
||||||
MmLockAddressSpace((PMADDRESS_SPACE)&CurrentProcess->VadRoot);
|
MmLockAddressSpace(&CurrentProcess->VadRoot);
|
||||||
Status = MmCreateMemoryArea((PMADDRESS_SPACE)&CurrentProcess->VadRoot,
|
Status = MmCreateMemoryArea(&CurrentProcess->VadRoot,
|
||||||
MEMORY_AREA_MDL_MAPPING,
|
MEMORY_AREA_MDL_MAPPING,
|
||||||
&Base,
|
&Base,
|
||||||
PageCount * PAGE_SIZE,
|
PageCount * PAGE_SIZE,
|
||||||
|
@ -742,7 +742,7 @@ MmMapLockedPagesSpecifyCache(IN PMDL Mdl,
|
||||||
(Base != NULL),
|
(Base != NULL),
|
||||||
0,
|
0,
|
||||||
BoundaryAddressMultiple);
|
BoundaryAddressMultiple);
|
||||||
MmUnlockAddressSpace((PMADDRESS_SPACE)&CurrentProcess->VadRoot);
|
MmUnlockAddressSpace(&CurrentProcess->VadRoot);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
if (Mdl->MdlFlags & MDL_MAPPING_CAN_FAIL)
|
if (Mdl->MdlFlags & MDL_MAPPING_CAN_FAIL)
|
||||||
|
|
|
@ -48,7 +48,7 @@ BOOLEAN NTAPI MmIsAddressValid(PVOID VirtualAddress)
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
|
|
||||||
if (VirtualAddress >= MmSystemRangeStart)
|
if (VirtualAddress >= MmSystemRangeStart)
|
||||||
{
|
{
|
||||||
|
@ -56,7 +56,7 @@ BOOLEAN NTAPI MmIsAddressValid(PVOID VirtualAddress)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddressSpace = (PMADDRESS_SPACE)&(PsGetCurrentProcess())->VadRoot;
|
AddressSpace = &PsGetCurrentProcess()->VadRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
@ -78,7 +78,7 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
|
||||||
ULONG_PTR Address,
|
ULONG_PTR Address,
|
||||||
BOOLEAN FromMdl)
|
BOOLEAN FromMdl)
|
||||||
{
|
{
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
BOOLEAN Locked = FromMdl;
|
BOOLEAN Locked = FromMdl;
|
||||||
|
@ -114,7 +114,7 @@ MmpAccessFault(KPROCESSOR_MODE Mode,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddressSpace = (PMADDRESS_SPACE)&(PsGetCurrentProcess())->VadRoot;
|
AddressSpace = &PsGetCurrentProcess()->VadRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FromMdl)
|
if (!FromMdl)
|
||||||
|
@ -179,7 +179,7 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
|
||||||
ULONG_PTR Address,
|
ULONG_PTR Address,
|
||||||
BOOLEAN FromMdl)
|
BOOLEAN FromMdl)
|
||||||
{
|
{
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
BOOLEAN Locked = FromMdl;
|
BOOLEAN Locked = FromMdl;
|
||||||
|
@ -210,7 +210,7 @@ MmNotPresentFault(KPROCESSOR_MODE Mode,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddressSpace = (PMADDRESS_SPACE)&(PsGetCurrentProcess())->VadRoot;
|
AddressSpace = &PsGetCurrentProcess()->VadRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!FromMdl)
|
if (!FromMdl)
|
||||||
|
|
|
@ -80,7 +80,7 @@ MiCreatePebOrTeb(PEPROCESS Process,
|
||||||
PVOID BaseAddress)
|
PVOID BaseAddress)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PMADDRESS_SPACE ProcessAddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
PMM_AVL_TABLE ProcessAddressSpace = &Process->VadRoot;
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||||
PVOID AllocatedBase = BaseAddress;
|
PVOID AllocatedBase = BaseAddress;
|
||||||
|
@ -161,7 +161,7 @@ STDCALL
|
||||||
MmDeleteTeb(PEPROCESS Process,
|
MmDeleteTeb(PEPROCESS Process,
|
||||||
PTEB Teb)
|
PTEB Teb)
|
||||||
{
|
{
|
||||||
PMADDRESS_SPACE ProcessAddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
PMM_AVL_TABLE ProcessAddressSpace = &Process->VadRoot;
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
|
|
||||||
/* Lock the Address Space */
|
/* Lock the Address Space */
|
||||||
|
@ -484,7 +484,7 @@ MmInitializeHandBuiltProcess2(IN PEPROCESS Process)
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PMADDRESS_SPACE ProcessAddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
PMM_AVL_TABLE ProcessAddressSpace = &Process->VadRoot;
|
||||||
BoundaryAddressMultiple.QuadPart = 0;
|
BoundaryAddressMultiple.QuadPart = 0;
|
||||||
|
|
||||||
/* Create the shared data page */
|
/* Create the shared data page */
|
||||||
|
@ -510,7 +510,7 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
|
||||||
IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL)
|
IN POBJECT_NAME_INFORMATION *AuditName OPTIONAL)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PMADDRESS_SPACE ProcessAddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
PMM_AVL_TABLE ProcessAddressSpace = &Process->VadRoot;
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||||
|
@ -519,9 +519,9 @@ MmInitializeProcessAddressSpace(IN PEPROCESS Process,
|
||||||
PROS_SECTION_OBJECT SectionObject = Section;
|
PROS_SECTION_OBJECT SectionObject = Section;
|
||||||
BoundaryAddressMultiple.QuadPart = 0;
|
BoundaryAddressMultiple.QuadPart = 0;
|
||||||
|
|
||||||
/* Initialize the Addresss Space */
|
/* Initialize the Addresss Space lock */
|
||||||
KeInitializeGuardedMutex(&Process->AddressCreationLock);
|
KeInitializeGuardedMutex(&Process->AddressCreationLock);
|
||||||
MmInitializeAddressSpace(Process, ProcessAddressSpace);
|
Process->VadRoot.BalancedRoot.u1.Parent = NULL;
|
||||||
|
|
||||||
/* Acquire the Lock */
|
/* Acquire the Lock */
|
||||||
MmLockAddressSpace(ProcessAddressSpace);
|
MmLockAddressSpace(ProcessAddressSpace);
|
||||||
|
@ -682,17 +682,17 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
|
||||||
DPRINT("MmDeleteProcessAddressSpace(Process %x (%s))\n", Process,
|
DPRINT("MmDeleteProcessAddressSpace(Process %x (%s))\n", Process,
|
||||||
Process->ImageFileName);
|
Process->ImageFileName);
|
||||||
|
|
||||||
MmLockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
MmLockAddressSpace(&Process->VadRoot);
|
||||||
|
|
||||||
while ((MemoryArea = ((PMADDRESS_SPACE)&Process->VadRoot)->MemoryAreaRoot) != NULL)
|
while ((MemoryArea = (PMEMORY_AREA)Process->VadRoot.BalancedRoot.u1.Parent) != NULL)
|
||||||
{
|
{
|
||||||
switch (MemoryArea->Type)
|
switch (MemoryArea->Type)
|
||||||
{
|
{
|
||||||
case MEMORY_AREA_SECTION_VIEW:
|
case MEMORY_AREA_SECTION_VIEW:
|
||||||
Address = (PVOID)MemoryArea->StartingAddress;
|
Address = (PVOID)MemoryArea->StartingAddress;
|
||||||
MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
MmUnlockAddressSpace(&Process->VadRoot);
|
||||||
MmUnmapViewOfSection(Process, Address);
|
MmUnmapViewOfSection(Process, Address);
|
||||||
MmLockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
MmLockAddressSpace(&Process->VadRoot);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEMORY_AREA_VIRTUAL_MEMORY:
|
case MEMORY_AREA_VIRTUAL_MEMORY:
|
||||||
|
@ -702,7 +702,7 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
|
||||||
|
|
||||||
case MEMORY_AREA_SHARED_DATA:
|
case MEMORY_AREA_SHARED_DATA:
|
||||||
case MEMORY_AREA_NO_ACCESS:
|
case MEMORY_AREA_NO_ACCESS:
|
||||||
MmFreeMemoryArea((PMADDRESS_SPACE)&Process->VadRoot,
|
MmFreeMemoryArea(&Process->VadRoot,
|
||||||
MemoryArea,
|
MemoryArea,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
@ -719,8 +719,7 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
|
||||||
|
|
||||||
Mmi386ReleaseMmInfo(Process);
|
Mmi386ReleaseMmInfo(Process);
|
||||||
|
|
||||||
MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
MmUnlockAddressSpace(&Process->VadRoot);
|
||||||
MmDestroyAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
|
||||||
|
|
||||||
DPRINT("Finished MmReleaseMmInfo()\n");
|
DPRINT("Finished MmReleaseMmInfo()\n");
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
|
|
@ -33,7 +33,7 @@ InsertAfterEntry(PLIST_ENTRY Previous,
|
||||||
PMM_REGION static
|
PMM_REGION static
|
||||||
MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
|
MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
|
||||||
PVOID StartAddress, ULONG Length, ULONG NewType,
|
PVOID StartAddress, ULONG Length, ULONG NewType,
|
||||||
ULONG NewProtect, PMADDRESS_SPACE AddressSpace,
|
ULONG NewProtect, PMM_AVL_TABLE AddressSpace,
|
||||||
PMM_ALTER_REGION_FUNC AlterFunc)
|
PMM_ALTER_REGION_FUNC AlterFunc)
|
||||||
{
|
{
|
||||||
PMM_REGION NewRegion1;
|
PMM_REGION NewRegion1;
|
||||||
|
@ -105,7 +105,7 @@ MmSplitRegion(PMM_REGION InitialRegion, PVOID InitialBaseAddress,
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmAlterRegion(PMADDRESS_SPACE AddressSpace, PVOID BaseAddress,
|
MmAlterRegion(PMM_AVL_TABLE AddressSpace, PVOID BaseAddress,
|
||||||
PLIST_ENTRY RegionListHead, PVOID StartAddress, ULONG Length,
|
PLIST_ENTRY RegionListHead, PVOID StartAddress, ULONG Length,
|
||||||
ULONG NewType, ULONG NewProtect, PMM_ALTER_REGION_FUNC AlterFunc)
|
ULONG NewType, ULONG NewProtect, PMM_ALTER_REGION_FUNC AlterFunc)
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,7 +58,7 @@ MmWritePagePhysicalAddress(PFN_TYPE Page)
|
||||||
{
|
{
|
||||||
PMM_RMAP_ENTRY entry;
|
PMM_RMAP_ENTRY entry;
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
PVOID Address;
|
PVOID Address;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
|
@ -91,7 +91,7 @@ MmWritePagePhysicalAddress(PFN_TYPE Page)
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ MmPageOutPhysicalAddress(PFN_TYPE Page)
|
||||||
{
|
{
|
||||||
PMM_RMAP_ENTRY entry;
|
PMM_RMAP_ENTRY entry;
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
ULONG Type;
|
ULONG Type;
|
||||||
PVOID Address;
|
PVOID Address;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
|
@ -222,7 +222,7 @@ MmPageOutPhysicalAddress(PFN_TYPE Page)
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,7 +152,7 @@ MmGetFileNameForAddress(IN PVOID Address,
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* FIXME: TODO.
|
* FIXME: TODO.
|
||||||
* Filip says to get the MADDRESS_SPACE from EPROCESS,
|
* Filip says to get the MM_AVL_TABLE from EPROCESS,
|
||||||
* then use the MmMarea routines to locate the Marea that
|
* then use the MmMarea routines to locate the Marea that
|
||||||
* corresponds to the address. Then make sure it's a section
|
* corresponds to the address. Then make sure it's a section
|
||||||
* view type (MEMORY_AREA_SECTION_VIEW) and use the marea's
|
* view type (MEMORY_AREA_SECTION_VIEW) and use the marea's
|
||||||
|
@ -707,7 +707,7 @@ MiReadPage(PMEMORY_AREA MemoryArea,
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
MmNotPresentFaultSectionView(PMM_AVL_TABLE AddressSpace,
|
||||||
MEMORY_AREA* MemoryArea,
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
BOOLEAN Locked)
|
BOOLEAN Locked)
|
||||||
|
@ -1227,7 +1227,7 @@ MmNotPresentFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmAccessFaultSectionView(PMADDRESS_SPACE AddressSpace,
|
MmAccessFaultSectionView(PMM_AVL_TABLE AddressSpace,
|
||||||
MEMORY_AREA* MemoryArea,
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
BOOLEAN Locked)
|
BOOLEAN Locked)
|
||||||
|
@ -1412,7 +1412,7 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address)
|
||||||
PageOutContext = (MM_SECTION_PAGEOUT_CONTEXT*)Context;
|
PageOutContext = (MM_SECTION_PAGEOUT_CONTEXT*)Context;
|
||||||
if (Process)
|
if (Process)
|
||||||
{
|
{
|
||||||
MmLockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
MmLockAddressSpace(&Process->VadRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
MmDeleteVirtualMapping(Process,
|
MmDeleteVirtualMapping(Process,
|
||||||
|
@ -1436,7 +1436,7 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address)
|
||||||
}
|
}
|
||||||
if (Process)
|
if (Process)
|
||||||
{
|
{
|
||||||
MmUnlockAddressSpace((PMADDRESS_SPACE)&Process->VadRoot);
|
MmUnlockAddressSpace(&Process->VadRoot);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PageOutContext->Private)
|
if (PageOutContext->Private)
|
||||||
|
@ -1449,7 +1449,7 @@ MmPageOutDeleteMapping(PVOID Context, PEPROCESS Process, PVOID Address)
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
|
MmPageOutSectionView(PMM_AVL_TABLE AddressSpace,
|
||||||
MEMORY_AREA* MemoryArea,
|
MEMORY_AREA* MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
PMM_PAGEOP PageOp)
|
PMM_PAGEOP PageOp)
|
||||||
|
@ -1803,7 +1803,7 @@ MmPageOutSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
|
MmWritePageSectionView(PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID Address,
|
PVOID Address,
|
||||||
PMM_PAGEOP PageOp)
|
PMM_PAGEOP PageOp)
|
||||||
|
@ -1950,7 +1950,7 @@ MmWritePageSectionView(PMADDRESS_SPACE AddressSpace,
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID static
|
VOID static
|
||||||
MmAlterViewAttributes(PMADDRESS_SPACE AddressSpace,
|
MmAlterViewAttributes(PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG RegionSize,
|
ULONG RegionSize,
|
||||||
ULONG OldType,
|
ULONG OldType,
|
||||||
|
@ -2015,7 +2015,7 @@ MmAlterViewAttributes(PMADDRESS_SPACE AddressSpace,
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
MmProtectSectionView(PMADDRESS_SPACE AddressSpace,
|
MmProtectSectionView(PMM_AVL_TABLE AddressSpace,
|
||||||
PMEMORY_AREA MemoryArea,
|
PMEMORY_AREA MemoryArea,
|
||||||
PVOID BaseAddress,
|
PVOID BaseAddress,
|
||||||
ULONG Length,
|
ULONG Length,
|
||||||
|
@ -3566,7 +3566,7 @@ NtOpenSection(PHANDLE SectionHandle,
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS static
|
NTSTATUS static
|
||||||
MmMapViewOfSegment(PMADDRESS_SPACE AddressSpace,
|
MmMapViewOfSegment(PMM_AVL_TABLE AddressSpace,
|
||||||
PROS_SECTION_OBJECT Section,
|
PROS_SECTION_OBJECT Section,
|
||||||
PMM_SECTION_SEGMENT Segment,
|
PMM_SECTION_SEGMENT Segment,
|
||||||
PVOID* BaseAddress,
|
PVOID* BaseAddress,
|
||||||
|
@ -3677,7 +3677,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||||
PROS_SECTION_OBJECT Section;
|
PROS_SECTION_OBJECT Section;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
KPROCESSOR_MODE PreviousMode;
|
KPROCESSOR_MODE PreviousMode;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
ULONG tmpProtect;
|
ULONG tmpProtect;
|
||||||
|
|
||||||
|
@ -3758,7 +3758,7 @@ NtMapViewOfSection(IN HANDLE SectionHandle,
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
|
|
||||||
Status = ObReferenceObjectByHandle(SectionHandle,
|
Status = ObReferenceObjectByHandle(SectionHandle,
|
||||||
SECTION_MAP_READ,
|
SECTION_MAP_READ,
|
||||||
|
@ -3840,10 +3840,10 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PROS_SECTION_OBJECT Section;
|
PROS_SECTION_OBJECT Section;
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
|
|
||||||
AddressSpace = (PMADDRESS_SPACE)Context;
|
AddressSpace = (PMM_AVL_TABLE)Context;
|
||||||
Process = MmGetAddressSpaceOwner(AddressSpace);
|
Process = MmGetAddressSpaceOwner(AddressSpace);
|
||||||
|
|
||||||
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
||||||
|
@ -3937,7 +3937,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
MmUnmapViewOfSegment(PMADDRESS_SPACE AddressSpace,
|
MmUnmapViewOfSegment(PMM_AVL_TABLE AddressSpace,
|
||||||
PVOID BaseAddress)
|
PVOID BaseAddress)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -3997,7 +3997,7 @@ MmUnmapViewOfSection(PEPROCESS Process,
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
PROS_SECTION_OBJECT Section;
|
PROS_SECTION_OBJECT Section;
|
||||||
PMM_PAGEOP PageOp;
|
PMM_PAGEOP PageOp;
|
||||||
ULONG_PTR Offset;
|
ULONG_PTR Offset;
|
||||||
|
@ -4008,7 +4008,7 @@ MmUnmapViewOfSection(PEPROCESS Process,
|
||||||
|
|
||||||
ASSERT(Process);
|
ASSERT(Process);
|
||||||
|
|
||||||
AddressSpace = (PMADDRESS_SPACE)&(Process)->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
|
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace,
|
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace,
|
||||||
|
@ -4398,7 +4398,7 @@ MmAllocateSection (IN ULONG Length, PVOID BaseAddress)
|
||||||
PVOID Result;
|
PVOID Result;
|
||||||
MEMORY_AREA* marea;
|
MEMORY_AREA* marea;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
PHYSICAL_ADDRESS BoundaryAddressMultiple;
|
||||||
|
|
||||||
DPRINT("MmAllocateSection(Length %x)\n",Length);
|
DPRINT("MmAllocateSection(Length %x)\n",Length);
|
||||||
|
@ -4494,7 +4494,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
IN ULONG Protect)
|
IN ULONG Protect)
|
||||||
{
|
{
|
||||||
PROS_SECTION_OBJECT Section;
|
PROS_SECTION_OBJECT Section;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
ULONG ViewOffset;
|
ULONG ViewOffset;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
@ -4514,7 +4514,7 @@ MmMapViewOfSection(IN PVOID SectionObject,
|
||||||
|
|
||||||
|
|
||||||
Section = (PROS_SECTION_OBJECT)SectionObject;
|
Section = (PROS_SECTION_OBJECT)SectionObject;
|
||||||
AddressSpace = (PMADDRESS_SPACE)&(Process)->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
|
|
||||||
AllocationType |= (Section->AllocationAttributes & SEC_NO_CHANGE);
|
AllocationType |= (Section->AllocationAttributes & SEC_NO_CHANGE);
|
||||||
|
|
||||||
|
@ -4743,7 +4743,7 @@ MmMapViewInSystemSpace (IN PVOID SectionObject,
|
||||||
IN OUT PULONG ViewSize)
|
IN OUT PULONG ViewSize)
|
||||||
{
|
{
|
||||||
PROS_SECTION_OBJECT Section;
|
PROS_SECTION_OBJECT Section;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("MmMapViewInSystemSpace() called\n");
|
DPRINT("MmMapViewInSystemSpace() called\n");
|
||||||
|
@ -4803,7 +4803,7 @@ MmMapViewInSessionSpace (
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
MmUnmapViewInSystemSpace (IN PVOID MappedBase)
|
MmUnmapViewInSystemSpace (IN PVOID MappedBase)
|
||||||
{
|
{
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
DPRINT("MmUnmapViewInSystemSpace() called\n");
|
DPRINT("MmUnmapViewInSystemSpace() called\n");
|
||||||
|
|
|
@ -425,7 +425,7 @@ MiQueryVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
PEPROCESS Process;
|
PEPROCESS Process;
|
||||||
MEMORY_AREA* MemoryArea;
|
MEMORY_AREA* MemoryArea;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
|
|
||||||
if (Address < MmSystemRangeStart)
|
if (Address < MmSystemRangeStart)
|
||||||
{
|
{
|
||||||
|
@ -441,7 +441,7 @@ MiQueryVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
DPRINT("NtQueryVirtualMemory() = %x\n",Status);
|
DPRINT("NtQueryVirtualMemory() = %x\n",Status);
|
||||||
return(Status);
|
return(Status);
|
||||||
}
|
}
|
||||||
AddressSpace = (PMADDRESS_SPACE)&Process->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -589,7 +589,7 @@ MiProtectVirtualMemory(IN PEPROCESS Process,
|
||||||
OUT PULONG OldAccessProtection OPTIONAL)
|
OUT PULONG OldAccessProtection OPTIONAL)
|
||||||
{
|
{
|
||||||
PMEMORY_AREA MemoryArea;
|
PMEMORY_AREA MemoryArea;
|
||||||
PMADDRESS_SPACE AddressSpace;
|
PMM_AVL_TABLE AddressSpace;
|
||||||
ULONG OldAccessProtection_;
|
ULONG OldAccessProtection_;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
@ -598,7 +598,7 @@ MiProtectVirtualMemory(IN PEPROCESS Process,
|
||||||
PAGE_ROUND_DOWN(*BaseAddress);
|
PAGE_ROUND_DOWN(*BaseAddress);
|
||||||
*BaseAddress = (PVOID)PAGE_ROUND_DOWN(*BaseAddress);
|
*BaseAddress = (PVOID)PAGE_ROUND_DOWN(*BaseAddress);
|
||||||
|
|
||||||
AddressSpace = (PMADDRESS_SPACE)&(Process)->VadRoot;
|
AddressSpace = &Process->VadRoot;
|
||||||
|
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, *BaseAddress);
|
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, *BaseAddress);
|
||||||
|
|
Loading…
Reference in a new issue