about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt2
-rw-r--r--src/wrapped/generated/wrappedlibsqlite3types.h4
-rw-r--r--src/wrapped/wrappedlibsqlite3.c36
-rw-r--r--src/wrapped/wrappedlibsqlite3_private.h2
4 files changed, 40 insertions, 4 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 3bcfcf16..fb46888d 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -4760,6 +4760,8 @@ wrappedlibsndfile:
 - pFpipp:
   - sf_open_virtual
 wrappedlibsqlite3:
+- iFppppp:
+  - sqlite3_exec
 wrappedlibssh2:
 wrappedlibssl:
 - pFp:
diff --git a/src/wrapped/generated/wrappedlibsqlite3types.h b/src/wrapped/generated/wrappedlibsqlite3types.h
index 03aa5289..b36662f6 100644
--- a/src/wrapped/generated/wrappedlibsqlite3types.h
+++ b/src/wrapped/generated/wrappedlibsqlite3types.h
@@ -11,7 +11,9 @@
 #define ADDED_FUNCTIONS() 
 #endif
 
+typedef int32_t (*iFppppp_t)(void*, void*, void*, void*, void*);
 
-#define SUPER() ADDED_FUNCTIONS()
+#define SUPER() ADDED_FUNCTIONS() \
+	GO(sqlite3_exec, iFppppp_t)
 
 #endif // __wrappedlibsqlite3TYPES_H_
diff --git a/src/wrapped/wrappedlibsqlite3.c b/src/wrapped/wrappedlibsqlite3.c
index 8cf7f4dc..e1720667 100644
--- a/src/wrapped/wrappedlibsqlite3.c
+++ b/src/wrapped/wrappedlibsqlite3.c
@@ -25,8 +25,40 @@ const char* libsqlite3Name = "libsqlite3.so.0";
 
 #include "generated/wrappedlibsqlite3types.h"
 
-//#include "wrappercallback.h"
+#include "wrappercallback.h"
 
-// Insert my_* functions here...
+#define SUPER() \
+GO(0)   \
+GO(1)   \
+GO(2)   \
+GO(3)   \
+GO(4)
+
+// sqlite3_exec ...
+#define GO(A) \
+static uintptr_t my_sqlite3_exec_fct_##A = 0; \
+static int my_sqlite3_exec_##A(void* a, int b, char** c, char** d) { \
+    return RunFunctionFmt(my_sqlite3_exec_fct_##A,  "pipp", a, b, c, d); \
+}
+SUPER()
+#undef GO
+static void *find_sqlite3_exec_fct(void *fct) {
+    if (!fct) return fct;
+    if (GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if (my_sqlite3_exec_fct_##A == (uintptr_t)fct) return my_sqlite3_exec_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if (my_sqlite3_exec_fct_##A == 0) {my_sqlite3_exec_fct_##A = (uintptr_t)fct; return my_sqlite3_exec_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for sqlite3_exec callback\n");
+    return NULL;
+}
+#undef SUPER
+
+EXPORT int my_sqlite3_exec(x64emu_t* emu, void *db, char *sql, void* callback, void* data, char **errmsg)
+{
+    return my->sqlite3_exec(db, sql, find_sqlite3_exec_fct(callback), data, errmsg);
+}
 
 #include "wrappedlib_init.h"
diff --git a/src/wrapped/wrappedlibsqlite3_private.h b/src/wrapped/wrappedlibsqlite3_private.h
index 3d19be80..a5c9dd99 100644
--- a/src/wrapped/wrappedlibsqlite3_private.h
+++ b/src/wrapped/wrappedlibsqlite3_private.h
@@ -93,7 +93,7 @@ GO(sqlite3_errcode, iFp)
 GO(sqlite3_errmsg, pFp)
 GO(sqlite3_errmsg16, pFp)
 GO(sqlite3_errstr, pFi)
-// GO(sqlite3_exec, 
+GOM(sqlite3_exec, iFEppppp)
 GO(sqlite3_expanded_sql, pFp)
 GO(sqlite3_extended_errcode, iFp)
 GO(sqlite3_extended_result_codes, iFpi)