mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-09-03 04:13:31 +00:00
- MmProtectAnonMem: Search all Regions in Memory Area up to Length for MEM_COMMIT prior to altering memory protection.
Fixes 6 kernel32_winetest for virtual memory. svn path=/trunk/; revision=40857
This commit is contained in:
@@ -1034,26 +1034,48 @@ MmProtectAnonMem(PMMSUPPORT AddressSpace,
|
||||
PULONG OldProtect)
|
||||
{
|
||||
PMM_REGION Region;
|
||||
NTSTATUS Status;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
ULONG LengthCount = 0;
|
||||
|
||||
Region = MmFindRegion(MemoryArea->StartingAddress,
|
||||
&MemoryArea->Data.VirtualMemoryData.RegionListHead,
|
||||
BaseAddress, NULL);
|
||||
if (Region->Type == MEM_COMMIT)
|
||||
/* Search all Regions in MemoryArea up to Length */
|
||||
/* Every Region up to Length must be committed for success */
|
||||
for (;;)
|
||||
{
|
||||
Region = MmFindRegion(MemoryArea->StartingAddress,
|
||||
&MemoryArea->Data.VirtualMemoryData.RegionListHead,
|
||||
(PVOID)((ULONG_PTR)BaseAddress + (ULONG_PTR)LengthCount), NULL);
|
||||
|
||||
/* If a Region was found and it is committed */
|
||||
if ((Region) && (Region->Type == MEM_COMMIT))
|
||||
{
|
||||
LengthCount += Region->Length;
|
||||
if (Length <= LengthCount) break;
|
||||
continue;
|
||||
}
|
||||
/* If Region was found and it is not commited */
|
||||
else if (Region)
|
||||
{
|
||||
Status = STATUS_NOT_COMMITTED;
|
||||
break;
|
||||
}
|
||||
/* If no Region was found at all */
|
||||
else if (LengthCount == 0)
|
||||
{
|
||||
Status = STATUS_INVALID_ADDRESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
/* FIXME: check if the whole range is committed
|
||||
* before altering the memory */
|
||||
*OldProtect = Region->Protect;
|
||||
Status = MmAlterRegion(AddressSpace, MemoryArea->StartingAddress,
|
||||
&MemoryArea->Data.VirtualMemoryData.RegionListHead,
|
||||
BaseAddress, Length, Region->Type, Protect,
|
||||
MmModifyAttributes);
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_NOT_COMMITTED;
|
||||
}
|
||||
return(Status);
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
|
||||
Reference in New Issue
Block a user