diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2021-03-13 13:11:06 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2021-03-13 13:11:06 +0100 |
| commit | ae4f43fdb99f4381525596c2790ed89fec9ab6da (patch) | |
| tree | 44da102242e5ed278f3294fddf0422627140949b /src | |
| parent | 4ce40ad239b2d172f18f2c016db8251b9adc6223 (diff) | |
| download | box64-ae4f43fdb99f4381525596c2790ed89fec9ab6da.tar.gz box64-ae4f43fdb99f4381525596c2790ed89fec9ab6da.zip | |
Added many wrapped function, and fixed a few one too
Diffstat (limited to 'src')
| -rwxr-xr-x | src/emu/x64int3.c | 5 | ||||
| -rwxr-xr-x | src/emu/x64syscall.c | 1 | ||||
| -rwxr-xr-x | src/include/myalign.h | 1 | ||||
| -rwxr-xr-x | src/libtools/myalign.c | 93 | ||||
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 6 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 11 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 6 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 75 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc_private.h | 58 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibpthread_private.h | 13 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibx11.c | 53 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibx11_private.h | 7 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibxxf86vm.c | 28 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibxxf86vm_private.h | 5 |
14 files changed, 248 insertions, 114 deletions
diff --git a/src/emu/x64int3.c b/src/emu/x64int3.c index a138ef0e..645d551e 100755 --- a/src/emu/x64int3.c +++ b/src/emu/x64int3.c @@ -103,8 +103,11 @@ void x64Int3(x64emu_t* emu) } else if(strstr(s, "my___printf_chk")) { tmp = (char*)(R_RSI); snprintf(buff, 255, "%04d|%p: Calling %s(%d, \"%s\" (,%p))", tid, *(void**)(R_RSP), s, R_EDI, (tmp)?tmp:"(nil)", (void*)(R_RDX)); + } else if(!strcmp(s, "sscanf")) { + tmp = (char*)(R_RSI); + snprintf(buff, 255, "%04d|%p: Calling %s(%p, \"%s\" (,%p))", tid, *(void**)(R_RSP), s, (void*)R_RDI, (tmp)?tmp:"(nil)", (void*)(R_RDX)); } else { - snprintf(buff, 255, "%04d|%p: Calling %s (0x%lX, 0x%lX, 0x%lX, ...)", tid, *(void**)(R_RSP), s, R_RDI, R_RSI, R_RDX); + snprintf(buff, 255, "%04d|%p: Calling %s(0x%lX, 0x%lX, 0x%lX, ...)", tid, *(void**)(R_RSP), s, R_RDI, R_RSI, R_RDX); } printf_log(LOG_NONE, "%s =>", buff); pthread_mutex_unlock(&emu->context->mutex_trace); diff --git a/src/emu/x64syscall.c b/src/emu/x64syscall.c index 2b26e17f..bec0562b 100755 --- a/src/emu/x64syscall.c +++ b/src/emu/x64syscall.c @@ -68,6 +68,7 @@ scwrap_t syscallwrap[] = { //{ 3, __NR_close, 1 }, // wrapped so SA_RESTART can be handled by libc { 5, __NR_fstat, 2}, + { 186, __NR_gettid, 0 }, }; struct mmap_arg_struct { diff --git a/src/include/myalign.h b/src/include/myalign.h index a222e3ff..9ffc42d9 100755 --- a/src/include/myalign.h +++ b/src/include/myalign.h @@ -86,6 +86,7 @@ typedef struct x64emu_s x64emu_t; // 1st pos is of vaarg is 0, not 1! void myStackAlign(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystack, int xmm, int pos); +void myStackAlignScanf(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystack, int pos); void myStackAlignGVariantNew(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystack, int xmm, int pos); void myStackAlignW(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystack, int xmm, int pos); diff --git a/src/libtools/myalign.c b/src/libtools/myalign.c index 662dd120..b42cc705 100755 --- a/src/libtools/myalign.c +++ b/src/libtools/myalign.c @@ -142,6 +142,99 @@ void myStackAlign(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystac } } +void myStackAlignScanf(x64emu_t* emu, const char* fmt, uint64_t* st, uint64_t* mystack, int pos) +{ + + if(!fmt) + return; + // loop... + const char* p = fmt; + int state = 0; + while(*p) + { + switch(state) { + case 0: + switch(*p) { + case '%': state = 1; ++p; break; + default: + ++p; + } + break; + case 1: // normal + case 2: // l + case 3: // ll + case 4: // L + switch(*p) { + case '%': state = 0; ++p; break; //%% = back to 0 + case 'l': ++state; if (state>3) state=3; ++p; break; + case 'L': state = 4; ++p; break; + case 'a': + case 'A': + case 'e': + case 'E': + case 'g': + case 'G': + case 'F': + case 'f': state += 10; break; // float + case 'd': + case 'i': + case 'o': + case 'u': + case 'x': + case 'X': state += 20; break; // int + case 'h': ++p; break; // ignored... + case '\'': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '.': + case '+': + case '-': ++p; break; // formating, ignored + case 'm': state = 0; ++p; break; // no argument + case 'n': + case 'p': + case 'S': + case 's': state = 30; break; // pointers + case '$': ++p; break; // should issue a warning, it's not handled... + case '*': *(mystack++) = *(st++); ++p; break; // fetch an int in the stack.... + case ' ': state=0; ++p; break; + default: + state=20; // other stuff, put an int... + } + break; + case 11: //double + case 12: //%lg, still double + case 13: //%llg, still double + case 14: //%LG long double + case 20: // fallback + case 21: + case 22: + case 23: // 64bits int + case 24: // normal int / pointer + case 30: + if(pos<6) + *mystack = emu->regs[regs_abi[pos++]].q[0]; + else { + *mystack = *st; + ++st; + } + ++mystack; + state = 0; + ++p; + break; + default: + // whattt? + state = 0; + } + } +} #if 0 void myStackAlignGVariantNew(const char* fmt, uint32_t* st, uint32_t* mystack) { diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 2379470c..d34f086d 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -427,6 +427,7 @@ #() lFipLl #() LFpuuu #() LFpLLp +#() LFpLpp #() LFppii #() pFEipp #() pFEupp @@ -535,6 +536,7 @@ #() iFEpipp #() iFEpipV #() iFEpLpp +#() iFEpLpV #() iFEppip #() iFEppiV #() iFEpppp @@ -573,7 +575,9 @@ #() uFpuuuu #() uFppiip #() uFppppp +#() LFLpppp #() LFpLLLp +#() LFpLppL #() LFppppp #() pFEpiii #() pFEpipL @@ -740,6 +744,7 @@ #() vFppiiipi #() vFpppiiii #() vFppppipi +#() iFEpLiLpV #() iFEppLpIi #() iFEpppiiu #() iFEpppppp @@ -930,5 +935,6 @@ #() pFppv -> pFpp #() iFEvpp -> iFEpp #() iFEpvpp -> iFEppp +#() iFEpvvppp -> iFEpppp #() iFEpLvvpp -> iFEpLpp #() iFEpuvvppp -> iFEpuppp diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 224afce3..fa9f89cc 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -460,6 +460,7 @@ typedef intptr_t (*lFipLI_t)(int32_t, void*, uintptr_t, int64_t); typedef intptr_t (*lFipLl_t)(int32_t, void*, uintptr_t, intptr_t); typedef uintptr_t (*LFpuuu_t)(void*, uint32_t, uint32_t, uint32_t); typedef uintptr_t (*LFpLLp_t)(void*, uintptr_t, uintptr_t, void*); +typedef uintptr_t (*LFpLpp_t)(void*, uintptr_t, void*, void*); typedef uintptr_t (*LFppii_t)(void*, void*, int32_t, int32_t); typedef void* (*pFEipp_t)(x64emu_t*, int32_t, void*, void*); typedef void* (*pFEupp_t)(x64emu_t*, uint32_t, void*, void*); @@ -568,6 +569,7 @@ typedef int32_t (*iFEpipi_t)(x64emu_t*, void*, int32_t, void*, int32_t); typedef int32_t (*iFEpipp_t)(x64emu_t*, void*, int32_t, void*, void*); typedef int32_t (*iFEpipV_t)(x64emu_t*, void*, int32_t, void*, void*); typedef int32_t (*iFEpLpp_t)(x64emu_t*, void*, uintptr_t, void*, void*); +typedef int32_t (*iFEpLpV_t)(x64emu_t*, void*, uintptr_t, void*, void*); typedef int32_t (*iFEppip_t)(x64emu_t*, void*, void*, int32_t, void*); typedef int32_t (*iFEppiV_t)(x64emu_t*, void*, void*, int32_t, void*); typedef int32_t (*iFEpppp_t)(x64emu_t*, void*, void*, void*, void*); @@ -606,7 +608,9 @@ typedef uint32_t (*uFpCCCC_t)(void*, uint8_t, uint8_t, uint8_t, uint8_t); typedef uint32_t (*uFpuuuu_t)(void*, uint32_t, uint32_t, uint32_t, uint32_t); typedef uint32_t (*uFppiip_t)(void*, void*, int32_t, int32_t, void*); typedef uint32_t (*uFppppp_t)(void*, void*, void*, void*, void*); +typedef uintptr_t (*LFLpppp_t)(uintptr_t, void*, void*, void*, void*); typedef uintptr_t (*LFpLLLp_t)(void*, uintptr_t, uintptr_t, uintptr_t, void*); +typedef uintptr_t (*LFpLppL_t)(void*, uintptr_t, void*, void*, uintptr_t); typedef uintptr_t (*LFppppp_t)(void*, void*, void*, void*, void*); typedef void* (*pFEpiii_t)(x64emu_t*, void*, int32_t, int32_t, int32_t); typedef void* (*pFEpipL_t)(x64emu_t*, void*, int32_t, void*, uintptr_t); @@ -773,6 +777,7 @@ typedef void (*vFpddiidd_t)(void*, double, double, int32_t, int32_t, double, dou typedef void (*vFppiiipi_t)(void*, void*, int32_t, int32_t, int32_t, void*, int32_t); typedef void (*vFpppiiii_t)(void*, void*, void*, int32_t, int32_t, int32_t, int32_t); typedef void (*vFppppipi_t)(void*, void*, void*, void*, int32_t, void*, int32_t); +typedef int32_t (*iFEpLiLpV_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, void*, void*); typedef int32_t (*iFEppLpIi_t)(x64emu_t*, void*, void*, uintptr_t, void*, int64_t, int32_t); typedef int32_t (*iFEpppiiu_t)(x64emu_t*, void*, void*, void*, int32_t, int32_t, uint32_t); typedef int32_t (*iFEpppppp_t)(x64emu_t*, void*, void*, void*, void*, void*, void*); @@ -1393,6 +1398,7 @@ void lFipLI(x64emu_t *emu, uintptr_t fcn) { lFipLI_t fn = (lFipLI_t)fcn; R_RAX=( void lFipLl(x64emu_t *emu, uintptr_t fcn) { lFipLl_t fn = (lFipLl_t)fcn; R_RAX=(intptr_t)fn((int32_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (intptr_t)R_RCX); } void LFpuuu(x64emu_t *emu, uintptr_t fcn) { LFpuuu_t fn = (LFpuuu_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX); } void LFpLLp(x64emu_t *emu, uintptr_t fcn) { LFpLLp_t fn = (LFpLLp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uintptr_t)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX); } +void LFpLpp(x64emu_t *emu, uintptr_t fcn) { LFpLpp_t fn = (LFpLpp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX, (void*)R_RCX); } void LFppii(x64emu_t *emu, uintptr_t fcn) { LFppii_t fn = (LFppii_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); } void pFEipp(x64emu_t *emu, uintptr_t fcn) { pFEipp_t fn = (pFEipp_t)fcn; R_RAX=(uintptr_t)fn(emu, (int32_t)R_RDI, (void*)R_RSI, (void*)R_RDX); } void pFEupp(x64emu_t *emu, uintptr_t fcn) { pFEupp_t fn = (pFEupp_t)fcn; R_RAX=(uintptr_t)fn(emu, (uint32_t)R_RDI, (void*)R_RSI, (void*)R_RDX); } @@ -1501,6 +1507,7 @@ void iFEpipi(x64emu_t *emu, uintptr_t fcn) { iFEpipi_t fn = (iFEpipi_t)fcn; R_RA void iFEpipp(x64emu_t *emu, uintptr_t fcn) { iFEpipp_t fn = (iFEpipp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX); } void iFEpipV(x64emu_t *emu, uintptr_t fcn) { iFEpipV_t fn = (iFEpipV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)(R_RSP + 8)); } void iFEpLpp(x64emu_t *emu, uintptr_t fcn) { iFEpLpp_t fn = (iFEpLpp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX, (void*)R_RCX); } +void iFEpLpV(x64emu_t *emu, uintptr_t fcn) { iFEpLpV_t fn = (iFEpLpV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX, (void*)(R_RSP + 8)); } void iFEppip(x64emu_t *emu, uintptr_t fcn) { iFEppip_t fn = (iFEppip_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)R_RCX); } void iFEppiV(x64emu_t *emu, uintptr_t fcn) { iFEppiV_t fn = (iFEppiV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (void*)(R_RSP + 8)); } void iFEpppp(x64emu_t *emu, uintptr_t fcn) { iFEpppp_t fn = (iFEpppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); } @@ -1539,7 +1546,9 @@ void uFpCCCC(x64emu_t *emu, uintptr_t fcn) { uFpCCCC_t fn = (uFpCCCC_t)fcn; R_RA void uFpuuuu(x64emu_t *emu, uintptr_t fcn) { uFpuuuu_t fn = (uFpuuuu_t)fcn; R_RAX=(uint32_t)fn((void*)R_RDI, (uint32_t)R_RSI, (uint32_t)R_RDX, (uint32_t)R_RCX, (uint32_t)R_R8); } void uFppiip(x64emu_t *emu, uintptr_t fcn) { uFppiip_t fn = (uFppiip_t)fcn; R_RAX=(uint32_t)fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (void*)R_R8); } void uFppppp(x64emu_t *emu, uintptr_t fcn) { uFppppp_t fn = (uFppppp_t)fcn; R_RAX=(uint32_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); } +void LFLpppp(x64emu_t *emu, uintptr_t fcn) { LFLpppp_t fn = (LFLpppp_t)fcn; R_RAX=(uintptr_t)fn((uintptr_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); } void LFpLLLp(x64emu_t *emu, uintptr_t fcn) { LFpLLLp_t fn = (LFpLLLp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uintptr_t)R_RSI, (uintptr_t)R_RDX, (uintptr_t)R_RCX, (void*)R_R8); } +void LFpLppL(x64emu_t *emu, uintptr_t fcn) { LFpLppL_t fn = (LFpLppL_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (uintptr_t)R_R8); } void LFppppp(x64emu_t *emu, uintptr_t fcn) { LFppppp_t fn = (LFppppp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8); } void pFEpiii(x64emu_t *emu, uintptr_t fcn) { pFEpiii_t fn = (pFEpiii_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); } void pFEpipL(x64emu_t *emu, uintptr_t fcn) { pFEpipL_t fn = (pFEpipL_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX); } @@ -1706,6 +1715,7 @@ void vFpddiidd(x64emu_t *emu, uintptr_t fcn) { vFpddiidd_t fn = (vFpddiidd_t)fcn void vFppiiipi(x64emu_t *emu, uintptr_t fcn) { vFppiiipi_t fn = (vFppiiipi_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (void*)R_R9, *(int32_t*)(R_RSP + 8)); } void vFpppiiii(x64emu_t *emu, uintptr_t fcn) { vFpppiiii_t fn = (vFpppiiii_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (int32_t)R_R9, *(int32_t*)(R_RSP + 8)); } void vFppppipi(x64emu_t *emu, uintptr_t fcn) { vFppppipi_t fn = (vFppppipi_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8, (void*)R_R9, *(int32_t*)(R_RSP + 8)); } +void iFEpLiLpV(x64emu_t *emu, uintptr_t fcn) { iFEpLiLpV_t fn = (iFEpLiLpV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)(R_RSP + 8)); } void iFEppLpIi(x64emu_t *emu, uintptr_t fcn) { iFEppLpIi_t fn = (iFEppLpIi_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX, (int64_t)R_R8, (int32_t)R_R9); } void iFEpppiiu(x64emu_t *emu, uintptr_t fcn) { iFEpppiiu_t fn = (iFEpppiiu_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX, (int32_t)R_R8, (uint32_t)R_R9); } void iFEpppppp(x64emu_t *emu, uintptr_t fcn) { iFEpppppp_t fn = (iFEpppppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); } @@ -1903,5 +1913,6 @@ void pFEv(x64emu_t *emu, uintptr_t fcn) { pFE_t fn = (pFE_t)fcn; R_RAX=(uintptr_ void pFppv(x64emu_t *emu, uintptr_t fcn) { pFpp_t fn = (pFpp_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (void*)R_RSI); } void iFEvpp(x64emu_t *emu, uintptr_t fcn) { iFEpp_t fn = (iFEpp_t)fcn; R_RAX=fn(emu, (void*)R_RSI, (void*)R_RDX); } void iFEpvpp(x64emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RDX, (void*)R_RCX); } +void iFEpvvppp(x64emu_t *emu, uintptr_t fcn) { iFEpppp_t fn = (iFEpppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RCX, (void*)R_R8, (void*)R_R9); } void iFEpLvvpp(x64emu_t *emu, uintptr_t fcn) { iFEpLpp_t fn = (iFEpLpp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (void*)R_R8, (void*)R_R9); } void iFEpuvvppp(x64emu_t *emu, uintptr_t fcn) { iFEpuppp_t fn = (iFEpuppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index 88ee6c40..88b969a9 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -457,6 +457,7 @@ void lFipLI(x64emu_t *emu, uintptr_t fnc); void lFipLl(x64emu_t *emu, uintptr_t fnc); void LFpuuu(x64emu_t *emu, uintptr_t fnc); void LFpLLp(x64emu_t *emu, uintptr_t fnc); +void LFpLpp(x64emu_t *emu, uintptr_t fnc); void LFppii(x64emu_t *emu, uintptr_t fnc); void pFEipp(x64emu_t *emu, uintptr_t fnc); void pFEupp(x64emu_t *emu, uintptr_t fnc); @@ -565,6 +566,7 @@ void iFEpipi(x64emu_t *emu, uintptr_t fnc); void iFEpipp(x64emu_t *emu, uintptr_t fnc); void iFEpipV(x64emu_t *emu, uintptr_t fnc); void iFEpLpp(x64emu_t *emu, uintptr_t fnc); +void iFEpLpV(x64emu_t *emu, uintptr_t fnc); void iFEppip(x64emu_t *emu, uintptr_t fnc); void iFEppiV(x64emu_t *emu, uintptr_t fnc); void iFEpppp(x64emu_t *emu, uintptr_t fnc); @@ -603,7 +605,9 @@ void uFpCCCC(x64emu_t *emu, uintptr_t fnc); void uFpuuuu(x64emu_t *emu, uintptr_t fnc); void uFppiip(x64emu_t *emu, uintptr_t fnc); void uFppppp(x64emu_t *emu, uintptr_t fnc); +void LFLpppp(x64emu_t *emu, uintptr_t fnc); void LFpLLLp(x64emu_t *emu, uintptr_t fnc); +void LFpLppL(x64emu_t *emu, uintptr_t fnc); void LFppppp(x64emu_t *emu, uintptr_t fnc); void pFEpiii(x64emu_t *emu, uintptr_t fnc); void pFEpipL(x64emu_t *emu, uintptr_t fnc); @@ -770,6 +774,7 @@ void vFpddiidd(x64emu_t *emu, uintptr_t fnc); void vFppiiipi(x64emu_t *emu, uintptr_t fnc); void vFpppiiii(x64emu_t *emu, uintptr_t fnc); void vFppppipi(x64emu_t *emu, uintptr_t fnc); +void iFEpLiLpV(x64emu_t *emu, uintptr_t fnc); void iFEppLpIi(x64emu_t *emu, uintptr_t fnc); void iFEpppiiu(x64emu_t *emu, uintptr_t fnc); void iFEpppppp(x64emu_t *emu, uintptr_t fnc); @@ -967,6 +972,7 @@ void pFEv(x64emu_t *emu, uintptr_t fnc); void pFppv(x64emu_t *emu, uintptr_t fnc); void iFEvpp(x64emu_t *emu, uintptr_t fnc); void iFEpvpp(x64emu_t *emu, uintptr_t fnc); +void iFEpvvppp(x64emu_t *emu, uintptr_t fnc); void iFEpLvvpp(x64emu_t *emu, uintptr_t fnc); void iFEpuvvppp(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 4910c6ab..ef4c5c25 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -48,7 +48,7 @@ #include "emu/x64emu_private.h" #include "box64context.h" #include "myalign.h" -//#include "signals.h" +#include "signals.h" #include "fileutils.h" #include "auxval.h" #include "elfloader.h" @@ -681,22 +681,22 @@ EXPORT void *my_div(void *result, int numerator, int denominator) { *(div_t *)result = div(numerator, denominator); return result; } - -EXPORT int my_snprintf(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) { - #ifndef NOALIGN - // need to align on arm - myStackAlign((const char*)fmt, b, emu->scratch); +#endif +EXPORT int my_snprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, uint64_t * b) { + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 3); PREPARE_VALIST; - void* f = vsnprintf; - int r = ((iFpupp_t)f)(buff, s, fmt, VARARGS); + int r = vsnprintf(buff, s, fmt, VARARGS); return r; - #else - return vsnprintf((char*)buff, s, (char*)fmt, V); - #endif } -EXPORT int my___snprintf_chk(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) __attribute__((alias("my_snprintf"))); -EXPORT int my___snprintf(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) __attribute__((alias("my_snprintf"))); -#endif +EXPORT int my___snprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, uint64_t * b) __attribute__((alias("my_snprintf"))); +EXPORT int my___snprintf_chk(x64emu_t* emu, void* buff, size_t s, int flags, size_t maxlen, void * fmt, uint64_t * b) +{ + myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 5); + PREPARE_VALIST; + int r = vsnprintf(buff, s, fmt, VARARGS); + return r; +} + EXPORT int my_sprintf(x64emu_t* emu, void* buff, void * fmt, void * b) { myStackAlign(emu, (const char*)fmt, b, emu->scratch, R_EAX, 2); PREPARE_VALIST; @@ -720,48 +720,40 @@ EXPORT int my_asprintf(x64emu_t* emu, void** buff, void * fmt, void * b, va_list #endif } EXPORT int my___asprintf(x64emu_t* emu, void** buff, void * fmt, void * b, va_list V) __attribute__((alias("my_asprintf"))); +#endif +EXPORT int my_vsprintf(x64emu_t* emu, void* buff, void * fmt, x64_va_list_t b) { + CONVERT_VALIST(b); -EXPORT int my_vsprintf(x64emu_t* emu, void* buff, void * fmt, void * b, va_list V) { - #ifndef NOALIGN - // need to align on arm - myStackAlign((const char*)fmt, (uint32_t*)b, emu->scratch); - PREPARE_VALIST; - void* f = vsprintf; - int r = ((iFppp_t)f)(buff, fmt, VARARGS); - return r; - #else - void* f = vsprintf; - int r = ((iFppp_t)f)(buff, fmt, (uint32_t*)b); - return r; - #endif + return vsprintf(buff, fmt, VARARGS); } -EXPORT int my___vsprintf_chk(x64emu_t* emu, void* buff, void * fmt, void * b, va_list V) __attribute__((alias("my_vsprintf"))); +EXPORT int my___vsprintf_chk(x64emu_t* emu, void* buff, void * fmt, x64_va_list_t b) __attribute__((alias("my_vsprintf"))); -#ifdef POWERPCLE -EXPORT int my_vfscanf(x64emu_t* emu, void* stream, void* fmt, void* b) // probably uneeded to do a GOM, a simple wrap should enough +EXPORT int my_vfscanf(x64emu_t* emu, void* stream, void* fmt, x64_va_list_t b) { - //myStackAlign((const char*)fmt, (uint32_t*)b, emu->scratch); - PREPARE_VALIST_(b); - void* f = vfscanf; + CONVERT_VALIST(b); - return ((iFppp_t)f)(stream, fmt, VARARGS_(b)); + return vfscanf(stream, fmt, VARARGS); } -EXPORT int my_vsscanf(x64emu_t* emu, void* stream, void* fmt, void* b) +EXPORT int my_vsscanf(x64emu_t* emu, void* stream, void* fmt, x64_va_list_t b) { - //myStackAlign((const char*)fmt, (uint32_t*)b, emu->scratch); - PREPARE_VALIST_(b); - void* f = vsscanf; + CONVERT_VALIST(b); - return ((iFppp_t)f)(stream, fmt, VARARGS_(b)); + return vsscanf(stream, fmt, VARARGS); } EXPORT int my__vsscanf(x64emu_t* emu, void* stream, void* fmt, void* b) __attribute__((alias("my_vsscanf"))); -EXPORT int my_sscanf(x64emu_t* emu, void* stream, void* fmt, void* b) __attribute__((alias("my_vsscanf"))); +EXPORT int my_sscanf(x64emu_t* emu, void* stream, void* fmt, uint64_t* b) +{ + myStackAlignScanf(emu, (const char*)fmt, b, emu->scratch, 2); + PREPARE_VALIST; + return vsscanf(stream, fmt, VARARGS); +} +#if 0 EXPORT int my__IO_vfscanf(x64emu_t* emu, void* stream, void* fmt, void* b) __attribute__((alias("my_vfscanf"))); EXPORT int my___isoc99_vsscanf(x64emu_t* emu, void* stream, void* fmt, void* b) __attribute__((alias("my_vsscanf"))); @@ -776,7 +768,7 @@ EXPORT int my___isoc99_sscanf(x64emu_t* emu, void* stream, void* fmt, void* b) return ((iFppp_t)f)(stream, fmt, VARARGS); } #endif -#endif + EXPORT int my_vsnprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, x64_va_list_t b) { // need to align on arm CONVERT_VALIST(b); @@ -1281,7 +1273,6 @@ EXPORT int32_t my_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mo return tmp; } #endif -if(!strcmp(pathname, "data.zip")) trace_end=0; int ret = open(pathname, flags, mode); return ret; } diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index b3e52f85..ef636efa 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -666,12 +666,12 @@ GOW(getrlimit64, iFip) //GO(host2netname, //GO(hsearch, //GOW(hsearch_r, -//GO(hstrerror, -//GO(htonl, -//GO(htons, -//GO(iconv, -//GO(iconv_close, -//GO(iconv_open, +GO(hstrerror, pFi) +GO(htonl, uFu) +GO(htons, uFu) +GO(iconv, LFLpppp) +GO(iconv_close, iFL) +GO(iconv_open, LFpp) //GO(__idna_from_dns_encoding, //GO(__idna_to_dns_encoding, //GOW(if_freenameindex, @@ -1068,9 +1068,9 @@ GOM(__libc_start_main, iFEpippppp) //GO(llseek, //DATAB(loc1, //DATAB(loc2, -//GO(localeconv, -//GO(localtime, -//GOW(localtime_r, +GO(localeconv, pFv) +GO(localtime, pFp) +GOW(localtime_r, pFpp) //GO(lockf, //GOW(lockf64, //DATAB(locs, @@ -1157,7 +1157,7 @@ GOW(mkstemp64, iFp) //GOW(mkstemps64, GO(__mktemp, pFp) GOW(mktemp, pFp) -GO(mktime, uFp) +GO(mktime, LFp) GO(mlock, iFpL) //GO(mlock2, GO(mlockall, iFi) @@ -1285,9 +1285,9 @@ GO(openlog, vFpii) //GO(pclose, //GO(perror, //GOW(personality, -//GO(__pipe, -//GOW(pipe, -//GOW(pipe2, +GO(__pipe, iFp) +GOW(pipe, iFp) +GOW(pipe2, iFpO) //GO(pivot_root, //GO(pkey_alloc, //GO(pkey_free, @@ -1664,8 +1664,8 @@ GOW(setpriority, iFiii) //GOW(shutdown, GOM(__sigaction, iFEipp) // Weak GOM(sigaction, iFEipp) // Weak -//GO(__sigaddset, -//GO(sigaddset, +GO(__sigaddset, iFpi) +GO(sigaddset, iFpi) GOM(sigaltstack, iFEpp) // Weak //GO(sigandset, GOW(sigblock, iFi) @@ -1681,7 +1681,7 @@ GO(siggetmask, iFv) //GO(__sigismember, GO(sigismember, iFpi) //GOW(siglongjmp, -//GOW(signal, +GOM(signal, pFEip) //Weak //GO(signalfd, //GO(__signbit, //GO(__signbitf, @@ -1706,9 +1706,9 @@ GOM(__sigsetjmp, iFEp) //GOW(sigwait, //GOW(sigwaitinfo, GOW(sleep, uFu) -//GO(__snprintf, -//GOW(snprintf, -//GO(__snprintf_chk, +GOM(__snprintf, iFEpLpV) +GOM(snprintf, iFEpLpV) //Weak +GOM(__snprintf_chk, iFEpLiLpV) //Weak //GO(sockatmark, //GO(__socket, //GOW(socket, @@ -1722,7 +1722,7 @@ GOW(srand, vFu) //GOW(srand48_r, //GOW(srandom, //GOW(srandom_r, -//GO(sscanf, +GOM(sscanf, iFEppV) //GOW(ssignal, //GO(sstk, GOM(__stack_chk_fail, vFE) @@ -1783,9 +1783,9 @@ GO(strerror_l, pFip) //GOW(strfromf64x, //GO(strfroml, //GO(strfry, -//GO(strftime, -//GO(__strftime_l, -//GOW(strftime_l, +GO(strftime, LFpLpp) +GO(__strftime_l, LFpLppL) +GOW(strftime_l, LFpLppL) GO(strlen, LFp) GO(strncasecmp, iFppL) //GOI(__strncasecmp_l, @@ -1851,7 +1851,7 @@ GOW(strtol, lFppi) //GO(__strtol_internal, //GO(__strtol_l, //GOW(strtol_l, -//GOW(strtoll, +GOW(strtoll, lFppi) //GO(__strtoll_internal, //GOW(__strtoll_l, //GOW(strtoll_l, @@ -1860,7 +1860,7 @@ GOW(strtoul, LFppi) GO(__strtoul_internal, LFppii) //GO(__strtoul_l, //GOW(strtoul_l, -//GOW(strtoull, +GOW(strtoull, LFppi) //GO(__strtoull_internal, //GOW(__strtoull_l, //GOW(strtoull_l, @@ -2055,10 +2055,10 @@ GOM(__vprintf_chk, iFEvpp) GOM(__vsnprintf, iFEpLpp) // Weak GOM(vsnprintf, iFEpLpp) // Weak GOM(__vsnprintf_chk, iFEpLvvpp) -//GOW(vsprintf, -//GO(__vsprintf_chk, -//GOW(__vsscanf, -//GOW(vsscanf, +GOM(vsprintf, iFEpppp) //Weak +GOM(__vsprintf_chk, iFEpvvppp) +GOM(__vsscanf, iFEppp) //Weak +GOM(vsscanf, iFEppp) //Weak GOM(vswprintf, iFEpuppp) // Weak GOM(__vswprintf_chk, iFEpuvvppp) // Weak //GO(vswscanf, diff --git a/src/wrapped/wrappedlibpthread_private.h b/src/wrapped/wrappedlibpthread_private.h index 33c2b5d5..df32d63d 100755 --- a/src/wrapped/wrappedlibpthread_private.h +++ b/src/wrapped/wrappedlibpthread_private.h @@ -73,10 +73,9 @@ GO(pthread_equal, iFLL) //GO(pthread_getconcurrency, iFv) //GO(pthread_getcpuclockid, iFup) GO(pthread_getschedparam, iFLpp) -//GO(__pthread_getspecific, pFu) -//GO(pthread_getspecific, pFu) +GO(__pthread_getspecific, pFL) +GO(pthread_getspecific, pFL) //GOM(pthread_getname_np, iFEppu) //not present on Pandora -//GOM(__pthread_initialize, vFv) // doesn't exist anymore... // __pthread_initialize_minimal GO(pthread_join, iFLp) GOM(__pthread_key_create, iFEpp) @@ -158,10 +157,10 @@ GO(pthread_rwlock_rdlock, iFp) //GO2(pthread_rwlock_wrlock, iFp, __pthread_rwlock_wrlock) // not always defined GO(pthread_self, LFv) //GOM(pthread_setaffinity_np, iFELup) -//GO(pthread_setcancelstate, iFip) -//GO(pthread_setcanceltype, iFip) -//GO(pthread_setconcurrency, iFi) -//GOM(pthread_setname_np, iFEpp) // not present on the Pandora +GO(pthread_setcancelstate, iFip) +GO(pthread_setcanceltype, iFip) +GO(pthread_setconcurrency, iFi) +GO(pthread_setname_np, iFpp) GO(pthread_setschedparam, iFLip) GO(pthread_setschedprio, iFpi) GO(__pthread_setspecific, iFLp) diff --git a/src/wrapped/wrappedlibx11.c b/src/wrapped/wrappedlibx11.c index d207f79f..1c6ca8f3 100755 --- a/src/wrapped/wrappedlibx11.c +++ b/src/wrapped/wrappedlibx11.c @@ -84,6 +84,7 @@ typedef void (*vFp_t)(void*); typedef void* (*pFp_t)(void*); typedef void (*vFpp_t)(void*, void*); typedef void* (*pFpp_t)(void*, void*); +typedef void* (*pFpi_t)(void*, int32_t); typedef void* (*pFpip_t)(void*, int32_t, void*); typedef int32_t (*iFp_t)(void*); typedef int32_t (*iFpi_t)(void*, int32_t); @@ -133,6 +134,8 @@ typedef int (*iFpppppp_t)(void*, void*, void*, void*, void*, void*); GO(XQueryExtension, iFppppp_t) \ GO(XAddConnectionWatch, iFppp_t) \ GO(XRemoveConnectionWatch, iFppp_t) \ + GO(XSetAfterFunction, pFpp_t) \ + GO(XSynchronize, pFpi_t) \ typedef struct x11_my_s { // functions @@ -471,6 +474,40 @@ static void* findXInternalAsyncHandlerFct(void* fct) printf_log(LOG_NONE, "Warning, no more slot for libX11 XInternalAsyncHandler callback\n"); return NULL; } + +// XSynchronizeProc +#define GO(A) \ +static uintptr_t my_XSynchronizeProc_fct_##A = 0; \ +static int my_XSynchronizeProc_##A() \ +{ \ + return (int)RunFunction(my_context, my_XSynchronizeProc_fct_##A, 0);\ +} +SUPER() +#undef GO +static void* findXSynchronizeProcFct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_XSynchronizeProc_fct_##A == (uintptr_t)fct) return my_XSynchronizeProc_##A; + SUPER() + #undef GO + #define GO(A) if(my_XSynchronizeProc_fct_##A == 0) {my_XSynchronizeProc_fct_##A = (uintptr_t)fct; return my_XSynchronizeProc_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for libX11 XSynchronizeProc callback\n"); + return NULL; +} +static void* reverse_XSynchronizeProcFct(library_t* lib, void* fct) +{ + if(!fct) return fct; + if(CheckBridged(lib->priv.w.bridge, fct)) + return (void*)CheckBridged(lib->priv.w.bridge, fct); + #define GO(A) if(my_XSynchronizeProc_##A == fct) return (void*)my_XSynchronizeProc_fct_##A; + SUPER() + #undef GO + return (void*)AddBridge(lib->priv.w.bridge, iFppp, fct, 0, NULL); +} + #undef SUPER void* my_XCreateImage(x64emu_t* emu, void* disp, void* vis, uint32_t depth, int32_t fmt, int32_t off @@ -790,6 +827,22 @@ EXPORT int my_XRemoveConnectionWatch(x64emu_t* emu, void* display, char* f, void return my->XRemoveConnectionWatch(display, findXConnectionWatchProcFct(f), data); } +EXPORT void* my_XSetAfterFunction(x64emu_t* emu, void* display, void* f) +{ + library_t* lib = emu->context->x11lib; + x11_my_t *my = (x11_my_t *)lib->priv.w.p2; + + return reverse_XSynchronizeProcFct(lib, my->XSetAfterFunction(display, findXSynchronizeProcFct(f))); +} + +EXPORT void* my_XSynchronize(x64emu_t* emu, void* display, int onoff) +{ + library_t* lib = emu->context->x11lib; + x11_my_t *my = (x11_my_t *)lib->priv.w.p2; + + return reverse_XSynchronizeProcFct(lib, my->XSynchronize(display, onoff)); +} + #define CUSTOM_INIT \ box64->x11lib = lib; \ lib->priv.w.p2 = getX11My(lib); \ diff --git a/src/wrapped/wrappedlibx11_private.h b/src/wrapped/wrappedlibx11_private.h index 7579722f..c824579d 100755 --- a/src/wrapped/wrappedlibx11_private.h +++ b/src/wrapped/wrappedlibx11_private.h @@ -919,7 +919,7 @@ GO(_XSend, vFppi) GO(XSendEvent, uFppiip) GO(XServerVendor, pFp) GO(XSetAccessControl, iFpi) -//GO(XSetAfterFunction +GOM(XSetAfterFunction, pFEpp) GO(XSetArcMode, iFppi) //GO(XSetAuthorization GO(XSetBackground, iFppL) @@ -1001,7 +1001,7 @@ GO(dummy_XSubImage, pFpiiuu) // for the wrapper GO(XSubtractRegion, iFppp) GO(XSupportsLocale, iFv) GO(XSync, iFpu) -//GOM(XSynchronize, pFEpi) // Needs wrapping, return a function +GOM(XSynchronize, pFEpi) GO(XTextExtents, iFppipppp) GO(XTextExtents16, iFppipppp) // _XTextHeight @@ -1089,5 +1089,8 @@ GO(XWithdrawWindow, iFppi) //GO(XWriteBitmapFile GO(XXorRegion, iFppp) +GO(_XData32, iFppu) +GO(_XRead32, iFppL) + GO(dummy_putpixel, iFpiiL) GO(dummy_addpixel, iFpl) \ No newline at end of file diff --git a/src/wrapped/wrappedlibxxf86vm.c b/src/wrapped/wrappedlibxxf86vm.c index d05a3464..bc956d0b 100755 --- a/src/wrapped/wrappedlibxxf86vm.c +++ b/src/wrapped/wrappedlibxxf86vm.c @@ -20,34 +20,6 @@ const char* libxxf86vmName = "libXxf86vm.so.1"; #define LIBNAME libxxf86vm -#ifdef PANDORA -typedef struct my_XF86VidModeGamma_s { - float red; - float green; - float blue; -} my_XF86VidModeGamma_t; - -static my_XF86VidModeGamma_t current_gamma = {0}; - -EXPORT int my_XF86VidModeGetGamma(void* display, int screen, my_XF86VidModeGamma_t* gamma) -{ - memcpy(gamma, ¤t_gamma, sizeof(current_gamma)); - return 1; -} - -EXPORT int my_XF86VidModeSetGamma(void* display, int screen, my_XF86VidModeGamma_t* gamma) -{ - memcpy(¤t_gamma, gamma, sizeof(current_gamma)); - float mean = (current_gamma.red+current_gamma.green+current_gamma.blue)/3; - char buf[50]; - if(mean==0.0f) - sprintf(buf, "sudo /usr/pandora/scripts/op_gamma.sh 0"); - else - sprintf(buf, "sudo /usr/pandora/scripts/op_gamma.sh %.2f", mean); - system(buf); - return 1; -} -#endif #define CUSTOM_INIT \ lib->priv.w.needed = 2; \ diff --git a/src/wrapped/wrappedlibxxf86vm_private.h b/src/wrapped/wrappedlibxxf86vm_private.h index 05904e40..b418072b 100755 --- a/src/wrapped/wrappedlibxxf86vm_private.h +++ b/src/wrapped/wrappedlibxxf86vm_private.h @@ -4,13 +4,8 @@ GO(XF86VidModeGetViewPort, iFpipp) GO(XF86VidModeValidateModeLine, iFpip) -#ifdef PANDORA -GOM(XF86VidModeGetGamma, iFpip) -GOM(XF86VidModeSetGamma, iFpip) -#else GO(XF86VidModeGetGamma, iFpip) GO(XF86VidModeSetGamma, iFpip) -#endif GO(XF86VidModeSetClientVersion, iFp) GO(XF86VidModeGetGammaRamp, iFpiippp) GO(XF86VidModeGetMonitor, iFpip) |