Added dprintf and __dprintf_chk wrapped functions (for #558)

This commit is contained in:
ptitSeb 2022-01-21 08:47:24 +01:00
parent c80356a90a
commit e31e5c1a5b
6 changed files with 37 additions and 2 deletions

View File

@ -2001,6 +2001,7 @@
#() iFpppppppppppppppppppppppppppppppppp
#defined(NOALIGN) IFpi
#defined(NOALIGN) iFipV
#defined(NOALIGN) iFiipV
#defined(NOALIGN) iFppiiiip
#!defined(NOALIGN) iFEi
#!defined(NOALIGN) iFEO
@ -2043,6 +2044,7 @@
#() pFpsvvvvs -> pFpss
#() iFEpuvvppp -> iFEpuppp
#defined(NOALIGN) iFpvpV -> iFppV
#!defined(NOALIGN) iFEivpV -> iFEipV
wrappedalure:
wrappedalut:
wrappedappindicator:
@ -2709,6 +2711,7 @@ wrappedlibc:
- iFipp:
- getopt
- iFipV:
- dprintf
- iFpuu:
- iFpLi:
- iFppi:
@ -2738,6 +2741,7 @@ wrappedlibc:
- vFpLLp:
- vFpppp:
- __libc_init
- iFivpV:
- iFiiip:
- iFiiiN:
- iFiiII:

View File

@ -71,6 +71,7 @@ typedef void* (*pFpLL_t)(void*, uintptr_t, uintptr_t);
typedef void (*vFiipV_t)(int32_t, int32_t, void*, ...);
typedef void (*vFpLLp_t)(void*, uintptr_t, uintptr_t, void*);
typedef void (*vFpppp_t)(void*, void*, void*, void*);
typedef int32_t (*iFivpV_t)(int32_t, void, void*, ...);
typedef int32_t (*iFiiip_t)(int32_t, int32_t, int32_t, void*);
typedef int32_t (*iFiiiN_t)(int32_t, int32_t, int32_t, ...);
typedef int32_t (*iFiiII_t)(int32_t, int32_t, int64_t, int64_t);
@ -134,6 +135,7 @@ typedef int32_t (*iFpuvvppp_t)(void*, uint32_t, void, void, void*, void*, void*)
GO(__vwprintf_chk, iFvpp_t) \
GO(modify_ldt, iFipL_t) \
GO(getopt, iFipp_t) \
GO(dprintf, iFipV_t) \
GO(_IO_vfscanf, iFppp_t) \
GO(__isoc99_fscanf, iFppV_t) \
GO(__isoc99_sscanf, iFppV_t) \

View File

@ -2075,6 +2075,7 @@ typedef int32_t (*iFpppppppppppppppppppppppppppppppppp_t)(void*, void*, void*, v
#if defined(NOALIGN)
typedef int64_t (*IFpi_t)(void*, int32_t);
typedef int32_t (*iFipV_t)(int32_t, void*, void*);
typedef int32_t (*iFiipV_t)(int32_t, int32_t, void*, void*);
typedef int32_t (*iFppiiiip_t)(void*, void*, int32_t, int32_t, int32_t, int32_t, void*);
#endif
@ -4130,6 +4131,7 @@ void iFpppppppppppppppppppppppppppppppppp(x86emu_t *emu, uintptr_t fcn) { iFpppp
#if defined(NOALIGN)
void IFpi(x86emu_t *emu, uintptr_t fcn) { IFpi_t fn = (IFpi_t)fcn; ui64_t r; r.i=fn(*(void**)(R_ESP + 4), *(int32_t*)(R_ESP + 8)); R_EAX=r.d[0]; R_EDX=r.d[1]; }
void iFipV(x86emu_t *emu, uintptr_t fcn) { iFipV_t fn = (iFipV_t)fcn; R_EAX=fn(*(int32_t*)(R_ESP + 4), *(void**)(R_ESP + 8), (void*)(R_ESP + 12)); }
void iFiipV(x86emu_t *emu, uintptr_t fcn) { iFiipV_t fn = (iFiipV_t)fcn; R_EAX=fn(*(int32_t*)(R_ESP + 4), *(int32_t*)(R_ESP + 8), *(void**)(R_ESP + 12), (void*)(R_ESP + 16)); }
void iFppiiiip(x86emu_t *emu, uintptr_t fcn) { iFppiiiip_t fn = (iFppiiiip_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 8), *(int32_t*)(R_ESP + 12), *(int32_t*)(R_ESP + 16), *(int32_t*)(R_ESP + 20), *(int32_t*)(R_ESP + 24), *(void**)(R_ESP + 28)); }
#endif
@ -4192,3 +4194,7 @@ void iFEpuvvppp(x86emu_t *emu, uintptr_t fcn) { iFEpuppp_t fn = (iFEpuppp_t)fcn;
#if defined(NOALIGN)
void iFpvpV(x86emu_t *emu, uintptr_t fcn) { iFppV_t fn = (iFppV_t)fcn; R_EAX=fn(*(void**)(R_ESP + 4), *(void**)(R_ESP + 12), (void*)(R_ESP + 16)); }
#endif
#if !defined(NOALIGN)
void iFEivpV(x86emu_t *emu, uintptr_t fcn) { iFEipV_t fn = (iFEipV_t)fcn; R_EAX=fn(emu, *(int32_t*)(R_ESP + 4), *(void**)(R_ESP + 12), (void*)(R_ESP + 16)); }
#endif

View File

@ -2035,6 +2035,7 @@ void iFpppppppppppppppppppppppppppppppppp(x86emu_t *emu, uintptr_t fnc);
#if defined(NOALIGN)
void IFpi(x86emu_t *emu, uintptr_t fnc);
void iFipV(x86emu_t *emu, uintptr_t fnc);
void iFiipV(x86emu_t *emu, uintptr_t fnc);
void iFppiiiip(x86emu_t *emu, uintptr_t fnc);
#endif
@ -2097,4 +2098,8 @@ void iFEpuvvppp(x86emu_t *emu, uintptr_t fnc);
#if defined(NOALIGN)
void iFpvpV(x86emu_t *emu, uintptr_t fnc);
#endif
#if !defined(NOALIGN)
void iFEivpV(x86emu_t *emu, uintptr_t fnc);
#endif
#endif // __WRAPPER_H_

View File

@ -756,6 +756,19 @@ EXPORT int my_vfprintf(x86emu_t *emu, void* F, void* fmt, void* b) {
EXPORT int my___vfprintf_chk(x86emu_t *emu, void* F, void* fmt, void* b) __attribute__((alias("my_vfprintf")));
EXPORT int my__IO_vfprintf(x86emu_t *emu, void* F, void* fmt, void* b) __attribute__((alias("my_vfprintf")));
EXPORT int my_dprintf(x86emu_t *emu, int fd, void* fmt, void* V) {
#ifndef NOALIGN
// need to align on arm
myStackAlign((const char*)fmt, V, emu->scratch);
PREPARE_VALIST;
void* f = vdprintf;
return ((iFipp_t)f)(fd, fmt, VARARGS);
#else
return vdprintf(fd, (const char*)fmt, (va_list)V);
#endif
}
EXPORT int my___dprintf_chk(x86emu_t *emu, int fd, void* fmt, void* V) __attribute__((alias("my_dprintf")));
EXPORT int my_fprintf(x86emu_t *emu, void* F, void* fmt, void* V) {
#ifndef NOALIGN
// need to align on arm

View File

@ -206,8 +206,13 @@ GOM(dl_iterate_phdr, iFEpp) //%%
// _dl_sym
// _dl_vsym
GOW(dngettext, pFpppu)
// dprintf
// __dprintf_chk
#ifdef NOALIGN
GO(dprintf, iFipV)
GO(__dprintf_chk, iFiipV)
#else
GOM(dprintf, iFEipV)
GOM(__dprintf_chk, iFEivpV) //%%
#endif
GO(drand48, dFv)
// drand48_r
GOW(dup, iFi)