Dmitry Timoshkov : ntdll: Make the VirtualProtect tests pass under Wine.

Alexandre Julliard julliard at winehq.org
Thu Nov 3 13:10:14 CDT 2011


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

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Mon Oct 31 13:48:54 2011 +0800

ntdll: Make the VirtualProtect tests pass under Wine.

---

 dlls/kernel32/tests/virtual.c |   16 ----------------
 dlls/ntdll/virtual.c          |    1 +
 2 files changed, 1 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 b23e596..8c5e773 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -2088,6 +2088,7 @@ NTSTATUS WINAPI NtProtectVirtualMemory( HANDLE process, PVOID *addr_ptr, SIZE_T
     size = ROUND_SIZE( addr, size );
     base = ROUND_ADDR( addr, page_mask );
     if ((status = get_vprot_flags( new_prot, &new_vprot ))) return status;
+    if (new_vprot & VPROT_WRITECOPY) return STATUS_INVALID_PAGE_PROTECTION;
     new_vprot |= VPROT_COMMITTED;
 
     server_enter_uninterrupted_section( &csVirtual, &sigset );




More information about the wine-cvs mailing list