about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-09-28 13:48:08 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-09-28 13:48:08 +0200
commit541489da4d67e8a2d41d3b88a79daf7608fb4b89 (patch)
tree987f9135d6cd5227fd764284956fd981051cd73d
parent79200d4df67bd419593f6545714f0cef3b010a96 (diff)
downloadbox64-541489da4d67e8a2d41d3b88a79daf7608fb4b89.tar.gz
box64-541489da4d67e8a2d41d3b88a79daf7608fb4b89.zip
[BOX32][WRAPPER] Some fixes to libexpat 32bits wrapping and more other 32bits functions
-rw-r--r--src/wrapped32/generated/functions_list.txt5
-rw-r--r--src/wrapped32/generated/wrappedexpattypes32.h4
-rw-r--r--src/wrapped32/generated/wrapper32.c7
-rw-r--r--src/wrapped32/generated/wrapper32.h3
-rw-r--r--src/wrapped32/wrappedexpat.c148
-rw-r--r--src/wrapped32/wrappedexpat_private.h2
-rwxr-xr-xsrc/wrapped32/wrappedlibc_private.h10
7 files changed, 142 insertions, 37 deletions
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 37c2a21e..bdd2146d 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -364,7 +364,6 @@
 #() uFuuu -> uFuuu
 #() uFuup -> uFuup
 #() uFupp -> uFupp
-#() uFpii -> uFpii
 #() uFpuU -> uFpuU
 #() uFppu -> uFppu
 #() fFuii -> fFuii
@@ -420,6 +419,7 @@
 #() iFBp_pi -> iFBpi
 #() IFpBp_i -> IFpBi
 #() UFpBp_i -> UFpBi
+#() fFpBp_p -> fFpBp
 #() fFpBp_a -> fFpBa
 #() dFpBp_i -> dFpBi
 #() dFpBp_a -> dFpBa
@@ -567,6 +567,7 @@
 #() iFXpip -> iFXpip
 #() iFXppp -> iFXppp
 #() CFuuff -> CFuuff
+#() uFEpii -> uFEpii
 #() uFuuuu -> uFuuuu
 #() uFpCCC -> uFpCCC
 #() lFEipi -> lFEipi
@@ -1073,6 +1074,8 @@ wrappedexpat:
 - vFppp:
   - XML_SetDoctypeDeclHandler
   - XML_SetElementHandler
+- uFpii:
+  - XML_ParseBuffer
 wrappedfreetype:
 - iFp:
   - FT_Done_Face
diff --git a/src/wrapped32/generated/wrappedexpattypes32.h b/src/wrapped32/generated/wrappedexpattypes32.h
index b3bed412..edafb443 100644
--- a/src/wrapped32/generated/wrappedexpattypes32.h
+++ b/src/wrapped32/generated/wrappedexpattypes32.h
@@ -13,10 +13,12 @@
 
 typedef void (*vFpp_t)(void*, void*);
 typedef void (*vFppp_t)(void*, void*, void*);
+typedef uint32_t (*uFpii_t)(void*, int32_t, int32_t);
 
 #define SUPER() ADDED_FUNCTIONS() \
 	GO(XML_SetCharacterDataHandler, vFpp_t) \
 	GO(XML_SetDoctypeDeclHandler, vFppp_t) \
-	GO(XML_SetElementHandler, vFppp_t)
+	GO(XML_SetElementHandler, vFppp_t) \
+	GO(XML_ParseBuffer, uFpii_t)
 
 #endif // __wrappedexpatTYPES32_H_
diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c
index 060788e5..85291cf2 100644
--- a/src/wrapped32/generated/wrapper32.c
+++ b/src/wrapped32/generated/wrapper32.c
@@ -454,7 +454,6 @@ typedef uint32_t (*uFuip_t)(uint32_t, int32_t, void*);
 typedef uint32_t (*uFuuu_t)(uint32_t, uint32_t, uint32_t);
 typedef uint32_t (*uFuup_t)(uint32_t, uint32_t, void*);
 typedef uint32_t (*uFupp_t)(uint32_t, void*, void*);
