mirror of
https://github.com/ptitSeb/box64.git
synced 2024-11-27 08:40:59 +00:00
[BOX32] Added a couple of 32bits function to libc
This commit is contained in:
parent
f81677278f
commit
82c7d45c4b
@ -151,6 +151,84 @@ EXPORT void* my32_gethostbyname(x64emu_t* emu, const char* a)
|
||||
return &ret;
|
||||
}
|
||||
|
||||
EXPORT int my32_gethostbyname_r(x64emu_t* emu, void* name, struct i386_hostent* ret, void* buff, size_t buflen, ptr_t* result, int* h_err)
|
||||
{
|
||||
struct hostent ret_l = {0};
|
||||
struct hostent *result_l = NULL;
|
||||
int r = gethostbyname_r(name, &ret_l, buff, buflen, &result_l, h_err);
|
||||
if(!result_l)
|
||||
*result = 0;
|
||||
else
|
||||
*result = to_ptrv(ret);
|
||||
// convert result, all memory allocated should be in program space
|
||||
if(result_l) {
|
||||
ret->h_name = to_cstring(result_l->h_name);
|
||||
ret->h_addrtype = result_l->h_addrtype;
|
||||
ret->h_length = result_l->h_length;
|
||||
int idx = 0;
|
||||
ret->h_aliases = to_ptrv(result_l->h_aliases);
|
||||
if(result_l->h_aliases) {
|
||||
char** p = result_l->h_aliases;
|
||||
ptr_t* strings = from_ptrv(ret->h_aliases);
|
||||
while(*p) {
|
||||
strings[idx++] = to_cstring(*p);
|
||||
++p;
|
||||
}
|
||||
strings[idx++] = 0;
|
||||
}
|
||||
ret->h_addr_list = to_ptrv(result_l->h_addr_list);
|
||||
if(result_l->h_addr_list) {
|
||||
char** p = result_l->h_addr_list;
|
||||
ptr_t* strings = from_ptrv(ret->h_addr_list);
|
||||
while(*p) {
|
||||
strings[idx++] = to_ptrv(*p);
|
||||
++p;
|
||||
}
|
||||
strings[idx++] = 0;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
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};
|
||||
struct hostent *result_l = NULL;
|
||||
int r = gethostbyaddr_r(addr, len, type, &ret_l, buff, buflen, &result_l, h_err);
|
||||
if(!result_l)
|
||||
*result = 0;
|
||||
else
|
||||
*result = to_ptrv(ret);
|
||||
// convert result, all memory allocated should be in program space
|
||||
if(result_l) {
|
||||
ret->h_name = to_cstring(result_l->h_name);
|
||||
ret->h_addrtype = result_l->h_addrtype;
|
||||
ret->h_length = result_l->h_length;
|
||||
int idx = 0;
|
||||
ret->h_aliases = to_ptrv(result_l->h_aliases);
|
||||
if(result_l->h_aliases) {
|
||||
char** p = result_l->h_aliases;
|
||||
ptr_t* strings = from_ptrv(ret->h_aliases);
|
||||
while(*p) {
|
||||
strings[idx++] = to_cstring(*p);
|
||||
++p;
|
||||
}
|
||||
strings[idx++] = 0;
|
||||
}
|
||||
ret->h_addr_list = to_ptrv(result_l->h_addr_list);
|
||||
if(result_l->h_addr_list) {
|
||||
char** p = result_l->h_addr_list;
|
||||
ptr_t* strings = from_ptrv(ret->h_addr_list);
|
||||
while(*p) {
|
||||
strings[idx++] = to_ptrv(*p);
|
||||
++p;
|
||||
}
|
||||
strings[idx++] = 0;
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
struct i386_ifaddrs
|
||||
{
|
||||
ptr_t ifa_next; // struct ifaddrs *
|
||||
|
@ -1170,6 +1170,7 @@
|
||||
#() vFXppiiii -> vFXppiiii
|
||||
#() iFEpLiipV -> iFEpLiipV
|
||||
#() iFEpLiLpV -> iFEpLiLpV
|
||||
#() iFEpppupp -> iFEpppupp
|
||||
#() iFEpppppp -> iFEpppppp
|
||||
#() iFEXLpiiL -> iFEXLpiiL
|
||||
#() iFEXLpppp -> iFEXLpppp
|
||||
@ -1237,6 +1238,7 @@
|
||||
#() iFEpippppp -> iFEpippppp
|
||||
#() iFEpLiLppp -> iFEpLiLppp
|
||||
#() iFuiiiiuup -> iFuiiiiuup
|
||||
#() iFpuippupp -> iFpuippupp
|
||||
#() iFXuupuupp -> iFXuupuupp
|
||||
#() iFXLpipppp -> iFXLpipppp
|
||||
#() iFXLppLpip -> iFXLppLpip
|
||||
@ -1628,6 +1630,8 @@ wrappedlibc:
|
||||
- iFpLvvpp:
|
||||
- iFpLiipV:
|
||||
- iFpLiLpV:
|
||||
- iFpppupp:
|
||||
- gethostbyname_r
|
||||
- iFpppppp:
|
||||
- posix_spawn
|
||||
- pFpLiiiI:
|
||||
|
@ -97,6 +97,7 @@ typedef void* (*pFppLLp_t)(void*, void*, uintptr_t, uintptr_t, void*);
|
||||
typedef int32_t (*iFpLvvpp_t)(void*, uintptr_t, void, void, void*, void*);
|
||||
typedef int32_t (*iFpLiipV_t)(void*, uintptr_t, int32_t, int32_t, void*, ...);
|
||||
typedef int32_t (*iFpLiLpV_t)(void*, uintptr_t, int32_t, uintptr_t, void*, ...);
|
||||
typedef int32_t (*iFpppupp_t)(void*, void*, void*, uint32_t, void*, void*);
|
||||
typedef int32_t (*iFpppppp_t)(void*, void*, void*, void*, void*, void*);
|
||||
typedef void* (*pFpLiiiI_t)(void*, uintptr_t, int32_t, int32_t, int32_t, int64_t);
|
||||
typedef void* (*pFpLiiil_t)(void*, uintptr_t, int32_t, int32_t, int32_t, intptr_t);
|
||||
@ -163,6 +164,7 @@ typedef int32_t (*iFpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void
|
||||
GO(getpwuid_r, iFuppLp_t) \
|
||||
GO(getgrnam_r, iFpppLp_t) \
|
||||
GO(getpwnam_r, iFpppLp_t) \
|
||||
GO(gethostbyname_r, iFpppupp_t) \
|
||||
GO(posix_spawn, iFpppppp_t)
|
||||
|
||||
#endif // __wrappedlibcTYPES32_H_
|
||||
|
@ -1260,6 +1260,7 @@ typedef void (*vFXpiipii_t)(void*, void*, int32_t, int32_t, void*, int32_t, int3
|
||||
typedef void (*vFXppiiii_t)(void*, void*, void*, int32_t, int32_t, int32_t, int32_t);
|
||||
typedef int32_t (*iFEpLiipV_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, void*, void*);
|
||||
typedef int32_t (*iFEpLiLpV_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, void*, void*);
|
||||
typedef int32_t (*iFEpppupp_t)(x64emu_t*, void*, void*, void*, uint32_t, void*, void*);
|
||||
typedef int32_t (*iFEpppppp_t)(x64emu_t*, void*, void*, void*, void*, void*, void*);
|
||||
typedef int32_t (*iFEXLpiiL_t)(x64emu_t*, void*, uintptr_t, void*, int32_t, int32_t, uintptr_t);
|
||||
typedef int32_t (*iFEXLpppp_t)(x64emu_t*, void*, uintptr_t, void*, void*, void*, void*);
|
||||
@ -1327,6 +1328,7 @@ typedef void (*vFXLppiipi_t)(void*, uintptr_t, void*, void*, int32_t, int32_t, v
|
||||
typedef int32_t (*iFEpippppp_t)(x64emu_t*, void*, int32_t, void*, void*, void*, void*, void*);
|
||||
typedef int32_t (*iFEpLiLppp_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, 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 (*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*);
|
||||
typedef int32_t (*iFXLppLpip_t)(void*, uintptr_t, void*, void*, uintptr_t, void*, int32_t, void*);
|
||||
@ -2654,6 +2656,7 @@ void vFXpiipii_32(x64emu_t *emu, uintptr_t fcn) { vFXpiipii_t fn = (vFXpiipii_t)
|
||||
void vFXppiiii_32(x64emu_t *emu, uintptr_t fcn) { vFXppiiii_t fn = (vFXppiiii_t)fcn; fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28)); }
|
||||
void iFEpLiipV_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiipV_t fn = (iFEpLiipV_t)fcn; 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_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptrv(R_ESP + 24)); }
|
||||
void iFEpLiLpV_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiLpV_t fn = (iFEpLiLpV_t)fcn; 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_ptrv(R_ESP + 24)); }
|
||||
void iFEpppupp_32(x64emu_t *emu, uintptr_t fcn) { iFEpppupp_t fn = (iFEpppupp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
|
||||
void iFEpppppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpppppp_t fn = (iFEpppppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
|
||||
void iFEXLpiiL_32(x64emu_t *emu, uintptr_t fcn) { iFEXLpiiL_t fn = (iFEXLpiiL_t)fcn; R_EAX = fn(emu, 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_ptri(int32_t, R_ESP + 20), from_ulong(from_ptri(ulong_t, R_ESP + 24))); }
|
||||
void iFEXLpppp_32(x64emu_t *emu, uintptr_t fcn) { iFEXLpppp_t fn = (iFEXLpppp_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
|
||||
@ -2721,6 +2724,7 @@ void vFXLppiipi_32(x64emu_t *emu, uintptr_t fcn) { vFXLppiipi_t fn = (vFXLppiipi
|
||||
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)); }
|
||||
void iFEpLiLppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiLppp_t fn = (iFEpLiLppp_t)fcn; 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)); }
|
||||
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 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)); }
|
||||
void iFXLppLpip_32(x64emu_t *emu, uintptr_t fcn) { iFXLppLpip_t fn = (iFXLppLpip_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_ptriv(R_ESP + 16), from_ulong(from_ptri(ulong_t, R_ESP + 20)), from_ptriv(R_ESP + 24), from_ptri(int32_t, R_ESP + 28), from_ptriv(R_ESP + 32)); }
|
||||
|
@ -1211,6 +1211,7 @@ void vFXpiipii_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void vFXppiiii_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpLiipV_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpLiLpV_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpppupp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpppppp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEXLpiiL_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEXLpppp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
@ -1278,6 +1279,7 @@ void vFXLppiipi_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpippppp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFEpLiLppp_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 iFXuupuupp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFXLpipppp_32(x64emu_t *emu, uintptr_t fnc);
|
||||
void iFXLppLpip_32(x64emu_t *emu, uintptr_t fnc);
|
||||
|
@ -495,11 +495,11 @@ GOM(getgrnam_r, iFEpppLp)
|
||||
GOW(getgroups, iFip)
|
||||
// __getgroups_chk
|
||||
//GO(gethostbyaddr, pFpui)
|
||||
//GO(gethostbyaddr_r, iFpuippupp)
|
||||
GO(gethostbyaddr_r, iFpuippupp)
|
||||
GOM(gethostbyname, pFEp)
|
||||
//GO(gethostbyname2, pFpi)
|
||||
//GO(gethostbyname2_r, iFpippupp)
|
||||
//GO(gethostbyname_r, iFpppupp)
|
||||
GOM(gethostbyname_r, iFEpppupp)
|
||||
//GO(gethostent, pFv)
|
||||
//GO(gethostent_r, iFppupp)
|
||||
// gethostid
|
||||
|
Loading…
Reference in New Issue
Block a user