about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-01-18 12:06:02 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-01-18 12:06:02 +0100
commit742998b4773b2c46d1660d8df1da004961017807 (patch)
treeb3d6f4e49c0f223b4bf3cded13c8cfe2b5164788 /src
parenta577fac1c59e159d86c722beeee2f149b38de39e (diff)
downloadbox64-742998b4773b2c46d1660d8df1da004961017807.tar.gz
box64-742998b4773b2c46d1660d8df1da004961017807.zip
Added 1 more wrapped function to libc
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt1
-rw-r--r--src/wrapped/generated/wrappedlibctypes.h1
-rw-r--r--src/wrapped/wrappedlibc.c28
-rw-r--r--src/wrapped/wrappedlibc_private.h2
4 files changed, 31 insertions, 1 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 74501de4..e7d296e9 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -4046,6 +4046,7 @@ wrappedlibc:
   - _obstack_free
   - obstack_free
   - tdestroy
+  - twalk
 - vFpV:
   - warn
   - warnx
diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h
index 665417b8..353f3c63 100644
--- a/src/wrapped/generated/wrappedlibctypes.h
+++ b/src/wrapped/generated/wrappedlibctypes.h
@@ -148,6 +148,7 @@ typedef int32_t (*iFppipppp_t)(void*, void*, int32_t, void*, void*, void*, void*
 	GO(_obstack_free, vFpp_t) \
 	GO(obstack_free, vFpp_t) \
 	GO(tdestroy, vFpp_t) \
+	GO(twalk, vFpp_t) \
 	GO(warn, vFpV_t) \
 	GO(warnx, vFpV_t) \
 	GO(fstat, iFip_t) \
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 8c9fa05f..8be303b6 100644
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -167,6 +167,29 @@ static void* findcompareFct(void* fct)
     printf_log(LOG_NONE, "Warning, no more slot for libc compare callback\n");
     return NULL;
 }
+// action
+#define GO(A)   \
+static uintptr_t my_action_fct_##A = 0;                 \
+static void my_action_##A(void* a, uint32_t b, int c)   \
+{                                                       \
+    RunFunctionFmt(my_action_fct_##A, "pui", a, b, c);  \
+}
+SUPER()
+#undef GO
+static void* findactionFct(void* fct)
+{
+    if(!fct) return NULL;
+    void* p;
+    if((p = GetNativeFnc((uintptr_t)fct))) return p;
+    #define GO(A) if(my_action_fct_##A == (uintptr_t)fct) return my_action_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_action_fct_##A == 0) {my_action_fct_##A = (uintptr_t)fct; return my_action_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for libc action callback\n");
+    return NULL;
+}
 
 // ftw64
 #define GO(A)   \
@@ -1391,6 +1414,11 @@ EXPORT void* my_tfind(x64emu_t* emu, void* key, void** root, void* fnc)
     (void)emu;
     return tfind(key, root, findcompareFct(fnc));
 }
+EXPORT void my_twalk(x64emu_t* emu, void* root, void* fnc)
+{
+    (void)emu;
+    twalk(root, findactionFct(fnc));
+}
 EXPORT void* my_lfind(x64emu_t* emu, void* key, void* base, size_t* nmemb, size_t size, void* fnc)
 {
     (void)emu;
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index c621688f..fc53bee8 100644
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -2115,7 +2115,7 @@ GO(ttyname_r, iFipL)
 //GO(__ttyname_r_chk, 
 GO(ttyslot, iFv)
 //GO(__twalk, 
-//GOW(twalk, vFp@)
+GOWM(twalk, vFEpp)
 //GOW(twalk_r, vFp@p)
 DATA(__tzname, sizeof(void*))
 DATA(tzname, sizeof(void*)) //type V