Skip to content

Commit

Permalink
Wrapped libsqlite3 (#1625)
Browse files Browse the repository at this point in the history
* Wrapped libsqlite3

* More functions
  • Loading branch information
ksco authored Jul 1, 2024
1 parent 15a7c4d commit dbb8424
Show file tree
Hide file tree
Showing 10 changed files with 361 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -658,6 +658,7 @@ set(WRAPPEDS
"${BOX64_ROOT}/src/wrapped/wrappedlibnettle8.c"
"${BOX64_ROOT}/src/wrapped/wrappedlibunistring2.c"
"${BOX64_ROOT}/src/wrapped/wrappedlibhogweed6.c"
"${BOX64_ROOT}/src/wrapped/wrappedlibsqlite3.c"
)
endif()
if(ANDROID)
Expand Down
1 change: 1 addition & 0 deletions src/library_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ GO("libtasn1.so.6", libtasn1)
GO("libnettle.so.8", libnettle8)
GO("libunistring.so.2", libunistring2)
GO("libhogweed.so.6", libhogweed6)
GO("libsqlite3.so.0", libsqlite3)

#ifdef ANDROID
GO("libc.so", libc)
Expand Down
6 changes: 6 additions & 0 deletions src/wrapped/generated/functions_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#() iFP
#() iFb
#() IFv
#() IFi
#() IFI
#() IFf
#() IFd
Expand Down Expand Up @@ -415,6 +416,7 @@
#() vFLup
#() vFLpL
#() vFLpp
#() vFpic
#() vFpii
#() vFpiI
#() vFpiC
Expand Down Expand Up @@ -513,10 +515,12 @@
#() iFLpp
#() iFpwp
#() iFpii
#() iFpiI
#() iFpiC
#() iFpiW
#() iFpiu
#() iFpiU
#() iFpid
#() iFpil
#() iFpiL
#() iFpip
Expand Down Expand Up @@ -2397,6 +2401,7 @@
#() iFpppLppp
#() iFppppilp
#() iFppppipp
#() iFppppIip
#() iFppppdpu
#() iFpppppip
#() iFpppppLp
Expand Down Expand Up @@ -4750,6 +4755,7 @@ wrappedlibsndfile:
- sf_close
- pFpipp:
- sf_open_virtual
wrappedlibsqlite3:
wrappedlibssh2:
wrappedlibssl:
- pFp:
Expand Down
8 changes: 8 additions & 0 deletions src/wrapped/generated/wrappedlibsqlite3defs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.4.0.21) *
*******************************************************************/
#ifndef __wrappedlibsqlite3DEFS_H_
#define __wrappedlibsqlite3DEFS_H_


#endif // __wrappedlibsqlite3DEFS_H_
17 changes: 17 additions & 0 deletions src/wrapped/generated/wrappedlibsqlite3types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.4.0.21) *
*******************************************************************/
#ifndef __wrappedlibsqlite3TYPES_H_
#define __wrappedlibsqlite3TYPES_H_

#ifndef LIBNAME
#error You should only #include this file inside a wrapped*.c file
#endif
#ifndef ADDED_FUNCTIONS
#define ADDED_FUNCTIONS()
#endif


#define SUPER() ADDED_FUNCTIONS()

#endif // __wrappedlibsqlite3TYPES_H_
8 changes: 8 additions & 0 deletions src/wrapped/generated/wrappedlibsqlite3undefs.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*******************************************************************
* File automatically generated by rebuild_wrappers.py (v2.4.0.21) *
*******************************************************************/
#ifndef __wrappedlibsqlite3UNDEFS_H_
#define __wrappedlibsqlite3UNDEFS_H_


