diff options
Diffstat (limited to 'src')
| -rwxr-xr-x | src/library_list.h | 2 | ||||
| -rw-r--r-- | src/wrapped/generated/functions_list.txt | 7 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibsndfiledefs.h | 8 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibsndfiletypes.h | 21 | ||||
| -rw-r--r-- | src/wrapped/generated/wrappedlibsndfileundefs.h | 8 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.c | 6 | ||||
| -rw-r--r-- | src/wrapped/generated/wrapper.h | 2 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibsndfile.c | 216 | ||||
| -rwxr-xr-x | src/wrapped/wrappedlibsndfile_private.h | 44 |
9 files changed, 313 insertions, 1 deletions
diff --git a/src/library_list.h b/src/library_list.h index 70478d56..f2cd5239 100755 --- a/src/library_list.h +++ b/src/library_list.h @@ -98,7 +98,7 @@ GO("libuuid.so.1", libuuid) GO("libresolv.so.2", libresolv) GO("libpulse-simple.so.0", pulsesimple) GO("libpulse.so.0", pulse) -//GO("libsndfile.so.1", libsndfile) +GO("libsndfile.so.1", libsndfile) GO("libgtk-x11-2.0.so.0", gtkx112) GO("libgdk-x11-2.0.so.0", gdkx112) //GO("libgtk-3.so.0", gtk3) diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt index 62102793..56c54d8f 100644 --- a/src/wrapped/generated/functions_list.txt +++ b/src/wrapped/generated/functions_list.txt @@ -388,6 +388,7 @@ #() IFiIi #() IFpIi #() IFppi +#() IFppI #() IFppu #() IFSIi #() uFEpW @@ -790,6 +791,7 @@ #() pFiiiu #() pFiiuu #() pFiiup +#() pFiipi #() pFipii #() pFipip #() pFippi @@ -2736,6 +2738,11 @@ wrappedlibsm: - SmcInteractRequest - pFppiiLpppip: - SmcOpenConnection +wrappedlibsndfile: +- iFp: + - sf_close +- pFpipp: + - sf_open_virtual wrappedlibssl: - vFpp: - SSL_CTX_set_default_passwd_cb diff --git a/src/wrapped/generated/wrappedlibsndfiledefs.h b/src/wrapped/generated/wrappedlibsndfiledefs.h new file mode 100644 index 00000000..76c1ded7 --- /dev/null +++ b/src/wrapped/generated/wrappedlibsndfiledefs.h @@ -0,0 +1,8 @@ +/******************************************************************* + * File automatically generated by rebuild_wrappers.py (v2.1.0.16) * + *******************************************************************/ +#ifndef __wrappedlibsndfileDEFS_H_ +#define __wrappedlibsndfileDEFS_H_ + + +#endif // __wrappedlibsndfileDEFS_H_ diff --git a/src/wrapped/generated/wrappedlibsndfiletypes.h b/src/wrapped/generated/wrappedlibsndfiletypes.h new file mode 100644 index 00000000..5363a54d --- /dev/null +++ b/src/wrapped/generated/wrappedlibsndfiletypes.h @@ -0,0 +1,21 @@ +/******************************************************************* + * File automatically generated by rebuild_wrappers.py (v2.1.0.16) * + *******************************************************************/ +#ifndef __wrappedlibsndfileTYPES_H_ +#define __wrappedlibsndfileTYPES_H_ + +#ifndef LIBNAME +#error You should only #include this file inside a wrapped*.c file +#endif +#ifndef ADDED_FUNCTIONS +#define ADDED_FUNCTIONS() +#endif + +typedef int64_t (*iFp_t)(void*); +typedef void* (*pFpipp_t)(void*, int64_t, void*, void*); + +#define SUPER() ADDED_FUNCTIONS() \ + GO(sf_close, iFp_t) \ + GO(sf_open_virtual, pFpipp_t) + +#endif // __wrappedlibsndfileTYPES_H_ diff --git a/src/wrapped/generated/wrappedlibsndfileundefs.h b/src/wrapped/generated/wrappedlibsndfileundefs.h new file mode 100644 index 00000000..81ff43f2 --- /dev/null +++ b/src/wrapped/generated/wrappedlibsndfileundefs.h @@ -0,0 +1,8 @@ +/******************************************************************* + * File automatically generated by rebuild_wrappers.py (v2.1.0.16) * + *******************************************************************/ +#ifndef __wrappedlibsndfileUNDEFS_H_ +#define __wrappedlibsndfileUNDEFS_H_ + + +#endif // __wrappedlibsndfileUNDEFS_H_ diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c index 22a2c6bb..50df6300 100644 --- a/src/wrapped/generated/wrapper.c +++ b/src/wrapped/generated/wrapper.c @@ -422,6 +422,7 @@ typedef int64_t (*iFSpL_t)(void*, void*, uintptr_t); typedef int64_t (*IFiIi_t)(int64_t, int64_t, int64_t); typedef int64_t (*IFpIi_t)(void*, int64_t, int64_t); typedef int64_t (*IFppi_t)(void*, void*, int64_t); +typedef int64_t (*IFppI_t)(void*, void*, int64_t); typedef int64_t (*IFppu_t)(void*, void*, uint64_t); typedef int64_t (*IFSIi_t)(void*, int64_t, int64_t); typedef uint64_t (*uFEpW_t)(x64emu_t*, void*, uint16_t); @@ -824,6 +825,7 @@ typedef void* (*pFiiii_t)(int64_t, int64_t, int64_t, int64_t); typedef void* (*pFiiiu_t)(int64_t, int64_t, int64_t, uint64_t); typedef void* (*pFiiuu_t)(int64_t, int64_t, uint64_t, uint64_t); typedef void* (*pFiiup_t)(int64_t, int64_t, uint64_t, void*); +typedef void* (*pFiipi_t)(int64_t, int64_t, void*, int64_t); typedef void* (*pFipii_t)(int64_t, void*, int64_t, int64_t); typedef void* (*pFipip_t)(int64_t, void*, int64_t, void*); typedef void* (*pFippi_t)(int64_t, void*, void*, int64_t); @@ -2278,6 +2280,7 @@ void iFSpL(x64emu_t *emu, uintptr_t fcn) { iFSpL_t fn = (iFSpL_t)fcn; R_RAX=(int void IFiIi(x64emu_t *emu, uintptr_t fcn) { IFiIi_t fn = (IFiIi_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX); } void IFpIi(x64emu_t *emu, uintptr_t fcn) { IFpIi_t fn = (IFpIi_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX); } void IFppi(x64emu_t *emu, uintptr_t fcn) { IFppi_t fn = (IFppi_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX); } +void IFppI(x64emu_t *emu, uintptr_t fcn) { IFppI_t fn = (IFppI_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (int64_t)R_RDX); } void IFppu(x64emu_t *emu, uintptr_t fcn) { IFppu_t fn = (IFppu_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (uint64_t)R_RDX); } void IFSIi(x64emu_t *emu, uintptr_t fcn) { IFSIi_t fn = (IFSIi_t)fcn; R_RAX=(int64_t)fn(io_convert((void*)R_RDI), (int64_t)R_RSI, (int64_t)R_RDX); } void uFEpW(x64emu_t *emu, uintptr_t fcn) { uFEpW_t fn = (uFEpW_t)fcn; R_RAX=(uint64_t)fn(emu, (void*)R_RDI, (uint16_t)R_RSI); } @@ -2680,6 +2683,7 @@ void pFiiii(x64emu_t *emu, uintptr_t fcn) { pFiiii_t fn = (pFiiii_t)fcn; R_RAX=( void pFiiiu(x64emu_t *emu, uintptr_t fcn) { pFiiiu_t fn = (pFiiiu_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (uint64_t)R_RCX); } void pFiiuu(x64emu_t *emu, uintptr_t fcn) { pFiiuu_t fn = (pFiiuu_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX); } void pFiiup(x64emu_t *emu, uintptr_t fcn) { pFiiup_t fn = (pFiiup_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (uint64_t)R_RDX, (void*)R_RCX); } +void pFiipi(x64emu_t *emu, uintptr_t fcn) { pFiipi_t fn = (pFiipi_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (void*)R_RDX, (int64_t)R_RCX); } void pFipii(x64emu_t *emu, uintptr_t fcn) { pFipii_t fn = (pFipii_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX); } void pFipip(x64emu_t *emu, uintptr_t fcn) { pFipip_t fn = (pFipip_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (void*)R_RCX); } void pFippi(x64emu_t *emu, uintptr_t fcn) { pFippi_t fn = (pFippi_t)fcn; R_RAX=(uintptr_t)fn((int64_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (int64_t)R_RCX); } @@ -4087,6 +4091,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &IFiIi) return 1; if (fun == &IFpIi) return 1; if (fun == &IFppi) return 1; + if (fun == &IFppI) return 1; if (fun == &IFppu) return 1; if (fun == &uFipu) return 1; if (fun == &uFuip) return 1; @@ -4421,6 +4426,7 @@ int isSimpleWrapper(wrapper_t fun) { if (fun == &pFiiiu) return 1; if (fun == &pFiiuu) return 1; if (fun == &pFiiup) return 1; + if (fun == &pFiipi) return 1; if (fun == &pFipii) return 1; if (fun == &pFipip) return 1; if (fun == &pFippi) return 1; diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h index 2ef7b0e4..b240f57c 100644 --- a/src/wrapped/generated/wrapper.h +++ b/src/wrapped/generated/wrapper.h @@ -421,6 +421,7 @@ void iFSpL(x64emu_t *emu, uintptr_t fnc); void IFiIi(x64emu_t *emu, uintptr_t fnc); void IFpIi(x64emu_t *emu, uintptr_t fnc); void IFppi(x64emu_t *emu, uintptr_t fnc); +void IFppI(x64emu_t *emu, uintptr_t fnc); void IFppu(x64emu_t *emu, uintptr_t fnc); void IFSIi(x64emu_t *emu, uintptr_t fnc); void uFEpW(x64emu_t *emu, uintptr_t fnc); @@ -823,6 +824,7 @@ void pFiiii(x64emu_t *emu, uintptr_t fnc); void pFiiiu(x64emu_t *emu, uintptr_t fnc); void pFiiuu(x64emu_t *emu, uintptr_t fnc); void pFiiup(x64emu_t *emu, uintptr_t fnc); +void pFiipi(x64emu_t *emu, uintptr_t fnc); void pFipii(x64emu_t *emu, uintptr_t fnc); void pFipip(x64emu_t *emu, uintptr_t fnc); void pFippi(x64emu_t *emu, uintptr_t fnc); diff --git a/src/wrapped/wrappedlibsndfile.c b/src/wrapped/wrappedlibsndfile.c new file mode 100755 index 00000000..2c4310d8 --- /dev/null +++ b/src/wrapped/wrappedlibsndfile.c @@ -0,0 +1,216 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#define _GNU_SOURCE /* See feature_test_macros(7) */ +#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 "librarian.h" +#include "box64context.h" +#include "emu/x64emu_private.h" + +const char* libsndfileName = "libsndfile.so.1"; +#define LIBNAME libsndfile + +typedef int (*iFp_t)(void*); +typedef void* (*pFpipp_t)(void*, int32_t, void*, void*); + +#define SUPER() \ + GO(sf_open_virtual, pFpipp_t) \ + GO(sf_close, iFp_t) + +typedef struct sndfile_my_s { + // functions + #define GO(A, B) B A; + SUPER() + #undef GO +} sndfile_my_t; + +void* getSndfileMy(library_t* lib) +{ + sndfile_my_t* my = (sndfile_my_t*)calloc(1, sizeof(sndfile_my_t)); + #define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A); + SUPER() + #undef GO + + return my; +} +#undef SUPER + +void freeSndfileMy(void* lib) +{ + //sndfile_my_t *my = (sndfile_my_t *)lib; +} + +#define SUPER() \ +GO(0) \ +GO(1) \ +GO(2) \ +GO(3) \ +GO(4) + +// sf_vio_get_filelen ... +#define GO(A) \ +static uintptr_t my_sf_vio_get_filelen_fct_##A = 0; \ +static int64_t my_sf_vio_get_filelen_##A(void* a) \ +{ \ + return (int64_t)RunFunction(my_context, my_sf_vio_get_filelen_fct_##A, 1, a); \ +} +SUPER() +#undef GO +static void* find_sf_vio_get_filelen_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_sf_vio_get_filelen_fct_##A == (uintptr_t)fct) return my_sf_vio_get_filelen_##A; + SUPER() + #undef GO + #define GO(A) if(my_sf_vio_get_filelen_fct_##A == 0) {my_sf_vio_get_filelen_fct_##A = (uintptr_t)fct; return my_sf_vio_get_filelen_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for sndfile sf_vio_get_filelen callback\n"); + return NULL; +} +// sf_vio_seek ... +#define GO(A) \ +static uintptr_t my_sf_vio_seek_fct_##A = 0; \ +static int64_t my_sf_vio_seek_##A(int64_t offset, int whence, void *user_data) \ +{ \ + return (int64_t)RunFunction(my_context, my_sf_vio_seek_fct_##A, 3, offset, whence, user_data); \ +} +SUPER() +#undef GO +static void* find_sf_vio_seek_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_sf_vio_seek_fct_##A == (uintptr_t)fct) return my_sf_vio_seek_##A; + SUPER() + #undef GO + #define GO(A) if(my_sf_vio_seek_fct_##A == 0) {my_sf_vio_seek_fct_##A = (uintptr_t)fct; return my_sf_vio_seek_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for sndfile sf_vio_seek callback\n"); + return NULL; +} +// sf_vio_read ... +#define GO(A) \ +static uintptr_t my_sf_vio_read_fct_##A = 0; \ +static int64_t my_sf_vio_read_##A(void* ptr, int64_t count, void *user_data) \ +{ \ + return (int64_t)RunFunction(my_context, my_sf_vio_read_fct_##A, 3, ptr, count, user_data); \ +} +SUPER() +#undef GO +static void* find_sf_vio_read_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_sf_vio_read_fct_##A == (uintptr_t)fct) return my_sf_vio_read_##A; + SUPER() + #undef GO + #define GO(A) if(my_sf_vio_read_fct_##A == 0) {my_sf_vio_read_fct_##A = (uintptr_t)fct; return my_sf_vio_read_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for sndfile sf_vio_read callback\n"); + return NULL; +} +// sf_vio_write ... +#define GO(A) \ +static uintptr_t my_sf_vio_write_fct_##A = 0; \ +static int64_t my_sf_vio_write_##A(const void* ptr, int64_t count, void *user_data) \ +{ \ + return (int64_t)RunFunction(my_context, my_sf_vio_write_fct_##A, 3, ptr, count, user_data); \ +} +SUPER() +#undef GO +static void* find_sf_vio_write_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_sf_vio_write_fct_##A == (uintptr_t)fct) return my_sf_vio_write_##A; + SUPER() + #undef GO + #define GO(A) if(my_sf_vio_write_fct_##A == 0) {my_sf_vio_write_fct_##A = (uintptr_t)fct; return my_sf_vio_write_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for sndfile sf_vio_write callback\n"); + return NULL; +} +// sf_vio_tell ... +#define GO(A) \ +static uintptr_t my_sf_vio_tell_fct_##A = 0; \ +static int64_t my_sf_vio_tell_##A(void* a) \ +{ \ + return (int64_t)RunFunction(my_context, my_sf_vio_tell_fct_##A, 1, a); \ +} +SUPER() +#undef GO +static void* find_sf_vio_tell_Fct(void* fct) +{ + if(!fct) return fct; + if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct); + #define GO(A) if(my_sf_vio_tell_fct_##A == (uintptr_t)fct) return my_sf_vio_tell_##A; + SUPER() + #undef GO + #define GO(A) if(my_sf_vio_tell_fct_##A == 0) {my_sf_vio_tell_fct_##A = (uintptr_t)fct; return my_sf_vio_tell_##A; } + SUPER() + #undef GO + printf_log(LOG_NONE, "Warning, no more slot for sndfile sf_vio_tell callback\n"); + return NULL; +} +#undef SUPER + +typedef int64_t (*sf_vio_get_filelen) (void *user_data) ; +typedef int64_t (*sf_vio_seek) (int64_t offset, int whence, void *user_data) ; +typedef int64_t (*sf_vio_read) (void *ptr, int64_t count, void *user_data) ; +typedef int64_t (*sf_vio_write) (const void *ptr, int64_t count, void *user_data) ; +typedef int64_t (*sf_vio_tell) (void *user_data) ; +typedef struct my_sfvirtual_io_s +{ sf_vio_get_filelen get_filelen; + sf_vio_seek seek ; + sf_vio_read read ; + sf_vio_write write ; + sf_vio_tell tell ; +} my_sfvirtual_io_t; + +EXPORT void* my_sf_open_virtual(x64emu_t* emu, my_sfvirtual_io_t* sfvirtual, int mode, void* sfinfo, void* data) +{ + library_t * lib = GetLibInternal(libsndfileName); + sndfile_my_t *my = (sndfile_my_t*)lib->priv.w.p2; + + my_sfvirtual_io_t native = {0}; + native.get_filelen = find_sf_vio_get_filelen_Fct(sfvirtual->get_filelen); + native.seek = find_sf_vio_seek_Fct(sfvirtual->seek); + native.read = find_sf_vio_read_Fct(sfvirtual->read); + native.write = find_sf_vio_write_Fct(sfvirtual->write); + native.tell = find_sf_vio_tell_Fct(sfvirtual->tell); + + return my->sf_open_virtual(&native, mode, sfinfo, data); +} + +EXPORT int my_sf_close(x64emu_t* emu, void* sf) +{ + library_t * lib = GetLibInternal(libsndfileName); + sndfile_my_t *my = (sndfile_my_t*)lib->priv.w.p2; + + return my->sf_close(sf); +} + +#define CUSTOM_INIT \ + lib->priv.w.p2 = getSndfileMy(lib); + +#define CUSTOM_FINI \ + freeSndfileMy(lib->priv.w.p2); \ + free(lib->priv.w.p2); + +#include "wrappedlib_init.h" + diff --git a/src/wrapped/wrappedlibsndfile_private.h b/src/wrapped/wrappedlibsndfile_private.h new file mode 100755 index 00000000..7aef440e --- /dev/null +++ b/src/wrapped/wrappedlibsndfile_private.h @@ -0,0 +1,44 @@ +#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA)) +#error Meh.... +#endif + +GOM(sf_close, iFEp) +GO(sf_command, iFpipi) +GO(sf_current_byterate, iFp) +GO(sf_error, iFp) +GO(sf_error_number, pFi) +GO(sf_error_str, pFpi) +GO(sf_format_check, iFp) +GO(sf_get_chunk_data, iFpp) +GO(sf_get_chunk_iterator, pFpp) +GO(sf_get_chunk_size, iFpp) +GO(sf_get_string, pFpi) +GO(sf_next_chunk_iterator, pFp) +GO(sf_open, pFpip) +GO(sf_open_fd, pFiipi) +GOM(sf_open_virtual, pFEpipp) +GO(sf_perror, iFp) +GO(sf_read_double, IFppI) +GO(sf_readf_double, IFppI) +GO(sf_readf_float, IFppI) +GO(sf_readf_int, IFppI) +GO(sf_read_float, IFppI) +GO(sf_readf_short, IFppI) +GO(sf_read_int, IFppI) +GO(sf_read_raw, IFppI) +GO(sf_read_short, IFppI) +GO(sf_seek, IFpIi) +GO(sf_set_chunk, iFpp) +GO(sf_set_string, iFpip) +GO(sf_strerror, pFp) +GO(sf_version_string, pFv) +GO(sf_write_double, IFppI) +GO(sf_writef_double, IFppI) +GO(sf_writef_float, IFppI) +GO(sf_writef_int, IFppI) +GO(sf_write_float, IFppI) +GO(sf_writef_short, IFppI) +GO(sf_write_int, IFppI) +GO(sf_write_raw, IFppI) +GO(sf_write_short, IFppI) +GO(sf_write_sync, vFp) |