-typedef uint32_t (*uFpii_t)(void*, int32_t, int32_t);
 typedef uint32_t (*uFpuU_t)(void*, uint32_t, uint64_t);
 typedef uint32_t (*uFppu_t)(void*, void*, uint32_t);
 typedef float (*fFuii_t)(uint32_t, int32_t, int32_t);
@@ -510,6 +509,7 @@ typedef int32_t (*iFBp_LL_t)(struct_p_t*, uintptr_t, uintptr_t);
 typedef int32_t (*iFBp_pi_t)(struct_p_t*, void*, int32_t);
 typedef int64_t (*IFpBp_i_t)(void*, struct_p_t*, int32_t);
 typedef uint64_t (*UFpBp_i_t)(void*, struct_p_t*, int32_t);
+typedef float (*fFpBp_p_t)(void*, struct_p_t*, void*);
 typedef float (*fFpBp_a_t)(void*, struct_p_t*, void*);
 typedef double (*dFpBp_i_t)(void*, struct_p_t*, int32_t);
 typedef double (*dFpBp_a_t)(void*, struct_p_t*, void*);
@@ -657,6 +657,7 @@ typedef int32_t (*iFXLii_t)(void*, uintptr_t, int32_t, int32_t);
 typedef int32_t (*iFXpip_t)(void*, void*, int32_t, void*);
 typedef int32_t (*iFXppp_t)(void*, void*, void*, void*);
 typedef uint8_t (*CFuuff_t)(uint32_t, uint32_t, float, float);
+typedef uint32_t (*uFEpii_t)(x64emu_t*, void*, int32_t, int32_t);
 typedef uint32_t (*uFuuuu_t)(uint32_t, uint32_t, uint32_t, uint32_t);
 typedef uint32_t (*uFpCCC_t)(void*, uint8_t, uint8_t, uint8_t);
 typedef intptr_t (*lFEipi_t)(x64emu_t*, int32_t, void*, int32_t);
@@ -1522,7 +1523,6 @@ void uFuip_32(x64emu_t *emu, uintptr_t fcn) { uFuip_t fn = (uFuip_t)fcn; R_EAX =
 void uFuuu_32(x64emu_t *emu, uintptr_t fcn) { uFuuu_t fn = (uFuuu_t)fcn; R_EAX = (uint32_t)fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); }
 void uFuup_32(x64emu_t *emu, uintptr_t fcn) { uFuup_t fn = (uFuup_t)fcn; R_EAX = (uint32_t)fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptriv(R_ESP + 12)); }
 void uFupp_32(x64emu_t *emu, uintptr_t fcn) { uFupp_t fn = (uFupp_t)fcn; R_EAX = (uint32_t)fn(from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12)); }
-void uFpii_32(x64emu_t *emu, uintptr_t fcn) { uFpii_t fn = (uFpii_t)fcn; R_EAX = (uint32_t)fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12)); }
 void uFpuU_32(x64emu_t *emu, uintptr_t fcn) { uFpuU_t fn = (uFpuU_t)fcn; R_EAX = (uint32_t)fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint64_t, R_ESP + 12)); }
 void uFppu_32(x64emu_t *emu, uintptr_t fcn) { uFppu_t fn = (uFppu_t)fcn; R_EAX = (uint32_t)fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); }
 void fFuii_32(x64emu_t *emu, uintptr_t fcn) { fFuii_t fn = (fFuii_t)fcn; float fl = fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12)); fpu_do_push(emu); ST0val = fl; }
