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.txt9
-rw-r--r--src/wrapped/generated/wrappedlzmatypes.h23
-rw-r--r--src/wrapped/generated/wrapper.c4
-rw-r--r--src/wrapped/generated/wrapper.h2
-rwxr-xr-xsrc/wrapped/wrappedlzma.c96
-rwxr-xr-xsrc/wrapped/wrappedlzma_private.h12
6 files changed, 139 insertions, 7 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 1f37540b..6ac6899a 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -1129,6 +1129,7 @@
 #() iFEpLiLpV
 #() iFEppLpIi
 #() iFEpppiiu
+#() iFEpppppL
 #() iFEpppppp
 #() iFiiiiiip
 #() iFpiiiiii
@@ -1325,6 +1326,7 @@
 #() vFffffffffff
 #() vFppdddddddd
 #() vFpppppppppp
+#() iFEpupppLppL
 #() iFEppppppppp
 #() iFiiiiiiiiip
 #() iFpuupiuiipp
@@ -1923,6 +1925,13 @@ wrappedlibz:
   - inflateInit2_
 - iFpiiiiipi:
   - deflateInit2_
+wrappedlzma:
+- vFpp:
+  - lzma_index_end
+- iFpppppL:
+  - lzma_index_buffer_decode
+- iFpupppLppL:
+  - lzma_stream_buffer_decode
 wrappedmpg123:
 - iFpppp:
   - mpg123_replace_reader_handle
diff --git a/src/wrapped/generated/wrappedlzmatypes.h b/src/wrapped/generated/wrappedlzmatypes.h
new file mode 100644
index 00000000..5cdd8d1d
--- /dev/null
+++ b/src/wrapped/generated/wrappedlzmatypes.h
@@ -0,0 +1,23 @@
+/*******************************************************************
+ * File automatically generated by rebuild_wrappers.py (v2.0.1.14) *
+ *******************************************************************/
+#ifndef __wrappedlzmaTYPES_H_
+#define __wrappedlzmaTYPES_H_
+
+#ifndef LIBNAME
+#error You should only #include this file inside a wrapped*.c file
+#endif
+#ifndef ADDED_FUNCTIONS
+#define ADDED_FUNCTIONS() 
+#endif
+
+typedef void (*vFpp_t)(void*, void*);
+typedef int64_t (*iFpppppL_t)(void*, void*, void*, void*, void*, uintptr_t);
+typedef int64_t (*iFpupppLppL_t)(void*, uint64_t, void*, void*, void*, uintptr_t, void*, void*, uintptr_t);
+
+#define SUPER() ADDED_FUNCTIONS() \
+	GO(lzma_index_end, vFpp_t) \
+	GO(lzma_index_buffer_decode, iFpppppL_t) \
+	GO(lzma_stream_buffer_decode, iFpupppLppL_t)
+
+#endif // __wrappedlzmaTYPES_H_
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index c0a26c95..77d6afd8 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -1163,6 +1163,7 @@ typedef void (*vFppppipi_t)(void*, void*, void*, void*, int64_t, void*, int64_t)
 typedef int64_t (*iFEpLiLpV_t)(x64emu_t*, void*, uintptr_t, int64_t, uintptr_t, void*, void*);
 typedef int64_t (*iFEppLpIi_t)(x64emu_t*, void*, void*, uintptr_t, void*, int64_t, int64_t);
 typedef int64_t (*iFEpppiiu_t)(x64emu_t*, void*, void*, void*, int64_t, int64_t, uint64_t);
+typedef int64_t (*iFEpppppL_t)(x64emu_t*, void*, void*, void*, void*, void*, uintptr_t);
 typedef int64_t (*iFEpppppp_t)(x64emu_t*, void*, void*, void*, void*, void*, void*);
 typedef int64_t (*iFiiiiiip_t)(int64_t, int64_t, int64_t, int64_t, int64_t, int64_t, void*);
 typedef int64_t (*iFpiiiiii_t)(void*, int64_t, int64_t, int64_t, int64_t, int64_t, int64_t);