#endif // __wrappedlibsqlite3UNDEFS_H_
14 changes: 14 additions & 0 deletions src/wrapped/generated/wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ typedef int32_t (*iFS_t)(void*);
typedef int32_t (*iFP_t)(void*);
typedef int32_t (*iFb_t)(void*);
typedef int64_t (*IFv_t)(void);
typedef int64_t (*IFi_t)(int32_t);
typedef int64_t (*IFI_t)(int64_t);
typedef int64_t (*IFf_t)(float);
typedef int64_t (*IFd_t)(double);
Expand Down Expand Up @@ -453,6 +454,7 @@ typedef void (*vFlpp_t)(intptr_t, void*, void*);
typedef void (*vFLup_t)(uintptr_t, uint32_t, void*);
typedef void (*vFLpL_t)(uintptr_t, void*, uintptr_t);
typedef void (*vFLpp_t)(uintptr_t, void*, void*);
typedef void (*vFpic_t)(void*, int32_t, int8_t);
typedef void (*vFpii_t)(void*, int32_t, int32_t);
typedef void (*vFpiI_t)(void*, int32_t, int64_t);
typedef void (*vFpiC_t)(void*, int32_t, uint8_t);
Expand Down Expand Up @@ -551,10 +553,12 @@ typedef int32_t (*iFLip_t)(uintptr_t, int32_t, void*);
typedef int32_t (*iFLpp_t)(uintptr_t, void*, void*);
typedef int32_t (*iFpwp_t)(void*, int16_t, void*);
typedef int32_t (*iFpii_t)(void*, int32_t, int32_t);
typedef int32_t (*iFpiI_t)(void*, int32_t, int64_t);
typedef int32_t (*iFpiC_t)(void*, int32_t, uint8_t);
typedef int32_t (*iFpiW_t)(void*, int32_t, uint16_t);
typedef int32_t (*iFpiu_t)(void*, int32_t, uint32_t);
typedef int32_t (*iFpiU_t)(void*, int32_t, uint64_t);
typedef int32_t (*iFpid_t)(void*, int32_t, double);
typedef int32_t (*iFpil_t)(void*, int32_t, intptr_t);
typedef int32_t (*iFpiL_t)(void*, int32_t, uintptr_t);
typedef int32_t (*iFpip_t)(void*, int32_t, void*);
Expand Down Expand Up @@ -2435,6 +2439,7 @@ typedef int32_t (*iFpppuiii_t)(void*, void*, void*, uint32_t, int32_t, int32_t,
typedef int32_t (*iFpppLppp_t)(void*, void*, void*, uintptr_t, void*, void*, void*);
typedef int32_t (*iFppppilp_t)(void*, void*, void*, void*, int32_t, intptr_t, void*);
typedef int32_t (*iFppppipp_t)(void*, void*, void*, void*, int32_t, void*, void*);
typedef int32_t (*iFppppIip_t)(void*, void*, void*, void*, int64_t, int32_t, void*);
typedef int32_t (*iFppppdpu_t)(void*, void*, void*, void*, double, void*, uint32_t);
typedef int32_t (*iFpppppip_t)(void*, void*, void*, void*, void*, int32_t, void*);
typedef int32_t (*iFpppppLp_t)(void*, void*, void*, void*, void*, uintptr_t, void*);
Expand Down Expand Up @@ -3172,6 +3177,7 @@ void iFS(x64emu_t *emu, uintptr_t fcn) { iFS_t fn = (iFS_t)fcn; R_RAX=(int32_t)f
void iFP(x64emu_t *emu, uintptr_t fcn) { iFP_t fn = (iFP_t)fcn; R_RAX=(int32_t)fn(*(void**)(R_RSP + 8)); }
void iFb(x64emu_t *emu, uintptr_t fcn) { iFb_t fn = (iFb_t)fcn; void *aligned_xcb = align_xcb_connection((void*)R_RDI); R_RAX=(int32_t)fn(aligned_xcb); unalign_xcb_connection(aligned_xcb, (void*)R_RDI); }
void IFv(x64emu_t *emu, uintptr_t fcn) { IFv_t fn = (IFv_t)fcn; R_RAX=(int64_t)fn(); }
void IFi(x64emu_t *emu, uintptr_t fcn) { IFi_t fn = (IFi_t)fcn; R_RAX=(int64_t)fn((int32_t)R_RDI); }
void IFI(x64emu_t *emu, uintptr_t fcn) { IFI_t fn = (IFI_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI); }
void IFf(x64emu_t *emu, uintptr_t fcn) { IFf_t fn = (IFf_t)fcn; R_RAX=(int64_t)fn(emu->xmm[0].f[0]); }
void IFd(x64emu_t *emu, uintptr_t fcn) { IFd_t fn = (IFd_t)fcn; R_RAX=(int64_t)fn(emu->xmm[0].d[0]); }
Expand Down Expand Up @@ -3547,6 +3553,7 @@ void vFlpp(x64emu_t *emu, uintptr_t fcn) { vFlpp_t fn = (vFlpp_t)fcn; fn((intptr
void vFLup(x64emu_t *emu, uintptr_t fcn) { vFLup_t fn = (vFLup_t)fcn; fn((uintptr_t)R_RDI, (uint32_t)R_RSI, (void*)R_RDX); }
void vFLpL(x64emu_t *emu, uintptr_t fcn) { vFLpL_t fn = (vFLpL_t)fcn; fn((uintptr_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX); }
void vFLpp(x64emu_t *emu, uintptr_t fcn) { vFLpp_t fn = (vFLpp_t)fcn; fn((uintptr_t)R_RDI, (void*)R_RSI, (void*)R_RDX); }
void vFpic(x64emu_t *emu, uintptr_t fcn) { vFpic_t fn = (vFpic_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (int8_t)R_RDX); }
void vFpii(x64emu_t *emu, uintptr_t fcn) { vFpii_t fn = (vFpii_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX); }
void vFpiI(x64emu_t *emu, uintptr_t fcn) { vFpiI_t fn = (vFpiI_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (int64_t)R_RDX); }
void vFpiC(x64emu_t *emu, uintptr_t fcn) { vFpiC_t fn = (vFpiC_t)fcn; fn((void*)R_RDI, (int32_t)R_RSI, (uint8_t)R_RDX); }
Expand Down Expand Up @@ -3645,10 +3652,12 @@ void iFLip(x64emu_t *emu, uintptr_t fcn) { iFLip_t fn = (iFLip_t)fcn; R_RAX=(int
void iFLpp(x64emu_t *emu, uintptr_t fcn) { iFLpp_t fn = (iFLpp_t)fcn; R_RAX=(int32_t)fn((uintptr_t)R_RDI, (void*)R_RSI, (void*)R_RDX); }
void iFpwp(x64emu_t *emu, uintptr_t fcn) { iFpwp_t fn = (iFpwp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int16_t)R_RSI, (void*)R_RDX); }
void iFpii(x64emu_t *emu, uintptr_t fcn) { iFpii_t fn = (iFpii_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX); }
void iFpiI(x64emu_t *emu, uintptr_t fcn) { iFpiI_t fn = (iFpiI_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (int64_t)R_RDX); }
void iFpiC(x64emu_t *emu, uintptr_t fcn) { iFpiC_t fn = (iFpiC_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uint8_t)R_RDX); }
void iFpiW(x64emu_t *emu, uintptr_t fcn) { iFpiW_t fn = (iFpiW_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uint16_t)R_RDX); }
void iFpiu(x64emu_t *emu, uintptr_t fcn) { iFpiu_t fn = (iFpiu_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uint32_t)R_RDX); }
void iFpiU(x64emu_t *emu, uintptr_t fcn) { iFpiU_t fn = (iFpiU_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uint64_t)R_RDX); }
void iFpid(x64emu_t *emu, uintptr_t fcn) { iFpid_t fn = (iFpid_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, emu->xmm[0].d[0]); }
void iFpil(x64emu_t *emu, uintptr_t fcn) { iFpil_t fn = (iFpil_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (intptr_t)R_RDX); }
void iFpiL(x64emu_t *emu, uintptr_t fcn) { iFpiL_t fn = (iFpiL_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (uintptr_t)R_RDX); }
void iFpip(x64emu_t *emu, uintptr_t fcn) { iFpip_t fn = (iFpip_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (int32_t)R_RSI, (void*)R_RDX); }
Expand Down Expand Up @@ -5529,6 +5538,7 @@ void iFpppuiii(x64emu_t *emu, uintptr_t fcn) { iFpppuiii_t fn = (iFpppuiii_t)fcn
void iFpppLppp(x64emu_t *emu, uintptr_t fcn) { iFpppLppp_t fn = (iFpppLppp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
void iFppppilp(x64emu_t *emu, uintptr_t fcn) { iFppppilp_t fn = (iFppppilp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8, (intptr_t)R_R9, *(void**)(R_RSP + 8)); }
void iFppppipp(x64emu_t *emu, uintptr_t fcn) { iFppppipp_t fn = (iFppppipp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int32_t)R_R8, (void*)R_R9, *(void**)(R_RSP + 8)); }
void iFppppIip(x64emu_t *emu, uintptr_t fcn) { iFppppIip_t fn = (iFppppIip_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (int64_t)R_R8, (int32_t)R_R9, *(void**)(R_RSP + 8)); }
void iFppppdpu(x64emu_t *emu, uintptr_t fcn) { iFppppdpu_t fn = (iFppppdpu_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, emu->xmm[0].d[0], (void*)R_R8, (uint32_t)R_R9); }
void iFpppppip(x64emu_t *emu, uintptr_t fcn) { iFpppppip_t fn = (iFpppppip_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (int32_t)R_R9, *(void**)(R_RSP + 8)); }
void iFpppppLp(x64emu_t *emu, uintptr_t fcn) { iFpppppLp_t fn = (iFpppppLp_t)fcn; R_RAX=(int32_t)fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (uintptr_t)R_R9, *(void**)(R_RSP + 8)); }
Expand Down Expand Up @@ -6269,6 +6279,7 @@ int isSimpleWrapper(wrapper_t fun) {
if (fun == &iFL) return 1;
if (fun == &iFp) return 1;
if (fun == &IFv) return 1;
if (fun == &IFi) return 1;
if (fun == &IFI) return 1;
if (fun == &IFf) return 2;
if (fun == &IFd) return 2;
Expand Down Expand Up @@ -6566,6 +6577,7 @@ int isSimpleWrapper(wrapper_t fun) {
if (fun == &vFLup) return 1;
if (fun == &vFLpL) return 1;
if (fun == &vFLpp) return 1;
if (fun == &vFpic) return 1;
if (fun == &vFpii) return 1;
if (fun == &vFpiI) return 1;
if (fun == &vFpiC) return 1;
Expand Down Expand Up @@ -6647,10 +6659,12 @@ int isSimpleWrapper(wrapper_t fun) {
if (fun == &iFLpp) return 1;
if (fun == &iFpwp) return 1;
if (fun == &iFpii) return 1;
if (fun == &iFpiI) return 1;
if (fun == &iFpiC) return 1;
if (fun == &iFpiW) return 1;
if (fun == &iFpiu) return 1;
if (fun == &iFpiU) return 1;
if (fun == &iFpid) return 2;
if (fun == &iFpil) return 1;
if (fun == &iFpiL) return 1;
if (fun == &iFpip) return 1;
Expand Down
5 changes: 5 additions & 0 deletions src/wrapped/generated/wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void iFS(x64emu_t *emu, uintptr_t fnc);
void iFP(x64emu_t *emu, uintptr_t fnc);
void iFb(x64emu_t *emu, uintptr_t fnc);
void IFv(x64emu_t *emu, uintptr_t fnc);
void IFi(x64emu_t *emu, uintptr_t fnc);
void IFI(x64emu_t *emu, uintptr_t fnc);
void IFf(x64emu_t *emu, uintptr_t fnc);
void IFd(x64emu_t *emu, uintptr_t fnc);
Expand Down Expand Up @@ -453,6 +454,7 @@ void vFlpp(x64emu_t *emu, uintptr_t fnc);
void vFLup(x64emu_t *emu, uintptr_t fnc);
void vFLpL(x64emu_t *emu, uintptr_t fnc);
void vFLpp(x64emu_t *emu, uintptr_t fnc);
void vFpic(x64emu_t *emu, uintptr_t fnc);
void vFpii(x64emu_t *emu, uintptr_t fnc);
void vFpiI(x64emu_t *emu, uintptr_t fnc);
void vFpiC(x64emu_t *emu, uintptr_t fnc);
Expand Down Expand Up @@ -551,10 +553,12 @@ void iFLip(x64emu_t *emu, uintptr_t fnc);
void iFLpp(x64emu_t *emu, uintptr_t fnc);
void iFpwp(x64emu_t *emu, uintptr_t fnc);
void iFpii(x64emu_t *emu, uintptr_t fnc);
void iFpiI(x64emu_t *emu, uintptr_t fnc);
void iFpiC(x64emu_t *emu, uintptr_t fnc);
void iFpiW(x64emu_t *emu, uintptr_t fnc);
void iFpiu(x64emu_t *emu, uintptr_t fnc);
void iFpiU(x64emu_t *emu, uintptr_t fnc);
void iFpid(x64emu_t *emu, uintptr_t fnc);
void iFpil(x64emu_t *emu, uintptr_t fnc);
void iFpiL(x64emu_t *emu, uintptr_t fnc);
void iFpip(x64emu_t *emu, uintptr_t fnc);
Expand Down Expand Up @@ -2435,6 +2439,7 @@ void iFpppuiii(x64emu_t *emu, uintptr_t fnc);
void iFpppLppp(x64emu_t *emu, uintptr_t fnc);
void iFppppilp(x64emu_t *emu, uintptr_t fnc);
void iFppppipp(x64emu_t *emu, uintptr_t fnc);
void iFppppIip(x64emu_t *emu, uintptr_t fnc);
void iFppppdpu(x64emu_t *emu, uintptr_t fnc);
void iFpppppip(x64emu_t *emu, uintptr_t fnc);
void iFpppppLp(x64emu_t *emu, uintptr_t fnc);
Expand Down
32 changes: 32 additions & 0 deletions src/wrapped/wrappedlibsqlite3.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dlfcn.h>

#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 "box64context.h"
#include "librarian.h"
#include "myalign.h"

const char* libsqlite3Name = "libsqlite3.so.0";
#define LIBNAME libsqlite3


#define ADDED_FUNCTIONS()

#include "generated/wrappedlibsqlite3types.h"

#include "wrappercallback.h"

// Insert my_* functions here...

#include "wrappedlib_init.h"
Loading

0 comments on commit dbb8424

Please sign in to comment.