@@ -1578,6 +1578,7 @@ void iFBp_LL_32(x64emu_t *emu, uintptr_t fcn) { iFBp_LL_t fn = (iFBp_LL_t)fcn; s
 void iFBp_pi_32(x64emu_t *emu, uintptr_t fcn) { iFBp_pi_t fn = (iFBp_pi_t)fcn; struct_p_t arg_4={0}; R_EAX = fn(*(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL, from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12)); if (*(ptr_t*)(from_ptr((R_ESP + 4)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 4))), &arg_4); }
 void IFpBp_i_32(x64emu_t *emu, uintptr_t fcn) { IFpBp_i_t fn = (IFpBp_i_t)fcn; struct_p_t arg_8={0}; ui64_t r; r.i = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_ptri(int32_t, R_ESP + 12)); R_EAX = r.d[0]; R_EDX = r.d[1]; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
 void UFpBp_i_32(x64emu_t *emu, uintptr_t fcn) { UFpBp_i_t fn = (UFpBp_i_t)fcn; struct_p_t arg_8={0}; ui64_t r; r.u = (uint64_t)fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_ptri(int32_t, R_ESP + 12)); R_EAX = r.d[0]; R_EDX = r.d[1]; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
+void fFpBp_p_32(x64emu_t *emu, uintptr_t fcn) { fFpBp_p_t fn = (fFpBp_p_t)fcn; struct_p_t arg_8={0}; float fl = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_ptriv(R_ESP + 12)); fpu_do_push(emu); ST0val = fl; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
 void fFpBp_a_32(x64emu_t *emu, uintptr_t fcn) { fFpBp_a_t fn = (fFpBp_a_t)fcn; struct_p_t arg_8={0}; float fl = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_locale(from_ptri(ptr_t, R_ESP + 12))); fpu_do_push(emu); ST0val = fl; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
 void dFpBp_i_32(x64emu_t *emu, uintptr_t fcn) { dFpBp_i_t fn = (dFpBp_i_t)fcn; struct_p_t arg_8={0}; double db = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_ptri(int32_t, R_ESP + 12)); fpu_do_push(emu); ST0val = db; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
 void dFpBp_a_32(x64emu_t *emu, uintptr_t fcn) { dFpBp_a_t fn = (dFpBp_a_t)fcn; struct_p_t arg_8={0}; double db = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL, from_locale(from_ptri(ptr_t, R_ESP + 12))); fpu_do_push(emu); ST0val = db; if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_p(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
@@ -1725,6 +1726,7 @@ void iFXLii_32(x64emu_t *emu, uintptr_t fcn) { iFXLii_t fn = (iFXLii_t)fcn; R_EA
 void iFXpip_32(x64emu_t *emu, uintptr_t fcn) { iFXpip_t fn = (iFXpip_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16)); }
 void iFXppp_32(x64emu_t *emu, uintptr_t fcn) { iFXppp_t fn = (iFXppp_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16)); }
 void CFuuff_32(x64emu_t *emu, uintptr_t fcn) { CFuuff_t fn = (CFuuff_t)fcn; R_EAX = (unsigned char)fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(float, R_ESP + 12), from_ptri(float, R_ESP + 16)); }
+void uFEpii_32(x64emu_t *emu, uintptr_t fcn) { uFEpii_t fn = (uFEpii_t)fcn; R_EAX = (uint32_t)fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12)); }
 void uFuuuu_32(x64emu_t *emu, uintptr_t fcn) { uFuuuu_t fn = (uFuuuu_t)fcn; R_EAX = (uint32_t)fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16)); }
 void uFpCCC_32(x64emu_t *emu, uintptr_t fcn) { uFpCCC_t fn = (uFpCCC_t)fcn; R_EAX = (uint32_t)fn(from_ptriv(R_ESP + 4), from_ptri(uint8_t, R_ESP + 8), from_ptri(uint8_t, R_ESP + 12), from_ptri(uint8_t, R_ESP + 16)); }
 void lFEipi_32(x64emu_t *emu, uintptr_t fcn) { lFEipi_t fn = (lFEipi_t)fcn; R_EAX = to_long(fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); }
