Skip to content

Commit

Permalink
[WRAPPER] Added a bunch of libc wrapped functions (for #2010)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptitSeb committed Nov 9, 2024
1 parent 1d607cb commit ee6e3a7
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/wrapped/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1787,6 +1787,7 @@
#() UFuiCiu
#() lFEippL
#() lFEuipp
#() lFEppLL
#() lFipiIi
#() lFipili
#() lFipLli
Expand Down Expand Up @@ -4461,6 +4462,7 @@ wrappedlibc:
- sscanf
- swscanf
- iFppA:
- __isoc23_vsscanf
- __isoc99_vfscanf
- __isoc99_vsscanf
- __isoc99_vswscanf
Expand Down Expand Up @@ -4554,6 +4556,8 @@ wrappedlibc:
- readlinkat
- lFuipp:
- ptrace
- lFppLL:
- __readlink_chk
- vFpLLpp:
- qsort_r
- iFiipup:
Expand Down
3 changes: 3 additions & 0 deletions src/wrapped/generated/wrappedlibctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ typedef int32_t (*iFppii_t)(void*, void*, int32_t, int32_t);
typedef int32_t (*iFpppp_t)(void*, void*, void*, void*);
typedef intptr_t (*lFippL_t)(int32_t, void*, void*, uintptr_t);
typedef intptr_t (*lFuipp_t)(uint32_t, int32_t, void*, void*);
typedef intptr_t (*lFppLL_t)(void*, void*, uintptr_t, uintptr_t);
typedef void (*vFpLLpp_t)(void*, uintptr_t, uintptr_t, void*, void*);
typedef int32_t (*iFiipup_t)(int32_t, int32_t, void*, uint32_t, void*);
typedef int32_t (*iFiippi_t)(int32_t, int32_t, void*, void*, int32_t);
Expand Down Expand Up @@ -229,6 +230,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*
GO(sprintf, iFppV_t) \
GO(sscanf, iFppV_t) \
GO(swscanf, iFppV_t) \
GO(__isoc23_vsscanf, iFppA_t) \
GO(__isoc99_vfscanf, iFppA_t) \
GO(__isoc99_vsscanf, iFppA_t) \
GO(__isoc99_vswscanf, iFppA_t) \
Expand Down Expand Up @@ -292,6 +294,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*
GO(scandir64, iFpppp_t) \
GO(readlinkat, lFippL_t) \
GO(ptrace, lFuipp_t) \
GO(__readlink_chk, lFppLL_t) \
GO(qsort_r, vFpLLpp_t) \
GO(__xmknodat, iFiipup_t) \
GO(__fxstatat, iFiippi_t) \
Expand Down
2 changes: 2 additions & 0 deletions src/wrapped/generated/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1816,6 +1816,7 @@ typedef uint32_t (*uFbuuup_t)(void*, uint32_t, uint32_t, uint32_t, void*);
typedef uint64_t (*UFuiCiu_t)(uint32_t, int32_t, uint8_t, int32_t, uint32_t);
typedef intptr_t (*lFEippL_t)(x64emu_t*, int32_t, void*, void*, uintptr_t);
typedef intptr_t (*lFEuipp_t)(x64emu_t*, uint32_t, int32_t, void*, void*);
typedef intptr_t (*lFEppLL_t)(x64emu_t*, void*, void*, uintptr_t, uintptr_t);
typedef intptr_t (*lFipiIi_t)(int32_t, void*, int32_t, int64_t, int32_t);
typedef intptr_t (*lFipili_t)(int32_t, void*, int32_t, intptr_t, int32_t);
typedef intptr_t (*lFipLli_t)(int32_t, void*, uintptr_t, intptr_t, int32_t);
Expand Down Expand Up @@ -5151,6 +5152,7 @@ void uFbuuup(x64emu_t *emu, uintptr_t fcn) { uFbuuup_t fn = (uFbuuup_t)fcn; void
void UFuiCiu(x64emu_t *emu, uintptr_t fcn) { UFuiCiu_t fn = (UFuiCiu_t)fcn; R_RAX=fn((uint32_t)R_RDI, (int32_t)R_RSI, (uint8_t)R_RDX, (int32_t)R_RCX, (uint32_t)R_R8); }
void lFEippL(x64emu_t *emu, uintptr_t fcn) { lFEippL_t fn = (lFEippL_t)fcn; R_RAX=(intptr_t)fn(emu, (int32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX); }
void lFEuipp(x64emu_t *emu, uintptr_t fcn) { lFEuipp_t fn = (lFEuipp_t)fcn; R_RAX=(intptr_t)fn(emu, (uint32_t)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (void*)R_RCX); }
void lFEppLL(x64emu_t *emu, uintptr_t fcn) { lFEppLL_t fn = (lFEppLL_t)fcn; R_RAX=(intptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (uintptr_t)R_RCX); }
void lFipiIi(x64emu_t *emu, uintptr_t fcn) { lFipiIi_t fn = (lFipiIi_t)fcn; R_RAX=(intptr_t)fn((int32_t)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (int64_t)R_RCX, (int32_t)R_R8); }
void lFipili(x64emu_t *emu, uintptr_t fcn) { lFipili_t fn = (lFipili_t)fcn; R_RAX=(intptr_t)fn((int32_t)R_RDI, (void*)R_RSI, (int32_t)R_RDX, (intptr_t)R_RCX, (int32_t)R_R8); }
void lFipLli(x64emu_t *emu, uintptr_t fcn) { lFipLli_t fn = (lFipLli_t)fcn; R_RAX=(intptr_t)fn((int32_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (intptr_t)R_RCX, (int32_t)R_R8); }
Expand Down
1 change: 1 addition & 0 deletions src/wrapped/generated/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,7 @@ void uFbuuup(x64emu_t *emu, uintptr_t fnc);
void UFuiCiu(x64emu_t *emu, uintptr_t fnc);
void lFEippL(x64emu_t *emu, uintptr_t fnc);
void lFEuipp(x64emu_t *emu, uintptr_t fnc);
void lFEppLL(x64emu_t *emu, uintptr_t fnc);
void lFipiIi(x64emu_t *emu, uintptr_t fnc);
void lFipili(x64emu_t *emu, uintptr_t fnc);
void lFipLli(x64emu_t *emu, uintptr_t fnc);
Expand Down
7 changes: 6 additions & 1 deletion src/wrapped/wrappedlibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1715,6 +1715,11 @@ EXPORT ssize_t my_readlink(x64emu_t* emu, void* path, void* buf, size_t sz)
return readlink((const char*)path, (char*)buf, sz);
}

EXPORT ssize_t my___readlink_chk(x64emu_t* emu, void* path, void* buf, size_t sz, size_t buflen)
{
return my_readlink(emu, path, buf, sz);
}

int getNCpu(); // defined in my_cpuid.c
const char* getBoxCpuName(); // defined in my_cpuid.c
const char* getCpuName(); // defined in my_cpu_id.c
Expand Down Expand Up @@ -3163,7 +3168,7 @@ EXPORT int my_mprotect(x64emu_t* emu, void *addr, unsigned long len, int prot)
if(prot& PROT_EXEC)
addDBFromAddressRange((uintptr_t)addr, len);
else
cleanDBFromAddressRange((uintptr_t)addr, len, 1);
cleanDBFromAddressRange((uintptr_t)addr, len, (!prot)?1:0);
}
#endif
if(!ret && len) {
Expand Down
12 changes: 9 additions & 3 deletions src/wrapped/wrappedlibc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ GO(gethostent, pFv)
GO(gethostent_r, iFppLpp)
GO(gethostid, lFv)
GOW(gethostname, iFpL)
//GO(__gethostname_chk,
GO(__gethostname_chk, iFpLL)
GOW(getifaddrs, iFp)
GO(getipv4sourcefilter, iFiuuppp)
GOW(getitimer, iFup)
Expand Down Expand Up @@ -1601,7 +1601,7 @@ GOW(readdir_r, iFppp)
GOWM(readlink, lFEppL)
GOM(readlinkat, lFEippL)
//GO(__readlinkat_chk,
//GO(__readlink_chk,
GOM(__readlink_chk, lFEppLL)
//GO(__read_nocancel,
GOW(readv, lFipi)
GO(realloc, pFpL)
Expand Down Expand Up @@ -2018,6 +2018,12 @@ GOW(strtof_l, fFppp)
//GO(__strtof_nan,
GO(strtoimax, IFppi)
GO2(__isoc23_strtoimax, IFppi, strtoimax)
GO2(__isoc23_strtoll_l, IFppip, strtoll_l)
GO2(__isoc23_strtoull_l, UFppip, strtoull_l)
GO2(__isoc23_vsscanf, iFEppA, my_vsscanf)
GO2(__isoc23_wcstoll, IFppi, wcstoll)
GO2(__isoc23_wcstoul, LFppi, wcstoul)
GO2(__isoc23_wcstoull, UFppi, wcstoull)
GO(strtok, pFpp)
GO(__strtok_r, pFppp)
GOW(strtok_r, pFppp)
Expand Down Expand Up @@ -2399,7 +2405,7 @@ GOW(wcstoll, IFppi)
//GOW(__wcstoll_l,
GOW(wcstoll_l, IFppip)
GO(wcstombs, LFppL)
//GO(__wcstombs_chk,
GO(__wcstombs_chk, LFppLL)
GOW(wcstoq, IFppi)
GO(wcstoul, LFppi)
//GO(__wcstoul_internal,
Expand Down

0 comments on commit ee6e3a7

Please sign in to comment.