Sebastian Lackner : ntdll: Return failure in NtProtectVirtualMemory when last argument is omitted.

Alexandre Julliard julliard at wine.codeweavers.com
Tue May 5 09:50:51 CDT 2015


Module: wine
Branch: master
Commit: ee6a477cab209aa34787d4711123993eed380d7e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ee6a477cab209aa34787d4711123993eed380d7e

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Sat May  2 18:46:38 2015 +0200

ntdll: Return failure in NtProtectVirtualMemory when last argument is omitted.

---

 dlls/kernel32/tests/virtual.c | 5 -----
 dlls/ntdll/virtual.c          | 3 +++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 2dea156..4f50df8 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -2492,27 +2492,22 @@ static void test_VirtualProtect(void)
 
     SetLastError(0xdeadbeef);
     ret = VirtualProtect(base, si.dwPageSize, PAGE_READONLY, NULL);
-    todo_wine
     ok(!ret, "VirtualProtect should fail\n");
-    todo_wine
     ok(GetLastError() == ERROR_NOACCESS, "expected ERROR_NOACCESS, got %d\n", GetLastError());
     old_prot = 0xdeadbeef;
     ret = VirtualProtect(base, si.dwPageSize, PAGE_NOACCESS, &old_prot);
     ok(ret, "VirtualProtect failed %d\n", GetLastError());
-    todo_wine
     ok(old_prot == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", old_prot);
 
     addr = base;
     size = si.dwPageSize;
     status = pNtProtectVirtualMemory(GetCurrentProcess(), &addr, &size, PAGE_READONLY, NULL);
-    todo_wine
     ok(status == STATUS_ACCESS_VIOLATION, "NtProtectVirtualMemory should fail, got %08x\n", status);
     addr = base;
     size = si.dwPageSize;
     old_prot = 0xdeadbeef;
     status = pNtProtectVirtualMemory(GetCurrentProcess(), &addr, &size, PAGE_NOACCESS, &old_prot);
     ok(status == STATUS_SUCCESS, "NtProtectVirtualMemory should succeed, got %08x\n", status);
-    todo_wine
     ok(old_prot == PAGE_NOACCESS, "got %#x != expected PAGE_NOACCESS\n", old_prot);
 
     for (i = 0; i < sizeof(td)/sizeof(td[0]); i++)
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 9d29c33..0629816 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -2164,6 +2164,9 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T
 
     TRACE("%p %p %08lx %08x\n", process, addr, size, new_prot );
 
+    if (!old_prot)
+        return STATUS_ACCESS_VIOLATION;
+
     if (process != NtCurrentProcess())
     {
         apc_call_t call;




More information about the wine-cvs mailing list