[NTOSKRNL]

Implement protection changing in NtAllocateVirtualMemory. 
Fixes "Assertion 'ChangeProtection == FALSE' failed"

svn path=/trunk/; revision=58108
This commit is contained in:
Timo Kreuzer 2013-01-04 01:06:51 +00:00
parent 5b8fa09fc2
commit fd43db5558

View file

@ -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);