[NTOS:MM] Remove usage of memory area in MiProtectVirtualMemory

This commit is contained in:
Timo Kreuzer 2024-04-06 23:03:55 +03:00
parent edecbf4799
commit f60128b69d

View file

@ -2201,7 +2201,6 @@ MiProtectVirtualMemory(IN PEPROCESS Process,
IN ULONG NewAccessProtection,
OUT PULONG OldAccessProtection OPTIONAL)
{
PMEMORY_AREA MemoryArea;
PMMVAD Vad;
PMMSUPPORT AddressSpace;
ULONG_PTR StartingAddress, EndingAddress;
@ -2240,19 +2239,6 @@ MiProtectVirtualMemory(IN PEPROCESS Process,
goto FailPath;
}
/* Check for ROS specific memory area */
MemoryArea = MmLocateMemoryAreaByAddress(&Process->Vm, *BaseAddress);
if ((MemoryArea) && (MemoryArea->Type != MEMORY_AREA_OWNED_BY_ARM3))
{
/* Evil hack */
MmUnlockAddressSpace(AddressSpace);
return MiRosProtectVirtualMemory(Process,
BaseAddress,
NumberOfBytesToProtect,
NewAccessProtection,
OldAccessProtection);
}
/* Get the VAD for this address range, and make sure it exists */
Result = MiCheckForConflictingNode(StartingAddress >> PAGE_SHIFT,
EndingAddress >> PAGE_SHIFT,
@ -2265,6 +2251,18 @@ MiProtectVirtualMemory(IN PEPROCESS Process,
goto FailPath;
}
/* Check if this is a ROSMM VAD */
if (MI_IS_ROSMM_VAD(Vad))
{
/* Not very awesome hack */
MmUnlockAddressSpace(AddressSpace);
return MiRosProtectVirtualMemory(Process,
BaseAddress,
NumberOfBytesToProtect,
NewAccessProtection,
OldAccessProtection);
}
/* Make sure the address is within this VAD's boundaries */
if ((((ULONG_PTR)StartingAddress >> PAGE_SHIFT) < Vad->StartingVpn) ||
(((ULONG_PTR)EndingAddress >> PAGE_SHIFT) > Vad->EndingVpn))