@@ -2261,6 +2263,7 @@ int isRetX87Wrapper32(wrapper_t fun) {
 	if (fun == &fFffp_32) return 1;
 	if (fun == &dFddd_32) return 1;
 	if (fun == &dFddp_32) return 1;
+	if (fun == &fFpBp_p_32) return 1;
 	if (fun == &fFpBp_a_32) return 1;
 	if (fun == &dFpBp_i_32) return 1;
 	if (fun == &dFpBp_a_32) return 1;
diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h
index 1ef62f5c..fa52aa49 100644
--- a/src/wrapped32/generated/wrapper32.h
+++ b/src/wrapped32/generated/wrapper32.h
@@ -405,7 +405,6 @@ void uFuip_32(x64emu_t *emu, uintptr_t fnc);
 void uFuuu_32(x64emu_t *emu, uintptr_t fnc);
 void uFuup_32(x64emu_t *emu, uintptr_t fnc);
 void uFupp_32(x64emu_t *emu, uintptr_t fnc);
-void uFpii_32(x64emu_t *emu, uintptr_t fnc);
 void uFpuU_32(x64emu_t *emu, uintptr_t fnc);
 void uFppu_32(x64emu_t *emu, uintptr_t fnc);
 void fFuii_32(x64emu_t *emu, uintptr_t fnc);
@@ -461,6 +460,7 @@ void iFBp_LL_32(x64emu_t *emu, uintptr_t fnc);
 void iFBp_pi_32(x64emu_t *emu, uintptr_t fnc);
 void IFpBp_i_32(x64emu_t *emu, uintptr_t fnc);
 void UFpBp_i_32(x64emu_t *emu, uintptr_t fnc);
+void fFpBp_p_32(x64emu_t *emu, uintptr_t fnc);
 void fFpBp_a_32(x64emu_t *emu, uintptr_t fnc);
 void dFpBp_i_32(x64emu_t *emu, uintptr_t fnc);
 void dFpBp_a_32(x64emu_t *emu, uintptr_t fnc);
@@ -608,6 +608,7 @@ void iFXLii_32(x64emu_t *emu, uintptr_t fnc);
 void iFXpip_32(x64emu_t *emu, uintptr_t fnc);
 void iFXppp_32(x64emu_t *emu, uintptr_t fnc);
 void CFuuff_32(x64emu_t *emu, uintptr_t fnc);
+void uFEpii_32(x64emu_t *emu, uintptr_t fnc);
 void uFuuuu_32(x64emu_t *emu, uintptr_t fnc);
 void uFpCCC_32(x64emu_t *emu, uintptr_t fnc);
 void lFEipi_32(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped32/wrappedexpat.c b/src/wrapped32/wrappedexpat.c
index 1467aaaf..9475780c 100644
--- a/src/wrapped32/wrappedexpat.c
+++ b/src/wrapped32/wrappedexpat.c
@@ -3,6 +3,8 @@
 #include <string.h>
 #define _GNU_SOURCE         /* See feature_test_macros(7) */
 #include <dlfcn.h>
+#include <ucontext.h>
+#include <sys/mman.h>
 
 #include "wrappedlibs.h"
 
@@ -32,6 +34,55 @@ GO(2)   \
 GO(3)   \
 GO(4)
 
+// StartElementHandler ...
+#define GO(A)   \
+static uintptr_t my_StartElementHandler_fct_##A = 0;                                                \
+static void* my_StartElementHandler_##A(void* data, void* name, void** attr)                        \
+{                                                                                                   \
+    int cnt = 0;                                                                                    \
+    while(attr[cnt]) cnt+=2;                                                                        \
+    ++cnt;                                                                                          \
+    ptr_t attr_s[cnt];                                                                              \
+    for(int i=0; i<cnt; ++i) attr_s[i] = to_ptrv(attr[i]);                                          \
+    return (void*)RunFunctionFmt(my_StartElementHandler_fct_##A, "ppp", data, name, attr_s);        \
+}
+SUPER()
+#undef GO
+static void* find_StartElementHandler_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_StartElementHandler_fct_##A == (uintptr_t)fct) return my_StartElementHandler_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_StartElementHandler_fct_##A == 0) {my_StartElementHandler_fct_##A = (uintptr_t)fct; return my_StartElementHandler_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat StartElementHandler callback\n");
+    return NULL;
+}
+// XML_StartDoctypeDecl ...
+#define GO(A)   \
+static uintptr_t my_XML_StartDoctypeDecl_fct_##A = 0;                                                               \
+static void* my_XML_StartDoctypeDecl_##A(void* data, void* name, void* sysid, void* pubid, int has_internal)        \
+{                                                                                                                   \
+    return (void*)RunFunctionFmt(my_XML_StartDoctypeDecl_fct_##A, "ppppi", data, name, sysid, pubid, has_internal); \
+}
+SUPER()
+#undef GO
+static void* find_XML_StartDoctypeDecl_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_XML_StartDoctypeDecl_fct_##A == (uintptr_t)fct) return my_XML_StartDoctypeDecl_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_XML_StartDoctypeDecl_fct_##A == 0) {my_XML_StartDoctypeDecl_fct_##A = (uintptr_t)fct; return my_XML_StartDoctypeDecl_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat XML_StartDoctypeDecl callback\n");
+    return NULL;
+}
 // Start ...
 #define GO(A)   \
 static uintptr_t my_Start_fct_##A = 0;                                                      \
@@ -51,7 +102,29 @@ static void* find_Start_Fct(void* fct)
     #define GO(A) if(my_Start_fct_##A == 0) {my_Start_fct_##A = (uintptr_t)fct; return my_Start_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat Start callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat Start callback\n");
+    return NULL;
+}
+// XML_EndDoctypeDecl ...
+#define GO(A)   \
+static uintptr_t my_XML_EndDoctypeDecl_fct_##A = 0;             \
+static void my_XML_EndDoctypeDecl_##A(void* data)               \
+{                                                               \
+    RunFunctionFmt(my_XML_EndDoctypeDecl_fct_##A, "p", data);   \
+}
+SUPER()
+#undef GO
+static void* find_XML_EndDoctypeDecl_Fct(void* fct)
+{
+    if(!fct) return fct;
+    if(GetNativeFnc((uintptr_t)fct))  return GetNativeFnc((uintptr_t)fct);
+    #define GO(A) if(my_XML_EndDoctypeDecl_fct_##A == (uintptr_t)fct) return my_XML_EndDoctypeDecl_##A;
+    SUPER()
+    #undef GO
+    #define GO(A) if(my_XML_EndDoctypeDecl_fct_##A == 0) {my_XML_EndDoctypeDecl_fct_##A = (uintptr_t)fct; return my_XML_EndDoctypeDecl_##A; }
+    SUPER()
+    #undef GO
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat XML_EndDoctypeDecl callback\n");
     return NULL;
 }
 // End ...
@@ -73,7 +146,7 @@ static void* find_End_Fct(void* fct)
     #define GO(A) if(my_End_fct_##A == 0) {my_End_fct_##A = (uintptr_t)fct; return my_End_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat End callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat End callback\n");
     return NULL;
 }
 // CharData ...
@@ -95,7 +168,7 @@ static void* find_CharData_Fct(void* fct)
     #define GO(A) if(my_CharData_fct_##A == 0) {my_CharData_fct_##A = (uintptr_t)fct; return my_CharData_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat CharData callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat CharData callback\n");
     return NULL;
 }
 // StartNamespaceDecl ...
