about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-02-11 20:06:21 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-02-11 20:06:21 +0100
commit6bf434a7abd75ad90d03a2fe070e0398f7421301 (patch)
treeab1ea9d0e786f5f519fc6d012b79d1485cd3f5d6 /src
parentd1e767d30c972945f7c745689a775b5f44b64daa (diff)
downloadbox64-6bf434a7abd75ad90d03a2fe070e0398f7421301.tar.gz
box64-6bf434a7abd75ad90d03a2fe070e0398f7421301.zip
Added some more function to wrapped libgcrypt.so
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt4
-rw-r--r--src/wrapped/generated/wrappedgcrypttypes.h4
-rw-r--r--src/wrapped/generated/wrapper.c5
-rw-r--r--src/wrapped/generated/wrapper.h2
-rw-r--r--src/wrapped/wrappedgcrypt.c78
-rw-r--r--src/wrapped/wrappedgcrypt_private.h26
6 files changed, 105 insertions, 14 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 63a1da02..11803e74 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -1261,8 +1261,10 @@
 #() uFEpipp
 #() uFEppuu
 #() uFEpppp
+#() uFEpppV
 #() uFiuuuu
 #() uFipipp
+#() uFipLpp
 #() uFuiiiu
 #() uFpCCCC
 #() uFpWuip
@@ -2432,6 +2434,8 @@ wrappedfreetype:
 wrappedgbm:
 wrappedgconf2:
 wrappedgcrypt:
+- uFpppV:
+  - gcry_sexp_build
 wrappedgdk3:
 - vFpp:
   - gdk_init
diff --git a/src/wrapped/generated/wrappedgcrypttypes.h b/src/wrapped/generated/wrappedgcrypttypes.h
index 74ee72d3..28748c69 100644
--- a/src/wrapped/generated/wrappedgcrypttypes.h
+++ b/src/wrapped/generated/wrappedgcrypttypes.h
@@ -11,7 +11,9 @@
 #define ADDED_FUNCTIONS() 
 #endif
 
+typedef uint64_t (*uFpppV_t)(void*, void*, void*, ...);
 
-#define SUPER() ADDED_FUNCTIONS()
+#define SUPER() ADDED_FUNCTIONS() \
+	GO(gcry_sexp_build, uFpppV_t)
 
 #endif // __wrappedgcryptTYPES_H_
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index 9359a98f..504336af 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -1295,8 +1295,10 @@ typedef uint64_t (*uFEippp_t)(x64emu_t*, int64_t, void*, void*, void*);
 typedef uint64_t (*uFEpipp_t)(x64emu_t*, void*, int64_t, void*, void*);
 typedef uint64_t (*uFEppuu_t)(x64emu_t*, void*, void*, uint64_t, uint64_t);
 typedef uint64_t (*uFEpppp_t)(x64emu_t*, void*, void*, void*, void*);
+typedef uint64_t (*uFEpppV_t)(x64emu_t*, void*, void*, void*, void*);
 typedef uint64_t (*uFiuuuu_t)(int64_t, uint64_t, uint64_t, uint64_t, uint64_t);
 typedef uint64_t (*uFipipp_t)(int64_t, void*, int64_t, void*, void*);
+typedef uint64_t (*uFipLpp_t)(int64_t, void*, uintptr_t, void*, void*);
 typedef uint64_t (*uFuiiiu_t)(uint64_t, int64_t, int64_t, int64_t, uint64_t);
 typedef uint64_t (*uFpCCCC_t)(void*, uint8_t, uint8_t, uint8_t, uint8_t);
 typedef uint64_t (*uFpWuip_t)(void*, uint16_t, uint64_t, int64_t, void*);
