Alexandre Julliard : server: Only the first mapping needs to be an image in NtAreMappedFilesTheSame().

Alexandre Julliard julliard at winehq.org
Fri Apr 30 16:03:27 CDT 2021


Module: wine
Branch: master
Commit: 734e3a91ac1d6d184c8b6aa18debcb7fd3c36a20
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=734e3a91ac1d6d184c8b6aa18debcb7fd3c36a20

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Fri Apr 30 16:46:55 2021 +0200

server: Only the first mapping needs to be an image in NtAreMappedFilesTheSame().

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=37488
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/virtual.c | 7 +++++++
 server/mapping.c              | 4 +---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/dlls/kernel32/tests/virtual.c b/dlls/kernel32/tests/virtual.c
index 4abaa5befd1..a3b2d365c33 100644
--- a/dlls/kernel32/tests/virtual.c
+++ b/dlls/kernel32/tests/virtual.c
@@ -1357,6 +1357,9 @@ static void test_NtAreMappedFilesTheSame(void)
     ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, GetModuleHandleA("kernel32.dll") );
     ok( status == STATUS_NOT_SAME_DEVICE, "NtAreMappedFilesTheSame returned %x\n", status );
+    status = pNtAreMappedFilesTheSame( GetModuleHandleA("kernel32.dll"), ptr );
+    todo_wine
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
     UnmapViewOfFile( ptr );
     CloseHandle( mapping );
 
@@ -1366,6 +1369,8 @@ static void test_NtAreMappedFilesTheSame(void)
     ok( ptr != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, GetModuleHandleA("kernel32.dll") );
     ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    status = pNtAreMappedFilesTheSame( GetModuleHandleA("kernel32.dll"), ptr );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
 
     file2 = CreateFileA( path, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
     ok( file2 != INVALID_HANDLE_VALUE, "CreateFile error %u\n", GetLastError() );
@@ -1375,6 +1380,8 @@ static void test_NtAreMappedFilesTheSame(void)
     ok( ptr2 != NULL, "MapViewOfFile FILE_MAP_READ error %u\n", GetLastError() );
     status = pNtAreMappedFilesTheSame( ptr, ptr2 );
     ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
+    status = pNtAreMappedFilesTheSame( ptr2, ptr );
+    ok( status == STATUS_SUCCESS, "NtAreMappedFilesTheSame returned %x\n", status );
     UnmapViewOfFile( ptr2 );
     CloseHandle( map2 );
     CloseHandle( file2 );
diff --git a/server/mapping.c b/server/mapping.c
index c9d64856024..9cb24a4213f 100644
--- a/server/mapping.c
+++ b/server/mapping.c
@@ -1268,9 +1268,7 @@ DECL_HANDLER(is_same_mapping)
     struct memory_view *view2 = find_mapped_view( current->process, req->base2 );
 
     if (!view1 || !view2) return;
-    if (!view1->fd || !view2->fd ||
-        !(view1->flags & SEC_IMAGE) || !(view2->flags & SEC_IMAGE) ||
-        !is_same_file_fd( view1->fd, view2->fd ))
+    if (!view1->fd || !view2->fd || !(view1->flags & SEC_IMAGE) || !is_same_file_fd( view1->fd, view2->fd ))
         set_error( STATUS_NOT_SAME_DEVICE );
 }
 




More information about the wine-cvs mailing list