Alexandre Julliard : ntdll: Return STATUS_IMAGE_NOT_AT_BASE when an image mapping has to be relocated.

Alexandre Julliard julliard at winehq.org
Thu Mar 4 11:21:40 CST 2010


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Mar  3 20:04:55 2010 +0100

ntdll: Return STATUS_IMAGE_NOT_AT_BASE when an image mapping has to be relocated.

---

 dlls/kernel32/virtual.c |    2 +-
 dlls/ntdll/loader.c     |    2 +-
 dlls/ntdll/virtual.c    |    5 +++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c
index 9ad941b..dcd5b85 100644
--- a/dlls/kernel32/virtual.c
+++ b/dlls/kernel32/virtual.c
@@ -545,7 +545,7 @@ LPVOID WINAPI MapViewOfFileEx( HANDLE handle, DWORD access,
     if (access & FILE_MAP_EXECUTE) protect <<= 4;
 
     if ((status = NtMapViewOfSection( handle, GetCurrentProcess(), &addr, 0, 0, &offset,
-                                      &count, ViewShare, 0, protect )))
+                                      &count, ViewShare, 0, protect )) < 0)
     {
         SetLastError( RtlNtStatusToDosError(status) );
         addr = NULL;
diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 7bbcf95..1723f18 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -1498,7 +1498,7 @@ static NTSTATUS load_native_dll( LPCWSTR load_path, LPCWSTR name, HANDLE file,
     status = NtMapViewOfSection( mapping, NtCurrentProcess(),
                                  &module, 0, 0, &size, &len, ViewShare, 0, PAGE_READONLY );
     NtClose( mapping );
-    if (status != STATUS_SUCCESS) return status;
+    if (status < 0) return status;
 
     /* create the MODREF */
 
diff --git a/dlls/ntdll/virtual.c b/dlls/ntdll/virtual.c
index 9731069..15973fb 100644
--- a/dlls/ntdll/virtual.c
+++ b/dlls/ntdll/virtual.c
@@ -1296,6 +1296,7 @@ static NTSTATUS map_image( HANDLE hmapping, int fd, char *base, SIZE_T total_siz
 #ifdef VALGRIND_LOAD_PDB_DEBUGINFO
     VALGRIND_LOAD_PDB_DEBUGINFO(fd, ptr, total_size, delta);
 #endif
+    if (ptr != base) return STATUS_IMAGE_NOT_AT_BASE;
     return STATUS_SUCCESS;
 
  error:
@@ -2409,7 +2410,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
         res = NTDLL_queue_process_apc( process, &call, &result );
         if (res != STATUS_SUCCESS) return res;
 
-        if (result.map_view.status == STATUS_SUCCESS)
+        if ((NTSTATUS)result.map_view.status >= 0)
         {
             *addr_ptr = wine_server_get_ptr( result.map_view.addr );
             *size_ptr = result.map_view.size;
@@ -2461,7 +2462,7 @@ NTSTATUS WINAPI NtMapViewOfSection( HANDLE handle, HANDLE process, PVOID *addr_p
                              -1, dup_mapping, addr_ptr );
         }
         if (needs_close) close( unix_handle );
-        if (!res) *size_ptr = size;
+        if (res >= 0) *size_ptr = size;
         return res;
     }
 




More information about the wine-cvs mailing list