From 296ee1bacaa99f4aca8c2f80238a47935029d72c Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 28 Jul 2021 13:19:32 +0200 Subject: Try to force 47bits on mmap64 all the time (not just when wine64 is detected) --- src/wrapped/wrappedlibc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 54942c7f..3796bfb9 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -2012,6 +2012,7 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot prot|=PROT_READ; // PROT_READ is implicit with PROT_WRITE on i386 if(box64_log ", addr, length, prot, flags, fd, offset);} #ifndef NOALIGN + void* old_addr = addr; if(flags&0x40) { // 0x40 is MAP_32BIT, wich only exist on x86_64! //flags &= ~0x40; // let the flags in? @@ -2019,7 +2020,7 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot addr = find32bitBlock(length); else addr = findBlockNearHint(addr, length); - } else if (box64_wine) { + } else /*if (box64_wine)*/ { if(!addr) addr = find47bitBlock(length); } @@ -2027,12 +2028,18 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot void* ret = mmap64(addr, length, prot, flags, fd, offset); if((ret!=(void*)-1) && (flags&0x40) && ((uintptr_t)ret>0xffffffff)) { printf_log(LOG_INFO, "Warning, mmap on 32bits didn't worked, ask %p, got %p ", addr, ret); - // the 32bit mmap didn't worded, lets try again munmap(ret, length); loadProtectionFromMap(); // reload map, because something went wrong previously addr = findBlockNearHint(addr, length); // is this the best way? ret = mmap64(addr, length, prot, flags, fd, offset); printf_log(LOG_INFO, " tried again with %p, got %p\n", addr, ret); + } else if((ret!=(void*)-1) && (old_addr==NULL) && ((uintptr_t)ret>0x7fffffffffffLL)) { + printf_log(LOG_INFO, "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? + ret = mmap64(addr, length, prot, flags, fd, offset); + printf_log(LOG_INFO, " tried again with %p, got %p\n", addr, ret); } if(box64_log