about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-12-06 19:09:09 +0100
committerptitSeb <sebastien.chev@gmail.com>2022-12-06 19:09:09 +0100
commit4304301701b1990f855d30f9874e333ccb233f6a (patch)
tree9f25c6a02277770b6d6180eb37940ce380dfb12d /src
parent2dd31b0a443f8dc14a27a3bd003c27f46a708128 (diff)
downloadbox64-4304301701b1990f855d30f9874e333ccb233f6a.tar.gz
box64-4304301701b1990f855d30f9874e333ccb233f6a.zip
Fixed wrapping of lzma_stream_decoder (for #360)
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt3
-rw-r--r--src/wrapped/generated/wrappedlzmatypes.h2
-rw-r--r--src/wrapped/generated/wrapper.c2
-rw-r--r--src/wrapped/generated/wrapper.h1
-rwxr-xr-xsrc/wrapped/wrappedlzma.c28
-rwxr-xr-xsrc/wrapped/wrappedlzma_private.h2
6 files changed, 37 insertions, 1 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 92f5837a..2ac6a602 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -729,6 +729,7 @@
 #() iFEpiV
 #() iFEpiA
 #() iFEpup
+#() iFEpUi
 #() iFEpUp
 #() iFEpLi
 #() iFEpLp
@@ -3603,6 +3604,8 @@ wrappedlibz:
 wrappedlzma:
 - vFpp:
   - lzma_index_end
+- iFpUi:
+  - lzma_stream_decoder
 - iFpppppL:
   - lzma_index_buffer_decode
 - iFpupppLppL:
diff --git a/src/wrapped/generated/wrappedlzmatypes.h b/src/wrapped/generated/wrappedlzmatypes.h
index 8b8b8646..b2e0af77 100644
--- a/src/wrapped/generated/wrappedlzmatypes.h
+++ b/src/wrapped/generated/wrappedlzmatypes.h
@@ -12,11 +12,13 @@
 #endif
 
 typedef void (*vFpp_t)(void*, void*);
+typedef int64_t (*iFpUi_t)(void*, uint64_t, int64_t);
 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_stream_decoder, iFpUi_t) \
 	GO(lzma_index_buffer_decode, iFpppppL_t) \
 	GO(lzma_stream_buffer_decode, iFpupppLppL_t)
 
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index 66e2715a..23d4f8a0 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -763,6 +763,7 @@ typedef int64_t (*iFEpip_t)(x64emu_t*, void*, int64_t, void*);
 typedef int64_t (*iFEpiV_t)(x64emu_t*, void*, int64_t, void*);
 typedef int64_t (*iFEpiA_t)(x64emu_t*, void*, int64_t, void*);
 typedef int64_t (*iFEpup_t)(x64emu_t*, void*, uint64_t, void*);
+typedef int64_t (*iFEpUi_t)(x64emu_t*, void*, uint64_t, int64_t);
 typedef int64_t (*iFEpUp_t)(x64emu_t*, void*, uint64_t, void*);
 typedef int64_t (*iFEpLi_t)(x64emu_t*, void*, uintptr_t, int64_t);
 typedef int64_t (*iFEpLp_t)(x64emu_t*, void*, uintptr_t, void*);