@@ -117,7 +190,7 @@ static void* find_StartNamespaceDecl_Fct(void* fct)
     #define GO(A) if(my_StartNamespaceDecl_fct_##A == 0) {my_StartNamespaceDecl_fct_##A = (uintptr_t)fct; return my_StartNamespaceDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat StartNamespaceDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat StartNamespaceDecl callback\n");
     return NULL;
 }
 // EndNamespaceDecl ...
@@ -139,7 +212,7 @@ static void* find_EndNamespaceDecl_Fct(void* fct)
     #define GO(A) if(my_EndNamespaceDecl_fct_##A == 0) {my_EndNamespaceDecl_fct_##A = (uintptr_t)fct; return my_EndNamespaceDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat EndNamespaceDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat EndNamespaceDecl callback\n");
     return NULL;
 }
 // StartElement ...
@@ -161,7 +234,7 @@ static void* find_StartElement_Fct(void* fct)
     #define GO(A) if(my_StartElement_fct_##A == 0) {my_StartElement_fct_##A = (uintptr_t)fct; return my_StartElement_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat StartElement callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat StartElement callback\n");
     return NULL;
 }
 // EndElement ...
@@ -183,7 +256,7 @@ static void* find_EndElement_Fct(void* fct)
     #define GO(A) if(my_EndElement_fct_##A == 0) {my_EndElement_fct_##A = (uintptr_t)fct; return my_EndElement_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat EndElement callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat EndElement callback\n");
     return NULL;
 }
 // ProcessingInstruction ...
