diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-03-08 16:40:35 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-03-08 16:40:35 +0100 |
| commit | e05796674bd7648faa4bbb4d61de2e641bed34b9 (patch) | |
| tree | 7d38c44b030c69de44fc9988840832999d7d719c /src/wrapped/wrappedlibc.c | |
| parent | 0ce169e7f55a84eef801fec61e352c800ac8e5e6 (diff) | |
| parent | 726af707ebe92f0f1a98ea985343f6641fa45ba8 (diff) | |
| download | box64-e05796674bd7648faa4bbb4d61de2e641bed34b9.tar.gz box64-e05796674bd7648faa4bbb4d61de2e641bed34b9.zip | |
Merge branch 'main' of https://github.com/ptitSeb/box64 into main
Diffstat (limited to 'src/wrapped/wrappedlibc.c')
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index e73e32cf..61429120 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -2198,18 +2198,20 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot #endif void* ret = mmap64(addr, length, prot, flags, fd, offset); #ifndef NOALIGN - if((ret!=(void*)-1) && (flags&0x40) && ((uintptr_t)ret>0xffffffff)) { + if((ret!=(void*)-1) && (flags&0x40) && + (((uintptr_t)ret>0xffffffff) || (box64_wine && ((uintptr_t)ret&~0xffff!=(uintptr_t)ret)))) { printf_log(LOG_DEBUG, "Warning, mmap on 32bits didn't worked, ask %p, got %p ", addr, ret); munmap(ret, length); loadProtectionFromMap(); // reload map, because something went wrong previously - addr = findBlockNearHint(addr, length); // is this the best way? + addr = findBlockNearHint(old_addr, length); // is this the best way? ret = mmap64(addr, length, prot, flags, fd, offset); printf_log(LOG_DEBUG, " tried again with %p, got %p\n", addr, ret); - } else if((ret!=(void*)-1) && ((flags&MAP_FIXED)==0) && (box64_wine) && ((uintptr_t)ret>0x7fffffffffffLL)) { + } else if((ret!=(void*)-1) && ((flags&MAP_FIXED)==0) && (box64_wine) && (old_addr) && (addr!=ret) && + (((uintptr_t)ret>0x7fffffffffffLL) || ((uintptr_t)ret&~0xffff!=(uintptr_t)ret))) { printf_log(LOG_DEBUG, "Warning, mmap on 47bits didn't worked, ask %p, got %p ", addr, ret); munmap(ret, length); loadProtectionFromMap(); // reload map, because something went wrong previously - addr = find47bitBlock(length); // is this the best way? + addr = find47bitBlockNearHint(old_addr, length); // is this the best way? ret = mmap64(addr, length, prot, flags, fd, offset); printf_log(LOG_DEBUG, " tried again with %p, got %p\n", addr, ret); } |