@@ -3026,6 +3027,7 @@ void iFEpip(x64emu_t *emu, uintptr_t fcn) { iFEpip_t fn = (iFEpip_t)fcn; R_RAX=(
 void iFEpiV(x64emu_t *emu, uintptr_t fcn) { iFEpiV_t fn = (iFEpiV_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (int64_t)R_RSI, (void*)(R_RSP + 8)); }
 void iFEpiA(x64emu_t *emu, uintptr_t fcn) { iFEpiA_t fn = (iFEpiA_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (int64_t)R_RSI, (void*)R_RDX); }
 void iFEpup(x64emu_t *emu, uintptr_t fcn) { iFEpup_t fn = (iFEpup_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI, (void*)R_RDX); }
+void iFEpUi(x64emu_t *emu, uintptr_t fcn) { iFEpUi_t fn = (iFEpUi_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI, (int64_t)R_RDX); }
 void iFEpUp(x64emu_t *emu, uintptr_t fcn) { iFEpUp_t fn = (iFEpUp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uint64_t)R_RSI, (void*)R_RDX); }
 void iFEpLi(x64emu_t *emu, uintptr_t fcn) { iFEpLi_t fn = (iFEpLi_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (int64_t)R_RDX); }
 void iFEpLp(x64emu_t *emu, uintptr_t fcn) { iFEpLp_t fn = (iFEpLp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI, (uintptr_t)R_RSI, (void*)R_RDX); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index d61e4352..c509113b 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -762,6 +762,7 @@ void iFEpip(x64emu_t *emu, uintptr_t fnc);
 void iFEpiV(x64emu_t *emu, uintptr_t fnc);
 void iFEpiA(x64emu_t *emu, uintptr_t fnc);
 void iFEpup(x64emu_t *emu, uintptr_t fnc);
+void iFEpUi(x64emu_t *emu, uintptr_t fnc);
 void iFEpUp(x64emu_t *emu, uintptr_t fnc);
 void iFEpLi(x64emu_t *emu, uintptr_t fnc);
 void iFEpLp(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedlzma.c b/src/wrapped/wrappedlzma.c
index 2862e491..541ea600 100755
--- a/src/wrapped/wrappedlzma.c
+++ b/src/wrapped/wrappedlzma.c
@@ -31,6 +31,27 @@ typedef struct lzma_allocator_s {
 	void *opaque;
 } lzma_allocator_t;
 
+typedef struct lzma_stream_s {
+	const uint8_t *next_in;
+	size_t avail_in;
+	uint64_t total_in;
+	uint8_t *next_out;
+	size_t avail_out;
+	uint64_t total_out;
+	lzma_allocator_t *allocator;
+	void* internal;
+	void *reserved_ptr1;
+	void *reserved_ptr2;
+	void *reserved_ptr3;
+	void *reserved_ptr4;
+	uint64_t reserved_int1;
+	uint64_t reserved_int2;
+	size_t reserved_int3;
+	size_t reserved_int4;
+	int reserved_enum1;
+	int reserved_enum2;
+} lzma_stream_t;
+
 #define SUPER() \
 GO(0)   \
 GO(1)   \
@@ -115,6 +136,13 @@ EXPORT int my_lzma_stream_buffer_decode(x64emu_t* emu, void* memlimit, uint32_t
     return my->lzma_stream_buffer_decode(memlimit, flags, alloc?&allocator:NULL, in_, in_pos, in_size, out_, out_pos, out_size);
 }
 
+EXPORT int my_lzma_stream_decoder(x64emu_t* emu, lzma_stream_t* stream, uint64_t memlimit, uint32_t flags)
+{
+    // not restoring the allocator after, so lzma_code and lzma_end can be used without "GOM" wrapping
+    if(stream->allocator)
+        wrap_alloc_struct(stream->allocator, stream->allocator);
+    return my->lzma_stream_decoder(stream, memlimit, flags);
+}
 
 #define CUSTOM_INIT \
     getMy(lib);
diff --git a/src/wrapped/wrappedlzma_private.h b/src/wrapped/wrappedlzma_private.h
index 13965c81..efc72c84 100755
--- a/src/wrapped/wrappedlzma_private.h
+++ b/src/wrapped/wrappedlzma_private.h
@@ -86,7 +86,7 @@ GO(lzma_index_uncompressed_size, UFp)
 //GO(lzma_stream_buffer_bound, 
 GOM(lzma_stream_buffer_decode, iFEpupppLppL)
 //GO(lzma_stream_buffer_encode, 
-GO(lzma_stream_decoder, iFpUi)
+GOM(lzma_stream_decoder, iFEpUi)
 //GO(lzma_stream_encoder, 
 //GO(lzma_stream_encoder_mt, 
 //GO(lzma_stream_encoder_mt_memusage,