@@ -205,7 +278,7 @@ static void* find_ProcessingInstruction_Fct(void* fct)
     #define GO(A) if(my_ProcessingInstruction_fct_##A == 0) {my_ProcessingInstruction_fct_##A = (uintptr_t)fct; return my_ProcessingInstruction_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat ProcessingInstruction callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat ProcessingInstruction callback\n");
     return NULL;
 }
 // Comment ...
@@ -227,7 +300,7 @@ static void* find_Comment_Fct(void* fct)
     #define GO(A) if(my_Comment_fct_##A == 0) {my_Comment_fct_##A = (uintptr_t)fct; return my_Comment_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat Comment callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat Comment callback\n");
     return NULL;
 }
 // StartCdataSection ...
@@ -249,7 +322,7 @@ static void* find_StartCdataSection_Fct(void* fct)
     #define GO(A) if(my_StartCdataSection_fct_##A == 0) {my_StartCdataSection_fct_##A = (uintptr_t)fct; return my_StartCdataSection_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat StartCdataSection callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat StartCdataSection callback\n");
     return NULL;
 }
 // EndCdataSection ...
@@ -271,7 +344,7 @@ static void* find_EndCdataSection_Fct(void* fct)
     #define GO(A) if(my_EndCdataSection_fct_##A == 0) {my_EndCdataSection_fct_##A = (uintptr_t)fct; return my_EndCdataSection_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat EndCdataSection callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat EndCdataSection callback\n");
     return NULL;
 }
 // Default ...
@@ -293,7 +366,7 @@ static void* find_Default_Fct(void* fct)
     #define GO(A) if(my_Default_fct_##A == 0) {my_Default_fct_##A = (uintptr_t)fct; return my_Default_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat Default callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat Default callback\n");
     return NULL;
 }
 // StartDoctypeDecl ...
@@ -315,7 +388,7 @@ static void* find_StartDoctypeDecl_Fct(void* fct)
     #define GO(A) if(my_StartDoctypeDecl_fct_##A == 0) {my_StartDoctypeDecl_fct_##A = (uintptr_t)fct; return my_StartDoctypeDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat StartDoctypeDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat StartDoctypeDecl callback\n");
     return NULL;
 }
 // EndDoctypeDecl ...
@@ -337,7 +410,7 @@ static void* find_EndDoctypeDecl_Fct(void* fct)
     #define GO(A) if(my_EndDoctypeDecl_fct_##A == 0) {my_EndDoctypeDecl_fct_##A = (uintptr_t)fct; return my_EndDoctypeDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat EndDoctypeDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat EndDoctypeDecl callback\n");
     return NULL;
 }
 // EntityDecl ...
@@ -359,7 +432,7 @@ static void* find_EntityDecl_Fct(void* fct)
     #define GO(A) if(my_EntityDecl_fct_##A == 0) {my_EntityDecl_fct_##A = (uintptr_t)fct; return my_EntityDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat EntityDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat EntityDecl callback\n");
     return NULL;
 }
 // ElementDecl ...
@@ -381,7 +454,7 @@ static void* find_ElementDecl_Fct(void* fct)
     #define GO(A) if(my_ElementDecl_fct_##A == 0) {my_ElementDecl_fct_##A = (uintptr_t)fct; return my_ElementDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat ElementDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat ElementDecl callback\n");
     return NULL;
 }
 // UnknownEncoding ...
@@ -403,7 +476,7 @@ static void* find_UnknownEncoding_Fct(void* fct)
     #define GO(A) if(my_UnknownEncoding_fct_##A == 0) {my_UnknownEncoding_fct_##A = (uintptr_t)fct; return my_UnknownEncoding_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat UnknownEncoding callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat UnknownEncoding callback\n");
     return NULL;
 }
 // UnparsedEntityDecl ...
