about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-04-16 19:39:29 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-04-16 19:39:29 +0200
commit097c0ac0b7de7951f8149e0bd83455b1919871af (patch)
tree2ef574f045aaffe95077279c39985957d2438049 /src
parent7a95dcd6b6bf51cde91d0cc2a17107b49d17a376 (diff)
downloadbox64-097c0ac0b7de7951f8149e0bd83455b1919871af.tar.gz
box64-097c0ac0b7de7951f8149e0bd83455b1919871af.zip
Added wrapped libFLAC
Diffstat (limited to 'src')
-rwxr-xr-xsrc/library_list.h1
-rw-r--r--src/wrapped/generated/functions_list.txt2
-rw-r--r--src/wrapped/generated/wrappedflactypes.h21
-rw-r--r--src/wrapped/generated/wrapper.c4
-rw-r--r--src/wrapped/generated/wrapper.h2
-rwxr-xr-xsrc/wrapped/wrappedflac.c377
-rwxr-xr-xsrc/wrapped/wrappedflac_private.h223
7 files changed, 630 insertions, 0 deletions
diff --git a/src/library_list.h b/src/library_list.h
index 54289ee8..6329c7f7 100755
--- a/src/library_list.h
+++ b/src/library_list.h
@@ -31,6 +31,7 @@ GO("libsmpeg2-2.0.so.0", smpeg2)
 GO("libvorbisfile.so.3", vorbisfile)
 GO("libvorbis.so.0", libvorbis)
 GO("libogg.so.0", libogg)
+GO("libFLAC.so.8", flac)
 //GO("libpng12.so.0", png12)
 //GO("libpng16.so.16", png16)
 GO("libXxf86vm.so.1", libxxf86vm)
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 9809749f..233e764e 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -1091,6 +1091,7 @@
 #() vFpppppippp
 #() iFEpiiiiipi
 #() iFEppplPPPP
+#() iFEppPPPPPP
 #() iFiiiiiiiip
 #() iFiiiipiiip
 #() iFipiipippi
@@ -1125,6 +1126,7 @@
 #() vFuddiiddiip
 #() vFffffffffff
 #() vFpppppppppp
+#() iFEppppppppp
 #() iFiiiiiiiiip
 #() iFpuupiuiipp
 #() iFppuuiiiiii
