Skip to content

Commit

Permalink
[BOX32][WRAPPER] Added a few more 32bts wrapped functions to libc and…
Browse files Browse the repository at this point in the history
… libresolv
  • Loading branch information
ptitSeb committed Jan 6, 2025
1 parent 8a7c2b5 commit 91e678d
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 14 deletions.
2 changes: 2 additions & 0 deletions src/wrapped32/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@
#() pFip -> pFip
#() pEia -> pEia
#() pFuu -> pFuu
#() pEup -> pEup
#() pFup -> pFup
#() pELL -> pELL
#() pFLL -> pFLL
Expand Down Expand Up @@ -2441,6 +2442,7 @@ wrappedlibresolv:
- __dn_expand
- iFppiipi:
- __res_nquery
- __res_nsearch
wrappedlibrt:
- iEuBLL_:
- __clock_gettime
Expand Down
3 changes: 2 additions & 1 deletion src/wrapped32/generated/wrappedlibresolvtypes32.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ typedef int32_t (*iFppiipi_t)(void*, void*, int32_t, int32_t, void*, int32_t);
GO(res_search, iEpiipi_t) \
GO(__res_search, iFpiipi_t) \
GO(__dn_expand, iFppppi_t) \
GO(__res_nquery, iFppiipi_t)
GO(__res_nquery, iFppiipi_t) \
GO(__res_nsearch, iFppiipi_t)

#endif // __wrappedlibresolvTYPES32_H_
2 changes: 2 additions & 0 deletions src/wrapped32/generated/wrapper32.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ typedef void* (*pFiu_t)(int32_t, uint32_t);
typedef void* (*pFip_t)(int32_t, void*);
typedef void* (*pEia_t)(int32_t, void*);
typedef void* (*pFuu_t)(uint32_t, uint32_t);
typedef void* (*pEup_t)(uint32_t, void*);
typedef void* (*pFup_t)(uint32_t, void*);
typedef void* (*pELL_t)(uintptr_t, uintptr_t);
typedef void* (*pFLL_t)(uintptr_t, uintptr_t);
Expand Down Expand Up @@ -2226,6 +2227,7 @@ void pFiu_32(x64emu_t *emu, uintptr_t fcn) { pFiu_t fn = (pFiu_t)fcn; R_EAX = to
void pFip_32(x64emu_t *emu, uintptr_t fcn) { pFip_t fn = (pFip_t)fcn; R_EAX = to_ptrv(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8))); }
void pEia_32(x64emu_t *emu, uintptr_t fcn) { pEia_t fn = (pEia_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(from_ptri(int32_t, R_ESP + 4), from_locale(from_ptri(ptr_t, R_ESP + 8)))); emu->libc_err = errno; }
void pFuu_32(x64emu_t *emu, uintptr_t fcn) { pFuu_t fn = (pFuu_t)fcn; R_EAX = to_ptrv(fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8))); }
void pEup_32(x64emu_t *emu, uintptr_t fcn) { pEup_t fn = (pEup_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8))); emu->libc_err = errno; }
void pFup_32(x64emu_t *emu, uintptr_t fcn) { pFup_t fn = (pFup_t)fcn; R_EAX = to_ptrv(fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8))); }
void pELL_32(x64emu_t *emu, uintptr_t fcn) { pELL_t fn = (pELL_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(from_ulong(from_ptri(ulong_t, R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)))); emu->libc_err = errno; }
void pFLL_32(x64emu_t *emu, uintptr_t fcn) { pFLL_t fn = (pFLL_t)fcn; R_EAX = to_ptrv(fn(from_ulong(from_ptri(ulong_t, R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)))); }
Expand Down
1 change: 1 addition & 0 deletions src/wrapped32/generated/wrapper32.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ void pFiu_32(x64emu_t *emu, uintptr_t fnc);
void pFip_32(x64emu_t *emu, uintptr_t fnc);
void pEia_32(x64emu_t *emu, uintptr_t fnc);
void pFuu_32(x64emu_t *emu, uintptr_t fnc);
void pEup_32(x64emu_t *emu, uintptr_t fnc);
void pFup_32(x64emu_t *emu, uintptr_t fnc);
void pELL_32(x64emu_t *emu, uintptr_t fnc);
void pFLL_32(x64emu_t *emu, uintptr_t fnc);
Expand Down
17 changes: 8 additions & 9 deletions src/wrapped32/wrappedlibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ static const char* libcName =

