Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/emu/x64printer.c
Original file line number Diff line number Diff line change
Expand Up @@ -5287,6 +5287,8 @@ void x64Print(x64emu_t* emu, char* buff, size_t buffsz, const char* func, int ti
snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIp ", %" PRIp ", %" PRIp ", %" PRIp ", %" PRIp ", %" PRIp ", %" PRIp ")", tid, *(void**)(R_RSP), func, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8));
} else if (w == iFElppppp) {
snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIi64 ", %" PRIp ", %" PRIp ", %" PRIp ", %" PRIp ", %" PRIp ")", tid, *(void**)(R_RSP), func, (intptr_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9);
} else if (w == iFEpipupp) {
snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIp ", %" PRIi32 ", %" PRIp ", %" PRIu32 ", %" PRIp ", %" PRIp ")", tid, *(void**)(R_RSP), func, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (void*)R_R8, (void*)R_R9);
} else if (w == iFEpupppp) {
snprintf(buff, buffsz, "%04d|%p: Calling %s(%" PRIp ", %" PRIu32 ", %" PRIp ", %" PRIp ", %" PRIp ", %" PRIp ")", tid, *(void**)(R_RSP), func, (void*)R_RDI, (uint32_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9);
} else if (w == iFEpUuppp) {
Expand Down
3 changes: 3 additions & 0 deletions src/wrapped/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2876,6 +2876,7 @@
#() vFppppppp
#() cFppppppp
#() iFElppppp
#() iFEpipupp
#() iFEpupppp
#() iFEpUuppp
#() iFEpLiLpp
Expand Down Expand Up @@ -5359,6 +5360,8 @@ wrappedlibc:
- lsearch
- vFiipupV:
- error_at_line
- iFpipupp:
- argp_parse
- iFpipppL:
- __sysctl
- sysctl
Expand Down
2 changes: 2 additions & 0 deletions src/wrapped/generated/wrappedlibctypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ 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 void (*vFiipupV_t)(int32_t, int32_t, void*, uint32_t, void*, ...);
typedef int32_t (*iFpipupp_t)(void*, int32_t, void*, uint32_t, void*, void*);
typedef int32_t (*iFpipppL_t)(void*, int32_t, void*, void*, void*, uintptr_t);
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*, ...);
Expand Down Expand Up @@ -345,6 +346,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*
GO(lfind, pFpppLp_t) \
GO(lsearch, pFpppLp_t) \
GO(error_at_line, vFiipupV_t) \
GO(argp_parse, iFpipupp_t) \
GO(__sysctl, iFpipppL_t) \
GO(sysctl, iFpipppL_t) \
GO(__vsnprintf_chk, iFpLiLpp_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 @@ -2903,6 +2903,7 @@ typedef void (*vFppppppL_t)(void*, void*, void*, void*, void*, void*, uintptr_t)
typedef void (*vFppppppp_t)(void*, void*, void*, void*, void*, void*, void*);
typedef int8_t (*cFppppppp_t)(void*, void*, void*, void*, void*, void*, void*);
typedef int32_t (*iFElppppp_t)(x64emu_t*, intptr_t, void*, void*, void*, void*, void*);
typedef int32_t (*iFEpipupp_t)(x64emu_t*, void*, int32_t, void*, uint32_t, 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*);
Expand Down Expand Up @@ -6833,6 +6834,7 @@ void vFppppppL(x64emu_t *emu, uintptr_t fcn) { vFppppppL_t fn = (vFppppppL_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 cFppppppp(x64emu_t *emu, uintptr_t fcn) { cFppppppp_t fn = (cFppppppp_t)fcn; R_RAX=(uint8_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
void iFElppppp(x64emu_t *emu, uintptr_t fcn) { iFElppppp_t fn = (iFElppppp_t)fcn; R_RAX=(uint32_t)fn(emu, (intptr_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9); }
void iFEpipupp(x64emu_t *emu, uintptr_t fcn) { iFEpipupp_t fn = (iFEpipupp_t)fcn; R_RAX=(uint32_t)fn(emu, (void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX, (uint32_t)R_RCX, (void*)R_R8, (void*)R_R9); }
void iFEpupppp(x64emu_t *emu, uintptr_t fcn) { iFEpupppp_t fn = (iFEpupppp_t)fcn; R_RAX=(uint32_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=(uint32_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=(uint32_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int32_t)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)R_R9); }
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 @@ -2913,6 +2913,7 @@ void vFppppppL(x64emu_t *emu, uintptr_t fnc);
void vFppppppp(x64emu_t *emu, uintptr_t fnc);
void cFppppppp(x64emu_t *emu, uintptr_t fnc);
void iFElppppp(x64emu_t *emu, uintptr_t fnc);
void iFEpipupp(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);
Expand Down
44 changes: 44 additions & 0 deletions src/wrapped/wrappedlibc.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#define _LARGEFILE_SOURCE 1
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE /* See feature_test_macros(7) */
#if !defined(TERMUX) && !defined(ANDROID)
#include <argp.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include <stddef.h>
Expand Down Expand Up @@ -450,8 +453,49 @@ static void* findprintf_typeFct(void* fct)
return NULL;
}

// printf_type
#define GO(A) \
static uintptr_t my_argp_parser_fct_##A = 0; \
static int my_argp_parser_##A(int a, void* b, void* c) \
{ \
return RunFunctionFmt(my_argp_parser_fct_##A, "ipp", a, b, c); \
}
SUPER()
#undef GO
static void* find_argp_parser_Fct(void* fct)
{
if (!fct) return NULL;
void* p;
if ((p = GetNativeFnc((uintptr_t)fct))) return p;
#define GO(A) \
if (my_argp_parser_fct_##A == (uintptr_t)fct) return my_argp_parser_##A;
SUPER()
#undef GO
#define GO(A) \
if (my_argp_parser_fct_##A == 0) { \
my_argp_parser_fct_##A = (uintptr_t)fct; \
return my_argp_parser_##A; \
}
SUPER()
#undef GO
printf_log(LOG_NONE, "Warning, no more slot for libc argp_parser callback\n");
return NULL;
}

#undef SUPER

EXPORT int my_argp_parse(x64emu_t* emu, struct argp* argp, int argc, char** argv, int flags, int* index, void* input)
{
#if !defined(TERMUX) && !defined(ANDROID)
void* fct = (void*)argp->parser;
if (fct) argp->parser = find_argp_parser_Fct(fct);
return argp_parse(argp, argc, argv, flags, index, input);
#else
printf_log(LOG_NONE, "Warning: unsupported argp_parse called, expecting failure\n");
return -1;
#endif
}

// some my_XXX declare and defines
int32_t my___libc_start_main(x64emu_t* emu, int (*main) (int, char * *, char * *),
int argc, char * * ubp_av, void (*init) (void), void (*fini) (void),
Expand Down
2 changes: 1 addition & 1 deletion src/wrapped/wrappedlibc_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ GOW(alphasort64, iFpp)
//GOWM(argp_error, vFppV)
//GOWM(argp_failure, vFpiipV)
//GOWM(argp_help, vFpSup)
//GOWM(argp_parse, iFpipupp)
GOWM(argp_parse, iFEpipupp)
//DATAB(argp_program_bug_address, 8)
//DATAB(argp_program_version, 8)
//DATAM(argp_program_version_hook, 8)
Expand Down
Loading