@@ -1359,6 +1360,7 @@ typedef void (*vFuddiiddiip_t)(uint64_t, double, double, int64_t, int64_t, doubl
 typedef void (*vFffffffffff_t)(float, float, float, float, float, float, float, float, float, float);
 typedef void (*vFppdddddddd_t)(void*, void*, double, double, double, double, double, double, double, double);
 typedef void (*vFpppppppppp_t)(void*, void*, void*, void*, void*, void*, void*, void*, void*, void*);
+typedef int64_t (*iFEpupppLppL_t)(x64emu_t*, void*, uint64_t, void*, void*, void*, uintptr_t, void*, void*, uintptr_t);
 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*);
@@ -2589,6 +2591,7 @@ void vFppppipi(x64emu_t *emu, uintptr_t fcn) { vFppppipi_t fn = (vFppppipi_t)fcn
 void iFEpLiLpV(x64emu_t *emu, uintptr_t fcn) { iFEpLiLpV_t fn = (iFEpLiLpV_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int64_t)R_RDX, (uintptr_t)R_RCX, (void*)R_R8, (void*)(R_RSP + 8)); }
 void iFEppLpIi(x64emu_t *emu, uintptr_t fcn) { iFEppLpIi_t fn = (iFEppLpIi_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX, (void*)R_RCX, (int64_t)R_R8, (int64_t)R_R9); }
 void iFEpppiiu(x64emu_t *emu, uintptr_t fcn) { iFEpppiiu_t fn = (iFEpppiiu_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (int64_t)R_RCX, (int64_t)R_R8, (uint64_t)R_R9); }