@@ -3567,8 +3569,10 @@ void uFEippp(x64emu_t *emu, uintptr_t fcn) { uFEippp_t fn = (uFEippp_t)fcn; R_RA
 void uFEpipp(x64emu_t *emu, uintptr_t fcn) { uFEpipp_t fn = (uFEpipp_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (int64_t)R_RSI, (void*)R_RDX, (void*)R_RCX); }
 void uFEppuu(x64emu_t *emu, uintptr_t fcn) { uFEppuu_t fn = (uFEppuu_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX); }
 void uFEpppp(x64emu_t *emu, uintptr_t fcn) { uFEpppp_t fn = (uFEpppp_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX); }
+void uFEpppV(x64emu_t *emu, uintptr_t fcn) { uFEpppV_t fn = (uFEpppV_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)(R_RSP + 8)); }
 void uFiuuuu(x64emu_t *emu, uintptr_t fcn) { uFiuuuu_t fn = (uFiuuuu_t)fcn; R_RAX=(uint64_t)fn((int64_t)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX, (uint64_t)R_R8); }
 void uFipipp(x64emu_t *emu, uintptr_t fcn) { uFipipp_t fn = (uFipipp_t)fcn; R_RAX=(uint64_t)fn((int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (void*)R_RCX, (void*)R_R8); }
+void uFipLpp(x64emu_t *emu, uintptr_t fcn) { uFipLpp_t fn = (uFipLpp_t)fcn; R_RAX=(uint64_t)fn((int64_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX, (void*)R_R8); }
 void uFuiiiu(x64emu_t *emu, uintptr_t fcn) { uFuiiiu_t fn = (uFuiiiu_t)fcn; R_RAX=(uint64_t)fn((uint64_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (uint64_t)R_R8); }
 void uFpCCCC(x64emu_t *emu, uintptr_t fcn) { uFpCCCC_t fn = (uFpCCCC_t)fcn; R_RAX=(uint64_t)fn((void*)R_RDI, (uint8_t)R_RSI, (uint8_t)R_RDX, (uint8_t)R_RCX, (uint8_t)R_R8); }
 void uFpWuip(x64emu_t *emu, uintptr_t fcn) { uFpWuip_t fn = (uFpWuip_t)fcn; R_RAX=(uint64_t)fn((void*)R_RDI, (uint16_t)R_RSI, (uint64_t)R_RDX, (int64_t)R_RCX, (void*)R_R8); }
@@ -5659,6 +5663,7 @@ int isSimpleWrapper(wrapper_t fun) {
 	if (fun == &IFppIII) return 1;
 	if (fun == &uFiuuuu) return 1;
 	if (fun == &uFipipp) return 1;
+	if (fun == &uFipLpp) return 1;
 	if (fun == &uFuiiiu) return 1;
 	if (fun == &uFpCCCC) return 1;
 	if (fun == &uFpWuip) return 1;
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index 06e8eea3..36fe7d7f 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -1294,8 +1294,10 @@ void uFEippp(x64emu_t *emu, uintptr_t fnc);
 void uFEpipp(x64emu_t *emu, uintptr_t fnc);
 void uFEppuu(x64emu_t *emu, uintptr_t fnc);
 void uFEpppp(x64emu_t *emu, uintptr_t fnc);
+void uFEpppV(x64emu_t *emu, uintptr_t fnc);
 void uFiuuuu(x64emu_t *emu, uintptr_t fnc);
 void uFipipp(x64emu_t *emu, uintptr_t fnc);
+void uFipLpp(x64emu_t *emu, uintptr_t fnc);
 void uFuiiiu(x64emu_t *emu, uintptr_t fnc);
 void uFpCCCC(x64emu_t *emu, uintptr_t fnc);
 void uFpWuip(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedgcrypt.c b/src/wrapped/wrappedgcrypt.c
index b8bd8fcc..1b9f9b36 100644
--- a/src/wrapped/wrappedgcrypt.c
+++ b/src/wrapped/wrappedgcrypt.c
@@ -6,13 +6,91 @@
 
 #include "wrappedlibs.h"
 
+#include "debug.h"
 #include "wrapper.h"
 #include "bridge.h"
 #include "librarian/library_private.h"
 #include "x64emu.h"
+#include "emu/x64emu_private.h"
+#include "callback.h"
+#include "librarian.h"
+#include "box64context.h"
+#include "emu/x64emu_private.h"
+#include "myalign.h"
 
 const char* gcryptName = "libgcrypt.so.20";
 #define LIBNAME gcrypt
 
+typedef uint32_t  (*uFpppp_t)(void*, void*, void*, void*);
+
+#define ADDED_FUNCTIONS()                   \
+    GO(gcry_sexp_build_array, uFpppp_t)     \
+
+#include "generated/wrappedgcrypttypes.h"
+
+#include "wrappercallback.h"
+
+EXPORT uint32_t my_gcry_sexp_build(x64emu_t* emu, void* r_sexp, void* erroff, const char* fmt, uintptr_t* V)
+{
+    // count the number of elements
+    int n;
+    const char* p = fmt;
+    while(p) {
+        if(*p == '%') {
+            ++p;
+            switch (*p) {
+                case 'm':
+                case 'M':
+                case 's':
+                case 'd':
+                case 'u':
+                case 'S':
+                    ++n;
+                    break;
+                case 'b':
+                    n+=2;
+                    break;
+            }
+        };
+        ++p;
+    }
+    // Ok, alloc the array
+    uintptr_t array[n];
+    // transfert the datas...
+    p = fmt;
+    int i = 0;
+    while(p) {
+        if(*p == '%') {
+            ++p;
+            switch (*p) {
+                case 'm':
+                case 'M':
+                case 's':
+                case 'd':
+                case 'u':
+                case 'S':
+                    array[i] = getVArgs(emu, 3, V, i);
+                    ++i;
+                    break;
+                case 'b':
+                    array[i] = getVArgs(emu, 3, V, i);
+                    ++i;
+                    array[i] = getVArgs(emu, 3, V, i);
+                    ++i;
+                    break;
+            }
+        };
+        ++p;
+    }
+    return my->gcry_sexp_build_array(r_sexp, erroff, (void*)fmt, array);
+}
+
+
+#define CUSTOM_INIT \
+    getMy(lib);
+
+#define CUSTOM_FINI \
+    freeMy();
+
 #include "wrappedlib_init.h"
 
diff --git a/src/wrapped/wrappedgcrypt_private.h b/src/wrapped/wrappedgcrypt_private.h
index ed8a826f..07830c3d 100644
--- a/src/wrapped/wrappedgcrypt_private.h
+++ b/src/wrapped/wrappedgcrypt_private.h
@@ -5,7 +5,7 @@
 
 //GO(gcry_calloc, 
 //GO(gcry_calloc_secure, 
-//GO(gcry_check_version, 
+GO(gcry_check_version, pFp)
 //GO(gcry_cipher_algo_info, 
 //GO(gcry_cipher_algo_name, 
 //GO(gcry_cipher_authenticate, 
@@ -123,7 +123,7 @@
 //GO(gcry_mpi_mulm, 
 //GO(gcry_mpi_mul_ui, 
 //GO(gcry_mpi_neg, 
-//GO(gcry_mpi_new, 
+GO(gcry_mpi_new, pFu)
 //GO(gcry_mpi_point_copy, 
 //GO(gcry_mpi_point_get, 
 //GO(gcry_mpi_point_new, 
@@ -132,9 +132,9 @@
 //GO(gcry_mpi_point_snatch_get, 
 //GO(gcry_mpi_point_snatch_set, 
 //GO(gcry_mpi_powm, 
-//GO(gcry_mpi_print, 
+GO(gcry_mpi_print, uFipLpp)
 //GO(gcry_mpi_randomize, 
-//GO(gcry_mpi_release, 
+GO(gcry_mpi_release, vFp)
 //GO(gcry_mpi_rshift, 
 //GO(gcry_mpi_scan, 
 //GO(gcry_mpi_set, 
@@ -145,7 +145,7 @@
 //GO(gcry_mpi_set_opaque_copy, 
 //GO(gcry_mpi_set_ui, 
 //GO(gcry_mpi_snatch, 
-//GO(gcry_mpi_snew, 
+GO(gcry_mpi_snew, pFu)
 //GO(gcry_mpi_sub, 
 //GO(gcry_mpi_subm, 
 //GO(gcry_mpi_sub_ui, 
@@ -155,7 +155,7 @@
 //GO(gcry_pk_algo_name, 
 //GO(gcry_pk_ctl, 
 //GO(gcry_pk_decrypt, 
-//GO(gcry_pk_encrypt, 
+GO(gcry_pk_encrypt, uFppp)
 //GO(gcry_pk_genkey, 
 //GO(gcry_pk_get_curve, 
 //GO(gcry_pk_get_keygrip, 
@@ -186,8 +186,8 @@
 //GO(gcry_set_progress_handler, 
 //GO(gcry_sexp_alist, 
 //GO(gcry_sexp_append, 
-//GO(gcry_sexp_build, 
-//GO(gcry_sexp_build_array, 
+GOM(gcry_sexp_build, uFEpppV)
+GO(gcry_sexp_build_array, uFpppp)
 //GO(gcry_sexp_cadr, 
 //GO(gcry_sexp_canon_len, 
 //GO(gcry_sexp_car, 
@@ -196,22 +196,22 @@
 //GO(gcry_sexp_create, 
 //GO(gcry_sexp_dump, 
 //GO(gcry_sexp_extract_param, 
-//GO(gcry_sexp_find_token, 
+GO(gcry_sexp_find_token, pFppL)
 //GO(gcry_sexp_length, 
 //GO(gcry_sexp_new, 
 //GO(gcry_sexp_nth, 
 //GO(gcry_sexp_nth_buffer, 
 //GO(gcry_sexp_nth_data, 
-//GO(gcry_sexp_nth_mpi, 
+GO(gcry_sexp_nth_mpi, pFpii)
 //GO(gcry_sexp_nth_string, 
 //GO(gcry_sexp_prepend, 
-//GO(gcry_sexp_release, 
+GO(gcry_sexp_release, vFp)
 //GO(gcry_sexp_sprint, 
 //GO(gcry_sexp_sscan, 
 //GO(gcry_sexp_vlist, 
 //GO(gcry_strdup, 
-//GO(gcry_strerror, 
-//GO(gcry_strsource, 
+GO(gcry_strerror, pFu)
+GO(gcry_strsource, pFu)
 //GO(gcry_xcalloc, 
 //GO(gcry_xcalloc_secure, 
 //GO(gcry_xmalloc,