@@ -425,7 +498,7 @@ static void* find_UnparsedEntityDecl_Fct(void* fct)
     #define GO(A) if(my_UnparsedEntityDecl_fct_##A == 0) {my_UnparsedEntityDecl_fct_##A = (uintptr_t)fct; return my_UnparsedEntityDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat UnparsedEntityDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat UnparsedEntityDecl callback\n");
     return NULL;
 }
 // NotationDecl ...
@@ -447,7 +520,7 @@ static void* find_NotationDecl_Fct(void* fct)
     #define GO(A) if(my_NotationDecl_fct_##A == 0) {my_NotationDecl_fct_##A = (uintptr_t)fct; return my_NotationDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat NotationDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat NotationDecl callback\n");
     return NULL;
 }
 // NotStandalone ...
@@ -469,7 +542,7 @@ static void* find_NotStandalone_Fct(void* fct)
     #define GO(A) if(my_NotStandalone_fct_##A == 0) {my_NotStandalone_fct_##A = (uintptr_t)fct; return my_NotStandalone_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat NotStandalone callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat NotStandalone callback\n");
     return NULL;
 }
 // ExternalEntityRef ...
@@ -491,7 +564,7 @@ static void* find_ExternalEntityRef_Fct(void* fct)
     #define GO(A) if(my_ExternalEntityRef_fct_##A == 0) {my_ExternalEntityRef_fct_##A = (uintptr_t)fct; return my_ExternalEntityRef_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat ExternalEntityRef callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat ExternalEntityRef callback\n");
     return NULL;
 }
 // XmlDecl ...
@@ -513,7 +586,7 @@ static void* find_XmlDecl_Fct(void* fct)
     #define GO(A) if(my_XmlDecl_fct_##A == 0) {my_XmlDecl_fct_##A = (uintptr_t)fct; return my_XmlDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat XmlDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat XmlDecl callback\n");
     return NULL;
 }
 // AttlistDecl ...
@@ -535,7 +608,7 @@ static void* find_AttlistDecl_Fct(void* fct)
     #define GO(A) if(my_AttlistDecl_fct_##A == 0) {my_AttlistDecl_fct_##A = (uintptr_t)fct; return my_AttlistDecl_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat AttlistDecl callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat AttlistDecl callback\n");
     return NULL;
 }
 // SkippedEntity ...
@@ -557,14 +630,14 @@ static void* find_SkippedEntity_Fct(void* fct)
     #define GO(A) if(my_SkippedEntity_fct_##A == 0) {my_SkippedEntity_fct_##A = (uintptr_t)fct; return my_SkippedEntity_##A; }
     SUPER()
     #undef GO
-    printf_log(LOG_NONE, "Warning, no more slot for expat SkippedEntity callback\n");
+    printf_log(LOG_NONE, "Warning, no more slot for 32bits expat SkippedEntity callback\n");
     return NULL;
 }
 #undef SUPER
 
 EXPORT void my32_XML_SetElementHandler(x64emu_t* emu, void* p, void* start, void* end)
 {
-    my->XML_SetElementHandler(p, find_Start_Fct(start), find_End_Fct(end));
+    my->XML_SetElementHandler(p, find_StartElementHandler_Fct(start), find_End_Fct(end));
 }
 
 EXPORT void my32_XML_SetCharacterDataHandler(x64emu_t* emu, void* p, void* h)
