Dmitry Timoshkov : kernel32: Add a test for read-only mapping of a write-only section, test actual page access rights of the mapping.

Alexandre Julliard julliard at winehq.org
Tue Sep 25 07:50:53 CDT 2007


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

Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date:   Mon Sep 24 23:41:08 2007 +0900

kernel32: Add a test for read-only mapping of a write-only section, test actual page access rights of the mapping.

---

 dlls/kernel32/tests/virtual.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 78c5643..4970628 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -271,6 +271,7 @@ static void test_MapViewOfFile(void)
     static const char testfile[] = "testfile.xxx";
     HANDLE file, mapping;
     void *ptr;
+    MEMORY_BASIC_INFORMATION info;
 
     SetLastError(0xdeadbeef);
     file = CreateFileA( testfile, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0 );
@@ -457,6 +458,41 @@ static void test_MapViewOfFile(void)
     ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
 todo_wine ok( !ptr, "MapViewOfFile FILE_MAP_WRITE should fail\n" );
 todo_wine ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+    SetLastError(0xdeadbeef);
+    ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
+    SetLastError(0xdeadbeef);
+    ok( VirtualQuery( ptr, &info, sizeof(info) ) == sizeof(info),
+        "VirtualQuery error %u\n", GetLastError() );
+    ok( info.BaseAddress == ptr, "%p != %p\n", info.BaseAddress, ptr );
+    ok( info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr );
+todo_wine ok( info.AllocationProtect == PAGE_READONLY, "%x != PAGE_READONLY\n", info.AllocationProtect );
+    ok( info.RegionSize == 4096, "%lx != 4096\n", info.RegionSize );
+    ok( info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State );
+todo_wine ok( info.Protect == PAGE_READONLY, "%x != PAGE_READONLY\n", info.Protect );
+    UnmapViewOfFile( ptr );
+    CloseHandle( mapping );
+
+    SetLastError(0xdeadbeef);
+    mapping = OpenFileMapping( FILE_MAP_WRITE, FALSE, "Global\\Foo" );
+    ok( mapping != 0, "OpenFileMapping FILE_MAP_WRITE error %u\n", GetLastError() );
+    SetLastError(0xdeadbeef);
+    ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 0 );
+todo_wine ok( !ptr, "MapViewOfFile FILE_MAP_READ should fail\n" );
+todo_wine ok( GetLastError() == ERROR_ACCESS_DENIED, "Wrong error %d\n", GetLastError() );
+    SetLastError(0xdeadbeef);
+    ptr = MapViewOfFile( mapping, FILE_MAP_WRITE, 0, 0, 0 );
+    ok( ptr != NULL, "MapViewOfFile FILE_MAP_WRITE error %u\n", GetLastError() );
+    SetLastError(0xdeadbeef);
+    ok( VirtualQuery( ptr, &info, sizeof(info) ) == sizeof(info),
+        "VirtualQuery error %u\n", GetLastError() );
+    ok( info.BaseAddress == ptr, "%p != %p\n", info.BaseAddress, ptr );
+    ok( info.AllocationBase == ptr, "%p != %p\n", info.AllocationBase, ptr );
+    ok( info.AllocationProtect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.AllocationProtect );
+    ok( info.RegionSize == 4096, "%lx != 4096\n", info.RegionSize );
+    ok( info.State == MEM_COMMIT, "%x != MEM_COMMIT\n", info.State );
+    ok( info.Protect == PAGE_READWRITE, "%x != PAGE_READWRITE\n", info.Protect );
+    UnmapViewOfFile( ptr );
     CloseHandle( mapping );
 
     CloseHandle( file );




More information about the wine-cvs mailing list