diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2023-04-19 17:49:09 +0000 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2023-04-19 20:37:20 +0000 |
| commit | 5d92a3a89119e8f52886b1d7751755e1b8b3ddf3 (patch) | |
| tree | 5118ca029a6cc18aa47107817e33de32065568ab /src | |
| parent | 70787b0a6d7b481e41bb498ca4beac9572bd798f (diff) | |
| download | box64-5d92a3a89119e8f52886b1d7751755e1b8b3ddf3.tar.gz box64-5d92a3a89119e8f52886b1d7751755e1b8b3ddf3.zip | |
Some sligth improvment to __vsnprintf_chk and vfprintf
Diffstat (limited to 'src')
| -rwxr-xr-x | src/emu/x64int3.c | 6 | ||||
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 6 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibctypes.h | 4 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 3 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 2 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc.c | 12 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibc_private.h | 2 |
7 files changed, 23 insertions, 12 deletions
diff --git a/src/emu/x64int3.c b/src/emu/x64int3.c index 61bf3b43..9d6f474b 100755 --- a/src/emu/x64int3.c +++ b/src/emu/x64int3.c @@ -202,14 +202,14 @@ void x64Int3(x64emu_t* emu, uintptr_t* addr) pu64 = (uint64_t*)R_RDI; post = 3; snprintf(buff, 256, "%04d|%p: Calling %s(%p, %zu, %d, %zu, \"%s\" (,%p))", tid, *(void**)(R_RSP), s, (void*)R_RDI, R_RSI, R_EDX, R_RCX, (tmp)?tmp:"(nil)", (void*)(R_R9)); - } else if (!strcmp(s, "snprintf")) { + } else if (strstr(s, "snprintf")==s) { tmp = (char*)(R_RDX); pu64 = (uint64_t*)R_RDI; post = 3; snprintf(buff, 256, "%04d|%p: Calling %s(%p, %zu, \"%s\" (,%p))", tid, *(void**)(R_RSP), s, (void*)R_RDI, R_RSI, (tmp)?tmp:"(nil)", (void*)(R_RCX)); - } else if (strstr(s, "vfprintf")) { + } else if (strstr(s, "vfprintf")==s) { tmp = (char*)(R_RSI); - snprintf(buff, 256, "%04d|%p: Calling %s(%p, \"%s\", ...", tid, *(void**)(R_RSP), s, (void*)R_RDI, (tmp)?tmp:"(nil)"); + snprintf(buff, 256, "%04d|%p: Calling %s(%p, \"%s\", ...)", tid, *(void**)(R_RSP), s, (void*)R_RDI, (tmp)?tmp:"(nil)"); } else if (!strcmp(s, "getcwd")) { post = 2; snprintf(buff, 256, "%04d|%p: Calling %s(%p, %zu)", tid, *(void**)(R_RSP), s, (void*)R_RDI, R_RSI); diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index ac0ce5be..9538d51e 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -1831,6 +1831,7 @@ #() vFppppppp #() iFEpupppp #() iFEpUuppp +#() iFEpLiLpp #() iFEpLiLpV #() iFEppuppp #() iFEppLpIi @@ -2397,7 +2398,6 @@ #() pFEppv -> pFEpp #() iFEpvpp -> iFEppp #() iFEpvvppp -> iFEpppp -#() iFEpLvvpp -> iFEpLpp #() iFEpuvvppp -> iFEpuppp wrappedalure: wrappedalut: @@ -3377,8 +3377,6 @@ wrappedlibc: - __fwprintf_chk - iFpipA: - __vfwprintf_chk -- iFpLpp: - - __vsnprintf_chk - iFpLpV: - __snprintf - snprintf @@ -3422,6 +3420,8 @@ wrappedlibc: - pFpppLp: - lfind - lsearch +- iFpLiLpp: + - __vsnprintf_chk - iFpLiLpV: - __snprintf_chk - __swprintf_chk diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h index d7726d63..cf1b0143 100644 --- a/src/wrapped/generated/wrappedlibctypes.h +++ b/src/wrapped/generated/wrappedlibctypes.h @@ -64,7 +64,6 @@ typedef int32_t (*iFippL_t)(int32_t, void*, void*, uintptr_t); typedef int32_t (*iFpipp_t)(void*, int32_t, void*, void*); typedef int32_t (*iFpipV_t)(void*, int32_t, void*, ...); typedef int32_t (*iFpipA_t)(void*, int32_t, void*, va_list); -typedef int32_t (*iFpLpp_t)(void*, uintptr_t, void*, void*); typedef int32_t (*iFpLpV_t)(void*, uintptr_t, void*, ...); typedef int32_t (*iFpLpA_t)(void*, uintptr_t, void*, va_list); typedef int32_t (*iFppii_t)(void*, void*, int32_t, int32_t); @@ -81,6 +80,7 @@ typedef int32_t (*iFpLLpp_t)(void*, uintptr_t, uintptr_t, void*, void*); typedef void* (*pFpLLiN_t)(void*, uintptr_t, uintptr_t, int32_t, ...); typedef void* (*pFppLLp_t)(void*, void*, uintptr_t, uintptr_t, void*); typedef void* (*pFpppLp_t)(void*, void*, void*, uintptr_t, void*); +typedef int32_t (*iFpLiLpp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void*); typedef int32_t (*iFpLiLpV_t)(void*, uintptr_t, int32_t, uintptr_t, void*, ...); typedef int32_t (*iFpppppp_t)(void*, void*, void*, void*, void*, void*); typedef void* (*pFpLiiil_t)(void*, uintptr_t, int32_t, int32_t, int32_t, intptr_t); @@ -228,7 +228,6 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(__fprintf_chk, iFpipV_t) \ GO(__fwprintf_chk, iFpipV_t) \ GO(__vfwprintf_chk, iFpipA_t) \ - GO(__vsnprintf_chk, iFpLpp_t) \ GO(__snprintf, iFpLpV_t) \ GO(snprintf, iFpLpV_t) \ GO(swprintf, iFpLpV_t) \ @@ -256,6 +255,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void* GO(bsearch, pFppLLp_t) \ GO(lfind, pFpppLp_t) \ GO(lsearch, pFpppLp_t) \ + GO(__vsnprintf_chk, iFpLiLpp_t) \ GO(__snprintf_chk, iFpLiLpV_t) \ GO(__swprintf_chk, iFpLiLpV_t) \ GO(posix_spawn, iFpppppp_t) \ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 498ca1ff..15dd58cc 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -1867,6 +1867,7 @@ typedef void (*vFppppppi_t)(void*, void*, void*, void*, void*, void*, int32_t); typedef void (*vFppppppp_t)(void*, void*, void*, void*, void*, void*, void*); typedef int32_t (*iFEpupppp_t)(x64emu_t*, void*, uint32_t, void*, void*, void*, void*); typedef int32_t (*iFEpUuppp_t)(x64emu_t*, void*, uint64_t, uint32_t, void*, void*, void*); +typedef int32_t (*iFEpLiLpp_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, void*, void*); typedef int32_t (*iFEpLiLpV_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, void*, void*); typedef int32_t (*iFEppuppp_t)(x64emu_t*, void*, void*, uint32_t, void*, void*, void*); typedef int32_t (*iFEppLpIi_t)(x64emu_t*, void*, void*, uintptr_t, void*, int64_t, int32_t); @@ -4271,6 +4272,7 @@ void vFppppppi(x64emu_t *emu, uintptr_t fcn) { vFppppppi_t fn = (vFppppppi_t)fcn void vFppppppp(x64emu_t *emu, uintptr_t fcn) { vFppppppp_t fn = (vFppppppp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } void iFEpupppp(x64emu_t *emu, uintptr_t fcn) { iFEpupppp_t fn = (iFEpupppp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); } void iFEpUuppp(x64emu_t *emu, uintptr_t fcn) { iFEpUuppp_t fn = (iFEpUuppp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI, (uint32_t)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); } +void iFEpLiLpp(x64emu_t *emu, uintptr_t fcn) { iFEpLiLpp_t fn = (iFEpLiLpp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)R_R9); } void iFEpLiLpV(x64emu_t *emu, uintptr_t fcn) { iFEpLiLpV_t fn = (iFEpLiLpV_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)(R_RSP + 8)); } void iFEppuppp(x64emu_t *emu, uintptr_t fcn) { iFEppuppp_t fn = (iFEppuppp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uint32_t)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); } void iFEppLpIi(x64emu_t *emu, uintptr_t fcn) { iFEppLpIi_t fn = (iFEppLpIi_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX, (int64_t)R_R8, (int32_t)R_R9); } @@ -4850,7 +4852,6 @@ void iFEvpp(x64emu_t *emu, uintptr_t fcn) { iFEpp_t fn = (iFEpp_t)fcn; R_RAX=(in void pFEppv(x64emu_t *emu, uintptr_t fcn) { pFEpp_t fn = (pFEpp_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (void*)R_RSI); } void iFEpvpp(x64emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RDX, (void*)R_RCX); } void iFEpvvppp(x64emu_t *emu, uintptr_t fcn) { iFEpppp_t fn = (iFEpppp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (void*)R_RCX, (void*)R_R8, (void*)R_R9); } -void iFEpLvvpp(x64emu_t *emu, uintptr_t fcn) { iFEpLpp_t fn = (iFEpLpp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (void*)R_R8, (void*)R_R9); } void iFEpuvvppp(x64emu_t *emu, uintptr_t fcn) { iFEpuppp_t fn = (iFEpuppp_t)fcn; R_RAX=(int32_t)fn(emu, (void*)R_RDI, (uint32_t)R_RSI, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); } int isSimpleWrapper(wrapper_t fun) { diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index 19fb8565..670497fb 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -1868,6 +1868,7 @@ void vFppppppi(x64emu_t *emu, uintptr_t fnc); void vFppppppp(x64emu_t *emu, uintptr_t fnc); void iFEpupppp(x64emu_t *emu, uintptr_t fnc); void iFEpUuppp(x64emu_t *emu, uintptr_t fnc); +void iFEpLiLpp(x64emu_t *emu, uintptr_t fnc); void iFEpLiLpV(x64emu_t *emu, uintptr_t fnc); void iFEppuppp(x64emu_t *emu, uintptr_t fnc); void iFEppLpIi(x64emu_t *emu, uintptr_t fnc); @@ -2447,7 +2448,6 @@ void iFEvpp(x64emu_t *emu, uintptr_t fnc); void pFEppv(x64emu_t *emu, uintptr_t fnc); void iFEpvpp(x64emu_t *emu, uintptr_t fnc); void iFEpvvppp(x64emu_t *emu, uintptr_t fnc); -void iFEpLvvpp(x64emu_t *emu, uintptr_t fnc); void iFEpuvvppp(x64emu_t *emu, uintptr_t fnc); int isSimpleWrapper(wrapper_t fun); diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c index 25076221..2d950aed 100755 --- a/src/wrapped/wrappedlibc.c +++ b/src/wrapped/wrappedlibc.c @@ -922,7 +922,17 @@ EXPORT int my_vsnprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, x64_va_ return r; } EXPORT int my___vsnprintf(x64emu_t* emu, void* buff, size_t s, void * fmt, x64_va_list_t b) __attribute__((alias("my_vsnprintf"))); -EXPORT int my___vsnprintf_chk(x64emu_t* emu, void* buff, size_t s, void * fmt, x64_va_list_t b) __attribute__((alias("my_vsnprintf"))); +EXPORT int my___vsnprintf_chk(x64emu_t* emu, void* buff, size_t s, int flags, size_t slen, int blah, void * fmt, x64_va_list_t b) { + (void)emu; + #ifdef CONVERT_VALIST + CONVERT_VALIST(b); + #else + myStackAlignValist(emu, (const char*)fmt, emu->scratch, b); + PREPARE_VALIST; + #endif + int r = vsnprintf(buff, s, fmt, VARARGS); + return r; +} #if 0 EXPORT int my_vasprintf(x64emu_t* emu, void* strp, void* fmt, void* b, va_list V) { diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h index ecf8c053..213a10f6 100755 --- a/src/wrapped/wrappedlibc_private.h +++ b/src/wrapped/wrappedlibc_private.h @@ -2073,7 +2073,7 @@ GOM(__vprintf_chk, iFEvpp) //GOW(vscanf, iFpA) GOWM(__vsnprintf, iFEpLpA) GOWM(vsnprintf, iFEpLpA) -GOM(__vsnprintf_chk, iFEpLvvpp) +GOM(__vsnprintf_chk, iFEpLiLpp) GOWM(vsprintf, iFEppA) GOM(__vsprintf_chk, iFEpvvppp) GOWM(__vsscanf, iFEppp) |