diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-08-28 17:12:00 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-08-28 17:12:00 +0200 |
| commit | b7be225846153a1ed44b149b6600fb86c3fa0b42 (patch) | |
| tree | 5d8ccd52428f0f1e788dd80c612826d89d7a10a5 /src | |
| parent | 041eb4e69d833a4bf5f68df59c1fe20385b5ad9f (diff) | |
| download | box64-b7be225846153a1ed44b149b6600fb86c3fa0b42.tar.gz box64-b7be225846153a1ed44b149b6600fb86c3fa0b42.zip | |
[BOX32] More 32bits wrapped functions
Diffstat (limited to 'src')
| -rw-r--r-- | src/box32.c | 45 | ||||
| -rw-r--r-- | src/emu/x64emu_private.h | 3 | ||||
| -rwxr-xr-x | src/emu/x86int3.c | 2 | ||||
| -rw-r--r-- | src/include/box32.h | 4 | ||||
| -rw-r--r-- | src/wrapped32/generated/converter32.c | 2 | ||||
| -rw-r--r-- | src/wrapped32/generated/functions_list.txt | 25 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrappedlibctypes32.h | 10 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.c | 28 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.h | 18 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc.c | 90 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc_private.h | 42 |
11 files changed, 172 insertions, 97 deletions
diff --git a/src/box32.c b/src/box32.c index 85a647a6..24af6b06 100644 --- a/src/box32.c +++ b/src/box32.c @@ -11,6 +11,7 @@ KHASH_MAP_INIT_INT64(to, ulong_t); KHASH_MAP_INIT_INT(from, uintptr_t); +KHASH_MAP_INIT_STR(strings, char*); static kh_from_t* hash_from; static kh_to_t* hash_to; @@ -22,6 +23,7 @@ static int hash_running = 0; // locale static kh_from_t* locale_from; static kh_to_t* locale_to; +static kh_strings_t* const_strings; void init_hash_helper() { @@ -29,6 +31,7 @@ void init_hash_helper() { hash_to = kh_init(to); locale_from = kh_init(from); locale_to = kh_init(to); + const_strings = kh_init(strings); pthread_rwlock_init(&hash_lock, NULL); hash_running = 1; } @@ -43,6 +46,8 @@ void fini_hash_helper() { locale_from = NULL; kh_destroy(to, locale_to); locale_to = NULL; + kh_destroy(strings, const_strings); //TODO: does not free memory correctly + const_strings = NULL; pthread_rwlock_destroy(&hash_lock); } @@ -280,4 +285,44 @@ ptr_t to_locale_d(void* p) { } pthread_rwlock_unlock(&hash_lock); return ret; +} + +char* from_cstring(ptr_t p) { + return (char*)from_ptrv(p); +} + +ptr_t to_cstring(char* p) { + if((uintptr_t)p<0x100000000LL) + return to_ptrv(p); + ptr_t ret = 0; + pthread_rwlock_rdlock(&hash_lock); + khint_t k = kh_get(strings, const_strings, p); + if(k==kh_end(const_strings)) { + // create a new key, but need write lock! + pthread_rwlock_unlock(&hash_lock); + pthread_rwlock_wrlock(&hash_lock); + ret = to_ptrv(box_strdup(p)); + int r; + k = kh_put(strings, const_strings, (char*)from_ptrv(ret), &r); + } else + ret = to_ptrv(kh_value(const_strings, k)); + pthread_rwlock_unlock(&hash_lock); + return ret; +} + +ptr_t to_cstring_d(char* p) { + if((uintptr_t)p<0x100000000LL) + return to_ptrv(p); + ptr_t ret = 0; + pthread_rwlock_wrlock(&hash_lock); + khint_t k = kh_get(strings, const_strings, p); + if(k==kh_end(const_strings)) { + // assert? + } else { + ret = to_ptrv(kh_value(const_strings, k)); + kh_del(strings, const_strings, k); + free(from_ptrv(ret)); + } + pthread_rwlock_unlock(&hash_lock); + return ret; } \ No newline at end of file diff --git a/src/emu/x64emu_private.h b/src/emu/x64emu_private.h index 35bfd97e..a8690343 100644 --- a/src/emu/x64emu_private.h +++ b/src/emu/x64emu_private.h @@ -133,6 +133,9 @@ typedef struct x64emu_s { void* uc_link; // to handle setcontext (can be x64_ucontext_t or a i386_ucontext_t) int type; // EMUTYPE_xxx define + #ifdef BOX32 + int libc_err; // copy of errno from libc + #endif } x64emu_t; #define EMUTYPE_NONE 0 diff --git a/src/emu/x86int3.c b/src/emu/x86int3.c index 73f5b3ae..cd53335d 100755 --- a/src/emu/x86int3.c +++ b/src/emu/x86int3.c @@ -136,7 +136,7 @@ void x86Int3(x64emu_t* emu, uintptr_t* addr) snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\", \"%s\")", tid, *(void**)from_ptr(R_ESP), s, from_ptrv(*(ptr_t*)from_ptr(R_ESP+4)), from_ptrv(*(ptr_t*)from_ptr(R_ESP+8))); perr = 2; } else if(!strcmp(s, "chdir")) { - pu32=*(uint32_t**)from_ptr(R_ESP+4); + pu32=(uint32_t*)from_ptrv(R_ESP+4); snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)from_ptr(R_ESP), s, pu32?((pu32==(uint32_t*)1)?"/1/":(char*)pu32):"/0/"); } else if(strstr(s, "getenv")==s) { snprintf(buff, 255, "%04d|%p: Calling %s(\"%s\")", tid, *(void**)from_ptr(R_ESP), s, from_ptrv(*(ptr_t*)from_ptr(R_ESP+4))); diff --git a/src/include/box32.h b/src/include/box32.h index 9554e65f..9d5a40ca 100644 --- a/src/include/box32.h +++ b/src/include/box32.h @@ -99,6 +99,10 @@ void* from_locale_d(ptr_t l); ptr_t to_locale(void* p); ptr_t to_locale_d(void* p); +char* from_cstring(ptr_t p); +ptr_t to_cstring(char* p); +ptr_t to_cstring_d(char* p); + void init_hash_helper(); void fini_hash_helper(); diff --git a/src/wrapped32/generated/converter32.c b/src/wrapped32/generated/converter32.c index 6c6274a8..d790ad9c 100644 --- a/src/wrapped32/generated/converter32.c +++ b/src/wrapped32/generated/converter32.c @@ -12,6 +12,7 @@ void to_struct_p(ptr_t d, const struct_p_t *src) { } void from_struct_L(struct_L_t *dest, ptr_t s) { + if(!s) return; uint8_t* src = (uint8_t*)from_ptrv(s); dest->L0 = from_ulong(*(ulong_t*)src); src += 4; } @@ -22,6 +23,7 @@ void to_struct_L(ptr_t d, const struct_L_t *src) { } void from_struct_LL(struct_LL_t *dest, ptr_t s) { + if(!s) return; uint8_t* src = (uint8_t*)from_ptrv(s); dest->L0 = from_ulong(*(ulong_t*)src); src += 4; dest->L1 = from_ulong(*(ulong_t*)src); src += 4; diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index af2dc17b..b634a1b4 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -32,6 +32,8 @@ #() pFp -> pFp #() hFv -> hFv #() aFa -> aFa +#() tFp -> tFp +#() LFrL_ -> LFB #() vFEv -> vFEv #() vFEp -> vFEp #() iFEv -> iFEv @@ -48,6 +50,7 @@ #() iFup -> iFup #() iFli -> iFli #() iFpi -> iFpi +#() iFpu -> iFpu #() iFpp -> iFpp #() iFhp -> iFhp #() iFhh -> iFhh @@ -73,6 +76,8 @@ #() pFEp -> pFEp #() pFLL -> pFLL #() pFpL -> pFpL +#() tFip -> tFip +#() tFpL -> tFpL #() iFHBp_ -> iFHB #() fFpBp_ -> fFpB #() dFpBp_ -> dFpB @@ -114,13 +119,14 @@ #() dFddd -> dFddd #() dFddp -> dFddp #() pFEip -> pFEip -#() pFEia -> pFEia #() pFEpi -> pFEpi #() pFEpp -> pFEpp #() pFpiL -> pFpiL +#() pFppu -> pFppu #() pFppL -> pFppL #() pFpOM -> pFpOM #() hFEpp -> hFEpp +#() hFppH -> hFppH #() aFipa -> aFipa #() IFpBp_i -> IFpBi #() lFpBp_i -> lFpBi @@ -134,6 +140,8 @@ #() iFEppu -> iFEppu #() iFEppL -> iFEppL #() iFEppp -> iFEppp +#() iFEpOu -> iFEpOu +#() iFEhpV -> iFEhpV #() iFiiII -> iFiiII #() iFiuui -> iFiuui #() LFpLLh -> LFpLLh @@ -146,6 +154,9 @@ #() iFEpppi -> iFEpppi #() iFiLLLL -> iFiLLLL #() iFEBh_ppp -> iFEBppp +#() iFEpuppp -> iFEpuppp +#() iFEpLppp -> iFEpLppp +#() iFEpLiipV -> iFEpLiipV #() iFEpippppp -> iFEpippppp #defined(ANDROID) pFv -> pFv #defined(ANDROID) vFEpppp -> vFEpppp @@ -157,6 +168,8 @@ #!defined(HAVE_LD80BITS) KFKp -> KFKp #() iFEvpV -> iFEpV #() UFsvvs -> UFss +#() iFEhvpV -> iFEhpV +#() iFEpuvvppp -> iFEpuppp wrappedcrashhandler: wrappedldlinux: - pFv: @@ -175,6 +188,8 @@ wrappedlibc: - uFu: - uFV: - LFL: +- pFv: + - __errno_location - pFL: - vFip: - vFpi: @@ -186,19 +201,23 @@ wrappedlibc: - UFUU: - pFip: - signal -- pFia: - - setlocale - hFpp: - vFipV: - iFvpV: - iFiiN: - iFipp: +- iFppL: - iFppp: +- iFpOu: - vFpppp: - __libc_init - iFiiII: - iFppiV: +- iFhvpV: +- iFpLppp: +- iFpLiipV: - iFpippppp: +- iFpuvvppp: wrappedlibdl: - iFp: - dlclose diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h index 2898c0b0..459586b4 100644 --- a/src/wrapped32/generated/wrappedlibctypes32.h +++ b/src/wrapped32/generated/wrappedlibctypes32.h @@ -21,6 +21,7 @@ typedef int32_t (*iFO_t)(int32_t); typedef uint32_t (*uFu_t)(uint32_t); typedef uint32_t (*uFV_t)(...); typedef uintptr_t (*LFL_t)(uintptr_t); +typedef void* (*pFv_t)(void); typedef void* (*pFL_t)(uintptr_t); typedef void (*vFip_t)(int32_t, void*); typedef void (*vFpi_t)(void*, int32_t); @@ -30,23 +31,28 @@ typedef int32_t (*iFpV_t)(void*, ...); typedef int64_t (*IFII_t)(int64_t, int64_t); typedef uint64_t (*UFUU_t)(uint64_t, uint64_t); typedef void* (*pFip_t)(int32_t, void*); -typedef void* (*pFia_t)(int32_t, void*); typedef uintptr_t (*hFpp_t)(void*, void*); typedef void (*vFipV_t)(int32_t, void*, ...); typedef int32_t (*iFvpV_t)(void, void*, ...); typedef int32_t (*iFiiN_t)(int32_t, int32_t, ...); typedef int32_t (*iFipp_t)(int32_t, void*, void*); +typedef int32_t (*iFppL_t)(void*, void*, uintptr_t); typedef int32_t (*iFppp_t)(void*, void*, void*); +typedef int32_t (*iFpOu_t)(void*, int32_t, uint32_t); typedef void (*vFpppp_t)(void*, void*, void*, void*); typedef int32_t (*iFiiII_t)(int32_t, int32_t, int64_t, int64_t); typedef int32_t (*iFppiV_t)(void*, void*, int32_t, ...); +typedef int32_t (*iFhvpV_t)(uintptr_t, void, void*, ...); +typedef int32_t (*iFpLppp_t)(void*, uintptr_t, void*, void*, void*); +typedef int32_t (*iFpLiipV_t)(void*, uintptr_t, int32_t, int32_t, void*, ...); typedef int32_t (*iFpippppp_t)(void*, int32_t, void*, void*, void*, void*, void*); +typedef int32_t (*iFpuvvppp_t)(void*, uint32_t, void, void, void*, void*, void*); #define SUPER() ADDED_FUNCTIONS() \ GO(__close_nocancel, iFi_t) \ + GO(__errno_location, pFv_t) \ GO(alphasort64, iFpp_t) \ GO(signal, pFip_t) \ - GO(setlocale, pFia_t) \ GO(__libc_init, vFpppp_t) #endif // __wrappedlibcTYPES32_H_ diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c index 62e56520..f4132f5f 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -106,6 +106,8 @@ typedef void* (*pFL_t)(uintptr_t); typedef void* (*pFp_t)(void*); typedef uintptr_t (*hFv_t)(void); typedef void* (*aFa_t)(void*); +typedef char* (*tFp_t)(void*); +typedef uintptr_t (*LFrL__t)(struct_L_t*); typedef void (*vFEv_t)(x64emu_t*); typedef void (*vFEp_t)(x64emu_t*, void*); typedef int32_t (*iFEv_t)(x64emu_t*); @@ -122,6 +124,7 @@ typedef int32_t (*iFuu_t)(uint32_t, uint32_t); typedef int32_t (*iFup_t)(uint32_t, void*); typedef int32_t (*iFli_t)(intptr_t, int32_t); typedef int32_t (*iFpi_t)(void*, int32_t); +typedef int32_t (*iFpu_t)(void*, uint32_t); typedef int32_t (*iFpp_t)(void*, void*); typedef int32_t (*iFhp_t)(uintptr_t, void*); typedef int32_t (*iFhh_t)(uintptr_t, uintptr_t); @@ -147,6 +150,8 @@ typedef void* (*pFEv_t)(x64emu_t*); typedef void* (*pFEp_t)(x64emu_t*, void*); typedef void* (*pFLL_t)(uintptr_t, uintptr_t); typedef void* (*pFpL_t)(void*, uintptr_t); +typedef char* (*tFip_t)(int32_t, void*); +typedef char* (*tFpL_t)(void*, uintptr_t); typedef int32_t (*iFHBp__t)(uintptr_t, struct_p_t*); typedef float (*fFpBp__t)(void*, struct_p_t*); typedef double (*dFpBp__t)(void*, struct_p_t*); @@ -188,13 +193,14 @@ typedef float (*fFffp_t)(float, float, void*); typedef double (*dFddd_t)(double, double, double); typedef double (*dFddp_t)(double, double, void*); typedef void* (*pFEip_t)(x64emu_t*, int32_t, void*); -typedef void* (*pFEia_t)(x64emu_t*, int32_t, void*); typedef void* (*pFEpi_t)(x64emu_t*, void*, int32_t); typedef void* (*pFEpp_t)(x64emu_t*, void*, void*); typedef void* (*pFpiL_t)(void*, int32_t, uintptr_t); +typedef void* (*pFppu_t)(void*, void*, uint32_t); typedef void* (*pFppL_t)(void*, void*, uintptr_t); typedef void* (*pFpOM_t)(void*, int32_t, ...); typedef uintptr_t (*hFEpp_t)(x64emu_t*, void*, void*); +typedef uintptr_t (*hFppH_t)(void*, void*, uintptr_t); typedef void* (*aFipa_t)(int32_t, void*, void*); typedef int64_t (*IFpBp_i_t)(void*, struct_p_t*, int32_t); typedef intptr_t (*lFpBp_i_t)(void*, struct_p_t*, int32_t); @@ -208,6 +214,8 @@ typedef int32_t (*iFEpup_t)(x64emu_t*, void*, uint32_t, void*); typedef int32_t (*iFEppu_t)(x64emu_t*, void*, void*, uint32_t); typedef int32_t (*iFEppL_t)(x64emu_t*, void*, void*, uintptr_t); typedef int32_t (*iFEppp_t)(x64emu_t*, void*, void*, void*); +typedef int32_t (*iFEpOu_t)(x64emu_t*, void*, int32_t, uint32_t); +typedef int32_t (*iFEhpV_t)(x64emu_t*, uintptr_t, void*, void*); typedef int32_t (*iFiiII_t)(int32_t, int32_t, int64_t, int64_t); typedef int32_t (*iFiuui_t)(int32_t, uint32_t, uint32_t, int32_t); typedef uintptr_t (*LFpLLh_t)(void*, uintptr_t, uintptr_t, uintptr_t); @@ -220,6 +228,9 @@ typedef int32_t (*iFEppiV_t)(x64emu_t*, void*, void*, int32_t, void*); typedef int32_t (*iFEpppi_t)(x64emu_t*, void*, void*, void*, int32_t); typedef int32_t (*iFiLLLL_t)(int32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t); typedef int32_t (*iFEBh_ppp_t)(x64emu_t*, struct_h_t*, void*, void*, void*); +typedef int32_t (*iFEpuppp_t)(x64emu_t*, void*, uint32_t, void*, void*, void*); +typedef int32_t (*iFEpLppp_t)(x64emu_t*, void*, uintptr_t, void*, void*, void*); +typedef int32_t (*iFEpLiipV_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, void*, void*); typedef int32_t (*iFEpippppp_t)(x64emu_t*, void*, int32_t, void*, void*, void*, void*, void*); #if defined(ANDROID) @@ -273,6 +284,8 @@ void pFL_32(x64emu_t *emu, uintptr_t fcn) { pFL_t fn = (pFL_t)fcn; R_EAX = to_pt void pFp_32(x64emu_t *emu, uintptr_t fcn) { pFp_t fn = (pFp_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4))); } void hFv_32(x64emu_t *emu, uintptr_t fcn) { hFv_t fn = (hFv_t)fcn; R_EAX = to_hash(fn()); } void aFa_32(x64emu_t *emu, uintptr_t fcn) { aFa_t fn = (aFa_t)fcn; R_EAX = to_locale(fn(from_locale(from_ptri(ptr_t, R_ESP + 4)))); } +void tFp_32(x64emu_t *emu, uintptr_t fcn) { tFp_t fn = (tFp_t)fcn; R_EAX = to_cstring(fn(from_ptriv(R_ESP + 4))); } +void LFrL__32(x64emu_t *emu, uintptr_t fcn) { LFrL__t fn = (LFrL__t)fcn; struct_L_t arg_4; from_struct_L(&arg_4, *(ptr_t*)(from_ptr((R_ESP + 4)))); R_EAX = to_ulong(fn(*(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL)); } void vFEv_32(x64emu_t *emu, uintptr_t fcn) { vFEv_t fn = (vFEv_t)fcn; fn(emu); } void vFEp_32(x64emu_t *emu, uintptr_t fcn) { vFEp_t fn = (vFEp_t)fcn; fn(emu, from_ptriv(R_ESP + 4)); } void iFEv_32(x64emu_t *emu, uintptr_t fcn) { iFEv_t fn = (iFEv_t)fcn; R_EAX = fn(emu); } @@ -289,6 +302,7 @@ void iFuu_32(x64emu_t *emu, uintptr_t fcn) { iFuu_t fn = (iFuu_t)fcn; R_EAX = fn void iFup_32(x64emu_t *emu, uintptr_t fcn) { iFup_t fn = (iFup_t)fcn; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8)); } void iFli_32(x64emu_t *emu, uintptr_t fcn) { iFli_t fn = (iFli_t)fcn; R_EAX = fn(to_long(from_ptri(long_t, R_ESP + 4)), from_ptri(int32_t, R_ESP + 8)); } void iFpi_32(x64emu_t *emu, uintptr_t fcn) { iFpi_t fn = (iFpi_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8)); } +void iFpu_32(x64emu_t *emu, uintptr_t fcn) { iFpu_t fn = (iFpu_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8)); } void iFpp_32(x64emu_t *emu, uintptr_t fcn) { iFpp_t fn = (iFpp_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8)); } void iFhp_32(x64emu_t *emu, uintptr_t fcn) { iFhp_t fn = (iFhp_t)fcn; R_EAX = fn(from_hash(from_ptri(ptr_t, R_ESP + 4)), from_ptriv(R_ESP + 8)); } void iFhh_32(x64emu_t *emu, uintptr_t fcn) { iFhh_t fn = (iFhh_t)fcn; R_EAX = fn(from_hash(from_ptri(ptr_t, R_ESP + 4)), from_hash(from_ptri(ptr_t, R_ESP + 8))); } @@ -314,6 +328,8 @@ void pFEv_32(x64emu_t *emu, uintptr_t fcn) { pFEv_t fn = (pFEv_t)fcn; R_EAX = to void pFEp_32(x64emu_t *emu, uintptr_t fcn) { pFEp_t fn = (pFEp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4))); } void pFLL_32(x64emu_t *emu, uintptr_t fcn) { pFLL_t fn = (pFLL_t)fcn; R_EAX = to_ptrv(fn(to_ulong(from_ptri(ulong_t, R_ESP + 4)), to_ulong(from_ptri(ulong_t, R_ESP + 8)))); } void pFpL_32(x64emu_t *emu, uintptr_t fcn) { pFpL_t fn = (pFpL_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)))); } +void tFip_32(x64emu_t *emu, uintptr_t fcn) { tFip_t fn = (tFip_t)fcn; R_EAX = to_cstring(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8))); } +void tFpL_32(x64emu_t *emu, uintptr_t fcn) { tFpL_t fn = (tFpL_t)fcn; R_EAX = to_cstring(fn(from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)))); } void iFHBp__32(x64emu_t *emu, uintptr_t fcn) { iFHBp__t fn = (iFHBp__t)fcn; struct_p_t arg_8; R_EAX = fn(from_hash_d(from_ptri(ptr_t, R_ESP + 4)), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); } void fFpBp__32(x64emu_t *emu, uintptr_t fcn) { fFpBp__t fn = (fFpBp__t)fcn; struct_p_t arg_8; float fl = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL); fpu_do_push(emu); ST0val = fl; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); } void dFpBp__32(x64emu_t *emu, uintptr_t fcn) { dFpBp__t fn = (dFpBp__t)fcn; struct_p_t arg_8; double db = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL); fpu_do_push(emu); ST0val = db; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); } @@ -355,13 +371,14 @@ void fFffp_32(x64emu_t *emu, uintptr_t fcn) { fFffp_t fn = (fFffp_t)fcn; float f void dFddd_32(x64emu_t *emu, uintptr_t fcn) { dFddd_t fn = (dFddd_t)fcn; double db = fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12), from_ptri(double, R_ESP + 20)); fpu_do_push(emu); ST0val = db; } void dFddp_32(x64emu_t *emu, uintptr_t fcn) { dFddp_t fn = (dFddp_t)fcn; double db = fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12), from_ptriv(R_ESP + 20)); fpu_do_push(emu); ST0val = db; } void pFEip_32(x64emu_t *emu, uintptr_t fcn) { pFEip_t fn = (pFEip_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8))); } -void pFEia_32(x64emu_t *emu, uintptr_t fcn) { pFEia_t fn = (pFEia_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptri(int32_t, R_ESP + 4), from_locale(from_ptri(ptr_t, R_ESP + 8)))); } void pFEpi_32(x64emu_t *emu, uintptr_t fcn) { pFEpi_t fn = (pFEpi_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8))); } void pFEpp_32(x64emu_t *emu, uintptr_t fcn) { pFEpp_t fn = (pFEpp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8))); } void pFpiL_32(x64emu_t *emu, uintptr_t fcn) { pFpiL_t fn = (pFpiL_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), to_ulong(from_ptri(ulong_t, R_ESP + 12)))); } +void pFppu_32(x64emu_t *emu, uintptr_t fcn) { pFppu_t fn = (pFppu_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12))); } void pFppL_32(x64emu_t *emu, uintptr_t fcn) { pFppL_t fn = (pFppL_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), to_ulong(from_ptri(ulong_t, R_ESP + 12)))); } void pFpOM_32(x64emu_t *emu, uintptr_t fcn) { pFpOM_t fn = (pFpOM_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), of_convert32(from_ptri(int32_t, R_ESP + 8)), from_ptriv(R_ESP + 12),from_ptriv(R_ESP + 12 + 4))); } void hFEpp_32(x64emu_t *emu, uintptr_t fcn) { hFEpp_t fn = (hFEpp_t)fcn; R_EAX = to_hash(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8))); } +void hFppH_32(x64emu_t *emu, uintptr_t fcn) { hFppH_t fn = (hFppH_t)fcn; R_EAX = to_hash(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_hash_d(from_ptri(ptr_t, R_ESP + 12)))); } void aFipa_32(x64emu_t *emu, uintptr_t fcn) { aFipa_t fn = (aFipa_t)fcn; R_EAX = to_locale(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_locale(from_ptri(ptr_t, R_ESP + 12)))); } void IFpBp_i_32(x64emu_t *emu, uintptr_t fcn) { IFpBp_i_t fn = (IFpBp_i_t)fcn; struct_p_t arg_8; ui64_t r; r.i = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_ptri(int32_t, R_ESP + 12)); R_EAX = r.d[0]; R_EDX = r.d[1]; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); } void lFpBp_i_32(x64emu_t *emu, uintptr_t fcn) { lFpBp_i_t fn = (lFpBp_i_t)fcn; struct_p_t arg_8; R_EAX = to_long(fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_ptri(int32_t, R_ESP + 12))); if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); } @@ -375,6 +392,8 @@ void iFEpup_32(x64emu_t *emu, uintptr_t fcn) { iFEpup_t fn = (iFEpup_t)fcn; R_EA void iFEppu_32(x64emu_t *emu, uintptr_t fcn) { iFEppu_t fn = (iFEppu_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); } void iFEppL_32(x64emu_t *emu, uintptr_t fcn) { iFEppL_t fn = (iFEppL_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), to_ulong(from_ptri(ulong_t, R_ESP + 12))); } void iFEppp_32(x64emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12)); } +void iFEpOu_32(x64emu_t *emu, uintptr_t fcn) { iFEpOu_t fn = (iFEpOu_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), of_convert32(from_ptri(int32_t, R_ESP + 8)), from_ptri(uint32_t, R_ESP + 12)); } +void iFEhpV_32(x64emu_t *emu, uintptr_t fcn) { iFEhpV_t fn = (iFEhpV_t)fcn; R_EAX = fn(emu, from_hash(from_ptri(ptr_t, R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptrv(R_ESP + 12)); } void iFiiII_32(x64emu_t *emu, uintptr_t fcn) { iFiiII_t fn = (iFiiII_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int64_t, R_ESP + 12), from_ptri(int64_t, R_ESP + 20)); } void iFiuui_32(x64emu_t *emu, uintptr_t fcn) { iFiuui_t fn = (iFiuui_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); } void LFpLLh_32(x64emu_t *emu, uintptr_t fcn) { LFpLLh_t fn = (LFpLLh_t)fcn; R_EAX = to_ulong(fn(from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), to_ulong(from_ptri(ulong_t, R_ESP + 12)), from_hash(from_ptri(ptr_t, R_ESP + 16)))); } @@ -387,6 +406,9 @@ void iFEppiV_32(x64emu_t *emu, uintptr_t fcn) { iFEppiV_t fn = (iFEppiV_t)fcn; R void iFEpppi_32(x64emu_t *emu, uintptr_t fcn) { iFEpppi_t fn = (iFEpppi_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); } void iFiLLLL_32(x64emu_t *emu, uintptr_t fcn) { iFiLLLL_t fn = (iFiLLLL_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), to_ulong(from_ptri(ulong_t, R_ESP + 12)), to_ulong(from_ptri(ulong_t, R_ESP + 16)), to_ulong(from_ptri(ulong_t, R_ESP + 20))); } void iFEBh_ppp_32(x64emu_t *emu, uintptr_t fcn) { iFEBh_ppp_t fn = (iFEBh_ppp_t)fcn; struct_h_t arg_4; R_EAX = fn(emu, *(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL, from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16)); if (*(ptr_t*)(from_ptr((R_ESP + 4)))) to_struct_h(*(ptr_t*)(from_ptr((R_ESP + 4))), &arg_4); } +void iFEpuppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpuppp_t fn = (iFEpuppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20)); } +void iFEpLppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpLppp_t fn = (iFEpLppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20)); } +void iFEpLiipV_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiipV_t fn = (iFEpLiipV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptrv(R_ESP + 24)); } void iFEpippppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpippppp_t fn = (iFEpippppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28)); } #if defined(ANDROID) @@ -408,6 +430,8 @@ void KFKp_32(x64emu_t *emu, uintptr_t fcn) { KFKp_t fn = (KFKp_t)fcn; double db void iFEvpV_32(x64emu_t *emu, uintptr_t fcn) { iFEpV_t fn = (iFEpV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 8), from_ptrv(R_ESP + 12)); } void UFsvvs_32(x64emu_t *emu, uintptr_t fcn) { UFss_t fn = (UFss_t)fcn; ui64_t r; r.u = (uint64_t)fn(from_ptrv(R_ESP + 4), from_ptrv(R_ESP + 12)); R_EAX = r.d[0]; R_EDX = r.d[1]; } +void iFEhvpV_32(x64emu_t *emu, uintptr_t fcn) { iFEhpV_t fn = (iFEhpV_t)fcn; R_EAX = fn(emu, from_hash(from_ptri(ptr_t, R_ESP + 4)), from_ptriv(R_ESP + 12), from_ptrv(R_ESP + 16)); } +void iFEpuvvppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpuppp_t fn = (iFEpuppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28)); } int isRetX87Wrapper32(wrapper_t fun) { if (fun == &fFf_32) return 1; diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index 733ed4cd..e9be1667 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -33,9 +33,10 @@ typedef void (*wrapper_t)(x64emu_t* emu, uintptr_t fnc); // N = ... automatically sending 1 arg // M = ... automatically sending 2 args // P = Vulkan struct pointer -// s..._ = pointer to read-only structure +// r..._ = pointer to read-only structure // B..._ = pointer to write-only structure // b..._ = pointer to read-write structure +// t = char* as a return value (copies to a lower address if the return address is too high) void vFv_32(x64emu_t *emu, uintptr_t fnc); void vFi_32(x64emu_t *emu, uintptr_t fnc); @@ -71,6 +72,8 @@ void pFL_32(x64emu_t *emu, uintptr_t fnc); void pFp_32(x64emu_t *emu, uintptr_t fnc); void hFv_32(x64emu_t *emu, uintptr_t fnc); void aFa_32(x64emu_t *emu, uintptr_t fnc); +void tFp_32(x64emu_t *emu, uintptr_t fnc); +void LFrL__32(x64emu_t *emu, uintptr_t fnc); void vFEv_32(x64emu_t *emu, uintptr_t fnc); void vFEp_32(x64emu_t *emu, uintptr_t fnc); void iFEv_32(x64emu_t *emu, uintptr_t fnc); @@ -87,6 +90,7 @@ void iFuu_32(x64emu_t *emu, uintptr_t fnc); void iFup_32(x64emu_t *emu, uintptr_t fnc); void iFli_32(x64emu_t *emu, uintptr_t fnc); void iFpi_32(x64emu_t *emu, uintptr_t fnc); +void iFpu_32(x64emu_t *emu, uintptr_t fnc); void iFpp_32(x64emu_t *emu, uintptr_t fnc); void iFhp_32(x64emu_t *emu, uintptr_t fnc); void iFhh_32(x64emu_t *emu, uintptr_t fnc); @@ -112,6 +116,8 @@ void pFEv_32(x64emu_t *emu, uintptr_t fnc); void pFEp_32(x64emu_t *emu, uintptr_t fnc); void pFLL_32(x64emu_t *emu, uintptr_t fnc); void pFpL_32(x64emu_t *emu, uintptr_t fnc); +void tFip_32(x64emu_t *emu, uintptr_t fnc); +void tFpL_32(x64emu_t *emu, uintptr_t fnc); void iFHBp__32(x64emu_t *emu, uintptr_t fnc); void fFpBp__32(x64emu_t *emu, uintptr_t fnc); void dFpBp__32(x64emu_t *emu, uintptr_t fnc); @@ -153,13 +159,14 @@ void fFffp_32(x64emu_t *emu, uintptr_t fnc); void dFddd_32(x64emu_t *emu, uintptr_t fnc); void dFddp_32(x64emu_t *emu, uintptr_t fnc); void pFEip_32(x64emu_t *emu, uintptr_t fnc); -void pFEia_32(x64emu_t *emu, uintptr_t fnc); void pFEpi_32(x64emu_t *emu, uintptr_t fnc); void pFEpp_32(x64emu_t *emu, uintptr_t fnc); void pFpiL_32(x64emu_t *emu, uintptr_t fnc); +void pFppu_32(x64emu_t *emu, uintptr_t fnc); void pFppL_32(x64emu_t *emu, uintptr_t fnc); void pFpOM_32(x64emu_t *emu, uintptr_t fnc); void hFEpp_32(x64emu_t *emu, uintptr_t fnc); +void hFppH_32(x64emu_t *emu, uintptr_t fnc); void aFipa_32(x64emu_t *emu, uintptr_t fnc); void IFpBp_i_32(x64emu_t *emu, uintptr_t fnc); void lFpBp_i_32(x64emu_t *emu, uintptr_t fnc); @@ -173,6 +180,8 @@ void iFEpup_32(x64emu_t *emu, uintptr_t fnc); void iFEppu_32(x64emu_t *emu, uintptr_t fnc); void iFEppL_32(x64emu_t *emu, uintptr_t fnc); void iFEppp_32(x64emu_t *emu, uintptr_t fnc); +void iFEpOu_32(x64emu_t *emu, uintptr_t fnc); +void iFEhpV_32(x64emu_t *emu, uintptr_t fnc); void iFiiII_32(x64emu_t *emu, uintptr_t fnc); void iFiuui_32(x64emu_t *emu, uintptr_t fnc); void LFpLLh_32(x64emu_t *emu, uintptr_t fnc); @@ -185,6 +194,9 @@ void iFEppiV_32(x64emu_t *emu, uintptr_t fnc); void iFEpppi_32(x64emu_t *emu, uintptr_t fnc); void iFiLLLL_32(x64emu_t *emu, uintptr_t fnc); void iFEBh_ppp_32(x64emu_t *emu, uintptr_t fnc); +void iFEpuppp_32(x64emu_t *emu, uintptr_t fnc); +void iFEpLppp_32(x64emu_t *emu, uintptr_t fnc); +void iFEpLiipV_32(x64emu_t *emu, uintptr_t fnc); void iFEpippppp_32(x64emu_t *emu, uintptr_t fnc); #if defined(ANDROID) @@ -206,4 +218,6 @@ void KFKp_32(x64emu_t *emu, uintptr_t fnc); void iFEvpV_32(x64emu_t *emu, uintptr_t fnc); void UFsvvs_32(x64emu_t *emu, uintptr_t fnc); +void iFEhvpV_32(x64emu_t *emu, uintptr_t fnc); +void iFEpuvvppp_32(x64emu_t *emu, uintptr_t fnc); #endif // __WRAPPER32_H_ diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c index 0f3d714e..54c444fb 100755 --- a/src/wrapped32/wrappedlibc.c +++ b/src/wrapped32/wrappedlibc.c @@ -134,7 +134,6 @@ typedef int32_t (*iFiiiV_t)(int, int, int, ...); typedef int32_t (*iFippi_t)(int32_t, void*, void*, int32_t); typedef int32_t (*iFpppp_t)(void*, void*, void*, void*); typedef int32_t (*iFpipp_t)(void*, int32_t, void*, void*); -typedef int32_t (*iFpLpp_t)(void*, size_t, void*, void*); typedef int32_t (*iFppii_t)(void*, void*, int32_t, int32_t); typedef int32_t (*iFipuu_t)(int32_t, void*, uint32_t, uint32_t); typedef int32_t (*iFipiI_t)(int32_t, void*, int32_t, int64_t); @@ -707,19 +706,15 @@ EXPORT int my32_dprintf(x64emu_t *emu, int fd, void* fmt, void* V) { } EXPORT int my32___dprintf_chk(x64emu_t *emu, int fd, void* fmt, void* V) __attribute__((alias("my32_dprintf"))); +#endif EXPORT int my32_fprintf(x64emu_t *emu, void* F, void* fmt, void* V) { - #ifndef NOALIGN // need to align on arm myStackAlign32((const char*)fmt, V, emu->scratch); PREPARE_VALIST_32; - void* f = vfprintf; - return ((iFppp_t)f)(F, fmt, VARARGS_32); - #else - return vfprintf((FILE*)F, (const char*)fmt, (va_list)V); - #endif + return vfprintf(F, fmt, VARARGS_32); } EXPORT int my32___fprintf_chk(x64emu_t *emu, void* F, void* fmt, void* V) __attribute__((alias("my32_fprintf"))); - +#if 0 EXPORT int my32_wprintf(x64emu_t *emu, void* fmt, void* V) { #ifndef NOALIGN // need to align on arm @@ -798,21 +793,17 @@ EXPORT int my32_snprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, void * #endif } EXPORT int my32___snprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, void * b) __attribute__((alias("my32_snprintf"))); +#endif EXPORT int my32___snprintf_chk(x64emu_t* emu, void* buff, size_t s, int f1, int f2, void * fmt, void * b) { (void)f1; (void)f2; - #ifndef NOALIGN // need to align on arm myStackAlign32((const char*)fmt, b, emu->scratch); PREPARE_VALIST_32; - void* f = vsnprintf; - return ((iFpLpp_t)f)(buff, s, fmt, VARARGS_32); - #else - return vsnprintf((char*)buff, s, (char*)fmt, b); - #endif + return vsnprintf(buff, s, fmt, VARARGS_32); } - +#if 0 EXPORT int my32_sprintf(x64emu_t* emu, void* buff, void * fmt, void * b) { #ifndef NOALIGN // need to align on arm @@ -906,24 +897,17 @@ EXPORT int my32___isoc99_sscanf(x64emu_t* emu, void* stream, void* fmt, void* b) return ((iFppp_t)f)(stream, fmt, VARARGS_32); } #endif - +#endif EXPORT int my32_vsnprintf(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) { - #ifndef NOALIGN // need to align on arm myStackAlign32((const char*)fmt, (uint32_t*)b, emu->scratch); PREPARE_VALIST_32; - void* f = vsnprintf; - int r = ((iFpupp_t)f)(buff, s, fmt, VARARGS_32); + int r = vsnprintf(buff, s, fmt, VARARGS_32); return r; - #else - void* f = vsnprintf; - int r = ((iFpupp_t)f)(buff, s, fmt, (uint32_t*)b); - return r; - #endif } EXPORT int my32___vsnprintf(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) __attribute__((alias("my32_vsnprintf"))); EXPORT int my32___vsnprintf_chk(x64emu_t* emu, void* buff, uint32_t s, void * fmt, void * b, va_list V) __attribute__((alias("my32_vsnprintf"))); - +#if 0 EXPORT int my32_vasprintf(x64emu_t* emu, void* strp, void* fmt, void* b, va_list V) { #ifndef NOALIGN @@ -1243,15 +1227,15 @@ EXPORT int my32___xstat(x64emu_t* emu, int v, void* path, void* buf) r = FillStatFromStat64(v, &st, buf); return r; } - +#endif EXPORT int my32___xstat64(x64emu_t* emu, int v, void* path, void* buf) { struct stat64 st; int r = stat64((const char*)path, &st); - UnalignStat64(&st, buf); + UnalignStat64_32(&st, buf); return r; } - +#if 0 EXPORT int my32___lxstat(x64emu_t* emu, int v, void* name, void* buf) { if (v == 1) @@ -1275,15 +1259,15 @@ EXPORT int my32___lxstat(x64emu_t* emu, int v, void* name, void* buf) r = FillStatFromStat64(v, &st, buf); return r; } - +#endif EXPORT int my32___lxstat64(x64emu_t* emu, int v, void* name, void* buf) { struct stat64 st; int r = lstat64((const char*)name, &st); - UnalignStat64(&st, buf); + UnalignStat64_32(&st, buf); return r; } - +#if 0 EXPORT int my32___fxstatat(x64emu_t* emu, int v, int d, void* path, void* buf, int flags) { struct stat64 st; @@ -1665,18 +1649,6 @@ EXPORT int32_t my32_open64(x64emu_t* emu, void* pathname, int32_t flags, uint32_ { if(isProcSelf((const char*)pathname, "cmdline")) { // special case for self command line... - #if 0 - char tmpcmdline[200] = {0}; - char tmpbuff[100] = {0}; - sprintf(tmpbuff, "%s/cmdlineXXXXXX", getenv("TMP")?getenv("TMP"):"."); - int tmp = mkstemp64(tmpbuff); - int dummy; - if(tmp<0) return open64(pathname, flags, mode); - dummy = write(tmp, emu->context->fullpath, strlen(emu->context->fullpath)+1); - for (int i=1; i<emu->context->argc; ++i) - dummy = write(tmp, emu->context->argv[i], strlen(emu->context->argv[i])+1); - lseek64(tmp, 0, SEEK_SET); - #else int tmp = shm_open(TMP_CMDLINE, O_RDWR | O_CREAT, S_IRWXU); if(tmp<0) return open64(pathname, flags, mode); shm_unlink(TMP_CMDLINE); // remove the shm file, but it will still exist because it's currently in use @@ -1685,7 +1657,6 @@ EXPORT int32_t my32_open64(x64emu_t* emu, void* pathname, int32_t flags, uint32_ for (int i=1; i<emu->context->argc; ++i) dummy = write(tmp, emu->context->argv[i], strlen(emu->context->argv[i])+1); lseek(tmp, 0, SEEK_SET); - #endif return tmp; } if(isProcSelf((const char*)pathname, "exe")) { @@ -2304,27 +2275,6 @@ EXPORT int my32_alphasort64(x64emu_t* emu, ptr_t* d1_, ptr_t* d2_) return alphasort64(d1_?(&d1):NULL, d2_?(&d2):NULL); } -EXPORT const void* my32_setlocale(x64emu_t* emu, int l, void* loc) -{ - #define VAL_MAX 20 - static char* val[VAL_MAX] = {0}; - static int idx = 0; - const char* ret = setlocale(l, loc); - if(!ret) - return ret; - //check if value already exist in array - for(int i=0; i<idx; ++i) - if(!strcmp(val[i], ret)) - return val[i]; - if(idx+1==VAL_MAX) { - printf_log(LOG_NONE, "BOX32, no enough slot for setlocale\n"); - return ret; - } - val[idx] = strdup(ret); - return val[idx++]; - #undef MAX_VAL -} - EXPORT struct __processor_model { unsigned int __cpu_vendor; @@ -2459,6 +2409,7 @@ EXPORT void* my32_realpath(x64emu_t* emu, void* path, void* resolved_path) return realpath(path, resolved_path); } +#endif EXPORT int my32_readlinkat(x64emu_t* emu, int fd, void* path, void* buf, size_t bufsize) { if(isProcSelf(path, "exe")) { @@ -2469,7 +2420,6 @@ EXPORT int my32_readlinkat(x64emu_t* emu, int fd, void* path, void* buf, size_t return readlinkat(fd, path, buf, bufsize); } -#endif EXPORT void* my32_mmap(x64emu_t* emu, void *addr, size_t length, int prot, int flags, int fd, int offset) { if(prot&PROT_WRITE) @@ -2842,6 +2792,14 @@ EXPORT ptr_t my32_stderr = 0; EXPORT int my32___libc_single_threaded = 0; +EXPORT void* my32___errno_location(x64emu_t* emu) +{ + // TODO: Find a better way to do this + // cannot use __thread as it makes the address not 32bits + emu->libc_err = errno; + return &emu->libc_err; +} + #define PRE_INIT\ if(1) \ my_lib = lib->w.lib = dlopen(NULL, RTLD_LAZY | RTLD_GLOBAL);\ diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h index 337c05f0..2e41febb 100755 --- a/src/wrapped32/wrappedlibc_private.h +++ b/src/wrapped32/wrappedlibc_private.h @@ -121,7 +121,7 @@ GOW(calloc, pFLL) //GO(cfsetispeed, iFpu) //GO(cfsetospeed, iFpu) //GO(cfsetspeed, iFpi) -//GOW(chdir, iFp) +GOW(chdir, iFp) //DATA(__check_rhosts_file, 4) // chflags // __chk_fail @@ -259,7 +259,7 @@ GOM(epoll_create1, iFEO) //%% // erand48_r // Weak //GO(err, vFippppppppp) // errno // type B -//GO(__errno_location, pFv) +GOM(__errno_location, pFEv) //GOW(error, vFiippppppppp) // Simple attempt: there is a vararg, but the alignment will/may be off if it tries some Double in the "printf" part // error_at_line // Weak // error_message_count // type B @@ -356,7 +356,7 @@ GOW(_flushlbf, vFv) // fmtmsg //GO(fnmatch, iFppi) GOM(fopen, hFEpp) //%% -//GOWM(fopen64, pFEpp) //%% +GOWM(fopen64, hFEpp) //%% //GOM(fopencookie, pFEpppppp) //%% last 4p are a struct with 4 callbacks... GOWM(fork, iFEv) //%% GOM(__fork, iFEv) //%% @@ -364,7 +364,7 @@ GOM(__fork, iFEv) //%% GOW(fpathconf, iFii) //GO(__fpending, uFp) //GOM(fprintf, iFEppV) //%% -//GOM(__fprintf_chk, iFEpvpV) //%% +GOM(__fprintf_chk, iFEhvpV) //%% // __fpu_control // type B //GO(__fpurge, vFp) //GOW(fputc, iFip) @@ -389,7 +389,7 @@ GOW(freelocale, vFA) GO(__freelocale, vFA) //GO(fremovexattr, iFip) //GO(freopen, pFppp) -//GO(freopen64, pFppp) +GO(freopen64, hFppH) // frexp // Weak // frexpf // Weak // frexpl // Weak @@ -455,7 +455,7 @@ GO(getchar_unlocked, iFv) GOM(getcontext, iFEp) //%% //GOW(getc_unlocked, iFp) //GO(get_current_dir_name, pFv) -//GOW(getcwd, pFpL) +GOW(getcwd, tFpL) //GO(__getcwd_chk, pFpLL) //GO(getdate, pFp) // getdate_err // type B @@ -468,7 +468,7 @@ GOM(getcontext, iFEp) //%% // __getdomainname_chk GOW(getdtablesize, iFv) GOW(getegid, iFv) -GO(getenv, pFp) +GO(getenv, tFp) //GOW(geteuid, pFv) // getfsent // getfsfile @@ -1042,7 +1042,7 @@ GOW(lseek64, IFiIi) //GO(lsetxattr, iFpppui) //GO(lutimes, iFpp) //GOM(__lxstat, iFEipp) //%% -//GOM(__lxstat64, iFEipp) //%% +GOM(__lxstat64, iFEipp) //%% //GO(madvise, iFpLi) GOM(makecontext, iFEppiV) //%% //GOW(mallinfo, pFv) @@ -1094,7 +1094,7 @@ GO(memmove, pFppL) GO(memset, pFpiL) GO(__memset_chk, pFpiLL) //GO(mincore, iFpLp) -//GOW(mkdir, iFpu) +GOW(mkdir, iFpu) //GO(mkdirat, iFipu) //GO(mkdtemp, pFp) //GO(mkfifo, iFpu) @@ -1191,7 +1191,7 @@ GOW(ntohs, uFu) //GOWM(open, iFEpOu) //%% //GOWM(__open, iFEpOu) //%% //GO(__open_2, iFpO) -//GOWM(open64, iFEpOu) //%% +GOWM(open64, iFEpOu) //%% // __open64 // Weak //GO(__open64_2, iFpO) //GOW(openat, iFipON) @@ -1341,7 +1341,7 @@ GOW(random, iFv) //GO(readdir64, pFp) // check if alignement is correct // readdir64_r //GOM(readdir_r, iFEppp) //%% should also be weak -//GOM(readlink, iFEppL) //%% +GOM(readlink, iFEppL) //%% //GOM(readlinkat, iFEippL) // __readlinkat_chk // __readlink_chk @@ -1349,7 +1349,7 @@ GOW(random, iFv) GO(realloc, pFpL) //DATAV(__realloc_hook, 4) //GOM(realpath, pFEpp) //%% -//GO(__realpath_chk, pFppu) +GO(__realpath_chk, pFppu) // reboot // re_comp // Weak // re_compile_fastmap // Weak @@ -1483,7 +1483,7 @@ GO(sethostent, vFi) GOM(setjmp, iFEp) //%% GOM(_setjmp, iFEp) //%% //GO(setlinebuf, vFp) -GOM(setlocale, pFEia) +GO(setlocale, tFip) // setlogin GO(setlogmask, iFi) //GOW(setmntent, pFpp) @@ -1568,7 +1568,7 @@ GOW(sigsetmask, iFi) //GOW(sigwaitinfo, iFpp) GOW(sleep, uFu) //GOM(snprintf, iFEpLpV) //%% -//GOM(__snprintf_chk, iFEpLiipV) //%% +GOM(__snprintf_chk, iFEpLiipV) //%% //GOM(__snprintf, iFEpLpV) //%% // sockatmark GOW(socket, iFiii) @@ -1620,7 +1620,7 @@ GO(strcmp, iFpp) //GO(__strcoll_l, iFppp) //GOW(strcoll_l, iFppp) //GO(strcpy, pFpp) -//GO(__strcpy_chk, pFppL) +GO(__strcpy_chk, pFppL) // __strcpy_small GO(strcspn, LFpp) // __strcspn_c1 @@ -1640,10 +1640,10 @@ GO(strcspn, LFpp) //GO(__strftime_l, LFpLppL) //GOW(strftime_l, LFpLppL) GO(strlen, LFp) -//GOW(strncasecmp, iFppL) +GOW(strncasecmp, iFppL) // __strncasecmp_l // strncasecmp_l // Weak -//GO(strncat, pFppL) +GO(strncat, pFppL) //GO(__strncat_chk, pFppLL) //GO(strncmp, iFppL) //GO(strncpy, pFppL) @@ -1791,7 +1791,7 @@ GO(tcsetpgrp, iFii) //GO(tempnam, pFpp) //GOW(textdomain, pFp) // tfind // Weak -//GO(time, LFp) +GO(time, LFrL_) //GO(timegm, LFp) // timelocal // Weak GO(timerfd_create, iFii) @@ -1889,9 +1889,9 @@ GOWM(vfork, iFEv) //%% //GOM(vprintf, iFEpp) //%% //GOM(__vprintf_chk, iFEvpp) //%% // vscanf // Weak -//GOWM(vsnprintf, iFEpLppp) //%% +GOWM(vsnprintf, iFEpLppp) //%% //GOWM(__vsnprintf, iFEpuppp) //%% -//GOM(__vsnprintf_chk, iFEpuvvppp) //%% +GOM(__vsnprintf_chk, iFEpuvvppp) //%% //GOWM(vsprintf, iFEppp) //%% //GOM(__vsprintf_chk, iFEpiLpp) //%% //GOM(vsscanf, iFEppp) //%% @@ -2108,7 +2108,7 @@ GOW(wmemmove, pFppL) // xprt_register // xprt_unregister //GOM(__xstat, iFEipp) //%% -//GOM(__xstat64, iFEipp) //%% +GOM(__xstat64, iFEipp) //%% // forcing a custom __gmon_start__ that does nothing GOM(__gmon_start__, vFEv) //%% |