[2/3] ntdll: NtUnmapViewOfSection should succeed for all offsets within the mapped range.

Sebastian Lackner sebastian at fds-team.de
Tue Jul 19 05:59:55 CDT 2016


From: Michael Müller <michael at fds-team.de>

Signed-off-by: Michael Müller <michael at fds-team.de>
Signed-off-by: Sebastian Lackner <sebastian at fds-team.de>
---
 dlls/kernel32/tests/virtual.c |    6 ++----
 dlls/ntdll/tests/info.c       |    6 +++---
 dlls/ntdll/virtual.c          |    3 +--
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 3c3a9c0..301fe4d 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -1007,15 +1007,13 @@ static void test_MapViewOfFile(void)
     ok( ptr != NULL, "MapViewOfFile failed with error %u\n", GetLastError() );
 
     ret = UnmapViewOfFile( (char *)ptr + 4096 );
-    todo_wine ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
-    if (!ret) UnmapViewOfFile( ptr );
+    ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
 
     ptr = MapViewOfFile( mapping, FILE_MAP_READ, 0, 0, 12288 );
     ok( ptr != NULL, "MapViewOfFile failed with error %u\n", GetLastError() );
 
     ret = UnmapViewOfFile( (char *)ptr + 4096 + 100 );
-    todo_wine ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
-    if (!ret) UnmapViewOfFile( ptr );
+    ok( ret, "UnmapViewOfFile failed with error %u\n", GetLastError() );
 
     CloseHandle(mapping);
     CloseHandle(file);
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index be355fb..19c7d66 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -1643,7 +1643,7 @@ static void test_mapprotection(void)
     status = pNtSetInformationProcess( GetCurrentProcess(), ProcessExecuteFlags, &flags, sizeof(flags) );
     ok( (status == STATUS_SUCCESS) || (status == STATUS_INVALID_INFO_CLASS), "Expected STATUS_SUCCESS, got %08x\n", status);
 
-    size.u.LowPart  = 0x1000;
+    size.u.LowPart  = 0x2000;
     size.u.HighPart = 0;
     status = pNtCreateSection ( &h,
         STANDARD_RIGHTS_REQUIRED | SECTION_QUERY | SECTION_MAP_READ | SECTION_MAP_WRITE | SECTION_MAP_EXECUTE,
@@ -1657,7 +1657,7 @@ static void test_mapprotection(void)
 
     offset.u.LowPart  = 0;
     offset.u.HighPart = 0;
-    count = 0x1000;
+    count = 0x2000;
     addr = NULL;
     status = pNtMapViewOfSection ( h, GetCurrentProcess(), &addr, 0, 0, &offset, &count, ViewShare, 0, PAGE_READWRITE);
     ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
@@ -1680,7 +1680,7 @@ static void test_mapprotection(void)
     ok( retlen == sizeof(info), "Expected STATUS_SUCCESS, got %08x\n", status);
     ok((info.Protect & ~PAGE_NOCACHE) == PAGE_READWRITE, "addr.Protect is not PAGE_READWRITE, but 0x%x\n", info.Protect);
 
-    status = pNtUnmapViewOfSection (GetCurrentProcess(), addr);
+    status = pNtUnmapViewOfSection( GetCurrentProcess(), (char *)addr + 0x1050 );
     ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
     pNtClose (h);
 
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 2e63b78..1e692c7 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -2737,7 +2737,6 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
     struct file_view *view;
     NTSTATUS status = STATUS_NOT_MAPPED_VIEW;
     sigset_t sigset;
-    void *base = ROUND_ADDR( addr, page_mask );
 
     if (process != NtCurrentProcess())
     {
@@ -2754,7 +2753,7 @@ NTSTATUS WINAPI NtUnmapViewOfSection( HANDLE process, PVOID addr )
     }
 
     server_enter_uninterrupted_section( &csVirtual, &sigset );
-    if ((view = VIRTUAL_FindView( base, 0 )) && (base == view->base) && !(view->protect & VPROT_VALLOC))
+    if ((view = VIRTUAL_FindView( addr, 0 )) && !(view->protect & VPROT_VALLOC))
     {
         delete_view( view );
         status = STATUS_SUCCESS;
-- 
2.8.0



More information about the wine-patches mailing list