diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-12-13 10:30:36 +0100 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-12-13 10:30:43 +0100 |
| commit | 689d64b62a8f43d58afba6c3c7c1334fb613eb8b (patch) | |
| tree | 1e882d2c90a17684a45e59f19329194d4398545e /src | |
| parent | f6c33869602ae2a69cd2ea31e65a35cfea437d11 (diff) | |
| download | box64-689d64b62a8f43d58afba6c3c7c1334fb613eb8b.tar.gz box64-689d64b62a8f43d58afba6c3c7c1334fb613eb8b.zip | |
[BOX32][WRAPPER] Added 1 more libc 32bits wrapped funciton, and fixed an existing one
Diffstat (limited to 'src')
| -rw-r--r-- | src/libtools/libc_net32.c | 35 | ||||
| -rw-r--r-- | src/wrapped32/generated/functions_list.txt | 7 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrappedlibctypes32.h | 6 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.c | 6 | ||||
| -rw-r--r-- | src/wrapped32/generated/wrapper32.h | 3 | ||||
| -rwxr-xr-x | src/wrapped32/wrappedlibc_private.h | 4 |
6 files changed, 54 insertions, 7 deletions
diff --git a/src/libtools/libc_net32.c b/src/libtools/libc_net32.c index 3ad95202..b3fde053 100644 --- a/src/libtools/libc_net32.c +++ b/src/libtools/libc_net32.c @@ -238,6 +238,41 @@ EXPORT int my32_gethostbyname_r(x64emu_t* emu, void* name, struct i386_hostent* return r; } +EXPORT void* my32_gethostbyaddr(x64emu_t* emu, const char* a, uint32_t len, int type) +{ + static struct i386_hostent ret = {0}; + static ptr_t strings[128] = {0}; + struct hostent* h = gethostbyaddr(a, len, type); + if(!h) return NULL; + // convert... + ret.h_name = to_cstring(h->h_name); + ret.h_addrtype = h->h_addrtype; + ret.h_length = h->h_length; + ptr_t s = to_ptrv(&strings); + int idx = 0; + ret.h_aliases = h->h_aliases?s:0; + if(h->h_aliases) { + char** p = h->h_aliases; + while(*p) { + strings[idx++] = to_cstring(*p); + ++p; + } + strings[idx++] = 0; + } + ret.h_addr_list = h->h_addr_list?to_ptrv(&strings[idx]):0; + if(h->h_addr_list) { + char** p = h->h_addr_list; + while(*p) { + strings[idx++] = to_ptrv(*p); + ++p; + } + strings[idx++] = 0; + } + // done + emu->libc_herr = h_errno; + return &ret; +} + EXPORT int my32_gethostbyaddr_r(x64emu_t* emu, void* addr, uint32_t len, int type, struct i386_hostent* ret, void* buff, size_t buflen, ptr_t* result, int* h_err) { struct hostent ret_l = {0}; diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt index 3d14b2c1..211616d0 100644 --- a/src/wrapped32/generated/functions_list.txt +++ b/src/wrapped32/generated/functions_list.txt @@ -945,6 +945,7 @@ #() pFEupp -> pFEupp #() pEEpii -> pEEpii #() pFEpip -> pFEpip +#() pFEpui -> pFEpui #() pEEppi -> pEEppi #() pFEppi -> pFEppi #() pEEppp -> pEEppp @@ -1532,7 +1533,6 @@ #() iEEpLiLppp -> iEEpLiLppp #() iFEppipppp -> iFEppipppp #() iFuiiiiuup -> iFuiiiiuup -#() iFpuippupp -> iFpuippupp #() iFpuuiiuuu -> iFpuuiiuuu #() iFXuupuupp -> iFXuupuupp #() iFXLpipppp -> iFXLpipppp @@ -1573,6 +1573,7 @@ #() vFddddddddd -> vFddddddddd #() vFXiLLpiipi -> vFXiLLpiipi #() vFXLiiipiii -> vFXLiiipiii +#() iFEpuippupp -> iFEpuippupp #() iFEXLLLiipi -> iFEXLLLiipi #() iFuiiuuiiip -> iFuiiuuiiip #() iFuiiupiiup -> iFuiiupiiup @@ -1965,6 +1966,8 @@ wrappedlibc: - shmat - pEpii: - pEpII: +- pFpui: + - gethostbyaddr - pEpLL: - pEppi: - __realpath_chk @@ -2039,6 +2042,8 @@ wrappedlibc: - pEpLiiil: - iEpippppp: - iEpLiLppp: +- iFpuippupp: + - gethostbyaddr_r wrappedlibdl: - iEp: - dlclose diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h index e24906e9..c5b6db2d 100644 --- a/src/wrapped32/generated/wrappedlibctypes32.h +++ b/src/wrapped32/generated/wrappedlibctypes32.h @@ -82,6 +82,7 @@ typedef intptr_t (*lEppL_t)(void*, void*, uintptr_t); typedef void* (*pEipi_t)(int32_t, void*, int32_t); typedef void* (*pEpii_t)(void*, int32_t, int32_t); typedef void* (*pEpII_t)(void*, int64_t, int64_t); +typedef void* (*pFpui_t)(void*, uint32_t, int32_t); typedef void* (*pEpLL_t)(void*, uintptr_t, uintptr_t); typedef void* (*pEppi_t)(void*, void*, int32_t); typedef double (*KEpBp_a_t)(void*, struct_p_t*, void*); @@ -131,6 +132,7 @@ typedef void* (*pEpLiiiI_t)(void*, uintptr_t, int32_t, int32_t, int32_t, int64_t typedef void* (*pEpLiiil_t)(void*, uintptr_t, int32_t, int32_t, int32_t, intptr_t); typedef int32_t (*iEpippppp_t)(void*, int32_t, void*, void*, void*, void*, void*); typedef int32_t (*iEpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void*, void*); +typedef int32_t (*iFpuippupp_t)(void*, uint32_t, int32_t, void*, void*, uint32_t, void*, void*); #define SUPER() ADDED_FUNCTIONS() \ GO(freeaddrinfo, vEp_t) \ @@ -207,6 +209,7 @@ typedef int32_t (*iEpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void GO(sendmsg, lEipi_t) \ GO(writev, lEipi_t) \ GO(shmat, pEipi_t) \ + GO(gethostbyaddr, pFpui_t) \ GO(__realpath_chk, pEppi_t) \ GO(__strtold_l, KEpBp_a_t) \ GO(strtold_l, KEpBp_a_t) \ @@ -231,6 +234,7 @@ typedef int32_t (*iEpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void GO(gethostbyname_r, iFpppupp_t) \ GO(posix_spawn, iEpppppp_t) \ GO(process_vm_readv, lEipLpLL_t) \ - GO(process_vm_writev, lEipLpLL_t) + GO(process_vm_writev, lEipLpLL_t) \ + GO(gethostbyaddr_r, iFpuippupp_t) #endif // __wrappedlibcTYPES32_H_ diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c index f13a719e..a7b5aed1 100644 --- a/src/wrapped32/generated/wrapper32.c +++ b/src/wrapped32/generated/wrapper32.c @@ -1036,6 +1036,7 @@ typedef void* (*pEEipi_t)(x64emu_t*, int32_t, void*, int32_t); typedef void* (*pFEupp_t)(x64emu_t*, uint32_t, void*, void*); typedef void* (*pEEpii_t)(x64emu_t*, void*, int32_t, int32_t); typedef void* (*pFEpip_t)(x64emu_t*, void*, int32_t, void*); +typedef void* (*pFEpui_t)(x64emu_t*, void*, uint32_t, int32_t); typedef void* (*pEEppi_t)(x64emu_t*, void*, void*, int32_t); typedef void* (*pFEppi_t)(x64emu_t*, void*, void*, int32_t); typedef void* (*pEEppp_t)(x64emu_t*, void*, void*, void*); @@ -1623,7 +1624,6 @@ typedef int32_t (*iEEpippppp_t)(x64emu_t*, void*, int32_t, void*, void*, void*, typedef int32_t (*iEEpLiLppp_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, void*, void*, void*); typedef int32_t (*iFEppipppp_t)(x64emu_t*, void*, void*, int32_t, void*, void*, void*, void*); typedef int32_t (*iFuiiiiuup_t)(uint32_t, int32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, void*); -typedef int32_t (*iFpuippupp_t)(void*, uint32_t, int32_t, void*, void*, uint32_t, void*, void*); typedef int32_t (*iFpuuiiuuu_t)(void*, uint32_t, uint32_t, int32_t, int32_t, uint32_t, uint32_t, uint32_t); typedef int32_t (*iFXuupuupp_t)(void*, uint32_t, uint32_t, void*, uint32_t, uint32_t, void*, void*); typedef int32_t (*iFXLpipppp_t)(void*, uintptr_t, void*, int32_t, void*, void*, void*, void*); @@ -1664,6 +1664,7 @@ typedef void (*vFffCCCCfff_t)(float, float, uint8_t, uint8_t, uint8_t, uint8_t, typedef void (*vFddddddddd_t)(double, double, double, double, double, double, double, double, double); typedef void (*vFXiLLpiipi_t)(void*, int32_t, uintptr_t, uintptr_t, void*, int32_t, int32_t, void*, int32_t); typedef void (*vFXLiiipiii_t)(void*, uintptr_t, int32_t, int32_t, int32_t, void*, int32_t, int32_t, int32_t); +typedef int32_t (*iFEpuippupp_t)(x64emu_t*, void*, uint32_t, int32_t, void*, void*, uint32_t, void*, void*); typedef int32_t (*iFEXLLLiipi_t)(x64emu_t*, void*, uintptr_t, uintptr_t, uintptr_t, int32_t, int32_t, void*, int32_t); typedef int32_t (*iFuiiuuiiip_t)(uint32_t, int32_t, int32_t, uint32_t, uint32_t, int32_t, int32_t, int32_t, void*); typedef int32_t (*iFuiiupiiup_t)(uint32_t, int32_t, int32_t, uint32_t, void*, int32_t, int32_t, uint32_t, void*); @@ -2736,6 +2737,7 @@ void pEEipi_32(x64emu_t *emu, uintptr_t fcn) { pEEipi_t fn = (pEEipi_t)fcn; errn void pFEupp_32(x64emu_t *emu, uintptr_t fcn) { pFEupp_t fn = (pFEupp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12))); } void pEEpii_32(x64emu_t *emu, uintptr_t fcn) { pEEpii_t fn = (pEEpii_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); emu->libc_err = errno; } void pFEpip_32(x64emu_t *emu, uintptr_t fcn) { pFEpip_t fn = (pFEpip_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12))); } +void pFEpui_32(x64emu_t *emu, uintptr_t fcn) { pFEpui_t fn = (pFEpui_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); } void pEEppi_32(x64emu_t *emu, uintptr_t fcn) { pEEppi_t fn = (pEEppi_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); emu->libc_err = errno; } 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 pEEppp_32(x64emu_t *emu, uintptr_t fcn) { pEEppp_t fn = (pEEppp_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12))); emu->libc_err = errno; } @@ -3323,7 +3325,6 @@ void iEEpippppp_32(x64emu_t *emu, uintptr_t fcn) { iEEpippppp_t fn = (iEEpippppp void iEEpLiLppp_32(x64emu_t *emu, uintptr_t fcn) { iEEpLiLppp_t fn = (iEEpLiLppp_t)fcn; errno = emu->libc_err; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28)); emu->libc_err = errno; } void iFEppipppp_32(x64emu_t *emu, uintptr_t fcn) { iFEppipppp_t fn = (iFEppipppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28)); } void iFuiiiiuup_32(x64emu_t *emu, uintptr_t fcn) { iFuiiiiuup_t fn = (iFuiiiiuup_t)fcn; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptri(uint32_t, R_ESP + 28), from_ptriv(R_ESP + 32)); } -void iFpuippupp_32(x64emu_t *emu, uintptr_t fcn) { iFpuippupp_t fn = (iFpuippupp_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32)); } void iFpuuiiuuu_32(x64emu_t *emu, uintptr_t fcn) { iFpuuiiuuu_t fn = (iFpuuiiuuu_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptri(uint32_t, R_ESP + 28), from_ptri(uint32_t, R_ESP + 32)); } void iFXuupuupp_32(x64emu_t *emu, uintptr_t fcn) { iFXuupuupp_t fn = (iFXuupuupp_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptri(uint32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32)); } void iFXLpipppp_32(x64emu_t *emu, uintptr_t fcn) { iFXLpipppp_t fn = (iFXLpipppp_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32)); } @@ -3364,6 +3365,7 @@ void vFffCCCCfff_32(x64emu_t *emu, uintptr_t fcn) { vFffCCCCfff_t fn = (vFffCCCC void vFddddddddd_32(x64emu_t *emu, uintptr_t fcn) { vFddddddddd_t fn = (vFddddddddd_t)fcn; fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12), from_ptri(double, R_ESP + 20), from_ptri(double, R_ESP + 28), from_ptri(double, R_ESP + 36), from_ptri(double, R_ESP + 44), from_ptri(double, R_ESP + 52), from_ptri(double, R_ESP + 60), from_ptri(double, R_ESP + 68)); } void vFXiLLpiipi_32(x64emu_t *emu, uintptr_t fcn) { vFXiLLpiipi_t fn = (vFXiLLpiipi_t)fcn; fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(int32_t, R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptriv(R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28), from_ptriv(R_ESP + 32), from_ptri(int32_t, R_ESP + 36)); } void vFXLiiipiii_32(x64emu_t *emu, uintptr_t fcn) { vFXLiiipiii_t fn = (vFXLiiipiii_t)fcn; fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptriv(R_ESP + 24), from_ptri(int32_t, R_ESP + 28), from_ptri(int32_t, R_ESP + 32), from_ptri(int32_t, R_ESP + 36)); } +void iFEpuippupp_32(x64emu_t *emu, uintptr_t fcn) { iFEpuippupp_t fn = (iFEpuippupp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32)); } void iFEXLLLiipi_32(x64emu_t *emu, uintptr_t fcn) { iFEXLLLiipi_t fn = (iFEXLLLiipi_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptriv(R_ESP + 28), from_ptri(int32_t, R_ESP + 32)); } void iFuiiuuiiip_32(x64emu_t *emu, uintptr_t fcn) { iFuiiuuiiip_t fn = (iFuiiuuiiip_t)fcn; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptri(uint32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28), from_ptri(int32_t, R_ESP + 32), from_ptriv(R_ESP + 36)); } void iFuiiupiiup_32(x64emu_t *emu, uintptr_t fcn) { iFuiiupiiup_t fn = (iFuiiupiiup_t)fcn; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28), from_ptri(uint32_t, R_ESP + 32), from_ptriv(R_ESP + 36)); } diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h index 4c691e8d..f12a4471 100644 --- a/src/wrapped32/generated/wrapper32.h +++ b/src/wrapped32/generated/wrapper32.h @@ -986,6 +986,7 @@ void pEEipi_32(x64emu_t *emu, uintptr_t fnc); void pFEupp_32(x64emu_t *emu, uintptr_t fnc); void pEEpii_32(x64emu_t *emu, uintptr_t fnc); void pFEpip_32(x64emu_t *emu, uintptr_t fnc); +void pFEpui_32(x64emu_t *emu, uintptr_t fnc); void pEEppi_32(x64emu_t *emu, uintptr_t fnc); void pFEppi_32(x64emu_t *emu, uintptr_t fnc); void pEEppp_32(x64emu_t *emu, uintptr_t fnc); @@ -1573,7 +1574,6 @@ void iEEpippppp_32(x64emu_t *emu, uintptr_t fnc); void iEEpLiLppp_32(x64emu_t *emu, uintptr_t fnc); void iFEppipppp_32(x64emu_t *emu, uintptr_t fnc); void iFuiiiiuup_32(x64emu_t *emu, uintptr_t fnc); -void iFpuippupp_32(x64emu_t *emu, uintptr_t fnc); void iFpuuiiuuu_32(x64emu_t *emu, uintptr_t fnc); void iFXuupuupp_32(x64emu_t *emu, uintptr_t fnc); void iFXLpipppp_32(x64emu_t *emu, uintptr_t fnc); @@ -1614,6 +1614,7 @@ void vFffCCCCfff_32(x64emu_t *emu, uintptr_t fnc); void vFddddddddd_32(x64emu_t *emu, uintptr_t fnc); void vFXiLLpiipi_32(x64emu_t *emu, uintptr_t fnc); void vFXLiiipiii_32(x64emu_t *emu, uintptr_t fnc); +void iFEpuippupp_32(x64emu_t *emu, uintptr_t fnc); void iFEXLLLiipi_32(x64emu_t *emu, uintptr_t fnc); void iFuiiuuiiip_32(x64emu_t *emu, uintptr_t fnc); void iFuiiupiiup_32(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h index cdbf64da..f528642b 100755 --- a/src/wrapped32/wrappedlibc_private.h +++ b/src/wrapped32/wrappedlibc_private.h @@ -499,8 +499,8 @@ GOM(getgrnam_r, iEEpppLp) GO(getgrouplist, iEpipp) GOW(getgroups, iEip) // __getgroups_chk -//GO(gethostbyaddr, pFpui) // change h_errno only -GO(gethostbyaddr_r, iFpuippupp) +GOM(gethostbyaddr, pFEpui) +GOM(gethostbyaddr_r, iFEpuippupp) GOM(gethostbyname, pFEp) //GO(gethostbyname2, pFpi) //GO(gethostbyname2_r, iFpippupp) |