diff --git a/src/wrapped/generated/wrappedflactypes.h b/src/wrapped/generated/wrappedflactypes.h
new file mode 100644
index 00000000..3f8817fe
--- /dev/null
+++ b/src/wrapped/generated/wrappedflactypes.h
@@ -0,0 +1,21 @@
+/*******************************************************************
+ * File automatically generated by rebuild_wrappers.py (v1.3.0.11) *
+ *******************************************************************/
+#ifndef __wrappedflacTYPES_H_
+#define __wrappedflacTYPES_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 (*iFppPPPPPP_t)(void*, void*, void*, void*, void*, void*, void*, void*);
+typedef int64_t (*iFppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*);
+
+#define SUPER() ADDED_FUNCTIONS() \
+	GO(FLAC__metadata_chain_read_with_callbacks, iFppPPPPPP_t) \
+	GO(FLAC__stream_decoder_init_stream, iFppppppppp_t)
+
+#endif // __wrappedflacTYPES_H_
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index 126d6236..9595e7fa 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -1125,6 +1125,7 @@ typedef void (*vFpplpppppi_t)(void*, void*, intptr_t, void*, void*, void*, void*
 typedef void (*vFpppppippp_t)(void*, void*, void*, void*, void*, int64_t, void*, void*, void*);
 typedef int64_t (*iFEpiiiiipi_t)(x64emu_t*, void*, int64_t, int64_t, int64_t, int64_t, int64_t, void*, int64_t);
 typedef int64_t (*iFEppplPPPP_t)(x64emu_t*, void*, void*, void*, intptr_t, void*, void*, void*, void*);
+typedef int64_t (*iFEppPPPPPP_t)(x64emu_t*, void*, void*, void*, void*, void*, void*, void*, void*);
 typedef int64_t (*iFiiiiiiiip_t)(int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, void*);
 typedef int64_t (*iFiiiipiiip_t)(int64_t, int64_t, int64_t, int64_t, void*, int64_t, int64_t, int64_t, void*);
 typedef int64_t (*iFipiipippi_t)(int64_t, void*, int64_t, int64_t, void*, int64_t, void*, void*, int64_t);
@@ -1159,6 +1160,7 @@ typedef void (*vFuffiiffiip_t)(uint64_t, float, float, int64_t, int64_t, float,
 typedef void (*vFuddiiddiip_t)(uint64_t, double, double, int64_t, int64_t, double, double, int64_t, int64_t, void*);
 typedef void (*vFffffffffff_t)(float, float, float, float, float, float, float, float, float, float);
 typedef void (*vFpppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*);
+typedef int64_t (*iFEppppppppp_t)(x64emu_t*, void*, void*, void*, void*, void*, void*, void*, void*, void*);
 typedef int64_t (*iFiiiiiiiiip_t)(int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, void*);
 typedef int64_t (*iFpuupiuiipp_t)(void*, uint64_t, uint64_t, void*, int64_t, uint64_t, int64_t, int64_t, void*, void*);
 typedef int64_t (*iFppuuiiiiii_t)(void*, void*, uint64_t, uint64_t, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t);
@@ -2331,6 +2333,7 @@ void vFpplpppppi(x64emu_t *emu, uintptr_t fcn) { vFpplpppppi_t fn = (vFpplpppppi
 void vFpppppippp(x64emu_t *emu, uintptr_t fcn) { vFpppppippp_t fn = (vFpppppippp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (int64_t)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24)); }
 void iFEpiiiiipi(x64emu_t *emu, uintptr_t fcn) { iFEpiiiiipi_t fn = (iFEpiiiiipi_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(void**)(R_RSP + 8), *(int64_t*)(R_RSP + 16)); }
 void iFEppplPPPP(x64emu_t *emu, uintptr_t fcn) { iFEppplPPPP_t fn = (iFEppplPPPP_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (intptr_t)R_RCX, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32)); }
+void iFEppPPPPPP(x64emu_t *emu, uintptr_t fcn) { iFEppPPPPPP_t fn = (iFEppPPPPPP_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32), *(void**)(R_RSP + 40), *(void**)(R_RSP + 48)); }
 void iFiiiiiiiip(x64emu_t *emu, uintptr_t fcn) { iFiiiiiiiip_t fn = (iFiiiiiiiip_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(int64_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(void**)(R_RSP + 24)); }
 void iFiiiipiiip(x64emu_t *emu, uintptr_t fcn) { iFiiiipiiip_t fn = (iFiiiipiiip_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (void*)R_R8, (int64_t)R_R9, *(int64_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(void**)(R_RSP + 24)); }
 void iFipiipippi(x64emu_t *emu, uintptr_t fcn) { iFipiipippi_t fn = (iFipiipippi_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (void*)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (void*)R_R8, (int64_t)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(int64_t*)(R_RSP + 24)); }
@@ -2365,6 +2368,7 @@ void vFuffiiffiip(x64emu_t *emu, uintptr_t fcn) { vFuffiiffiip_t fn = (vFuffiiff
 void vFuddiiddiip(x64emu_t *emu, uintptr_t fcn) { vFuddiiddiip_t fn = (vFuddiiddiip_t)fcn; fn((uint64_t)R_RDI, emu->xmm[0].d[0], emu->xmm[1].d[0], (int64_t)R_RSI, (int64_t)R_RDX, emu->xmm[2].d[0], emu->xmm[3].d[0], (int64_t)R_RCX, (int64_t)R_R8, (void*)R_R9); }
 void vFffffffffff(x64emu_t *emu, uintptr_t fcn) { vFffffffffff_t fn = (vFffffffffff_t)fcn; fn(emu->xmm[0].f[0], emu->xmm[1].f[0], emu->xmm[2].f[0], emu->xmm[3].f[0], emu->xmm[4].f[0], emu->xmm[5].f[0], emu->xmm[6].f[0], emu->xmm[7].f[0], *(float*)(R_RSP + 8), *(float*)(R_RSP + 16)); }
 void vFpppppppppp(x64emu_t *emu, uintptr_t fcn) { vFpppppppppp_t fn = (vFpppppppppp_t)fcn; fn((void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32)); }
+void iFEppppppppp(x64emu_t *emu, uintptr_t fcn) { iFEppppppppp_t fn = (iFEppppppppp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (void*)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(void**)(R_RSP + 24)); }
 void iFiiiiiiiiip(x64emu_t *emu, uintptr_t fcn) { iFiiiiiiiiip_t fn = (iFiiiiiiiiip_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (int64_t)R_RSI, (int64_t)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(int64_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(int64_t*)(R_RSP + 24), *(void**)(R_RSP + 32)); }
 void iFpuupiuiipp(x64emu_t *emu, uintptr_t fcn) { iFpuupiuiipp_t fn = (iFpuupiuiipp_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (uint64_t)R_RSI, (uint64_t)R_RDX, (void*)R_RCX, (int64_t)R_R8, (uint64_t)R_R9, *(int64_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(void**)(R_RSP + 24), *(void**)(R_RSP + 32)); }
 void iFppuuiiiiii(x64emu_t *emu, uintptr_t fcn) { iFppuuiiiiii_t fn = (iFppuuiiiiii_t)fcn; R_RAX=(int64_t)fn((void*)R_RDI, (void*)R_RSI, (uint64_t)R_RDX, (uint64_t)R_RCX, (int64_t)R_R8, (int64_t)R_R9, *(int64_t*)(R_RSP + 8), *(int64_t*)(R_RSP + 16), *(int64_t*)(R_RSP + 24), *(int64_t*)(R_RSP + 32)); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index 6ba0307c..f0bc6966 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -1121,6 +1121,7 @@ void vFpplpppppi(x64emu_t *emu, uintptr_t fnc);
 void vFpppppippp(x64emu_t *emu, uintptr_t fnc);
 void iFEpiiiiipi(x64emu_t *emu, uintptr_t fnc);
 void iFEppplPPPP(x64emu_t *emu, uintptr_t fnc);
+void iFEppPPPPPP(x64emu_t *emu, uintptr_t fnc);
 void iFiiiiiiiip(x64emu_t *emu, uintptr_t fnc);
 void iFiiiipiiip(x64emu_t *emu, uintptr_t fnc);
 void iFipiipippi(x64emu_t *emu, uintptr_t fnc);
@@ -1155,6 +1156,7 @@ void vFuffiiffiip(x64emu_t *emu, uintptr_t fnc);
 void vFuddiiddiip(x64emu_t *emu, uintptr_t fnc);
 void vFffffffffff(x64emu_t *emu, uintptr_t fnc);
 void vFpppppppppp(x64emu_t *emu, uintptr_t fnc);
+void iFEppppppppp(x64emu_t *emu, uintptr_t fnc);
 void iFiiiiiiiiip(x64emu_t *emu, uintptr_t fnc);
 void iFpuupiuiipp(x64emu_t *emu, uintptr_t fnc);
 void iFppuuiiiiii(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedflac.c b/src/wrapped/wrappedflac.c
new file mode 100755
index 00000000..e195f6d1
--- /dev/null
+++ b/src/wrapped/wrappedflac.c
@@ -0,0 +1,377 @@
+#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 "box64context.h"
+#include "librarian.h"
+#include "myalign.h"
+#include "bridge.h"
+
+const char* flacName = "libFLAC.so.8";
+#define LIBNAME flac
+
+static library_t *my_lib = NULL;
+
+typedef struct {
+  size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *handle);
+  size_t (*write_func)  (void *ptr, size_t size, size_t nmemb, void *handle);
+  int    (*seek_func)  (void *handle, int64_t offset, int whence);
+  long   (*tell_func)  (void *handle);
+  int    (*eof_func) (void *handle);
+  int    (*close_func) (void *handle);
+} flac_callbacks;
+
+typedef int (*iFppC_t)(void*, void*, flac_callbacks);
+typedef int (*iFpppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*);
+
+typedef struct flac_my_s {
+    // functions
+    iFppC_t         FLAC__metadata_chain_read_with_callbacks;
+    iFpppppppppp_t  FLAC__stream_decoder_init_stream;
+} flac_my_t;
+
+void* getFlacMy(library_t* lib)
+{
+    flac_my_t* my = (flac_my_t*)calloc(1, sizeof(flac_my_t));
+    #define GO(A, W) my->A = (W)dlsym(lib->priv.w.lib, #A);
+    GO(FLAC__metadata_chain_read_with_callbacks, iFppC_t)
+    GO(FLAC__stream_decoder_init_stream, iFpppppppppp_t)
+    #undef GO
+    return my;
+}
+
+void freeFlacMy(void* lib)
+{
+    (void)lib;
+    //flac_my_t *my = (flac_my_t *)lib;
+}
+
+#define SUPER() \
+GO(0)           \
+GO(1)           \
+GO(2)           \
+GO(3)           \
+GO(4)           \
+GO(5)           \
+GO(6)           \
+GO(7)
+
+// read_write
+#define GO(A)   \
+static uintptr_t my_read_write_fct_##A = 0;   \
+static unsigned long my_read_write_##A(void* ptr, unsigned long size, unsigned long nmemb, void* handle)     \
+{                                       \
+    return RunFunction(my_context, my_read_write_fct_##A, 4, ptr, size, nmemb, handle);\
+}
+SUPER()
+#undef GO
+static void* findread_writeFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_read_write_fct_##A == (uintptr_t)fct) return my_read_write_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_read_write_fct_##A == 0) {my_read_write_fct_##A = (uintptr_t)fct; return my_read_write_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC read_write callback\n");
+    return NULL;
+}
+// seek
+#define GO(A)   \
+static uintptr_t my_seek_fct_##A = 0;   \
+static int my_seek_##A(void* ptr, int64_t offset, int whence)     \
+{                                       \
+    return (int)RunFunction(my_context, my_seek_fct_##A, 3, ptr, offset, whence);\
+}
+SUPER()
+#undef GO
+static void* findseekFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_seek_fct_##A == (uintptr_t)fct) return my_seek_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_seek_fct_##A == 0) {my_seek_fct_##A = (uintptr_t)fct; return my_seek_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC seek callback\n");
+    return NULL;
+}
+// close_eof
+#define GO(A)   \
+static uintptr_t my_close_eof_fct_##A = 0;   \
+static int my_close_eof_##A(void* ptr)     \
+{                   \
+    return (int)RunFunction(my_context, my_close_eof_fct_##A, 1, ptr);\
+}
+SUPER()
+#undef GO
+static void* findclose_eofFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_close_eof_fct_##A == (uintptr_t)fct) return my_close_eof_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_close_eof_fct_##A == 0) {my_close_eof_fct_##A = (uintptr_t)fct; return my_close_eof_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC close_eof callback\n");
+    return NULL;
+}
+// tell
+#define GO(A)   \
+static uintptr_t my_tell_fct_##A = 0;   \
+static long my_tell_##A(void* ptr)     \
+{                                       \
+    return (long)RunFunction(my_context, my_tell_fct_##A, 1, ptr);\
+}
+SUPER()
+#undef GO
+static void* findtellFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_tell_fct_##A == (uintptr_t)fct) return my_tell_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_tell_fct_##A == 0) {my_tell_fct_##A = (uintptr_t)fct; return my_tell_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for vorbisfile tell callback\n");
+    return NULL;
+}
+// Read
+#define GO(A)                                                                               \
+static uintptr_t my_Read_fct_##A = 0;                                                       \
+static int my_Read_##A(void* decoder, void* buffer, size_t* bytes, void* data)              \
+{                                                                                           \
+    return (int)RunFunction(my_context, my_Read_fct_##A, 4, decoder, buffer, bytes, data);  \
+}
+SUPER()
+#undef GO
+static void* findReadFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_Read_fct_##A == (uintptr_t)fct) return my_Read_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_Read_fct_##A == 0) {my_Read_fct_##A = (uintptr_t)fct; return my_Read_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC Read callback\n");
+    return NULL;
+}
+// Seek
+#define GO(A)                                                                       \
+static uintptr_t my_Seek_fct_##A = 0;                                               \
+static int my_Seek_##A(void* decoder, uint64_t offset, void* data)                  \
+{                                                                                   \
+    return (int)RunFunction(my_context, my_Seek_fct_##A, 3, decoder, offset, data); \
+}
+SUPER()
+#undef GO
+static void* findSeekFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_Seek_fct_##A == (uintptr_t)fct) return my_Seek_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_Seek_fct_##A == 0) {my_Seek_fct_##A = (uintptr_t)fct; return my_Seek_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC Seek callback\n");
+    return NULL;
+}
+// Tell
+#define GO(A)                                                                       \
+static uintptr_t my_Tell_fct_##A = 0;                                               \
+static int my_Tell_##A(void* decoder, uint64_t *offset, void* data)                 \
+{                                                                                   \
+    return (int)RunFunction(my_context, my_Tell_fct_##A, 3, decoder, offset, data); \
+}
+SUPER()
+#undef GO
+static void* findTellFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_Tell_fct_##A == (uintptr_t)fct) return my_Tell_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_Tell_fct_##A == 0) {my_Tell_fct_##A = (uintptr_t)fct; return my_Tell_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC Tell callback\n");
+    return NULL;
+}
+// Length
+#define GO(A)                                                                           \
+static uintptr_t my_Length_fct_##A = 0;                                                 \
+static int my_Length_##A(void* decoder, uint64_t *length, void* data)                   \
+{                                                                                       \
+    return (int)RunFunction(my_context, my_Length_fct_##A, 3, decoder, length, data);   \
+}
+SUPER()
+#undef GO
+static void* findLengthFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_Length_fct_##A == (uintptr_t)fct) return my_Length_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_Length_fct_##A == 0) {my_Length_fct_##A = (uintptr_t)fct; return my_Length_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC Length callback\n");
+    return NULL;
+}
+// Eof
+#define GO(A)                                                               \
+static uintptr_t my_Eof_fct_##A = 0;                                        \
+static int my_Eof_##A(void* decoder, void* data)                            \
+{                                                                           \
+    return (int)RunFunction(my_context, my_Eof_fct_##A, 2, decoder, data);  \
+}
+SUPER()
+#undef GO
+static void* findEofFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_Eof_fct_##A == (uintptr_t)fct) return my_Eof_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_Eof_fct_##A == 0) {my_Eof_fct_##A = (uintptr_t)fct; return my_Eof_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC Eof callback\n");
+    return NULL;
+}
+// Write
+#define GO(A)                                                                               \
+static uintptr_t my_Write_fct_##A = 0;                                                      \
+static int my_Write_##A(void* decoder, void* frame, void* buffer, void* data)               \
+{                                                                                           \
+    return (int)RunFunction(my_context, my_Write_fct_##A, 4, decoder, frame, buffer, data); \
+}
+SUPER()
+#undef GO
+static void* findWriteFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_Write_fct_##A == (uintptr_t)fct) return my_Write_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_Write_fct_##A == 0) {my_Write_fct_##A = (uintptr_t)fct; return my_Write_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC Write callback\n");
+    return NULL;
+}
+// Metadata
+#define GO(A)                                                                               \
+static uintptr_t my_Metadata_fct_##A = 0;                                                   \
+static int my_Metadata_##A(void* decoder, void* metadata, void* data)                       \
+{                                                                                           \
+    return (int)RunFunction(my_context, my_Metadata_fct_##A, 3, decoder, metadata, data);   \
+}
+SUPER()
+#undef GO
+static void* findMetadataFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_Metadata_fct_##A == (uintptr_t)fct) return my_Metadata_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_Metadata_fct_##A == 0) {my_Metadata_fct_##A = (uintptr_t)fct; return my_Metadata_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC Metadata callback\n");
+    return NULL;
+}
+// Error
+#define GO(A)                                                               \
+static uintptr_t my_Error_fct_##A = 0;                                      \
+static void my_Error_##A(void* decoder, int status, void* data)             \
+{                                                                           \
+    RunFunction(my_context, my_Error_fct_##A, 3, decoder, status, data);    \
+}
+SUPER()
+#undef GO
+static void* findErrorFct(void* fct)
+{
+    if(!fct) return NULL;
+    if(GetNativeFnc((uintptr_t)fct)) return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_Error_fct_##A == (uintptr_t)fct) return my_Error_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_Error_fct_##A == 0) {my_Error_fct_##A = (uintptr_t)fct; return my_Error_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for FLAC Error callback\n");
+    return NULL;
+}
+
+
+#undef SUPER
+
+EXPORT int my_FLAC__metadata_chain_read_with_callbacks(x64emu_t* emu, void* chain, void* handle, 
+    void* read_fnc, void* write_fnc, void* seek_fnc, void* tell_fnc, void* eof_fnc, void* close_fnc)
+{
+    flac_my_t* my = (flac_my_t*)my_lib->priv.w.p2;
+    flac_callbacks cbs = {0};
+    cbs.read_func = findread_writeFct(read_fnc);
+    cbs.write_func = findread_writeFct(write_fnc);
+    cbs.seek_func = findseekFct(seek_fnc);
+    cbs.tell_func = findtellFct(tell_fnc);
+    cbs.eof_func = findclose_eofFct(eof_fnc);
+    cbs.close_func = findclose_eofFct(close_fnc);
+    int ret =  my->FLAC__metadata_chain_read_with_callbacks(chain, handle, cbs);
+    return ret;
+}
+
+EXPORT int my_FLAC__stream_decoder_init_stream(x64emu_t* emu, void* decoder,
+    void* read_fnc, void* seek_fnc, void* tell_fnc, void* length_fnc, void* eof_fnc, 
+    void* write_fnc, void* metadata_fnc, void* error_fnc, void* data)
+{
+    flac_my_t* my = (flac_my_t*)my_lib->priv.w.p2;
+
+    int ret =  my->FLAC__stream_decoder_init_stream(decoder, 
+        findReadFct(read_fnc), findSeekFct(seek_fnc), findTellFct(tell_fnc),
+        findLengthFct(length_fnc), findEofFct(eof_fnc), findWriteFct(write_fnc),
+        findMetadataFct(metadata_fnc), findErrorFct(error_fnc), data);
+    return ret;
+}
+
+
+#define CUSTOM_INIT \
+    lib->priv.w.p2 = getFlacMy(lib);    \
+    my_lib = lib;
+
+#define CUSTOM_FINI \
+    freeFlacMy(lib->priv.w.p2);     \
+    free(lib->priv.w.p2);           \
+    my_lib = NULL;
+
+#include "wrappedlib_init.h"
+
diff --git a/src/wrapped/wrappedflac_private.h b/src/wrapped/wrappedflac_private.h
new file mode 100755
index 00000000..5dea8548
--- /dev/null
+++ b/src/wrapped/wrappedflac_private.h
@@ -0,0 +1,223 @@
+#if !(defined(GO) && defined(GOM) && defined(GO2) && defined(DATA))
+#error meh!
+#endif
+
+//DATA(FLAC_API_SUPPORTS_OGG_FLAC, 
+//DATA(FLAC__ChannelAssignmentString, 
+//DATA(FLAC__EntropyCodingMethodTypeString, 
+//GO(FLAC__format_blocksize_is_subset, 
+//GO(FLAC__format_cuesheet_is_legal, 
+//GO(FLAC__format_picture_is_legal, 
+//GO(FLAC__format_sample_rate_is_subset, 
+//GO(FLAC__format_sample_rate_is_valid, 
+//GO(FLAC__format_seektable_is_legal, 
+//GO(FLAC__format_seektable_sort, 
+//GO(FLAC__format_vorbiscomment_entry_is_legal, 
+//GO(FLAC__format_vorbiscomment_entry_name_is_legal, 
+//GO(FLAC__format_vorbiscomment_entry_value_is_legal, 
+//DATA(FLAC__FrameNumberTypeString, 
+//GO(FLAC__metadata_chain_check_if_tempfile_needed, 
+//GO(FLAC__metadata_chain_delete, 
+//GO(FLAC__metadata_chain_merge_padding, 
+GO(FLAC__metadata_chain_new, pFv)
+//GO(FLAC__metadata_chain_read, 
+//GO(FLAC__metadata_chain_read_ogg, 
+//GO(FLAC__metadata_chain_read_ogg_with_callbacks, 
+GOM(FLAC__metadata_chain_read_with_callbacks, iFEppPPPPPP)   // FLAC__IOCallbacks is a struct with all callbacks
+//GO(FLAC__metadata_chain_sort_padding, 
+GO(FLAC__metadata_chain_status, iFp)
+DATA(FLAC__Metadata_ChainStatusString, sizeof(void*))
+//GO(FLAC__metadata_chain_write, 
+//GO(FLAC__metadata_chain_write_with_callbacks, 
+//GO(FLAC__metadata_chain_write_with_callbacks_and_tempfile, 
+//GO(FLAC__metadata_get_cuesheet, 
+//GO(FLAC__metadata_get_picture, 
+//GO(FLAC__metadata_get_streaminfo, 
+//GO(FLAC__metadata_get_tags, 
+GO(FLAC__metadata_iterator_delete, vFp)
+GO(FLAC__metadata_iterator_delete_block, iFpi)
+GO(FLAC__metadata_iterator_get_block, pFp)
+GO(FLAC__metadata_iterator_get_block_type, iFp)
+GO(FLAC__metadata_iterator_init, vFpp)
+GO(FLAC__metadata_iterator_insert_block_after, iFpp)
+GO(FLAC__metadata_iterator_insert_block_before, iFpp)
+GO(FLAC__metadata_iterator_new, pFv)
+GO(FLAC__metadata_iterator_next, iFp)
+GO(FLAC__metadata_iterator_prev, iFp)
+GO(FLAC__metadata_iterator_set_block, iFpp)
+//GO(FLAC__metadata_object_application_set_data, 
+//GO(FLAC__metadata_object_clone, 
+//GO(FLAC__metadata_object_cuesheet_calculate_cddb_id, 
+//GO(FLAC__metadata_object_cuesheet_delete_track, 
+//GO(FLAC__metadata_object_cuesheet_insert_blank_track, 
+//GO(FLAC__metadata_object_cuesheet_insert_track, 
+//GO(FLAC__metadata_object_cuesheet_is_legal, 
+//GO(FLAC__metadata_object_cuesheet_resize_tracks, 
+//GO(FLAC__metadata_object_cuesheet_set_track, 
+//GO(FLAC__metadata_object_cuesheet_track_clone, 
+//GO(FLAC__metadata_object_cuesheet_track_delete, 
+//GO(FLAC__metadata_object_cuesheet_track_delete_index, 
+//GO(FLAC__metadata_object_cuesheet_track_insert_blank_index, 
+//GO(FLAC__metadata_object_cuesheet_track_insert_index, 
+//GO(FLAC__metadata_object_cuesheet_track_new, 
+//GO(FLAC__metadata_object_cuesheet_track_resize_indices, 
+GO(FLAC__metadata_object_delete, vFp)
+//GO(FLAC__metadata_object_is_equal, 
+//GO(FLAC__metadata_object_new, 
+//GO(FLAC__metadata_object_picture_is_legal, 
+//GO(FLAC__metadata_object_picture_set_data, 
+//GO(FLAC__metadata_object_picture_set_description, 
+//GO(FLAC__metadata_object_picture_set_mime_type, 
+//GO(FLAC__metadata_object_seektable_delete_point, 
+//GO(FLAC__metadata_object_seektable_insert_point, 
+//GO(FLAC__metadata_object_seektable_is_legal, 
+//GO(FLAC__metadata_object_seektable_resize_points, 
+//GO(FLAC__metadata_object_seektable_set_point, 
+//GO(FLAC__metadata_object_seektable_template_append_placeholders, 
+//GO(FLAC__metadata_object_seektable_template_append_point, 
+//GO(FLAC__metadata_object_seektable_template_append_points, 
+//GO(FLAC__metadata_object_seektable_template_append_spaced_points, 
+//GO(FLAC__metadata_object_seektable_template_append_spaced_points_by_samples, 
+//GO(FLAC__metadata_object_seektable_template_sort, 
+//GO(FLAC__metadata_object_vorbiscomment_append_comment, 
+//GO(FLAC__metadata_object_vorbiscomment_delete_comment, 
+//GO(FLAC__metadata_object_vorbiscomment_entry_from_name_value_pair, 
+//GO(FLAC__metadata_object_vorbiscomment_entry_matches, 
+//GO(FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair, 
+//GO(FLAC__metadata_object_vorbiscomment_find_entry_from, 
+//GO(FLAC__metadata_object_vorbiscomment_insert_comment, 
+//GO(FLAC__metadata_object_vorbiscomment_remove_entries_matching, 
+//GO(FLAC__metadata_object_vorbiscomment_remove_entry_matching, 
+//GO(FLAC__metadata_object_vorbiscomment_replace_comment, 
+//GO(FLAC__metadata_object_vorbiscomment_resize_comments, 
+//GO(FLAC__metadata_object_vorbiscomment_set_comment, 
+//GO(FLAC__metadata_object_vorbiscomment_set_vendor_string, 
+//GO(FLAC__metadata_simple_iterator_delete, 
+//GO(FLAC__metadata_simple_iterator_delete_block, 
+//GO(FLAC__metadata_simple_iterator_get_application_id, 
+//GO(FLAC__metadata_simple_iterator_get_block, 
+//GO(FLAC__metadata_simple_iterator_get_block_length, 
+//GO(FLAC__metadata_simple_iterator_get_block_offset, 
+//GO(FLAC__metadata_simple_iterator_get_block_type, 
+//GO(FLAC__metadata_simple_iterator_init, 
+//GO(FLAC__metadata_simple_iterator_insert_block_after, 
+//GO(FLAC__metadata_simple_iterator_is_last, 
+//GO(FLAC__metadata_simple_iterator_is_writable, 
+//GO(FLAC__metadata_simple_iterator_new, 
+//GO(FLAC__metadata_simple_iterator_next, 
+//GO(FLAC__metadata_simple_iterator_prev, 
+//GO(FLAC__metadata_simple_iterator_set_block, 
+//GO(FLAC__metadata_simple_iterator_status, 
+//DATA(FLAC__Metadata_SimpleIteratorStatusString, 
+//DATA(FLAC__MetadataTypeString, 
+GO(FLAC__stream_decoder_delete, vFp)
+DATA(FLAC__StreamDecoderErrorStatusString, sizeof(void*))
+GO(FLAC__stream_decoder_finish, iFp)
+GO(FLAC__stream_decoder_flush, iFp)
+//GO(FLAC__stream_decoder_get_bits_per_sample, 
+//GO(FLAC__stream_decoder_get_blocksize, 
+//GO(FLAC__stream_decoder_get_channel_assignment, 
+//GO(FLAC__stream_decoder_get_channels, 
+GO(FLAC__stream_decoder_get_decode_position, iFpp)
+//GO(FLAC__stream_decoder_get_md5_checking, 
+GO(FLAC__stream_decoder_get_resolved_state_string, pFp)
+//GO(FLAC__stream_decoder_get_sample_rate, 
+GO(FLAC__stream_decoder_get_state, iFp)
+//GO(FLAC__stream_decoder_get_total_samples, 
+//GO(FLAC__stream_decoder_init_file, 
+//GO(FLAC__stream_decoder_init_FILE, 
+//GO(FLAC__stream_decoder_init_ogg_file, 
+//GO(FLAC__stream_decoder_init_ogg_FILE, 
+//GO(FLAC__stream_decoder_init_ogg_stream, 
+//DATA(FLAC__StreamDecoderInitStatusString, 
+GOM(FLAC__stream_decoder_init_stream, iFEppppppppp)
+//DATA(FLAC__StreamDecoderLengthStatusString, 
+GO(FLAC__stream_decoder_new, pFv)
+GO(FLAC__stream_decoder_process_single, iFp)
+//GO(FLAC__stream_decoder_process_until_end_of_metadata, 
+//GO(FLAC__stream_decoder_process_until_end_of_stream, 
+//DATA(FLAC__StreamDecoderReadStatusString, 
+//GO(FLAC__stream_decoder_reset, 
+GO(FLAC__stream_decoder_seek_absolute, iFpU)
+//DATA(FLAC__StreamDecoderSeekStatusString, 
+//GO(FLAC__stream_decoder_set_md5_checking, 
+//GO(FLAC__stream_decoder_set_metadata_ignore, 
+GO(FLAC__stream_decoder_set_metadata_ignore_all, iFp)
+//GO(FLAC__stream_decoder_set_metadata_ignore_application, 
+//GO(FLAC__stream_decoder_set_metadata_respond, 
+//GO(FLAC__stream_decoder_set_metadata_respond_all, 
+//GO(FLAC__stream_decoder_set_metadata_respond_application, 
+//GO(FLAC__stream_decoder_set_ogg_serial_number, 
+//GO(FLAC__stream_decoder_skip_single_frame, 
+//DATA(FLAC__StreamDecoderStateString, 
+//DATA(FLAC__StreamDecoderTellStatusString, 
+//DATA(FLAC__StreamDecoderWriteStatusString, 
+//GO(FLAC__stream_encoder_delete, 
+//GO(FLAC__stream_encoder_disable_constant_subframes, 
+//GO(FLAC__stream_encoder_disable_fixed_subframes, 
+//GO(FLAC__stream_encoder_disable_verbatim_subframes, 
+//GO(FLAC__stream_encoder_finish, 
+//GO(FLAC__stream_encoder_get_bits_per_sample, 
+//GO(FLAC__stream_encoder_get_blocksize, 
+//GO(FLAC__stream_encoder_get_channels, 
+//GO(FLAC__stream_encoder_get_do_escape_coding, 
+//GO(FLAC__stream_encoder_get_do_exhaustive_model_search, 
+//GO(FLAC__stream_encoder_get_do_md5, 
+//GO(FLAC__stream_encoder_get_do_mid_side_stereo, 
+//GO(FLAC__stream_encoder_get_do_qlp_coeff_prec_search, 
+//GO(FLAC__stream_encoder_get_loose_mid_side_stereo, 
+//GO(FLAC__stream_encoder_get_max_lpc_order, 
+//GO(FLAC__stream_encoder_get_max_residual_partition_order, 
+//GO(FLAC__stream_encoder_get_min_residual_partition_order, 
+//GO(FLAC__stream_encoder_get_qlp_coeff_precision, 
+//GO(FLAC__stream_encoder_get_resolved_state_string, 
+//GO(FLAC__stream_encoder_get_rice_parameter_search_dist, 
+//GO(FLAC__stream_encoder_get_sample_rate, 
+//GO(FLAC__stream_encoder_get_state, 
+//GO(FLAC__stream_encoder_get_streamable_subset, 
+//GO(FLAC__stream_encoder_get_total_samples_estimate, 
+//GO(FLAC__stream_encoder_get_verify, 
+//GO(FLAC__stream_encoder_get_verify_decoder_error_stats, 
+//GO(FLAC__stream_encoder_get_verify_decoder_state, 
+//GO(FLAC__stream_encoder_init_file, 
+//GO(FLAC__stream_encoder_init_FILE, 
+//GO(FLAC__stream_encoder_init_ogg_file, 
+//GO(FLAC__stream_encoder_init_ogg_FILE, 
+//GO(FLAC__stream_encoder_init_ogg_stream, 
+//DATA(FLAC__StreamEncoderInitStatusString, 
+//GO(FLAC__stream_encoder_init_stream, 
+//GO(FLAC__stream_encoder_new, 
+//GO(FLAC__stream_encoder_process, 
+//GO(FLAC__stream_encoder_process_interleaved, 
+//DATA(FLAC__StreamEncoderReadStatusString, 
+//DATA(FLAC__StreamEncoderSeekStatusString, 
+//GO(FLAC__stream_encoder_set_apodization, 
+//GO(FLAC__stream_encoder_set_bits_per_sample, 
+//GO(FLAC__stream_encoder_set_blocksize, 
+//GO(FLAC__stream_encoder_set_channels, 
+//GO(FLAC__stream_encoder_set_compression_level, 
+//GO(FLAC__stream_encoder_set_do_escape_coding, 
+//GO(FLAC__stream_encoder_set_do_exhaustive_model_search, 
+//GO(FLAC__stream_encoder_set_do_md5, 
+//GO(FLAC__stream_encoder_set_do_mid_side_stereo, 
+//GO(FLAC__stream_encoder_set_do_qlp_coeff_prec_search, 
+//GO(FLAC__stream_encoder_set_loose_mid_side_stereo, 
+//GO(FLAC__stream_encoder_set_max_lpc_order, 
+//GO(FLAC__stream_encoder_set_max_residual_partition_order, 
+//GO(FLAC__stream_encoder_set_metadata, 
+//GO(FLAC__stream_encoder_set_min_residual_partition_order, 
+//GO(FLAC__stream_encoder_set_ogg_serial_number, 
+//GO(FLAC__stream_encoder_set_qlp_coeff_precision, 
+//GO(FLAC__stream_encoder_set_rice_parameter_search_dist, 
+//GO(FLAC__stream_encoder_set_sample_rate, 
+//GO(FLAC__stream_encoder_set_streamable_subset, 
+//GO(FLAC__stream_encoder_set_total_samples_estimate, 
+//GO(FLAC__stream_encoder_set_verify, 
+//DATA(FLAC__StreamEncoderStateString, 
+//DATA(FLAC__StreamEncoderTellStatusString, 
+//DATA(FLAC__StreamEncoderWriteStatusString, 
+//DATA(FLAC__StreamMetadata_Picture_TypeString, 
+//DATA(FLAC__SubframeTypeString, 
+//DATA(FLAC__VENDOR_STRING, 
+//DATA(FLAC__VERSION_STRING, 
+//GO(get_client_data_from_decoder,