diff --git a/dlls/kernel32/virtual.c b/dlls/kernel32/virtual.c index 9ad941b76ac..dcd5b855284 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 7bbcf95b85a..1723f183c4e 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 9731069e815..15973fb4729 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; }