mirror of
https://github.com/reactos/reactos.git
synced 2024-10-02 07:26:47 +00:00
[NTOS]: Preparations for the VAD-based Virtual Memory system begin. Disable changing protection on Virtual Memory pages, and make all pages PAGE_EXECUTE_READWRITE for now. In theory, this should not cause any real problems, and sets the stage for the initial functionality regressions that the VAD-based system will introduce. I will eventually plan on fixing them.
svn path=/trunk/; revision=55883
This commit is contained in:
parent
2c7855ed9d
commit
aaa881ed5a
|
@ -527,9 +527,7 @@ MiProtectVirtualMemory(IN PEPROCESS Process,
|
|||
|
||||
if (MemoryArea->Type == MEMORY_AREA_VIRTUAL_MEMORY)
|
||||
{
|
||||
Status = MmProtectAnonMem(AddressSpace, MemoryArea, *BaseAddress,
|
||||
*NumberOfBytesToProtect, NewAccessProtection,
|
||||
OldAccessProtection);
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else if (MemoryArea->Type == MEMORY_AREA_SECTION_VIEW)
|
||||
{
|
||||
|
@ -775,6 +773,11 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle,
|
|||
|
||||
AddressSpace = &Process->Vm;
|
||||
MmLockAddressSpace(AddressSpace);
|
||||
|
||||
//
|
||||
// Force PAGE_EXECUTE_READWRITE for everything, for now
|
||||
//
|
||||
Protect = PAGE_EXECUTE_READWRITE;
|
||||
|
||||
if (PBaseAddress != 0)
|
||||
{
|
||||
|
@ -1249,84 +1252,4 @@ unlock_deref_and_return:
|
|||
return(Status);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
MmProtectAnonMem(PMMSUPPORT AddressSpace,
|
||||
PMEMORY_AREA MemoryArea,
|
||||
PVOID BaseAddress,
|
||||
SIZE_T Length,
|
||||
ULONG Protect,
|
||||
PULONG OldProtect)
|
||||
{
|
||||
PMM_REGION Region;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
ULONG_PTR LengthCount = 0;
|
||||
|
||||
/* 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 + 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))
|
||||
{
|
||||
*OldProtect = Region->Protect;
|
||||
Status = MmAlterRegion(AddressSpace, MemoryArea->StartingAddress,
|
||||
&MemoryArea->Data.VirtualMemoryData.RegionListHead,
|
||||
BaseAddress, Length, Region->Type, Protect,
|
||||
MmModifyAttributes);
|
||||
}
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
MmQueryAnonMem(PMEMORY_AREA MemoryArea,
|
||||
PVOID Address,
|
||||
PMEMORY_BASIC_INFORMATION Info,
|
||||
PSIZE_T ResultLength)
|
||||
{
|
||||
PMM_REGION Region;
|
||||
PVOID RegionBase = NULL;
|
||||
|
||||
Info->BaseAddress = (PVOID)PAGE_ROUND_DOWN(Address);
|
||||
|
||||
Region = MmFindRegion(MemoryArea->StartingAddress,
|
||||
&MemoryArea->Data.VirtualMemoryData.RegionListHead,
|
||||
Address, &RegionBase);
|
||||
Info->BaseAddress = RegionBase;
|
||||
Info->AllocationBase = MemoryArea->StartingAddress;
|
||||
Info->AllocationProtect = MemoryArea->Protect;
|
||||
Info->RegionSize = Region->Length;
|
||||
Info->State = Region->Type;
|
||||
Info->Protect = Region->Protect;
|
||||
Info->Type = MEM_PRIVATE;
|
||||
|
||||
*ResultLength = sizeof(MEMORY_BASIC_INFORMATION);
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
Loading…
Reference in a new issue