From fd43db5558d8791e7cf4d42a29782dbdbb46ef5a Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Fri, 4 Jan 2013 01:06:51 +0000 Subject: [PATCH] [NTOSKRNL] Implement protection changing in NtAllocateVirtualMemory. Fixes "Assertion 'ChangeProtection == FALSE' failed" svn path=/trunk/; revision=58108 --- reactos/ntoskrnl/mm/ARM3/virtual.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/virtual.c b/reactos/ntoskrnl/mm/ARM3/virtual.c index 0504471cdf2..3d3b4a1f25d 100644 --- a/reactos/ntoskrnl/mm/ARM3/virtual.c +++ b/reactos/ntoskrnl/mm/ARM3/virtual.c @@ -4308,7 +4308,6 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, // There's a change in protection, remember this for later, but do // not yet handle it. // - DPRINT1("Protection change to: 0x%lx not implemented\n", Protect); ChangeProtection = TRUE; } @@ -4318,11 +4317,6 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, PointerPte++; } - // - // This path is not yet handled - // - ASSERT(ChangeProtection == FALSE); - // // Release the working set lock, unlock the address space, and detach from // the target process if it was not the current process. Also dereference the @@ -4332,6 +4326,26 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, Status = STATUS_SUCCESS; FailPath: MmUnlockAddressSpace(AddressSpace); + + // + // Check if we need to update the protection + // + if (ChangeProtection) + { + PVOID ProtectBaseAddress = (PVOID)StartingAddress; + SIZE_T ProtectSize = PRegionSize; + ULONG OldProtection; + + // + // Change the protection of the region + // + MiProtectVirtualMemory(Process, + &ProtectBaseAddress, + &ProtectSize, + Protect, + &OldProtection); + } + FailPathNoLock: if (Attached) KeUnstackDetachProcess(&ApcState); if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process);