[BOX32] Added some more 32bits wrapped function to libc

This commit is contained in:
ptitSeb 2024-10-13 17:44:14 +02:00
parent 59ba2fc7ab
commit d30488da87
8 changed files with 50 additions and 10 deletions

View File

@ -1288,6 +1288,7 @@
#() iFXpLiWwL -> iFXpLiWwL
#() iFXpLuuii -> iFXpLuuii
#() uFuippppp -> uFuippppp
#() lFEipLpLL -> lFEipLpLL
#() pFEpiiiiu -> pFEpiiiiu
#() pFEpLiiii -> pFEpLiiii
#() pFEpLiiiI -> pFEpLiiiI
@ -1667,6 +1668,7 @@ wrappedlibc:
- backtrace_symbols
- pFpp:
- __cmsg_nxthdr
- __gmtime_r
- gmtime_r
- localtime_r
- SFpp:
@ -1688,6 +1690,7 @@ wrappedlibc:
- iFppp:
- vswscanf
- iFppV:
- __isoc99_fscanf
- swscanf
- iFpON:
- iFSpp:
@ -1749,6 +1752,9 @@ wrappedlibc:
- gethostbyname_r
- iFpppppp:
- posix_spawn
- lFipLpLL:
- process_vm_readv
- process_vm_writev
- pFpLiiiI:
- pFpLiiil:
- iFpippppp:
@ -2007,6 +2013,8 @@ wrappedlibpthread:
- iFBh_ppp:
- pthread_create
wrappedlibrt:
- iFuBLL_:
- __clock_gettime
wrappedlibuuid:
wrappedlibx11:
- vFp:

View File

