diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-03-25 10:34:10 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-03-25 10:34:10 +0100 |
| commit | 636c350461670f2c8e216bf33d82f239aa934318 (patch) | |
| tree | 57e0a2237a328b5a62bb07ab27295d379467c7a0 /src | |
| parent | 89e305878b683ee1ec5bd3cc60e94477fb9961a4 (diff) | |
| download | box64-636c350461670f2c8e216bf33d82f239aa934318.tar.gz box64-636c350461670f2c8e216bf33d82f239aa934318.zip | |
Added wrapped mmap64 and friends
Diffstat (limited to 'src')
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 3 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 6 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 3 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 33 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc_private.h | 10 |
5 files changed, 21 insertions, 34 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 70fcf17d..f24622f9 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -381,6 +381,7 @@ #() iFEipV #() iFEupp #() iFEpip +#() iFEpLi #() iFEppi #() iFEppL #() iFEppp @@ -716,6 +717,7 @@ #() pFEpuipp #() pFEpuupp #() pFEpuppp +#() pFEpLLiN #() pFEppLLp #() pFEpppLp #() pFEppppp @@ -791,6 +793,7 @@ #() iFppppdpi #() iFppppppp #() uFuippppp +#() pFEpLiiiI #() pFEppppip #() pFifffppp #() pFuupupup diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 2331678f..60ee37a1 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -414,6 +414,7 @@ typedef int32_t (*iFEipp_t)(x64emu_t*, int32_t, void*, void*); typedef int32_t (*iFEipV_t)(x64emu_t*, int32_t, void*, void*); typedef int32_t (*iFEupp_t)(x64emu_t*, uint32_t, void*, void*); typedef int32_t (*iFEpip_t)(x64emu_t*, void*, int32_t, void*); +typedef int32_t (*iFEpLi_t)(x64emu_t*, void*, uintptr_t, int32_t); typedef int32_t (*iFEppi_t)(x64emu_t*, void*, void*, int32_t); typedef int32_t (*iFEppL_t)(x64emu_t*, void*, void*, uintptr_t); typedef int32_t (*iFEppp_t)(x64emu_t*, void*, void*, void*); @@ -749,6 +750,7 @@ typedef void* (*pFEpippp_t)(x64emu_t*, void*, int32_t, void*, void*, void*); typedef void* (*pFEpuipp_t)(x64emu_t*, void*, uint32_t, int32_t, void*, void*); typedef void* (*pFEpuupp_t)(x64emu_t*, void*, uint32_t, uint32_t, void*, void*); typedef void* (*pFEpuppp_t)(x64emu_t*, void*, uint32_t, void*, void*, void*); +typedef void* (*pFEpLLiN_t)(x64emu_t*, void*, uintptr_t, uintptr_t, int32_t, ...); typedef void* (*pFEppLLp_t)(x64emu_t*, void*, void*, uintptr_t, uintptr_t, void*); typedef void* (*pFEpppLp_t)(x64emu_t*, void*, void*, void*, uintptr_t, void*); typedef void* (*pFEppppp_t)(x64emu_t*, void*, void*, void*, void*, void*); @@ -824,6 +826,7 @@ typedef int32_t (*iFppppiii_t)(void*, void*, void*, void*, int32_t, int32_t, int typedef int32_t (*iFppppdpi_t)(void*, void*, void*, void*, double, void*, int32_t); typedef int32_t (*iFppppppp_t)(void*, void*, void*, void*, void*, void*, void*); typedef uint32_t (*uFuippppp_t)(uint32_t, int32_t, void*, void*, void*, void*, void*); +typedef void* (*pFEpLiiiI_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, int32_t, int64_t); typedef void* (*pFEppppip_t)(x64emu_t*, void*, void*, void*, void*, int32_t, void*); typedef void* (*pFifffppp_t)(int32_t, float, float, float, void*, void*, void*); typedef void* (*pFuupupup_t)(uint32_t, uint32_t, void*, uint32_t, void*, uint32_t, void*); @@ -1378,6 +1381,7 @@ void iFEipp(x64emu_t *emu, uintptr_t fcn) { iFEipp_t fn = (iFEipp_t)fcn; R_RAX=f void iFEipV(x64emu_t *emu, uintptr_t fcn) { iFEipV_t fn = (iFEipV_t)fcn; R_RAX=fn(emu, (int32_t)R_RDI, (void*)R_RSI, (void*)(R_RSP + 8)); } void iFEupp(x64emu_t *emu, uintptr_t fcn) { iFEupp_t fn = (iFEupp_t)fcn; R_RAX=fn(emu, (uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX); } void iFEpip(x64emu_t *emu, uintptr_t fcn) { iFEpip_t fn = (iFEpip_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX); } +void iFEpLi(x64emu_t *emu, uintptr_t fcn) { iFEpLi_t fn = (iFEpLi_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX); } void iFEppi(x64emu_t *emu, uintptr_t fcn) { iFEppi_t fn = (iFEppi_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX); } void iFEppL(x64emu_t *emu, uintptr_t fcn) { iFEppL_t fn = (iFEppL_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX); } void iFEppp(x64emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX); } @@ -1713,6 +1717,7 @@ void pFEpippp(x64emu_t *emu, uintptr_t fcn) { pFEpippp_t fn = (pFEpippp_t)fcn; R void pFEpuipp(x64emu_t *emu, uintptr_t fcn) { pFEpuipp_t fn = (pFEpuipp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (int32_t)R_RDX, (void*)R_RCX, (void*)R_R8); } void pFEpuupp(x64emu_t *emu, uintptr_t fcn) { pFEpuupp_t fn = (pFEpuupp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (void*)R_RCX, (void*)R_R8); } void pFEpuppp(x64emu_t *emu, uintptr_t fcn) { pFEpuppp_t fn = (pFEpuppp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); } +void pFEpLLiN(x64emu_t *emu, uintptr_t fcn) { pFEpLLiN_t fn = (pFEpLLiN_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (uintptr_t)R_RDX, (int32_t)R_RCX, (void*)R_R8); } void pFEppLLp(x64emu_t *emu, uintptr_t fcn) { pFEppLLp_t fn = (pFEppLLp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (uintptr_t)R_RCX, (void*)R_R8); } void pFEpppLp(x64emu_t *emu, uintptr_t fcn) { pFEpppLp_t fn = (pFEpppLp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX, (void*)R_R8); } void pFEppppp(x64emu_t *emu, uintptr_t fcn) { pFEppppp_t fn = (pFEppppp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); } @@ -1788,6 +1793,7 @@ void iFppppiii(x64emu_t *emu, uintptr_t fcn) { iFppppiii_t fn = (iFppppiii_t)fcn void iFppppdpi(x64emu_t *emu, uintptr_t fcn) { iFppppdpi_t fn = (iFppppdpi_t)fcn; R_RAX=fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, emu->xmm[0].d[0], (void*)R_R8, (int32_t)R_R9); } void iFppppppp(x64emu_t *emu, uintptr_t fcn) { iFppppppp_t fn = (iFppppppp_t)fcn; R_RAX=fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } void uFuippppp(x64emu_t *emu, uintptr_t fcn) { uFuippppp_t fn = (uFuippppp_t)fcn; R_RAX=(uint32_t)fn((uint32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } +void pFEpLiiiI(x64emu_t *emu, uintptr_t fcn) { pFEpLiiiI_t fn = (pFEpLiiiI_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (int64_t)R_R9); } void pFEppppip(x64emu_t *emu, uintptr_t fcn) { pFEppppip_t fn = (pFEppppip_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8, (void*)R_R9); } void pFifffppp(x64emu_t *emu, uintptr_t fcn) { pFifffppp_t fn = (pFifffppp_t)fcn; R_RAX=(uintptr_t)fn((int32_t)R_RDI, emu->xmm[0].f[0], emu->xmm[1].f[0], emu->xmm[2].f[0], (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); } void pFuupupup(x64emu_t *emu, uintptr_t fcn) { pFuupupup_t fn = (pFuupupup_t)fcn; R_RAX=(uintptr_t)fn((uint32_t)R_RDI, (uint32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (void*)R_R8, (uint32_t)R_R9, *(void**)(R_RSP + 8)); } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index 002bdee5..77caae6a 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -411,6 +411,7 @@ void iFEipp(x64emu_t *emu, uintptr_t fnc); void iFEipV(x64emu_t *emu, uintptr_t fnc); void iFEupp(x64emu_t *emu, uintptr_t fnc); void iFEpip(x64emu_t *emu, uintptr_t fnc); +void iFEpLi(x64emu_t *emu, uintptr_t fnc); void iFEppi(x64emu_t *emu, uintptr_t fnc); void iFEppL(x64emu_t *emu, uintptr_t fnc); void iFEppp(x64emu_t *emu, uintptr_t fnc); @@ -746,6 +747,7 @@ void pFEpippp(x64emu_t *emu, uintptr_t fnc); void pFEpuipp(x64emu_t *emu, uintptr_t fnc); void pFEpuupp(x64emu_t *emu, uintptr_t fnc); void pFEpuppp(x64emu_t *emu, uintptr_t fnc); +void pFEpLLiN(x64emu_t *emu, uintptr_t fnc); void pFEppLLp(x64emu_t *emu, uintptr_t fnc); void pFEpppLp(x64emu_t *emu, uintptr_t fnc); void pFEppppp(x64emu_t *emu, uintptr_t fnc); @@ -821,6 +823,7 @@ void iFppppiii(x64emu_t *emu, uintptr_t fnc); void iFppppdpi(x64emu_t *emu, uintptr_t fnc); void iFppppppp(x64emu_t *emu, uintptr_t fnc); void uFuippppp(x64emu_t *emu, uintptr_t fnc); +void pFEpLiiiI(x64emu_t *emu, uintptr_t fnc); void pFEppppip(x64emu_t *emu, uintptr_t fnc); void pFifffppp(x64emu_t *emu, uintptr_t fnc); void pFuupupup(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 516a671f..812c1d2d 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -1971,38 +1971,12 @@ EXPORT void* my_realpath(x64emu_t* emu, void* path, void* resolved_path) } return realpath(path, resolved_path); } -#if 0 -EXPORT void* my_mmap(x64emu_t* emu, void *addr, unsigned long length, int prot, int flags, int fd, int offset) -{ - if(prot&PROT_WRITE) - prot|=PROT_READ; // PROT_READ is implicit with PROT_WRITE on i386 - if(box64_log<LOG_DEBUG) {dynarec_log(LOG_DEBUG, "mmap(%p, %lu, 0x%x, 0x%x, %d, %d) =>", addr, length, prot, flags, fd, offset);} - void* ret = mmap(addr, length, prot, flags, fd, offset); - if(box64_log<LOG_DEBUG) {dynarec_log(LOG_DEBUG, "%p\n", ret);} - #ifdef DYNAREC - if(box64_dynarec && ret!=(void*)-1) { - if(flags&0x100000 && addr!=ret) - { - // program used MAP_FIXED_NOREPLACE but the host linux didn't support it - // and responded with a different address, so ignore it - } else { - if(prot& PROT_EXEC) - addDBFromAddressRange((uintptr_t)ret, length); - else - cleanDBFromAddressRange((uintptr_t)ret, length, prot?0:1); - } - } - #endif - if(ret!=(void*)-1) - setProtection((uintptr_t)ret, length, prot); - return ret; -} EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot, int flags, int fd, int64_t offset) { if(prot&PROT_WRITE) prot|=PROT_READ; // PROT_READ is implicit with PROT_WRITE on i386 - if(box64_log<LOG_DEBUG) {dynarec_log(LOG_DEBUG, "mmap64(%p, %lu, 0x%x, 0x%x, %d, %lld) =>", addr, length, prot, flags, fd, offset);} + if(box64_log<LOG_DEBUG) {dynarec_log(LOG_DEBUG, "mmap64(%p, %lu, 0x%x, 0x%x, %d, %ld) =>", addr, length, prot, flags, fd, offset);} void* ret = mmap64(addr, length, prot, flags, fd, offset); if(box64_log<LOG_DEBUG) {dynarec_log(LOG_DEBUG, "%p\n", ret);} #ifdef DYNAREC @@ -2023,10 +1997,11 @@ EXPORT void* my_mmap64(x64emu_t* emu, void *addr, unsigned long length, int prot setProtection((uintptr_t)ret, length, prot); return ret; } +EXPORT void* my_mmap(x64emu_t* emu, void *addr, unsigned long length, int prot, int flags, int fd, int64_t offset) __attribute__((alias("my_mmap64"))); EXPORT void* my_mremap(x64emu_t* emu, void* old_addr, size_t old_size, size_t new_size, int flags, void* new_addr) { - dynarec_log(/*LOG_DEBUG*/LOG_NONE, "mremap(%p, %u, %u, %d, %p)=>", old_addr, old_size, new_size, flags, new_addr); + dynarec_log(/*LOG_DEBUG*/LOG_NONE, "mremap(%p, %lu, %lu, %d, %p)=>", old_addr, old_size, new_size, flags, new_addr); void* ret = mremap(old_addr, old_size, new_size, flags, new_addr); if(ret==(void*)-1) return ret; // failed... @@ -2104,7 +2079,7 @@ EXPORT int my_mprotect(x64emu_t* emu, void *addr, unsigned long len, int prot) updateProtection((uintptr_t)addr, len, prot); return ret; } - +#if 0 typedef struct my_cookie_s { uintptr_t r, w, s, c; void* cookie; diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index feeb3607..6568f2d9 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -1162,8 +1162,8 @@ GO(mlock, iFpL) //GO(mlock2, GO(mlockall, iFi) //GO(__mmap, -//GOW(mmap, -//GOW(mmap64, +GOW(mmap, pFEpLiiiI) +GOW(mmap64, pFEpLiiiI) //GOW(modf, //GOW(modff, //GOW(modfl, @@ -1175,10 +1175,10 @@ GO(mlockall, iFi) //GOW(mount, //GO(mprobe, //GO(__mprotect, -//GOW(mprotect, +GOW(mprotect, iFEpLi) //GO(mrand48, //GO(mrand48_r, -//GOW(mremap, +GOW(mremap, pFEpLLiN) //GO(msgctl, //GO(msgget, //GOW(msgrcv, @@ -1188,7 +1188,7 @@ GO(mlockall, iFi) //GO(munlock, //GO(munlockall, //GO(__munmap, -//GOW(munmap, +GOW(munmap, iFEpL) //GO(muntrace, GO(name_to_handle_at, iFipppi) GO(__nanosleep, iFpp) |