[NTOSKRNL] Get rid of MEMORY_AREA::Protect

Use the VAD node instead
This commit is contained in:
Jérôme Gardou 2020-10-23 16:55:00 +02:00
parent c9f924940a
commit c6a87f28bf
3 changed files with 10 additions and 11 deletions

View file

@ -212,7 +212,6 @@ typedef struct _MEMORY_AREA
MMVAD VadNode;
ULONG Type;
ULONG Protect;
ULONG Flags;
BOOLEAN DeleteInProgress;
ULONG Magic;

View file

@ -165,12 +165,13 @@ MiMakeProtectionMask(
static VOID
MmInsertMemoryArea(
PMMSUPPORT AddressSpace,
PMEMORY_AREA marea)
PMEMORY_AREA marea,
ULONG Protect)
{
PEPROCESS Process = MmGetAddressSpaceOwner(AddressSpace);
marea->VadNode.u.VadFlags.Spare = 1;
marea->VadNode.u.VadFlags.Protection = MiMakeProtectionMask(marea->Protect);
marea->VadNode.u.VadFlags.Protection = MiMakeProtectionMask(Protect);
/* Build a lame VAD if this is a user-space allocation */
if (marea->VadNode.EndingVpn + 1 < (ULONG_PTR)MmSystemRangeStart >> PAGE_SHIFT)
@ -457,7 +458,6 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
RtlZeroMemory(MemoryArea, sizeof(MEMORY_AREA));
MemoryArea->Type = Type & ~MEMORY_AREA_STATIC;
MemoryArea->Protect = Protect;
MemoryArea->Flags = AllocationFlags;
MemoryArea->Magic = 'erAM';
MemoryArea->DeleteInProgress = FALSE;
@ -478,7 +478,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
MemoryArea->VadNode.StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT;
MemoryArea->VadNode.EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT;
MmInsertMemoryArea(AddressSpace, MemoryArea);
MmInsertMemoryArea(AddressSpace, MemoryArea, Protect);
}
else
{
@ -516,7 +516,7 @@ MmCreateMemoryArea(PMMSUPPORT AddressSpace,
MemoryArea->VadNode.StartingVpn = (ULONG_PTR)*BaseAddress >> PAGE_SHIFT;
MemoryArea->VadNode.EndingVpn = ((ULONG_PTR)*BaseAddress + tmpLength - 1) >> PAGE_SHIFT;
MmInsertMemoryArea(AddressSpace, MemoryArea);
MmInsertMemoryArea(AddressSpace, MemoryArea, Protect);
}
*Result = MemoryArea;

View file

@ -2222,7 +2222,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
{
Status = MmCreateVirtualMapping(Process,
Address,
MemoryArea->Protect,
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection],
&Page,
1);
MmSetDirtyPage(Process, Address);
@ -2243,7 +2243,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
*/
Status = MmCreateVirtualMapping(Process,
Address,
MemoryArea->Protect,
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection],
&Page,
1);
MmSetDirtyPage(Process, Address);
@ -2280,7 +2280,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
{
Status = MmCreateVirtualMapping(Process,
Address,
MemoryArea->Protect,
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection],
&Page,
1);
MmSetDirtyPage(Process, Address);
@ -2293,7 +2293,7 @@ MmPageOutSectionView(PMMSUPPORT AddressSpace,
MmLockSectionSegment(Context.Segment);
Status = MmCreateVirtualMapping(Process,
Address,
MemoryArea->Protect,
MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection],
&Page,
1);
MmSetDirtyPage(Process, Address);
@ -2579,7 +2579,7 @@ MmQuerySectionView(PMEMORY_AREA MemoryArea,
Info->Type = MEM_MAPPED;
}
Info->BaseAddress = RegionBaseAddress;
Info->AllocationProtect = MemoryArea->Protect;
Info->AllocationProtect = MmProtectToValue[MemoryArea->VadNode.u.VadFlags.Protection];
Info->RegionSize = Region->Length;
Info->State = MEM_COMMIT;
Info->Protect = Region->Protect;