@ -103,6 +103,7 @@ 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 intptr_t (*lFipLpLL_t)(int32_t, void*, uintptr_t, void*, uintptr_t, uintptr_t);
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);
typedef int32_t (*iFpippppp_t)(void*, int32_t, void*, void*, void*, void*, void*);
@ -150,12 +151,14 @@ typedef int32_t (*iFpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void
GO(signal, pFip_t) \
GO(backtrace_symbols, pFpi_t) \
GO(__cmsg_nxthdr, pFpp_t) \
GO(__gmtime_r, pFpp_t) \
GO(gmtime_r, pFpp_t) \
GO(localtime_r, pFpp_t) \
GO(vsyslog, vFipp_t) \
GO(_ITM_addUserCommitAction, vFpup_t) \
GO(posix_spawn_file_actions_adddup2, iFpii_t) \
GO(vswscanf, iFppp_t) \
GO(__isoc99_fscanf, iFppV_t) \
GO(swscanf, iFppV_t) \
GO(fscanf, iFSpV_t) \
GO(recvmsg, lFipi_t) \
@ -176,6 +179,8 @@ typedef int32_t (*iFpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void
GO(getgrnam_r, iFpppLp_t) \
GO(getpwnam_r, iFpppLp_t) \
GO(gethostbyname_r, iFpppupp_t) \
GO(posix_spawn, iFpppppp_t)
GO(posix_spawn, iFpppppp_t) \
GO(process_vm_readv, lFipLpLL_t) \
GO(process_vm_writev, lFipLpLL_t)
#endif // __wrappedlibcTYPES32_H_

View File

@ -11,7 +11,9 @@
#define ADDED_FUNCTIONS()
#endif
typedef int32_t (*iFuBLL__t)(uint32_t, struct_LL_t*);
#define SUPER() ADDED_FUNCTIONS()
#define SUPER() ADDED_FUNCTIONS() \
GO(__clock_gettime, iFuBLL__t)
#endif // __wrappedlibrtTYPES32_H_

View File

@ -1378,6 +1378,7 @@ typedef int32_t (*iFXpiipii_t)(void*, void*, int32_t, int32_t, void*, int32_t, i
typedef int32_t (*iFXpLiWwL_t)(void*, void*, uintptr_t, int32_t, uint16_t, int16_t, uintptr_t);
typedef int32_t (*iFXpLuuii_t)(void*, void*, uintptr_t, uint32_t, uint32_t, int32_t, int32_t);
typedef uint32_t (*uFuippppp_t)(uint32_t, int32_t, void*, void*, void*, void*, void*);
typedef intptr_t (*lFEipLpLL_t)(x64emu_t*, int32_t, void*, uintptr_t, void*, uintptr_t, uintptr_t);
typedef void* (*pFEpiiiiu_t)(x64emu_t*, void*, int32_t, int32_t, int32_t, int32_t, uint32_t);
typedef void* (*pFEpLiiii_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, int32_t, int32_t);
typedef void* (*pFEpLiiiI_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, int32_t, int64_t);
@ -2878,6 +2879,7 @@ void iFXpiipii_32(x64emu_t *emu, uintptr_t fcn) { iFXpiipii_t fn = (iFXpiipii_t)
void iFXpLiWwL_32(x64emu_t *emu, uintptr_t fcn) { iFXpLiWwL_t fn = (iFXpLiWwL_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptri(int32_t, R_ESP + 16), from_ptri(uint16_t, R_ESP + 20), from_ptri(int16_t, R_ESP + 24), from_ulong(from_ptri(ulong_t, R_ESP + 28))); }
void iFXpLuuii_32(x64emu_t *emu, uintptr_t fcn) { iFXpLuuii_t fn = (iFXpLuuii_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ulong(from_ptri(ulong_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)); }
void uFuippppp_32(x64emu_t *emu, uintptr_t fcn) { uFuippppp_t fn = (uFuippppp_t)fcn; R_EAX = (uint32_t)fn(from_ptri(uint32_t, 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 lFEipLpLL_32(x64emu_t *emu, uintptr_t fcn) { lFEipLpLL_t fn = (lFEipLpLL_t)fcn; R_EAX = to_long(fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptriv(R_ESP + 16), from_ulong(from_ptri(ulong_t, R_ESP + 20)), from_ulong(from_ptri(ulong_t, R_ESP + 24)))); }
void pFEpiiiiu_32(x64emu_t *emu, uintptr_t fcn) { pFEpiiiiu_t fn = (pFEpiiiiu_t)fcn; 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), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24))); }
void pFEpLiiii_32(x64emu_t *emu, uintptr_t fcn) { pFEpLiiii_t fn = (pFEpLiiii_t)fcn; R_EAX = to_ptrv(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_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24))); }
void pFEpLiiiI_32(x64emu_t *emu, uintptr_t fcn) { pFEpLiiiI_t fn = (pFEpLiiiI_t)fcn; R_EAX = to_ptrv(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_ptri(int32_t, R_ESP + 20), from_ptri(int64_t, R_ESP + 24))); }

View File

@ -1329,6 +1329,7 @@ void iFXpiipii_32(x64emu_t *emu, uintptr_t fnc);
void iFXpLiWwL_32(x64emu_t *emu, uintptr_t fnc);
void iFXpLuuii_32(x64emu_t *emu, uintptr_t fnc);
void uFuippppp_32(x64emu_t *emu, uintptr_t fnc);
void lFEipLpLL_32(x64emu_t *emu, uintptr_t fnc);
void pFEpiiiiu_32(x64emu_t *emu, uintptr_t fnc);
void pFEpLiiii_32(x64emu_t *emu, uintptr_t fnc);
void pFEpLiiiI_32(x64emu_t *emu, uintptr_t fnc);

View File

