From 75ff9ef0c0bf63689ca69dc5ee55e5c02a4f872e Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 15 Nov 2011 22:16:57 +0000 Subject: [PATCH] [NTOSKRNL] - Fix 2 broken failure cases (forgot to detach from process and/or forgot to dereference process) svn path=/trunk/; revision=54389 --- reactos/ntoskrnl/mm/anonmem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/reactos/ntoskrnl/mm/anonmem.c b/reactos/ntoskrnl/mm/anonmem.c index 659be426093..5838e327df3 100644 --- a/reactos/ntoskrnl/mm/anonmem.c +++ b/reactos/ntoskrnl/mm/anonmem.c @@ -683,6 +683,7 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, { /* Fail without it */ DPRINT1("Privilege not held for MEM_LARGE_PAGES\n"); + if (Attached) KeUnstackDetachProcess(&ApcState); if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process); return STATUS_PRIVILEGE_NOT_HELD; } @@ -701,6 +702,8 @@ NtAllocateVirtualMemory(IN HANDLE ProcessHandle, (Protect & (PAGE_WRITECOPY | PAGE_EXECUTE_WRITECOPY))) { DPRINT1("Copy on write is not supported by VirtualAlloc\n"); + if (Attached) KeUnstackDetachProcess(&ApcState); + if (ProcessHandle != NtCurrentProcess()) ObDereferenceObject(Process); return STATUS_INVALID_PAGE_PROTECTION; }