+void iFEpppppL(x64emu_t *emu, uintptr_t fcn) { iFEpppppL_t fn = (iFEpppppL_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (uintptr_t)R_R9); }
 void iFEpppppp(x64emu_t *emu, uintptr_t fcn) { iFEpppppp_t fn = (iFEpppppp_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 iFiiiiiip(x64emu_t *emu, uintptr_t fcn) { iFiiiiiip_t fn = (iFiiiiiip_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, *(void**)(R_RSP + 8)); }
 void iFpiiiiii(x64emu_t *emu, uintptr_t fcn) { iFpiiiiii_t fn = (iFpiiiiii_t)fcn; R_RAX=(int64_t)fn((void*)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)); }
@@ -2785,6 +2788,7 @@ void vFuddiiddiip(x64emu_t *emu, uintptr_t fcn) { vFuddiiddiip_t fn = (vFuddiidd
 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 vFppdddddddd(x64emu_t *emu, uintptr_t fcn) { vFppdddddddd_t fn = (vFppdddddddd_t)fcn; fn((void*)R_RDI, (void*)R_RSI, emu->xmm[0].d[0], emu->xmm[1].d[0], emu->xmm[2].d[0], emu->xmm[3].d[0], emu->xmm[4].d[0], emu->xmm[5].d[0], emu->xmm[6].d[0], emu->xmm[7].d[0]); }
 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 iFEpupppLppL(x64emu_t *emu, uintptr_t fcn) { iFEpupppLppL_t fn = (iFEpupppLppL_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI, (void*)R_RDX, (void*)R_RCX, (void*)R_R8, (uintptr_t)R_R9, *(void**)(R_RSP + 8), *(void**)(R_RSP + 16), *(uintptr_t*)(R_RSP + 24)); }
 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)); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index 8b6ed6e6..c7683597 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -1159,6 +1159,7 @@ void vFppppipi(x64emu_t *emu, uintptr_t fnc);
 void iFEpLiLpV(x64emu_t *emu, uintptr_t fnc);
 void iFEppLpIi(x64emu_t *emu, uintptr_t fnc);
 void iFEpppiiu(x64emu_t *emu, uintptr_t fnc);
+void iFEpppppL(x64emu_t *emu, uintptr_t fnc);
 void iFEpppppp(x64emu_t *emu, uintptr_t fnc);
 void iFiiiiiip(x64emu_t *emu, uintptr_t fnc);
 void iFpiiiiii(x64emu_t *emu, uintptr_t fnc);
@@ -1355,6 +1356,7 @@ void vFuddiiddiip(x64emu_t *emu, uintptr_t fnc);
 void vFffffffffff(x64emu_t *emu, uintptr_t fnc);
 void vFppdddddddd(x64emu_t *emu, uintptr_t fnc);
 void vFpppppppppp(x64emu_t *emu, uintptr_t fnc);
+void iFEpupppLppL(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);
diff --git a/src/wrapped/wrappedlzma.c b/src/wrapped/wrappedlzma.c
index 72be8f66..f364d45d 100755
--- a/src/wrapped/wrappedlzma.c
+++ b/src/wrapped/wrappedlzma.c
@@ -23,7 +23,7 @@ const char* lzmaName = "liblzma.so.5";
 static library_t* my_lib = NULL;
 
 
-#define SUPER() \
+#include "generated/wrappedlzmatypes.h"
 
 typedef struct lzma_my_s {
     // functions
@@ -49,6 +49,100 @@ void freeLzmaMy(void* lib)
     //lzma_my_t *my = (lzma_my_t *)lib;
 }
 
+typedef struct lzma_allocator_s {
+	void *(*alloc)(void *opaque, size_t nmemb, size_t size);
+	void (*free)(void *opaque, void *ptr);
+	void *opaque;
+} lzma_allocator_t;
+
+#define SUPER() \
+GO(0)   \
+GO(1)   \
+GO(2)   \
+GO(3)   \
+GO(4)
+
+// alloc ...
+#define GO(A)   \
+static uintptr_t my_alloc_fct_##A = 0;                                              \
+static void* my_alloc_##A(void* opaque, size_t items, size_t size)                  \
+{                                                                                   \
+    return (void*)RunFunction(my_context, my_alloc_fct_##A, 3, opaque, items, size);\
+}
+SUPER()
+#undef GO
+static void* find_alloc_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_alloc_fct_##A == (uintptr_t)fct) return my_alloc_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_alloc_fct_##A == 0) {my_alloc_fct_##A = (uintptr_t)fct; return my_alloc_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for zlib alloc callback\n");
+    return NULL;
+}
+// free ...
+#define GO(A)   \
+static uintptr_t my_free_fct_##A = 0;                               \
+static void my_free_##A(void* opaque, void* address)                \
+{                                                                   \
+    RunFunction(my_context, my_free_fct_##A, 2, opaque, address);   \
+}
+SUPER()
+#undef GO
+static void* find_free_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_free_fct_##A == (uintptr_t)fct) return my_free_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_free_fct_##A == 0) {my_free_fct_##A = (uintptr_t)fct; return my_free_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for zlib free callback\n");
+    return NULL;
+}
+#undef SUPER
+
+static void wrap_alloc_struct(lzma_allocator_t* dst, lzma_allocator_t* src)
+{
+    if(!src)
+        return;
+    dst->opaque = src->opaque;
+    dst->alloc = find_alloc_Fct(src->alloc);
+    dst->free = find_free_Fct(src->free);
+    
+}
+
+EXPORT int my_lzma_index_buffer_decode(x64emu_t* emu, void* i, void* memlimit, lzma_allocator_t* alloc, void* in_, void* in_pos, size_t in_size)
+{
+    lzma_my_t *my = (lzma_my_t *)my_lib->priv.w.p2;
+    lzma_allocator_t allocator = {0};
+    wrap_alloc_struct(&allocator, alloc);
+    return my->lzma_index_buffer_decode(i, memlimit, alloc?&allocator:NULL, in_, in_pos, in_size);
+}
+
+EXPORT void my_lzma_index_end(x64emu_t* emu, void* i, lzma_allocator_t* alloc)
+{
+    lzma_my_t *my = (lzma_my_t *)my_lib->priv.w.p2;
+    lzma_allocator_t allocator = {0};
+    wrap_alloc_struct(&allocator, alloc);
+    return my->lzma_index_end(i,alloc?&allocator:NULL);
+}
+
+EXPORT int my_lzma_stream_buffer_decode(x64emu_t* emu, void* memlimit, uint32_t flags, lzma_allocator_t* alloc, void* in_, void* in_pos, size_t in_size, void* out_, void* out_pos, size_t out_size)
+{
+    lzma_my_t *my = (lzma_my_t *)my_lib->priv.w.p2;
+    lzma_allocator_t allocator = {0};
+    wrap_alloc_struct(&allocator, alloc);
+    return my->lzma_stream_buffer_decode(memlimit, flags, alloc?&allocator:NULL, in_, in_pos, in_size, out_, out_pos, out_size);
+}
+
+
 #define CUSTOM_INIT \
     lib->priv.w.p2 = getLzmaMy(lib); \
     my_lib = lib;
diff --git a/src/wrapped/wrappedlzma_private.h b/src/wrapped/wrappedlzma_private.h
index a4e9fae8..3099c26c 100755
--- a/src/wrapped/wrappedlzma_private.h
+++ b/src/wrapped/wrappedlzma_private.h
@@ -39,14 +39,14 @@ GO(lzma_end, vFp)
 //GO(lzma_get_progress, 
 //GO(lzma_index_append, 
 //GO(lzma_index_block_count, 
-//GO(lzma_index_buffer_decode, 
+GOM(lzma_index_buffer_decode, iFEpppppL)
 //GO(lzma_index_buffer_encode, 
 //GO(lzma_index_cat, 
 //GO(lzma_index_checks, 
 //GO(lzma_index_decoder, 
 //GO(lzma_index_dup, 
 //GO(lzma_index_encoder, 
-//GO(lzma_index_end, 
+GOM(lzma_index_end, vFEpp)
 //GO(lzma_index_file_size, 
 //GO(lzma_index_hash_append, 
 //GO(lzma_index_hash_decode, 
@@ -60,13 +60,13 @@ GO(lzma_end, vFp)
 //GO(lzma_index_iter_rewind, 
 //GO(lzma_index_memusage, 
 //GO(lzma_index_memused, 
-//GO(lzma_index_size, 
+GO(lzma_index_size, UFp)
 //GO(lzma_index_stream_count, 
 //GO(lzma_index_stream_flags, 
 //GO(lzma_index_stream_padding, 
 //GO(lzma_index_stream_size, 
 //GO(lzma_index_total_size, 
-//GO(lzma_index_uncompressed_size, 
+GO(lzma_index_uncompressed_size, UFp)
 //GO(lzma_lzma_preset, 
 //GO(lzma_memlimit_get, 
 //GO(lzma_memlimit_set, 
@@ -84,14 +84,14 @@ GO(lzma_end, vFp)
 //GO(lzma_raw_encoder, 
 //GO(lzma_raw_encoder_memusage, 
 //GO(lzma_stream_buffer_bound, 
-//GO(lzma_stream_buffer_decode, 
+GOM(lzma_stream_buffer_decode, iFEpupppLppL)
 //GO(lzma_stream_buffer_encode, 
 GO(lzma_stream_decoder, iFpUi)
 //GO(lzma_stream_encoder, 
 //GO(lzma_stream_encoder_mt, 
 //GO(lzma_stream_encoder_mt_memusage, 
 //GO(lzma_stream_flags_compare, 
-//GO(lzma_stream_footer_decode, 
+GO(lzma_stream_footer_decode, iFpp)
 //GO(lzma_stream_footer_encode, 
 //GO(lzma_stream_header_decode, 
 //GO(lzma_stream_header_encode,