mirror of
https://github.com/reactos/reactos.git
synced 2025-05-01 19:50:36 +00:00
[NTOSKRNL]
Convert MEMORY_AREA::StartingAddress to StaringVpn svn path=/trunk/; revision=67785
This commit is contained in:
parent
418daaac86
commit
85f59f294f
8 changed files with 61 additions and 57 deletions
6
reactos/ntoskrnl/cache/section/data.c
vendored
6
reactos/ntoskrnl/cache/section/data.c
vendored
|
@ -160,7 +160,7 @@ _MiFlushMappedSection(PVOID BaseAddress,
|
||||||
DPRINT("STATUS_NOT_MAPPED_DATA\n");
|
DPRINT("STATUS_NOT_MAPPED_DATA\n");
|
||||||
return STATUS_NOT_MAPPED_DATA;
|
return STATUS_NOT_MAPPED_DATA;
|
||||||
}
|
}
|
||||||
BeginningAddress = PAGE_ROUND_DOWN((ULONG_PTR)MemoryArea->StartingAddress);
|
BeginningAddress = PAGE_ROUND_DOWN(MA_GetStartingAddress(MemoryArea));
|
||||||
EndingAddress = PAGE_ROUND_UP((ULONG_PTR)MemoryArea->EndingAddress);
|
EndingAddress = PAGE_ROUND_UP((ULONG_PTR)MemoryArea->EndingAddress);
|
||||||
Segment = MemoryArea->Data.SectionData.Segment;
|
Segment = MemoryArea->Data.SectionData.Segment;
|
||||||
ViewOffset.QuadPart = MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
ViewOffset.QuadPart = MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
@ -681,7 +681,7 @@ MmFreeCacheSectionPage(PVOID Context,
|
||||||
Process = MmGetAddressSpaceOwner(AddressSpace);
|
Process = MmGetAddressSpaceOwner(AddressSpace);
|
||||||
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
||||||
Segment = ContextData[1];
|
Segment = ContextData[1];
|
||||||
Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress +
|
Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea) +
|
||||||
MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
|
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
|
||||||
|
@ -732,7 +732,7 @@ MmUnmapViewOfCacheSegment(PMMSUPPORT AddressSpace,
|
||||||
|
|
||||||
DPRINT("MmFreeMemoryArea(%p,%p)\n",
|
DPRINT("MmFreeMemoryArea(%p,%p)\n",
|
||||||
MmGetAddressSpaceOwner(AddressSpace),
|
MmGetAddressSpaceOwner(AddressSpace),
|
||||||
MemoryArea->StartingAddress);
|
MA_GetStartingAddress(MemoryArea));
|
||||||
|
|
||||||
MmLockAddressSpace(AddressSpace);
|
MmLockAddressSpace(AddressSpace);
|
||||||
|
|
||||||
|
|
12
reactos/ntoskrnl/cache/section/fault.c
vendored
12
reactos/ntoskrnl/cache/section/fault.c
vendored
|
@ -122,7 +122,7 @@ MmNotPresentFaultCachePage (
|
||||||
DPRINT("Not Present: %p %p (%p-%p)\n",
|
DPRINT("Not Present: %p %p (%p-%p)\n",
|
||||||
AddressSpace,
|
AddressSpace,
|
||||||
Address,
|
Address,
|
||||||
MemoryArea->StartingAddress,
|
MA_GetStartingAddress(MemoryArea),
|
||||||
MemoryArea->EndingAddress);
|
MemoryArea->EndingAddress);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -138,7 +138,7 @@ MmNotPresentFaultCachePage (
|
||||||
|
|
||||||
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
||||||
TotalOffset.QuadPart = (ULONG_PTR)PAddress -
|
TotalOffset.QuadPart = (ULONG_PTR)PAddress -
|
||||||
(ULONG_PTR)MemoryArea->StartingAddress;
|
MA_GetStartingAddress(MemoryArea);
|
||||||
|
|
||||||
Segment = MemoryArea->Data.SectionData.Segment;
|
Segment = MemoryArea->Data.SectionData.Segment;
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ MiCowCacheSectionPage (
|
||||||
|
|
||||||
/* Find the offset of the page */
|
/* Find the offset of the page */
|
||||||
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
||||||
Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress +
|
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea) +
|
||||||
MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
if (!Segment->WriteCopy /*&&
|
if (!Segment->WriteCopy /*&&
|
||||||
|
@ -584,7 +584,7 @@ MmpSectionAccessFaultInner(KPROCESSOR_MODE Mode,
|
||||||
|
|
||||||
DPRINT("Type %x (%p -> %p)\n",
|
DPRINT("Type %x (%p -> %p)\n",
|
||||||
MemoryArea->Type,
|
MemoryArea->Type,
|
||||||
MemoryArea->StartingAddress,
|
MA_GetStartingAddress(MemoryArea),
|
||||||
MemoryArea->EndingAddress);
|
MemoryArea->EndingAddress);
|
||||||
|
|
||||||
Resources.DoAcquisition = NULL;
|
Resources.DoAcquisition = NULL;
|
||||||
|
@ -660,7 +660,7 @@ MmpSectionAccessFaultInner(KPROCESSOR_MODE Mode,
|
||||||
DPRINT1("Completed page fault handling %Ix %x\n", Address, Status);
|
DPRINT1("Completed page fault handling %Ix %x\n", Address, Status);
|
||||||
DPRINT1("Type %x (%p -> %p)\n",
|
DPRINT1("Type %x (%p -> %p)\n",
|
||||||
MemoryArea->Type,
|
MemoryArea->Type,
|
||||||
MemoryArea->StartingAddress,
|
MA_GetStartingAddress(MemoryArea),
|
||||||
MemoryArea->EndingAddress);
|
MemoryArea->EndingAddress);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ MmNotPresentFaultCacheSectionInner(KPROCESSOR_MODE Mode,
|
||||||
|
|
||||||
DPRINTC("Type %x (%p -> %08Ix -> %p) in %p\n",
|
DPRINTC("Type %x (%p -> %08Ix -> %p) in %p\n",
|
||||||
MemoryArea->Type,
|
MemoryArea->Type,
|
||||||
MemoryArea->StartingAddress,
|
MA_GetStartingAddress(MemoryArea),
|
||||||
Address,
|
Address,
|
||||||
MemoryArea->EndingAddress,
|
MemoryArea->EndingAddress,
|
||||||
PsGetCurrentThread());
|
PsGetCurrentThread());
|
||||||
|
|
5
reactos/ntoskrnl/cache/section/swapout.c
vendored
5
reactos/ntoskrnl/cache/section/swapout.c
vendored
|
@ -289,7 +289,8 @@ MmPageOutCacheSection(PMMSUPPORT AddressSpace,
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
PVOID PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
PVOID PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
||||||
|
|
||||||
TotalOffset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress +
|
TotalOffset.QuadPart = (ULONG_PTR)PAddress -
|
||||||
|
MA_GetStartingAddress(MemoryArea) +
|
||||||
MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
Segment = MemoryArea->Data.SectionData.Segment;
|
Segment = MemoryArea->Data.SectionData.Segment;
|
||||||
|
@ -456,7 +457,7 @@ MmpPageOutPhysicalAddress(PFN_NUMBER Page)
|
||||||
|
|
||||||
DPRINTC("Type %x (%p -> %p)\n",
|
DPRINTC("Type %x (%p -> %p)\n",
|
||||||
MemoryArea->Type,
|
MemoryArea->Type,
|
||||||
MemoryArea->StartingAddress,
|
MA_GetStartingAddress(MemoryArea),
|
||||||
MemoryArea->EndingAddress);
|
MemoryArea->EndingAddress);
|
||||||
|
|
||||||
Resources.DoAcquisition = NULL;
|
Resources.DoAcquisition = NULL;
|
||||||
|
|
|
@ -199,9 +199,12 @@ typedef struct _ROS_SECTION_OBJECT
|
||||||
};
|
};
|
||||||
} ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT;
|
} ROS_SECTION_OBJECT, *PROS_SECTION_OBJECT;
|
||||||
|
|
||||||
|
#define MA_GetStartingAddress(_MemoryArea) ((_MemoryArea)->StartingVpn << PAGE_SHIFT)
|
||||||
|
#define MA_GetEndingAddress(_MemoryArea) (((_MemoryArea)->EndingVpn + 1) << PAGE_SHIFT)
|
||||||
|
|
||||||
typedef struct _MEMORY_AREA
|
typedef struct _MEMORY_AREA
|
||||||
{
|
{
|
||||||
ULONG_PTR StartingAddress;
|
ULONG_PTR StartingVpn;
|
||||||
ULONG_PTR EndingAddress;
|
ULONG_PTR EndingAddress;
|
||||||
struct _MEMORY_AREA *Parent;
|
struct _MEMORY_AREA *Parent;
|
||||||
struct _MEMORY_AREA *LeftChild;
|
struct _MEMORY_AREA *LeftChild;
|
||||||
|
|
|
@ -1886,7 +1886,7 @@ MiQueryMemoryBasicInformation(IN HANDLE ProcessHandle,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
DPRINT1("MmQuerySectionView failed. MemoryArea=%p (%p-%p), BaseAddress=%p\n",
|
DPRINT1("MmQuerySectionView failed. MemoryArea=%p (%p-%p), BaseAddress=%p\n",
|
||||||
MemoryArea, MemoryArea->StartingAddress, MemoryArea->EndingAddress, BaseAddress);
|
MemoryArea, MA_GetStartingAddress(MemoryArea), MemoryArea->EndingAddress, BaseAddress);
|
||||||
NT_ASSERT(NT_SUCCESS(Status));
|
NT_ASSERT(NT_SUCCESS(Status));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5317,7 +5317,7 @@ NtFreeVirtualMemory(IN HANDLE ProcessHandle,
|
||||||
Vad->u.VadFlags.CommitCharge -= CommitReduction;
|
Vad->u.VadFlags.CommitCharge -= CommitReduction;
|
||||||
// For ReactOS: shrink the corresponding memory area
|
// For ReactOS: shrink the corresponding memory area
|
||||||
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, (PVOID)StartingAddress);
|
MemoryArea = MmLocateMemoryAreaByAddress(AddressSpace, (PVOID)StartingAddress);
|
||||||
ASSERT(Vad->StartingVpn << PAGE_SHIFT == MemoryArea->StartingAddress);
|
ASSERT(Vad->StartingVpn << PAGE_SHIFT == MA_GetStartingAddress(MemoryArea));
|
||||||
ASSERT((Vad->EndingVpn + 1) << PAGE_SHIFT == MemoryArea->EndingAddress);
|
ASSERT((Vad->EndingVpn + 1) << PAGE_SHIFT == MemoryArea->EndingAddress);
|
||||||
Vad->EndingVpn = (StartingAddress - 1) >> PAGE_SHIFT;
|
Vad->EndingVpn = (StartingAddress - 1) >> PAGE_SHIFT;
|
||||||
MemoryArea->EndingAddress = StartingAddress;
|
MemoryArea->EndingAddress = StartingAddress;
|
||||||
|
|
|
@ -172,14 +172,14 @@ MmLocateMemoryAreaByAddress(
|
||||||
|
|
||||||
while (Node != NULL)
|
while (Node != NULL)
|
||||||
{
|
{
|
||||||
if (Address < Node->StartingAddress)
|
if (Address < MA_GetStartingAddress(Node))
|
||||||
Node = Node->LeftChild;
|
Node = Node->LeftChild;
|
||||||
else if (Address >= Node->EndingAddress)
|
else if (Address >= Node->EndingAddress)
|
||||||
Node = Node->RightChild;
|
Node = Node->RightChild;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DPRINT("MmLocateMemoryAreaByAddress(%p): %p [%p - %p]\n",
|
DPRINT("MmLocateMemoryAreaByAddress(%p): %p [%p - %p]\n",
|
||||||
Address, Node, Node->StartingAddress, Node->EndingAddress);
|
Address, Node, MA_GetStartingAddress(Node), Node->EndingAddress);
|
||||||
return Node;
|
return Node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -207,11 +207,11 @@ MmLocateMemoryAreaByRegion(
|
||||||
Node != NULL;
|
Node != NULL;
|
||||||
Node = MmIterateNextNode(Node))
|
Node = MmIterateNextNode(Node))
|
||||||
{
|
{
|
||||||
if (Node->StartingAddress >= Address &&
|
if (MA_GetStartingAddress(Node) >= Address &&
|
||||||
Node->StartingAddress < Extent)
|
MA_GetStartingAddress(Node) < Extent)
|
||||||
{
|
{
|
||||||
DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
|
DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
|
||||||
Address, (ULONG_PTR)Address + Length, Node->StartingAddress,
|
Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node),
|
||||||
Node->EndingAddress);
|
Node->EndingAddress);
|
||||||
return Node;
|
return Node;
|
||||||
}
|
}
|
||||||
|
@ -219,19 +219,19 @@ MmLocateMemoryAreaByRegion(
|
||||||
Node->EndingAddress < Extent)
|
Node->EndingAddress < Extent)
|
||||||
{
|
{
|
||||||
DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
|
DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
|
||||||
Address, (ULONG_PTR)Address + Length, Node->StartingAddress,
|
Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node),
|
||||||
Node->EndingAddress);
|
Node->EndingAddress);
|
||||||
return Node;
|
return Node;
|
||||||
}
|
}
|
||||||
if (Node->StartingAddress <= Address &&
|
if (MA_GetStartingAddress(Node) <= Address &&
|
||||||
Node->EndingAddress >= Extent)
|
Node->EndingAddress >= Extent)
|
||||||
{
|
{
|
||||||
DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
|
DPRINT("MmLocateMemoryAreaByRegion(%p - %p): %p - %p\n",
|
||||||
Address, (ULONG_PTR)Address + Length, Node->StartingAddress,
|
Address, (ULONG_PTR)Address + Length, MA_GetStartingAddress(Node),
|
||||||
Node->EndingAddress);
|
Node->EndingAddress);
|
||||||
return Node;
|
return Node;
|
||||||
}
|
}
|
||||||
if (Node->StartingAddress >= Extent)
|
if (MA_GetStartingAddress(Node) >= Extent)
|
||||||
{
|
{
|
||||||
DPRINT("Finished MmLocateMemoryAreaByRegion() = NULL\n");
|
DPRINT("Finished MmLocateMemoryAreaByRegion() = NULL\n");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -387,13 +387,13 @@ MmInsertMemoryArea(
|
||||||
Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD), TAG_MVAD);
|
Vad = ExAllocatePoolWithTag(NonPagedPool, sizeof(MMVAD), TAG_MVAD);
|
||||||
ASSERT(Vad);
|
ASSERT(Vad);
|
||||||
RtlZeroMemory(Vad, sizeof(MMVAD));
|
RtlZeroMemory(Vad, sizeof(MMVAD));
|
||||||
Vad->StartingVpn = PAGE_ROUND_DOWN(marea->StartingAddress) >> PAGE_SHIFT;
|
Vad->StartingVpn = PAGE_ROUND_DOWN(MA_GetStartingAddress(marea)) >> PAGE_SHIFT;
|
||||||
/*
|
/*
|
||||||
* For some strange reason, it is perfectly valid to create a MAREA from 0x1000 to... 0x1000.
|
* For some strange reason, it is perfectly valid to create a MAREA from 0x1000 to... 0x1000.
|
||||||
* In a normal OS/Memory Manager, this would be retarded, but ReactOS allows this (how it works
|
* In a normal OS/Memory Manager, this would be retarded, but ReactOS allows this (how it works
|
||||||
* I don't even want to know).
|
* I don't even want to know).
|
||||||
*/
|
*/
|
||||||
if (marea->EndingAddress != marea->StartingAddress)
|
if (marea->EndingAddress != MA_GetStartingAddress(marea))
|
||||||
{
|
{
|
||||||
Vad->EndingVpn = PAGE_ROUND_DOWN((ULONG_PTR)marea->EndingAddress - 1) >> PAGE_SHIFT;
|
Vad->EndingVpn = PAGE_ROUND_DOWN((ULONG_PTR)marea->EndingAddress - 1) >> PAGE_SHIFT;
|
||||||
}
|
}
|
||||||
|
@ -424,16 +424,16 @@ MmInsertMemoryArea(
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
DPRINT("marea->EndingAddress: %p Node->StartingAddress: %p\n",
|
DPRINT("marea->EndingAddress: %p Node->StartingAddress: %p\n",
|
||||||
marea->EndingAddress, Node->StartingAddress);
|
marea->EndingAddress, MA_GetStartingAddress(Node));
|
||||||
DPRINT("marea->StartingAddress: %p Node->EndingAddress: %p\n",
|
DPRINT("marea->StartingAddress: %p Node->EndingAddress: %p\n",
|
||||||
marea->StartingAddress, Node->EndingAddress);
|
MA_GetStartingAddress(marea), Node->EndingAddress);
|
||||||
ASSERT(marea->EndingAddress <= Node->StartingAddress ||
|
ASSERT(marea->EndingAddress <= MA_GetStartingAddress(Node) ||
|
||||||
marea->StartingAddress >= Node->EndingAddress);
|
MA_GetStartingAddress(marea) >= Node->EndingAddress);
|
||||||
ASSERT(marea->StartingAddress != Node->StartingAddress);
|
ASSERT(MA_GetStartingAddress(marea) != MA_GetStartingAddress(Node));
|
||||||
|
|
||||||
PreviousNode = Node;
|
PreviousNode = Node;
|
||||||
|
|
||||||
if (marea->StartingAddress < Node->StartingAddress)
|
if (MA_GetStartingAddress(marea) < MA_GetStartingAddress(Node))
|
||||||
Node = Node->LeftChild;
|
Node = Node->LeftChild;
|
||||||
else
|
else
|
||||||
Node = Node->RightChild;
|
Node = Node->RightChild;
|
||||||
|
@ -452,7 +452,7 @@ MmInsertMemoryArea(
|
||||||
|
|
||||||
marea->LeftChild = marea->RightChild = NULL;
|
marea->LeftChild = marea->RightChild = NULL;
|
||||||
marea->Parent = PreviousNode;
|
marea->Parent = PreviousNode;
|
||||||
if (marea->StartingAddress < PreviousNode->StartingAddress)
|
if (MA_GetStartingAddress(marea) < MA_GetStartingAddress(PreviousNode))
|
||||||
PreviousNode->LeftChild = marea;
|
PreviousNode->LeftChild = marea;
|
||||||
else
|
else
|
||||||
PreviousNode->RightChild = marea;
|
PreviousNode->RightChild = marea;
|
||||||
|
@ -499,7 +499,7 @@ MmFindGapBottomUp(
|
||||||
while (Node && ((ULONG_PTR)Node->EndingAddress < HighestAddress))
|
while (Node && ((ULONG_PTR)Node->EndingAddress < HighestAddress))
|
||||||
{
|
{
|
||||||
/* Check if the memory area fits before the current node */
|
/* Check if the memory area fits before the current node */
|
||||||
if ((ULONG_PTR)Node->StartingAddress >= (Candidate + Length))
|
if (MA_GetStartingAddress(Node) >= (Candidate + Length))
|
||||||
{
|
{
|
||||||
DPRINT("MmFindGapBottomUp: %p\n", Candidate);
|
DPRINT("MmFindGapBottomUp: %p\n", Candidate);
|
||||||
ASSERT(Candidate >= LowestAddress);
|
ASSERT(Candidate >= LowestAddress);
|
||||||
|
@ -561,13 +561,13 @@ MmFindGapTopDown(
|
||||||
|
|
||||||
/* Go to the node with highest address in the tree. */
|
/* Go to the node with highest address in the tree. */
|
||||||
Node = Root ? MmIterateLastNode(Root) : NULL;
|
Node = Root ? MmIterateLastNode(Root) : NULL;
|
||||||
while (Node && ((ULONG_PTR)Node->StartingAddress > HighestAddress))
|
while (Node && (MA_GetStartingAddress(Node) > HighestAddress))
|
||||||
{
|
{
|
||||||
Node = MmIteratePrevNode(Node);
|
Node = MmIteratePrevNode(Node);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Traverse the tree from high to low addresses */
|
/* Traverse the tree from high to low addresses */
|
||||||
while (Node && ((ULONG_PTR)Node->StartingAddress > LowestAddress))
|
while (Node && (MA_GetStartingAddress(Node) > LowestAddress))
|
||||||
{
|
{
|
||||||
/* Check if the memory area fits after the current node */
|
/* Check if the memory area fits after the current node */
|
||||||
if ((ULONG_PTR)Node->EndingAddress <= Candidate)
|
if ((ULONG_PTR)Node->EndingAddress <= Candidate)
|
||||||
|
@ -577,11 +577,11 @@ MmFindGapTopDown(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate next possible adress below this node */
|
/* Calculate next possible adress below this node */
|
||||||
Candidate = ALIGN_DOWN_BY((ULONG_PTR)Node->StartingAddress - Length,
|
Candidate = ALIGN_DOWN_BY(MA_GetStartingAddress(Node) - Length,
|
||||||
Granularity);
|
Granularity);
|
||||||
|
|
||||||
/* Check for overflow. */
|
/* Check for overflow. */
|
||||||
if (Candidate > (ULONG_PTR)Node->StartingAddress)
|
if (Candidate > MA_GetStartingAddress(Node))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Go to the next lower node */
|
/* Go to the next lower node */
|
||||||
|
@ -630,10 +630,10 @@ MiRosCheckMemoryAreasRecursive(
|
||||||
|
|
||||||
/* Check some fields */
|
/* Check some fields */
|
||||||
ASSERT(Node->Magic == 'erAM');
|
ASSERT(Node->Magic == 'erAM');
|
||||||
ASSERT(PAGE_ALIGN(Node->StartingAddress) == (PVOID)Node->StartingAddress);
|
ASSERT(PAGE_ALIGN(MA_GetStartingAddress(Node)) == (PVOID)MA_GetStartingAddress(Node));
|
||||||
ASSERT(Node->EndingAddress != 0);
|
ASSERT(Node->EndingAddress != 0);
|
||||||
ASSERT(PAGE_ALIGN(Node->EndingAddress) == (PVOID)Node->EndingAddress);
|
ASSERT(PAGE_ALIGN(Node->EndingAddress) == (PVOID)Node->EndingAddress);
|
||||||
ASSERT(Node->StartingAddress < Node->EndingAddress);
|
ASSERT(MA_GetStartingAddress(Node) < Node->EndingAddress);
|
||||||
ASSERT((Node->Type == 0) ||
|
ASSERT((Node->Type == 0) ||
|
||||||
(Node->Type == MEMORY_AREA_CACHE) ||
|
(Node->Type == MEMORY_AREA_CACHE) ||
|
||||||
// (Node->Type == MEMORY_AREA_CACHE_SEGMENT) ||
|
// (Node->Type == MEMORY_AREA_CACHE_SEGMENT) ||
|
||||||
|
@ -766,7 +766,7 @@ MmFreeMemoryArea(
|
||||||
}
|
}
|
||||||
|
|
||||||
EndAddress = MM_ROUND_UP(MemoryArea->EndingAddress, PAGE_SIZE);
|
EndAddress = MM_ROUND_UP(MemoryArea->EndingAddress, PAGE_SIZE);
|
||||||
for (Address = (ULONG_PTR)MemoryArea->StartingAddress;
|
for (Address = MA_GetStartingAddress(MemoryArea);
|
||||||
Address < (ULONG_PTR)EndAddress;
|
Address < (ULONG_PTR)EndAddress;
|
||||||
Address += PAGE_SIZE)
|
Address += PAGE_SIZE)
|
||||||
{
|
{
|
||||||
|
@ -1008,7 +1008,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
|
||||||
|
|
||||||
RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
|
RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
|
||||||
MemoryArea->Type = Type;
|
MemoryArea->Type = Type;
|
||||||
MemoryArea->StartingAddress = (ULONG_PTR)*BaseAddress;
|
MemoryArea->StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT;
|
||||||
MemoryArea->EndingAddress = ((ULONG_PTR)*BaseAddress + tmpLength);
|
MemoryArea->EndingAddress = ((ULONG_PTR)*BaseAddress + tmpLength);
|
||||||
MemoryArea->Protect = Protect;
|
MemoryArea->Protect = Protect;
|
||||||
MemoryArea->Flags = AllocationFlags;
|
MemoryArea->Flags = AllocationFlags;
|
||||||
|
@ -1049,14 +1049,14 @@ MmDeleteProcessAddressSpace(PEPROCESS Process)
|
||||||
switch (MemoryArea->Type)
|
switch (MemoryArea->Type)
|
||||||
{
|
{
|
||||||
case MEMORY_AREA_SECTION_VIEW:
|
case MEMORY_AREA_SECTION_VIEW:
|
||||||
Address = (PVOID)MemoryArea->StartingAddress;
|
Address = (PVOID)MA_GetStartingAddress(MemoryArea);
|
||||||
MmUnlockAddressSpace(&Process->Vm);
|
MmUnlockAddressSpace(&Process->Vm);
|
||||||
MmUnmapViewOfSection(Process, Address);
|
MmUnmapViewOfSection(Process, Address);
|
||||||
MmLockAddressSpace(&Process->Vm);
|
MmLockAddressSpace(&Process->Vm);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MEMORY_AREA_CACHE:
|
case MEMORY_AREA_CACHE:
|
||||||
Address = (PVOID)MemoryArea->StartingAddress;
|
Address = (PVOID)MA_GetStartingAddress(MemoryArea);
|
||||||
MmUnlockAddressSpace(&Process->Vm);
|
MmUnlockAddressSpace(&Process->Vm);
|
||||||
MmUnmapViewOfCacheSegment(&Process->Vm, Address);
|
MmUnmapViewOfCacheSegment(&Process->Vm, Address);
|
||||||
MmLockAddressSpace(&Process->Vm);
|
MmLockAddressSpace(&Process->Vm);
|
||||||
|
|
|
@ -137,7 +137,7 @@ MmPageOutPhysicalAddress(PFN_NUMBER Page)
|
||||||
{
|
{
|
||||||
ULONG_PTR Entry;
|
ULONG_PTR Entry;
|
||||||
Offset = MemoryArea->Data.SectionData.ViewOffset.QuadPart +
|
Offset = MemoryArea->Data.SectionData.ViewOffset.QuadPart +
|
||||||
((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress);
|
((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea));
|
||||||
|
|
||||||
MmLockSectionSegment(MemoryArea->Data.SectionData.Segment);
|
MmLockSectionSegment(MemoryArea->Data.SectionData.Segment);
|
||||||
|
|
||||||
|
|
|
@ -1323,12 +1323,12 @@ MmNotPresentFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
|
|
||||||
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
||||||
Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
|
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
Segment = MemoryArea->Data.SectionData.Segment;
|
Segment = MemoryArea->Data.SectionData.Segment;
|
||||||
Section = MemoryArea->Data.SectionData.Section;
|
Section = MemoryArea->Data.SectionData.Section;
|
||||||
Region = MmFindRegion((PVOID)MemoryArea->StartingAddress,
|
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
&MemoryArea->Data.SectionData.RegionListHead,
|
&MemoryArea->Data.SectionData.RegionListHead,
|
||||||
Address, NULL);
|
Address, NULL);
|
||||||
ASSERT(Region != NULL);
|
ASSERT(Region != NULL);
|
||||||
|
@ -1700,12 +1700,12 @@ MmAccessFaultSectionView(PMMSUPPORT AddressSpace,
|
||||||
* Find the offset of the page
|
* Find the offset of the page
|
||||||
*/
|
*/
|
||||||
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
PAddress = MM_ROUND_DOWN(Address, PAGE_SIZE);
|
||||||
Offset.QuadPart = (ULONG_PTR)PAddress - (ULONG_PTR)MemoryArea->StartingAddress
|
Offset.QuadPart = (ULONG_PTR)PAddress - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
Segment = MemoryArea->Data.SectionData.Segment;
|
Segment = MemoryArea->Data.SectionData.Segment;
|
||||||
Section = MemoryArea->Data.SectionData.Section;
|
Section = MemoryArea->Data.SectionData.Section;
|
||||||
Region = MmFindRegion((PVOID)MemoryArea->StartingAddress,
|
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
&MemoryArea->Data.SectionData.RegionListHead,
|
&MemoryArea->Data.SectionData.RegionListHead,
|
||||||
Address, NULL);
|
Address, NULL);
|
||||||
ASSERT(Region != NULL);
|
ASSERT(Region != NULL);
|
||||||
|
@ -1895,7 +1895,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
|
||||||
Context.SectionEntry = Entry;
|
Context.SectionEntry = Entry;
|
||||||
Context.CallingProcess = Process;
|
Context.CallingProcess = Process;
|
||||||
|
|
||||||
Context.Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
|
Context.Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
DirectMapped = FALSE;
|
DirectMapped = FALSE;
|
||||||
|
@ -2294,7 +2294,7 @@ MmWritePageSectionView(PMMSUPPORT AddressSpace,
|
||||||
|
|
||||||
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
||||||
|
|
||||||
Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
|
Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2478,7 +2478,7 @@ MmAlterViewAttributes(PMMSUPPORT AddressSpace,
|
||||||
ULONG_PTR Entry;
|
ULONG_PTR Entry;
|
||||||
PFN_NUMBER Page;
|
PFN_NUMBER Page;
|
||||||
|
|
||||||
Offset.QuadPart = (ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress
|
Offset.QuadPart = (ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)
|
||||||
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
+ MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
|
Entry = MmGetPageEntrySectionSegment(Segment, &Offset);
|
||||||
/*
|
/*
|
||||||
|
@ -2524,7 +2524,7 @@ MmProtectSectionView(PMMSUPPORT AddressSpace,
|
||||||
if (Length > MaxLength)
|
if (Length > MaxLength)
|
||||||
Length = (ULONG)MaxLength;
|
Length = (ULONG)MaxLength;
|
||||||
|
|
||||||
Region = MmFindRegion((PVOID)MemoryArea->StartingAddress,
|
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
&MemoryArea->Data.SectionData.RegionListHead,
|
&MemoryArea->Data.SectionData.RegionListHead,
|
||||||
BaseAddress, NULL);
|
BaseAddress, NULL);
|
||||||
ASSERT(Region != NULL);
|
ASSERT(Region != NULL);
|
||||||
|
@ -2536,7 +2536,7 @@ MmProtectSectionView(PMMSUPPORT AddressSpace,
|
||||||
}
|
}
|
||||||
|
|
||||||
*OldProtect = Region->Protect;
|
*OldProtect = Region->Protect;
|
||||||
Status = MmAlterRegion(AddressSpace, (PVOID)MemoryArea->StartingAddress,
|
Status = MmAlterRegion(AddressSpace, (PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
&MemoryArea->Data.SectionData.RegionListHead,
|
&MemoryArea->Data.SectionData.RegionListHead,
|
||||||
BaseAddress, Length, Region->Type, Protect,
|
BaseAddress, Length, Region->Type, Protect,
|
||||||
MmAlterViewAttributes);
|
MmAlterViewAttributes);
|
||||||
|
@ -2555,7 +2555,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
|
||||||
PROS_SECTION_OBJECT Section;
|
PROS_SECTION_OBJECT Section;
|
||||||
PMM_SECTION_SEGMENT Segment;
|
PMM_SECTION_SEGMENT Segment;
|
||||||
|
|
||||||
Region = MmFindRegion((PVOID)MemoryArea->StartingAddress,
|
Region = MmFindRegion((PVOID)MA_GetStartingAddress(MemoryArea),
|
||||||
&MemoryArea->Data.SectionData.RegionListHead,
|
&MemoryArea->Data.SectionData.RegionListHead,
|
||||||
Address, &RegionBaseAddress);
|
Address, &RegionBaseAddress);
|
||||||
if (Region == NULL)
|
if (Region == NULL)
|
||||||
|
@ -2567,12 +2567,12 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
|
||||||
if (Section->AllocationAttributes & SEC_IMAGE)
|
if (Section->AllocationAttributes & SEC_IMAGE)
|
||||||
{
|
{
|
||||||
Segment = MemoryArea->Data.SectionData.Segment;
|
Segment = MemoryArea->Data.SectionData.Segment;
|
||||||
Info->AllocationBase = (PUCHAR)MemoryArea->StartingAddress - Segment->Image.VirtualAddress;
|
Info->AllocationBase = (PUCHAR)MA_GetStartingAddress(MemoryArea) - Segment->Image.VirtualAddress;
|
||||||
Info->Type = MEM_IMAGE;
|
Info->Type = MEM_IMAGE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Info->AllocationBase = (PVOID)MemoryArea->StartingAddress;
|
Info->AllocationBase = (PVOID)MA_GetStartingAddress(MemoryArea);
|
||||||
Info->Type = MEM_MAPPED;
|
Info->Type = MEM_MAPPED;
|
||||||
}
|
}
|
||||||
Info->BaseAddress = RegionBaseAddress;
|
Info->BaseAddress = RegionBaseAddress;
|
||||||
|
@ -4008,7 +4008,7 @@ MmFreeSectionPage(PVOID Context, MEMORY_AREA* MemoryArea, PVOID Address,
|
||||||
|
|
||||||
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
Address = (PVOID)PAGE_ROUND_DOWN(Address);
|
||||||
|
|
||||||
Offset.QuadPart = ((ULONG_PTR)Address - (ULONG_PTR)MemoryArea->StartingAddress) +
|
Offset.QuadPart = ((ULONG_PTR)Address - MA_GetStartingAddress(MemoryArea)) +
|
||||||
MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
MemoryArea->Data.SectionData.ViewOffset.QuadPart;
|
||||||
|
|
||||||
Section = MemoryArea->Data.SectionData.Section;
|
Section = MemoryArea->Data.SectionData.Section;
|
||||||
|
|
Loading…
Reference in a new issue