@ -2936,6 +2936,27 @@ EXPORT int my32_sysinfo(struct sysinfo_32* p)
p->mem_unit = info.mem_unit;
return ret;
}
EXPORT ssize_t my32_process_vm_readv(x64emu_t* emu, int pid, struct i386_iovec* local_iovec, size_t liovect, struct i386_iovec* remote_iovec, size_t riovect, unsigned long flags)
{
struct iovec local_iovec_l[liovect];
struct iovec remove_iovec_l[riovect];
for (int i=0; i<liovect; ++i)
AlignIOV_32(local_iovec_l+i, local_iovec+i);
for (int i=0; i<riovect; ++i)
AlignIOV_32(remove_iovec_l+i, remote_iovec+i);
return process_vm_readv(pid, local_iovec_l, liovect, remove_iovec_l, riovect, flags);
}
EXPORT ssize_t my32_process_vm_writev(x64emu_t* emu, int pid, struct i386_iovec* local_iovec, size_t liovect, struct i386_iovec* remote_iovec, size_t riovect, unsigned long flags)
{
struct iovec local_iovec_l[liovect];
struct iovec remove_iovec_l[riovect];
for (int i=0; i<liovect; ++i)
AlignIOV_32(local_iovec_l+i, local_iovec+i);
for (int i=0; i<riovect; ++i)
AlignIOV_32(remove_iovec_l+i, remote_iovec+i);
return process_vm_writev(pid, local_iovec_l, liovect, remove_iovec_l, riovect, flags);
}
#if 0
#ifndef __NR_memfd_create
#define MFD_CLOEXEC 0x0001U

View File

@ -625,7 +625,7 @@ GO(getxattr, iFpppL)
//GO(globfree64, vFp)
// glob_pattern_p // Weak
GOM(gmtime, pFEp)
//GO(__gmtime_r, pFpp)
GO2(__gmtime_r, pFpp, my32_gmtime_r)
GOWM(gmtime_r, pFEpp)
GO(gnu_dev_major, uFU)
GO(gnu_dev_makedev, UFuu)
@ -664,7 +664,7 @@ GO(iconv_open, pFpp)
//GO(if_nametoindex, uFp)
// imaxabs // Weak
GOWS(imaxdiv, pFpII) //%%
//DATA(in6addr_any, 16) // type R
DATA(in6addr_any, 16) // type R
//DATA(in6addr_loopback, 16) // type R
// inb // Weak
//GOW(index, pFpi)
@ -888,7 +888,7 @@ GOW(isnanf, iFf)
GO(__isnanf, iFf)
// isnanl // Weak
// __isnanl
//GOM(__isoc99_fscanf, iFEppV) //%%
GO2(__isoc99_fscanf, iFEppV, my32_fscanf)
// __isoc99_fwscanf
// __isoc99_scanf
GOM(__isoc99_sscanf, iFEppV) //%%
@ -1393,7 +1393,7 @@ GO(renameat, iFipip)
// re_set_registers // Weak
GOW(re_set_syntax, LFL)
// _res_hconf // type B
//GO(__res_iclose, vFpi)
GO(__res_iclose, vFpi)
GO(__res_init, iFv)
//GO(__res_maybe_init, iFpi)
//GO(__res_nclose, vFp)
@ -1452,8 +1452,8 @@ GO(__sched_setscheduler, iFiip)
GOW(sched_setscheduler, iFiip)
GO(__sched_yield, iFv)
GOW(sched_yield, iFv)
GO(__secure_getenv, pFp)
GO(secure_getenv, pFp)
GO(__secure_getenv, tFp)
GO(secure_getenv, tFp)
// seed48
// seed48_r // Weak
//GO(seekdir, vFpi)
@ -2131,8 +2131,8 @@ GOM(__fdelt_chk, LFL) //%%,noE
GOM(getauxval, LFEL) //%% implemented since glibc 2.16
//GOM(prlimit64, lFpupp) //%%,noE
//GO(process_vm_readv, lFipLpLL)
//GO(process_vm_writev, lFipLpLL)
GOM(process_vm_readv, lFEipLpLL)
GOM(process_vm_writev, lFEipLpLL)
//GOM(reallocarray, pFpLL) //%%,noE
//GOM(__open_nocancel, iFEpOV) //%%
//GO2(__read_nocancel, lFipL, read)

View File

@ -26,6 +26,7 @@ GO(aio_write64, iFp)
GO(clock_getcpuclockid, iFup)
GO(clock_getres, iFup)
GO(clock_gettime, iFuBLL_) // *timespec
GO2(__clock_gettime, iFuBLL_, clock_gettime)
GO(clock_nanosleep, iFuirLL_BLL_)
//GO(clock_settime, iFup)
// lio_listio