[3/3] ntdll: Make the VirtualProtect tests pass under Wine.

Dmitry Timoshkov dmitry at baikal.ru
Mon Oct 31 00:48:54 CDT 2011


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

diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 49630fd..d0b9f4f 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -1472,16 +1472,8 @@ static void test_VirtualProtect(void)
         }
         else
         {
-            /* FIXME: remove the condition below once Wine is fixed */
-            if ((td[i].prot_set == PAGE_WRITECOPY) || (td[i].prot_set == PAGE_EXECUTE_WRITECOPY))
-            todo_wine {
             ok(!ret, "%d: VirtualProtect should fail\n", i);
             ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
-            }
-            else {
-            ok(!ret, "%d: VirtualProtect should fail\n", i);
-            ok(GetLastError() == ERROR_INVALID_PARAMETER, "%d: expected ERROR_INVALID_PARAMETER, got %d\n", i, GetLastError());
-            }
         }
 
         old_prot = 0xdeadbeef;
@@ -1491,13 +1483,7 @@ static void test_VirtualProtect(void)
         if (td[i].prot_get)
             ok(old_prot == td[i].prot_get, "%d: got %#x != expected %#x\n", i, old_prot, td[i].prot_get);
         else
-        {
-            /* FIXME: remove the condition below once Wine is fixed */
-            if ((td[i].prot_set == PAGE_WRITECOPY) || (td[i].prot_set == PAGE_EXECUTE_WRITECOPY))
-            todo_wine ok(old_prot == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, old_prot);
-            else
             ok(old_prot == PAGE_NOACCESS, "%d: got %#x != expected PAGE_NOACCESS\n", i, old_prot);
-        }
     }
 
     exec_prot = 0;
@@ -1521,10 +1507,8 @@ static void test_VirtualProtect(void)
             {
                 if (prot & (PAGE_WRITECOPY | PAGE_EXECUTE_WRITECOPY))
                 {
-                    todo_wine {
                     ok(!ret, "VirtualProtect(%02x) should fail\n", prot);
                     ok(GetLastError() == ERROR_INVALID_PARAMETER, "expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
-                    }
                 }
                 else
                     ok(ret, "VirtualProtect(%02x) error %d\n", prot, GetLastError());
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 7185f14..d1e355e 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -2056,6 +2056,9 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T
 
     TRACE("%p %p %08lx %08x\n", process, addr, size, new_prot );
 
+    if (new_prot == PAGE_WRITECOPY || new_prot == PAGE_EXECUTE_WRITECOPY)
+        return STATUS_INVALID_PAGE_PROTECTION;
+
     if (process != NtCurrentProcess())
     {
         apc_call_t call;
-- 
1.7.5.1




More information about the wine-patches mailing list