[3/3] kernel32: In Win9x mode UnmapViewOfFile requires base address of a mapping.

Sebastian Lackner sebastian at fds-team.de
Tue Jul 19 06:00:30 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/virtual.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c
index 37ab264..5733a42 100644
--- a/dlls/kernel32/virtual.c
+++ b/dlls/kernel32/virtual.c
@@ -576,7 +576,19 @@ LPVOID WINAPI MapViewOfFileEx( HANDLE handle, DWORD access,
  */
 BOOL WINAPI UnmapViewOfFile( LPCVOID addr )
 {
-    NTSTATUS status = NtUnmapViewOfSection( GetCurrentProcess(), (void *)addr );
+    NTSTATUS status;
+
+    if (GetVersion() & 0x80000000)
+    {
+        MEMORY_BASIC_INFORMATION info;
+        if (!VirtualQuery( addr, &info, sizeof(info) ) || info.AllocationBase != addr)
+        {
+            SetLastError( ERROR_INVALID_ADDRESS );
+            return FALSE;
+        }
+    }
+
+    status = NtUnmapViewOfSection( GetCurrentProcess(), (void *)addr );
     if (status) SetLastError( RtlNtStatusToDosError(status) );
     return !status;
 }
-- 
2.8.0



More information about the wine-patches mailing list