@@ -690,7 +763,30 @@ EXPORT void my32_XML_SetCharacterDataHandler(x64emu_t* emu, void* p, void* h)
 EXPORT void my32_XML_SetDoctypeDeclHandler(x64emu_t* emu, void* p, void* start, void* end)
 {
     (void)emu;
-    my->XML_SetDoctypeDeclHandler(p, find_Start_Fct(start), find_End_Fct(end));
+    my->XML_SetDoctypeDeclHandler(p, find_StartDoctypeDecl_Fct(start), find_EndDoctypeDecl_Fct(end));
+}
+
+// this function will call the callbacks with many structures created on the stack, wich might be a 64bits walue on the initial thred
+// so using a swapcontext trick to use a 32bits stack temporarily
+// TODO: generalise this on main?
+static void func1(uint32_t* ret, void* p, int a, int b)
+{
+    *ret = my->XML_ParseBuffer(p, a, b);
+}
+ucontext_t uctx_main, uctx_func1;
+EXPORT uint32_t my32_XML_ParseBuffer(x64emu_t* emu, void* p, int a, int b)
+{
+    getcontext(&uctx_func1);
+    size_t stack_size = 1024*1024;
+    void* func1_stack = mmap(NULL, stack_size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_32BIT|MAP_ANONYMOUS|MAP_GROWSDOWN, -1, 0);
+    uctx_func1.uc_stack.ss_sp = func1_stack;
+    uctx_func1.uc_stack.ss_size = stack_size;
+    uctx_func1.uc_link = &uctx_main;
+    uint32_t ret = 0;
+    makecontext(&uctx_func1, (void*)func1, 4, &ret, p, a, b);
+    swapcontext(&uctx_main, &uctx_func1);
+    munmap(func1_stack, stack_size);
+    return ret;
 }
 
 #include "wrappedlib_init32.h"
diff --git a/src/wrapped32/wrappedexpat_private.h b/src/wrapped32/wrappedexpat_private.h
index 975de9d5..5de7b18f 100644
--- a/src/wrapped32/wrappedexpat_private.h
+++ b/src/wrapped32/wrappedexpat_private.h
@@ -25,7 +25,7 @@ GO(XML_GetErrorCode, uFp)
 //GO(XML_MemMalloc, pFpL)
 //GO(XML_MemRealloc, pFppL)
 //GO(XML_Parse, uFppii)
-GO(XML_ParseBuffer, uFpii)
+GOM(XML_ParseBuffer, uFEpii)
 GO(XML_ParserCreate, pFp)
 //GO(XML_ParserCreate_MM, pFpppp) // return a structure
 //GO(XML_ParserCreateNS, pFpc)
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index 05fc21e1..9fa0fe6e 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -1682,7 +1682,7 @@ GO(__strtod_internal, dFpBp_i)
 GO(__strtod_l, dFpBp_a)
 GOW(strtod_l, dFpBp_a)
 GO(strtof, fFpBp_)
-//GO(__strtof_internal, fFppp)
+GO(__strtof_internal, fFpBp_p)
 GO(__strtof_l, fFpBp_a)
 //GOW(strtof_l, fFppu)
 //GO(strtoimax, IFppi)
@@ -1936,7 +1936,7 @@ GOW(wcscasecmp, iFpp)
 // __wcscasecmp_l
 //GOW(wcscasecmp_l, iFppp)
 GOW(wcscat, pFpp)
-//GO(__wcscat_chk, pFppu)
+GO(__wcscat_chk, pFppL)
 GO(wcschr, pFpi)
 // wcschrnul    // Weak
 GO(wcscmp, iFpp)
@@ -1955,7 +1955,7 @@ GOW(wcsncasecmp, iFppL)
 // __wcsncasecmp_l
 //GOW(wcsncasecmp_l, iFppup)
 GO(wcsncat, pFppL)
-// __wcsncat_chk
+GO(__wcsncat_chk, pFppLL)
 GO(wcsncmp, iFppL)
 GOW(wcsncpy, pFppL)
 GO(__wcsncpy_chk, pFppLL)
@@ -1963,12 +1963,12 @@ GOW(wcsnlen, LFpL)
 GOW(wcsnrtombs, LFpBp_LLp)
 // __wcsnrtombs_chk
 //GO(wcspbrk, pFpp)
-//GO(wcsrchr, pFpi)
+GO(wcsrchr, pFpi)
 //GOW(wcsrtombs, uFppup)
 // __wcsrtombs_chk
 //GO(wcsspn, uFpp)
 GO(wcsstr, pFpp)
-//GO(wcstod, dFpp)
+GO(wcstod, dFpBp_)
 //GO(__wcstod_internal, dFppi)
 // __wcstod_l
 // wcstod_l // Weak