diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-08-28 15:03:16 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-08-28 15:03:16 +0200 |
| commit | 041eb4e69d833a4bf5f68df59c1fe20385b5ad9f (patch) | |
| tree | 2574612f90e2e01b34195cacc659b6d719d0c20b /src | |
| parent | 04157f25025b276fd6526ac851617f59a972c1fd (diff) | |
| download | box64-041eb4e69d833a4bf5f68df59c1fe20385b5ad9f.tar.gz box64-041eb4e69d833a4bf5f68df59c1fe20385b5ad9f.zip | |
[BOX32] Adding some more 32bits wrapped functions
Diffstat (limited to 'src')
| -rwxr-xr-x | src/include/myalign32.h | 8 | ||||
| -rwxr-xr-x | src/libtools/myalign64_32.c | 10 | ||||
| -rw-r--r-- | src/wrapped32/generated/converter32.c | 11 | ||||
| -rw-r--r-- | src/wrapped32/generated/converter32.h | 6 | ||||
| -rw-r--r-- | src/wrapped32/generated/functions_list.txt | 14 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrappedlibctypes32.h | 3 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.c | 24 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.h | 11 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc.c | 79 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc_private.h | 44 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibrt_private.h | 2 |
11 files changed, 138 insertions, 74 deletions
diff --git a/src/include/myalign32.h b/src/include/myalign32.h index c81ccdf6..fb2eb132 100755 --- a/src/include/myalign32.h +++ b/src/include/myalign32.h @@ -362,7 +362,7 @@ typedef struct __attribute__((packed)) x86_ftsent_s { void UnalignFTSENT(void* dest, void* source); // Arm -> x86 void AlignFTSENT(void* dest, void* source); // x86 -> Arm - +#endif typedef struct my_flock64_s { uint16_t l_type; uint16_t l_whence; @@ -379,9 +379,9 @@ typedef struct __attribute__((packed)) x86_flock64_s { int l_pid; } x86_flock64_t; -void UnalignFlock64(void* dest, void* source); // Arm -> x86 -void AlignFlock64(void* dest, void* source); // x86 -> Arm - +void UnalignFlock64_32(void* dest, void* source); // Arm -> x86 +void AlignFlock64_32(void* dest, void* source); // x86 -> Arm +#if 0 // defined in wrapperlibc.c int of_convert(int); // x86->arm int of_unconvert(int); // arm->x86 diff --git a/src/libtools/myalign64_32.c b/src/libtools/myalign64_32.c index 8f11c5b2..0369099e 100755 --- a/src/libtools/myalign64_32.c +++ b/src/libtools/myalign64_32.c @@ -77,7 +77,6 @@ void UnalignStatFS64_32(const void* source, void* dest) i386st->f_spare[2] = st->f_spare[2]; i386st->f_spare[3] = st->f_spare[3]; } -#if 0 #define TRANSFERT \ GO(l_type) \ GO(l_whence) \ @@ -85,20 +84,19 @@ GO(l_start) \ GO(l_len) \ GO(l_pid) -// Arm -> x64 +// Arm -> x86 void UnalignFlock64_32(void* dest, void* source) { - #define GO(A) ((x64_flock64_t*)dest)->A = ((my_flock64_t*)source)->A; + #define GO(A) ((x86_flock64_t*)dest)->A = ((my_flock64_t*)source)->A; TRANSFERT #undef GO } -// x64 -> Arm +// x86 -> Arm void AlignFlock64_32(void* dest, void* source) { - #define GO(A) ((my_flock64_t*)dest)->A = ((x64_flock64_t*)source)->A; + #define GO(A) ((my_flock64_t*)dest)->A = ((x86_flock64_t*)source)->A; TRANSFERT #undef GO } #undef TRANSFERT -#endif \ No newline at end of file diff --git a/src/wrapped32/generated/converter32.c b/src/wrapped32/generated/converter32.c index e098645a..6c6274a8 100644 --- a/src/wrapped32/generated/converter32.c +++ b/src/wrapped32/generated/converter32.c @@ -21,6 +21,17 @@ void to_struct_L(ptr_t d, const struct_L_t *src) { *(ulong_t*)dest = to_ulong(src->L0); dest += 4; } +void from_struct_LL(struct_LL_t *dest, ptr_t s) { + 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; +} +void to_struct_LL(ptr_t d, const struct_LL_t *src) { + if (!src) return; + uint8_t* dest = (uint8_t*)from_ptrv(d); + *(ulong_t*)dest = to_ulong(src->L0); dest += 4; + *(ulong_t*)dest = to_ulong(src->L1); dest += 4; +} void from_struct_h(struct_h_t *dest, ptr_t s) { uint8_t* src = (uint8_t*)from_ptrv(s); diff --git a/src/wrapped32/generated/converter32.h b/src/wrapped32/generated/converter32.h index 86dd3e21..015ceadd 100644 --- a/src/wrapped32/generated/converter32.h +++ b/src/wrapped32/generated/converter32.h @@ -14,6 +14,12 @@ typedef struct struct_L_s { } struct_L_t; void from_struct_L(struct_L_t *dest, ptr_t src); void to_struct_L(ptr_t dest, const struct_L_t *src); +typedef struct struct_LL_s { + unsigned long L0; + unsigned long L1; +} struct_LL_t; +void from_struct_LL(struct_LL_t *dest, ptr_t src); +void to_struct_LL(ptr_t dest, const struct_LL_t *src); typedef struct struct_h_s { uintptr_t h0; } struct_h_t; diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index 28592269..af2dc17b 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -26,6 +26,7 @@ #() lFp -> lFp #() LFv -> LFv #() LFL -> LFL +#() LFp -> LFp #() pFu -> pFu #() pFL -> pFL #() pFp -> pFp @@ -71,8 +72,11 @@ #() pFEv -> pFEv #() pFEp -> pFEp #() pFLL -> pFLL -#() aFia -> aFia +#() pFpL -> pFpL #() iFHBp_ -> iFHB +#() fFpBp_ -> fFpB +#() dFpBp_ -> dFpB +#() iFuBLL_ -> iFuB #() vFEip -> vFEip #() vFEpi -> vFEpi #() vFEpu -> vFEpu @@ -99,6 +103,7 @@ #() iFpiu -> iFpiu #() iFpip -> iFpip #() iFpuu -> iFpuu +#() iFpLL -> iFpLL #() iFppu -> iFppu #() iFppL -> iFppL #() iFppp -> iFppp @@ -109,12 +114,15 @@ #() dFddd -> dFddd #() dFddp -> dFddp #() pFEip -> pFEip +#() pFEia -> pFEia #() pFEpi -> pFEpi #() pFEpp -> pFEpp +#() pFpiL -> pFpiL #() pFppL -> pFppL #() pFpOM -> pFpOM #() hFEpp -> hFEpp #() aFipa -> aFipa +#() IFpBp_i -> IFpBi #() lFpBp_i -> lFpBi #() vFEipV -> vFEipV #() vFEppp -> vFEppp @@ -131,6 +139,7 @@ #() LFpLLh -> LFpLLh #() pFEppi -> pFEppi #() pFEppp -> pFEppp +#() pFpiLL -> pFpiLL #() pFppuL -> pFppuL #() pFppLL -> pFppLL #() iFEppiV -> iFEppiV @@ -171,11 +180,14 @@ wrappedlibc: - vFpi: - vFpu: - iFpp: + - alphasort64 - iFpV: - IFII: - UFUU: - pFip: - signal +- pFia: + - setlocale - hFpp: - vFipV: - iFvpV: diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h index 1b3d5ab3..2898c0b0 100644 --- a/src/wrapped32/generated/wrappedlibctypes32.h +++ b/src/wrapped32/generated/wrappedlibctypes32.h @@ -30,6 +30,7 @@ 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*, ...); @@ -43,7 +44,9 @@ typedef int32_t (*iFpippppp_t)(void*, int32_t, void*, void*, void*, void*, void* #define SUPER() ADDED_FUNCTIONS() \ GO(__close_nocancel, iFi_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 1d8c2890..62e56520 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -100,6 +100,7 @@ typedef intptr_t (*lFi_t)(int32_t); typedef intptr_t (*lFp_t)(void*); typedef uintptr_t (*LFv_t)(void); typedef uintptr_t (*LFL_t)(uintptr_t); +typedef uintptr_t (*LFp_t)(void*); typedef void* (*pFu_t)(uint32_t); typedef void* (*pFL_t)(uintptr_t); typedef void* (*pFp_t)(void*); @@ -145,8 +146,11 @@ typedef uintptr_t (*LFpp_t)(void*, void*); typedef void* (*pFEv_t)(x64emu_t*); typedef void* (*pFEp_t)(x64emu_t*, void*); typedef void* (*pFLL_t)(uintptr_t, uintptr_t); -typedef void* (*aFia_t)(int32_t, void*); +typedef void* (*pFpL_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*); +typedef int32_t (*iFuBLL__t)(uint32_t, struct_LL_t*); typedef void (*vFEip_t)(x64emu_t*, int32_t, void*); typedef void (*vFEpi_t)(x64emu_t*, void*, int32_t); typedef void (*vFEpu_t)(x64emu_t*, void*, uint32_t); @@ -173,6 +177,7 @@ typedef int32_t (*iFupp_t)(uint32_t, void*, void*); typedef int32_t (*iFpiu_t)(void*, int32_t, uint32_t); typedef int32_t (*iFpip_t)(void*, int32_t, void*); typedef int32_t (*iFpuu_t)(void*, uint32_t, uint32_t); +typedef int32_t (*iFpLL_t)(void*, uintptr_t, uintptr_t); typedef int32_t (*iFppu_t)(void*, void*, uint32_t); typedef int32_t (*iFppL_t)(void*, void*, uintptr_t); typedef int32_t (*iFppp_t)(void*, void*, void*); @@ -183,12 +188,15 @@ 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* (*pFppL_t)(void*, void*, uintptr_t); typedef void* (*pFpOM_t)(void*, int32_t, ...); typedef uintptr_t (*hFEpp_t)(x64emu_t*, void*, void*); 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); typedef void (*vFEipV_t)(x64emu_t*, int32_t, void*, void*); typedef void (*vFEppp_t)(x64emu_t*, void*, void*, void*); @@ -205,6 +213,7 @@ 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); typedef void* (*pFEppi_t)(x64emu_t*, void*, void*, int32_t); typedef void* (*pFEppp_t)(x64emu_t*, void*, void*, void*); +typedef void* (*pFpiLL_t)(void*, int32_t, uintptr_t, uintptr_t); typedef void* (*pFppuL_t)(void*, void*, uint32_t, uintptr_t); typedef void* (*pFppLL_t)(void*, void*, uintptr_t, uintptr_t); typedef int32_t (*iFEppiV_t)(x64emu_t*, void*, void*, int32_t, void*); @@ -258,6 +267,7 @@ void lFi_32(x64emu_t *emu, uintptr_t fcn) { lFi_t fn = (lFi_t)fcn; R_EAX = to_lo void lFp_32(x64emu_t *emu, uintptr_t fcn) { lFp_t fn = (lFp_t)fcn; R_EAX = to_long(fn(from_ptriv(R_ESP + 4))); } void LFv_32(x64emu_t *emu, uintptr_t fcn) { LFv_t fn = (LFv_t)fcn; R_EAX = to_ulong(fn()); } void LFL_32(x64emu_t *emu, uintptr_t fcn) { LFL_t fn = (LFL_t)fcn; R_EAX = to_ulong(fn(to_ulong(from_ptri(ulong_t, R_ESP + 4)))); } +void LFp_32(x64emu_t *emu, uintptr_t fcn) { LFp_t fn = (LFp_t)fcn; R_EAX = to_ulong(fn(from_ptriv(R_ESP + 4))); } void pFu_32(x64emu_t *emu, uintptr_t fcn) { pFu_t fn = (pFu_t)fcn; R_EAX = to_ptrv(fn(from_ptri(uint32_t, R_ESP + 4))); } void pFL_32(x64emu_t *emu, uintptr_t fcn) { pFL_t fn = (pFL_t)fcn; R_EAX = to_ptrv(fn(to_ulong(from_ptri(ulong_t, R_ESP + 4)))); } 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))); } @@ -303,8 +313,11 @@ void LFpp_32(x64emu_t *emu, uintptr_t fcn) { LFpp_t fn = (LFpp_t)fcn; R_EAX = to void pFEv_32(x64emu_t *emu, uintptr_t fcn) { pFEv_t fn = (pFEv_t)fcn; R_EAX = to_ptrv(fn(emu)); } 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 aFia_32(x64emu_t *emu, uintptr_t fcn) { aFia_t fn = (aFia_t)fcn; R_EAX = to_locale(fn(from_ptri(int32_t, R_ESP + 4), from_locale(from_ptri(ptr_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 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); } +void iFuBLL__32(x64emu_t *emu, uintptr_t fcn) { iFuBLL__t fn = (iFuBLL__t)fcn; struct_LL_t arg_8; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_LL(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); } void vFEip_32(x64emu_t *emu, uintptr_t fcn) { vFEip_t fn = (vFEip_t)fcn; fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8)); } void vFEpi_32(x64emu_t *emu, uintptr_t fcn) { vFEpi_t fn = (vFEpi_t)fcn; fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8)); } void vFEpu_32(x64emu_t *emu, uintptr_t fcn) { vFEpu_t fn = (vFEpu_t)fcn; fn(emu, from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8)); } @@ -331,6 +344,7 @@ void iFupp_32(x64emu_t *emu, uintptr_t fcn) { iFupp_t fn = (iFupp_t)fcn; R_EAX = void iFpiu_32(x64emu_t *emu, uintptr_t fcn) { iFpiu_t fn = (iFpiu_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); } void iFpip_32(x64emu_t *emu, uintptr_t fcn) { iFpip_t fn = (iFpip_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12)); } void iFpuu_32(x64emu_t *emu, uintptr_t fcn) { iFpuu_t fn = (iFpuu_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); } +void iFpLL_32(x64emu_t *emu, uintptr_t fcn) { iFpLL_t fn = (iFpLL_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), to_ulong(from_ptri(ulong_t, R_ESP + 12))); } void iFppu_32(x64emu_t *emu, uintptr_t fcn) { iFppu_t fn = (iFppu_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); } void iFppL_32(x64emu_t *emu, uintptr_t fcn) { iFppL_t fn = (iFppL_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), to_ulong(from_ptri(ulong_t, R_ESP + 12))); } void iFppp_32(x64emu_t *emu, uintptr_t fcn) { iFppp_t fn = (iFppp_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12)); } @@ -341,12 +355,15 @@ 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 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 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); } void vFEipV_32(x64emu_t *emu, uintptr_t fcn) { vFEipV_t fn = (vFEipV_t)fcn; fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptrv(R_ESP + 12)); } void vFEppp_32(x64emu_t *emu, uintptr_t fcn) { vFEppp_t fn = (vFEppp_t)fcn; fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12)); } @@ -363,6 +380,7 @@ void iFiuui_32(x64emu_t *emu, uintptr_t fcn) { iFiuui_t fn = (iFiuui_t)fcn; R_EA 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)))); } void pFEppi_32(x64emu_t *emu, uintptr_t fcn) { pFEppi_t fn = (pFEppi_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); } void pFEppp_32(x64emu_t *emu, uintptr_t fcn) { pFEppp_t fn = (pFEppp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12))); } +void pFpiLL_32(x64emu_t *emu, uintptr_t fcn) { pFpiLL_t fn = (pFpiLL_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)), to_ulong(from_ptri(ulong_t, R_ESP + 16)))); } void pFppuL_32(x64emu_t *emu, uintptr_t fcn) { pFppuL_t fn = (pFppuL_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), to_ulong(from_ptri(ulong_t, R_ESP + 16)))); } void pFppLL_32(x64emu_t *emu, uintptr_t fcn) { pFppLL_t fn = (pFppLL_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)), to_ulong(from_ptri(ulong_t, R_ESP + 16)))); } void iFEppiV_32(x64emu_t *emu, uintptr_t fcn) { iFEppiV_t fn = (iFEppiV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptrv(R_ESP + 16)); } @@ -405,6 +423,8 @@ int isRetX87Wrapper32(wrapper_t fun) { if (fun == &dFdd_32) return 1; if (fun == &dFdD_32) return 1; if (fun == &dFdp_32) return 1; + if (fun == &fFpBp__32) return 1; + if (fun == &dFpBp__32) return 1; if (fun == &fFfff_32) return 1; if (fun == &fFffp_32) return 1; if (fun == &dFddd_32) return 1; diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index 3496a5ea..733ed4cd 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -65,6 +65,7 @@ void lFi_32(x64emu_t *emu, uintptr_t fnc); void lFp_32(x64emu_t *emu, uintptr_t fnc); void LFv_32(x64emu_t *emu, uintptr_t fnc); void LFL_32(x64emu_t *emu, uintptr_t fnc); +void LFp_32(x64emu_t *emu, uintptr_t fnc); void pFu_32(x64emu_t *emu, uintptr_t fnc); void pFL_32(x64emu_t *emu, uintptr_t fnc); void pFp_32(x64emu_t *emu, uintptr_t fnc); @@ -110,8 +111,11 @@ void LFpp_32(x64emu_t *emu, uintptr_t fnc); 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 aFia_32(x64emu_t *emu, uintptr_t fnc); +void pFpL_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); +void iFuBLL__32(x64emu_t *emu, uintptr_t fnc); void vFEip_32(x64emu_t *emu, uintptr_t fnc); void vFEpi_32(x64emu_t *emu, uintptr_t fnc); void vFEpu_32(x64emu_t *emu, uintptr_t fnc); @@ -138,6 +142,7 @@ void iFupp_32(x64emu_t *emu, uintptr_t fnc); void iFpiu_32(x64emu_t *emu, uintptr_t fnc); void iFpip_32(x64emu_t *emu, uintptr_t fnc); void iFpuu_32(x64emu_t *emu, uintptr_t fnc); +void iFpLL_32(x64emu_t *emu, uintptr_t fnc); void iFppu_32(x64emu_t *emu, uintptr_t fnc); void iFppL_32(x64emu_t *emu, uintptr_t fnc); void iFppp_32(x64emu_t *emu, uintptr_t fnc); @@ -148,12 +153,15 @@ 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 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 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); void vFEipV_32(x64emu_t *emu, uintptr_t fnc); void vFEppp_32(x64emu_t *emu, uintptr_t fnc); @@ -170,6 +178,7 @@ void iFiuui_32(x64emu_t *emu, uintptr_t fnc); void LFpLLh_32(x64emu_t *emu, uintptr_t fnc); void pFEppi_32(x64emu_t *emu, uintptr_t fnc); void pFEppp_32(x64emu_t *emu, uintptr_t fnc); +void pFpiLL_32(x64emu_t *emu, uintptr_t fnc); void pFppuL_32(x64emu_t *emu, uintptr_t fnc); void pFppLL_32(x64emu_t *emu, uintptr_t fnc); void iFEppiV_32(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c index 952d7f7f..0f3d714e 100755 --- a/src/wrapped32/wrappedlibc.c +++ b/src/wrapped32/wrappedlibc.c @@ -57,31 +57,6 @@ #include "globalsymbols.h" #include "box32.h" -#ifdef PANDORA -#ifndef __NR_preadv -#define __NR_preadv (__NR_SYSCALL_BASE+361) -#endif -#ifndef __NR_pwritev -#define __NR_pwritev (__NR_SYSCALL_BASE+362) -#endif -#ifndef __NR_accept4 -#define __NR_accept4 (__NR_SYSCALL_BASE+366) -#endif -#ifndef __NR_sendmmsg -#define __NR_sendmmsg (__NR_SYSCALL_BASE+374) -#endif -#ifndef __NR_prlimit64 -#define __NR_prlimit64 (__NR_SYSCALL_BASE+369) -#endif -#ifndef __NR_recvmmsg -#define __NR_recvmmsg (__NR_SYSCALL_BASE+365) -#endif -#elif defined(__arm__) -#ifndef __NR_accept4 -#define __NR_accept4 (__NR_SYSCALL_BASE+366) -#endif -#endif - // need to undef all read / read64 stuffs! #undef pread #undef pwrite @@ -140,6 +115,7 @@ static const char* libcName = static library_t* my_lib = NULL; extern int fix_64bit_inodes; +typedef int32_t (*iFiiV_t)(int32_t, int32_t, ...); #if 0 typedef int (*iFL_t)(unsigned long); typedef void (*vFpp_t)(void*, void*); @@ -163,7 +139,6 @@ 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); typedef int32_t (*iFipuup_t)(int32_t, void*, uint32_t, uint32_t, void*); -typedef int32_t (*iFiiV_t)(int32_t, int32_t, ...); typedef void* (*pFp_t)(void*); typedef void* (*pFu_t)(uint32_t); #define SUPER() \ @@ -2083,7 +2058,6 @@ EXPORT int32_t my32___cxa_thread_atexit_impl(x64emu_t* emu, void* dtor, void* ob printf_log(LOG_INFO, "Warning, call to __cxa_thread_atexit_impl(%p, %p, %p) ignored\n", dtor, obj, dso); return 0; } -#if 0 #ifndef ANDROID extern void __chk_fail(); EXPORT unsigned long int my32___fdelt_chk (unsigned long int d) @@ -2095,6 +2069,7 @@ EXPORT unsigned long int my32___fdelt_chk (unsigned long int d) } #endif +#if 0 EXPORT int32_t my32_getrandom(x64emu_t* emu, void* buf, uint32_t buflen, uint32_t flags) { // not always implemented on old linux version... @@ -2190,25 +2165,25 @@ EXPORT int32_t my32___poll_chk(void* a, uint32_t b, int c, int l) return poll(a, b, c); // no check... } +#endif EXPORT int32_t my32_fcntl64(x64emu_t* emu, int32_t a, int32_t b, uint32_t d1, uint32_t d2, uint32_t d3, uint32_t d4, uint32_t d5, uint32_t d6) { // Implemented starting glibc 2.14+ library_t* lib = my_lib; if(!lib) return 0; - iFiiV_t f = dlsym(lib->priv.w.lib, "fcntl64"); if(b==F_SETFL) d1 = of_convert32(d1); if(b==F_GETLK64 || b==F_SETLK64 || b==F_SETLKW64) { - my32_flock64_t fl; - AlignFlock64(&fl, (void*)d1); - int ret = f?f(a, b, &fl):fcntl(a, b, &fl); - UnalignFlock64((void*)d1, &fl); + my_flock64_t fl; + AlignFlock64_32(&fl, from_ptrv(d1)); + int ret = fcntl(a, b, &fl); + UnalignFlock64_32(from_ptrv(d1), &fl); return ret; } //TODO: check if better to use the syscall or regular fcntl? //return syscall(__NR_fcntl64, a, b, d1); // should be enough - int ret = f?f(a, b, d1):fcntl(a, b, d1); + int ret = fcntl(a, b, d1); if(b==F_GETFL && ret!=-1) ret = of_unconvert32(ret); @@ -2231,10 +2206,10 @@ EXPORT int32_t my32_fcntl(x64emu_t* emu, int32_t a, int32_t b, uint32_t d1, uint d1 = of_convert32(d1); if(b==F_GETLK64 || b==F_SETLK64 || b==F_SETLKW64) { - my32_flock64_t fl; - AlignFlock64(&fl, (void*)d1); + my_flock64_t fl; + AlignFlock64_32(&fl, from_ptrv(d1)); int ret = fcntl(a, b, &fl); - UnalignFlock64((void*)d1, &fl); + UnalignFlock64_32(from_ptrv(d1), &fl); return ret; } int ret = fcntl(a, b, d1); @@ -2244,7 +2219,7 @@ EXPORT int32_t my32_fcntl(x64emu_t* emu, int32_t a, int32_t b, uint32_t d1, uint return ret; } EXPORT int32_t my32___fcntl(x64emu_t* emu, int32_t a, int32_t b, uint32_t d1, uint32_t d2, uint32_t d3, uint32_t d4, uint32_t d5, uint32_t d6) __attribute__((alias("my32_fcntl"))); - +#if 0 EXPORT int32_t my32_preadv64(x64emu_t* emu, int32_t fd, void* v, int32_t c, int64_t o) { library_t* lib = my_lib; @@ -2320,6 +2295,36 @@ EXPORT int my32_getopt_long_only(int argc, char* const argv[], const char* optst } #endif +EXPORT int my32_alphasort64(x64emu_t* emu, ptr_t* d1_, ptr_t* d2_) +{ + const struct dirent64* d1 = NULL; + const struct dirent64* d2 = NULL; + if(d1_) d1 = (struct dirent64*)from_ptrv(*d1_); + if(d2_) d2 = (struct dirent64*)from_ptrv(*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; diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h index c43f0f21..337c05f0 100755 --- a/src/wrapped32/wrappedlibc_private.h +++ b/src/wrapped32/wrappedlibc_private.h @@ -39,7 +39,7 @@ GO(alarm, iFu) //GO2(aligned_alloc, pFuu, memalign) //GO(alphasort, iFpp) -//GO(alphasort64, iFpp) +GOM(alphasort64, iFEpp) //DATA(argp_err_exit_status, 4) // argp_error // Weak // argp_failure // Weak @@ -554,8 +554,8 @@ GOW(getpt, iFv) //GO(getpwuid_r, iFuppup) //GOW(getresgid, iFppp) //GOW(getresuid, iFppp) -//GO(getrlimit, iFip) -//GO(getrlimit64, iFip) +GO(getrlimit, iFip) +GO(getrlimit64, iFip) // getrpcbyname // getrpcbyname_r // getrpcbynumber @@ -1053,7 +1053,7 @@ GOM(malloc, pFL) //%%,noE // malloc_set_state // Weak // malloc_stats // Weak GOW(malloc_trim, iFu) -//GOW(malloc_usable_size, LFp) +GOW(malloc_usable_size, LFp) GOW(mallopt, iFii) // Weak // mallwatch // type B //GO(mblen, iFpL) @@ -1084,15 +1084,15 @@ GO(memcpy, pFppL) GO(__memcpy_chk, pFppuL) // memfrob //GO(memmem, pFpupu) -//GO(memmove, pFppL) +GO(memmove, pFppL) //GO(__memmove_chk, pFppLL) //GO(mempcpy, pFppL) //GO(__mempcpy, pFppu) // __mempcpy_chk // __mempcpy_small //GOW(memrchr, pFpiL) -//GO(memset, pFpiL) -//GO(__memset_chk, pFpiLL) +GO(memset, pFpiL) +GO(__memset_chk, pFpiLL) //GO(mincore, iFpLp) //GOW(mkdir, iFpu) //GO(mkdirat, iFipu) @@ -1235,7 +1235,7 @@ GO(posix_fadvise64, iFiuui) GO(posix_fallocate, iFiii) GO(posix_fallocate64, iFiII) // posix_madvise -//GOW(posix_memalign, iFpLL) +GOW(posix_memalign, iFpLL) // posix_openpt // Weak //GO(posix_spawn, iFpppppp) // posix_spawnattr_destroy @@ -1346,7 +1346,7 @@ GOW(random, iFv) // __readlinkat_chk // __readlink_chk //GO(readv, lFipi) -//GO(realloc, pFpL) +GO(realloc, pFpL) //DATAV(__realloc_hook, 4) //GOM(realpath, pFEpp) //%% //GO(__realpath_chk, pFppu) @@ -1483,7 +1483,7 @@ GO(sethostent, vFi) GOM(setjmp, iFEp) //%% GOM(_setjmp, iFEp) //%% //GO(setlinebuf, vFp) -GO(setlocale, aFia) +GOM(setlocale, pFEia) // setlogin GO(setlogmask, iFi) //GOW(setmntent, pFpp) @@ -1500,8 +1500,8 @@ GOW(setregid, iFuu) GOW(setresgid, iFuuu) GOW(setresuid, iFuuu) GOW(setreuid, iFuu) -//GO(setrlimit, iFip) -//GO(setrlimit64, iFip) +GO(setrlimit, iFip) // needs wrapping? +GO(setrlimit64, iFip) // setrpcent // setservent GOW(setsid, iFv) @@ -1527,15 +1527,15 @@ GOW(shmget, iFuui) GOW(shutdown, iFii) //GOWM(sigaction, iFEipp) //%% //GOWM(__sigaction, iFEipp) //%% -//GO(sigaddset, iFpi) +GO(sigaddset, iFpi) // __sigaddset GOWM(sigaltstack, iFEpp) //%% // sigandset GOW(sigblock, iFi) //GO(sigdelset, iFpi) // __sigdelset -//GO(sigemptyset, iFp) -//GO(sigfillset, iFp) +GO(sigemptyset, iFp) +GO(sigfillset, iFp) GO(siggetmask, iFv) // sighold // sigignore @@ -1552,7 +1552,7 @@ GO(__signbitf, iFf) // sigpause // Weak // __sigpause //GO(sigpending, iFp) -//GOW(sigprocmask, iFipp) +GOW(sigprocmask, iFipp) // sigqueue // Weak // sigrelse // sigreturn // Weak @@ -1605,7 +1605,7 @@ DATAM(stdout, 4) //GOW(stpncpy, pFppL) //GO(__stpncpy, pFppL) //GO(__stpncpy_chk, pFppLL) -//GOW(strcasecmp, iFpp) +GOW(strcasecmp, iFpp) //GO(__strcasecmp, iFpp) // __strcasecmp_l // strcasecmp_l // Weak @@ -1639,7 +1639,7 @@ GO(strcspn, LFpp) //GO(strftime, LFpLpp) //GO(__strftime_l, LFpLppL) //GOW(strftime_l, LFpLppL) -//GO(strlen, LFp) +GO(strlen, LFp) //GOW(strncasecmp, iFppL) // __strncasecmp_l // strncasecmp_l // Weak @@ -1668,11 +1668,11 @@ GO(strcspn, LFpp) // __strspn_c2 // __strspn_c3 //GO(strstr, pFpp) -//GO(strtod, dFpp) +GO(strtod, dFpBp_) //GO(__strtod_internal, dFppi) //GO(__strtod_l, dFppp) //GOW(strtod_l, dFppu) -//GO(strtof, fFpp) +GO(strtof, fFpBp_) //GO(__strtof_internal, fFppp) //GO(__strtof_l, fFppp) //GOW(strtof_l, fFppu) @@ -1694,7 +1694,7 @@ GO(strtol, lFpBp_i) //GOW2(strtold_l, KFppu, strtod_l) #endif //GO(__strtol_internal, lFppi) -//GO(strtoll, IFppi) +GO(strtoll, IFpBp_i) //GO(__strtol_l, lFppiip) //GOW(strtol_l, lFppiip) //GO(__strtoll_internal, IFppii) @@ -2012,7 +2012,7 @@ GOW(wctype_l, uFpa) GO(wmemcmp, iFppL) GOW(wmemcpy, pFppL) GO(__wmemcpy_chk, pFppLL) -//GOW(wmemmove, pFppL) +GOW(wmemmove, pFppL) // __wmemmove_chk // wmempcpy // Weak // __wmempcpy_chk diff --git a/src/wrapped32/wrappedlibrt_private.h b/src/wrapped32/wrappedlibrt_private.h index dffbc20f..5d84140f 100755 --- a/src/wrapped32/wrappedlibrt_private.h +++ b/src/wrapped32/wrappedlibrt_private.h @@ -25,7 +25,7 @@ GO(aio_suspend64, iFpip) GO(aio_write64, iFp) GO(clock_getcpuclockid, iFup) GO(clock_getres, iFup) -//GO(clock_gettime, iFup) // p is *timespec +GO(clock_gettime, iFuBLL_) // *timespec //GO(clock_nanosleep, iFuipp) //GO(clock_settime, iFup) // lio_listio |