extern int fix_64bit_inodes;
typedef int32_t (*iFiiV_t)(int32_t, int32_t, ...);
typedef int32_t (*iFpipp_t)(void*, int32_t, void*, void*);
#if 0
typedef int (*iFL_t)(unsigned long);
typedef void (*vFpp_t)(void*, void*);
Expand All @@ -147,7 +148,6 @@ typedef int32_t (*iFiiII_t)(int, int, int64_t, int64_t);
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 (*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);
Expand Down Expand Up @@ -305,13 +305,13 @@ static void* findnftw64Fct(void* fct)
printf_log(LOG_NONE, "Warning, no more slot for libc nftw64 callback\n");
return NULL;
}
#if 0

// globerr
#define GO(A) \
static uintptr_t my32_globerr_fct_##A = 0; \
static int my32_globerr_##A(void* epath, int eerrno) \
static uintptr_t my32_globerr_fct_##A = 0; \
static int my32_globerr_##A(void* epath, int eerrno) \
{ \
return (int)RunFunction(my_context, my32_globerr_fct_##A, 2, epath, eerrno); \
return (int)RunFunctionFmt(my32_globerr_fct_##A, "pi", epath, eerrno); \
}
SUPER()
#undef GO
Expand All @@ -329,7 +329,7 @@ static void* findgloberrFct(void* fct)
printf_log(LOG_NONE, "Warning, no more slot for libc globerr callback\n");
return NULL;
}
#endif

#undef dirent
// filter_dir
#define GO(A) \
Expand Down Expand Up @@ -1626,19 +1626,18 @@ EXPORT int32_t my32_epoll_wait(x64emu_t* emu, int32_t epfd, void* events, int32_
UnalignEpollEvent32(events, _events, ret);
return ret;
}
#if 0
EXPORT int32_t my32_glob(x64emu_t *emu, void* pat, int32_t flags, void* errfnc, void* pglob)
{
static iFpipp_t f = NULL;
if(!f) {
library_t* lib = my_lib;
if(!lib) return 0;
f = (iFpipp_t)dlsym(lib->priv.w.lib, "glob");
f = (iFpipp_t)dlsym(NULL, "glob");
}

return f(pat, flags, findgloberrFct(errfnc), pglob);
}

#if 0
#ifndef ANDROID
EXPORT int32_t my32_glob64(x64emu_t *emu, void* pat, int32_t flags, void* errfnc, void* pglob)
{
Expand Down
6 changes: 3 additions & 3 deletions src/wrapped32/wrappedlibc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ GO(getwchar_unlocked, uEv)
//GO(getwd, pEp)
// __getwd_chk
GO(getxattr, iEpppL)
//GOM(glob, iEEpipp) //%%
GOM(glob, iEEpipp) //%%
//GOM(glob64, iEEpipp) //%%
//GO(globfree, vEp)
GO(globfree, vEp)
//GO(globfree64, vEp)
// glob_pattern_p // Weak
GOM(gmtime, pEEp)
Expand Down Expand Up @@ -668,7 +668,7 @@ GO(iconv, LELbp_bL_bp_bL_)
GO(iconv_close, iEp)
GO(iconv_open, pEpp)
//GO(if_freenameindex, vEp)
//GO(if_indextoname, pEup)
GOW(if_indextoname, pEup)
//GO(if_nameindex, pEv)
GO(if_nametoindex, uEp)
// imaxabs // Weak
Expand Down
2 changes: 1 addition & 1 deletion src/wrapped32/wrappedlibresolv_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ GOM(ns_parserr, iFEpuip)
//GO(__res_nmkquery,
GO2(__res_nquery, iFppiipi, res_nquery)
//GO(__res_nquerydomain,
//GO(__res_nsearch, iFppiipi)
GO2(__res_nsearch, iFppiipi, res_nsearch)
//GO(__res_nsend,
//DATA(_res_opcodes, 4)
//GO(__res_ownok, iFp)
Expand Down

0 comments on commit 91e678d

Please sign in to comment.