about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-08-29 16:30:39 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-08-29 16:30:39 +0200
commit9633ad35a8f5cb8274f9d8256812e02d8710c062 (patch)
tree96faf1e307f6f425b1604062f3b17352525f4f46 /src
parent4bd6294862a094c64f2711d180ba44843929bdfe (diff)
downloadbox64-9633ad35a8f5cb8274f9d8256812e02d8710c062.tar.gz
box64-9633ad35a8f5cb8274f9d8256812e02d8710c062.zip
[BOX32] Added more 32bits wrapped function and more fixes
Diffstat (limited to 'src')
-rw-r--r--src/emu/x64emu_private.h1
-rw-r--r--src/wrapped32/generated/converter32.c30
-rw-r--r--src/wrapped32/generated/converter32.h15
-rw-r--r--src/wrapped32/generated/functions_list.txt9
-rw-r--r--src/wrapped32/generated/wrappedlibctypes32.h5
-rw-r--r--src/wrapped32/generated/wrapper32.c8
-rw-r--r--src/wrapped32/generated/wrapper32.h4
-rwxr-xr-xsrc/wrapped32/wrappedlibc.c37
-rwxr-xr-xsrc/wrapped32/wrappedlibc_private.h14
9 files changed, 108 insertions, 15 deletions
diff --git a/src/emu/x64emu_private.h b/src/emu/x64emu_private.h
index 39b41aa4..2f6730e5 100644
--- a/src/emu/x64emu_private.h
+++ b/src/emu/x64emu_private.h
@@ -136,7 +136,6 @@ typedef struct x64emu_s {
     #ifdef BOX32
     int         libc_err;   // copy of errno from libc
     unsigned short libctype[384];   // copy from __ctype_b because, again, is thread local
-    const unsigned short **orig_ctype;    // source used for this copy
     #endif
 } x64emu_t;
 
diff --git a/src/wrapped32/generated/converter32.c b/src/wrapped32/generated/converter32.c
index d790ad9c..c615d378 100644
--- a/src/wrapped32/generated/converter32.c
+++ b/src/wrapped32/generated/converter32.c
@@ -72,3 +72,33 @@ void to_struct_ppppp(ptr_t d, const struct_ppppp_t *src) {
 	*(ptr_t*)dest = to_ptrv(src->p3); dest += 4;
 	*(ptr_t*)dest = to_ptrv(src->p4); dest += 4;
 }
+
+void from_struct_iiiiiiiiilt(struct_iiiiiiiiilt_t* dest, ptr_t s) {
+	uint8_t* src = (uint8_t*)from_ptrv(s);
+	dest->i0 = *(int*)src; src += 4;
+	dest->i1 = *(int*)src; src += 4;
+	dest->i2 = *(int*)src; src += 4;
+	dest->i3 = *(int*)src; src += 4;
+	dest->i4 = *(int*)src; src += 4;
+	dest->i5 = *(int*)src; src += 4;
+	dest->i6 = *(int*)src; src += 4;
+	dest->i7 = *(int*)src; src += 4;
+	dest->i8 = *(int*)src; src += 4;
+	dest->l9 = from_long(*(long_t*)src); src += 4;
+	dest->p10 = *(void**)src; src += 4;
+}
+void to_struct_iiiiiiiiilt(ptr_t d, const struct_iiiiiiiiilt_t* src) {
+	if (!src) return;
+	uint8_t* dest = (uint8_t*)from_ptrv(d);
+	*(int*)dest = src->i0; dest += 4;
+	*(int*)dest = src->i1; dest += 4;
+	*(int*)dest = src->i2; dest += 4;
+	*(int*)dest = src->i3; dest += 4;
+	*(int*)dest = src->i4; dest += 4;
+	*(int*)dest = src->i5; dest += 4;
+	*(int*)dest = src->i6; dest += 4;
+	*(int*)dest = src->i7; dest += 4;
+	*(int*)dest = src->i8; dest += 4;
+	*(long_t*)dest = to_long(src->l9); dest += 4;
+	*(ptr_t*)dest = to_cstring(src->p10); dest += 4;
+}
diff --git a/src/wrapped32/generated/converter32.h b/src/wrapped32/generated/converter32.h
index 015ceadd..ae99e85d 100644
--- a/src/wrapped32/generated/converter32.h
+++ b/src/wrapped32/generated/converter32.h
@@ -39,5 +39,20 @@ typedef struct struct_ppppp_s {
 } struct_ppppp_t;
 void from_struct_ppppp(struct_ppppp_t *dest, ptr_t src);
 void to_struct_ppppp(ptr_t dest, const struct_ppppp_t *src);
+typedef struct struct_iiiiiiiiilt_s {
+	int i0;
+	int i1;
+	int i2;
+	int i3;
+	int i4;
+	int i5;
+	int i6;
+	int i7;
+	int i8;
+	long l9;
+	void* p10;
+} struct_iiiiiiiiilt_t;
+void from_struct_iiiiiiiiilt(struct_iiiiiiiiilt_t* dest, ptr_t src);
+void to_struct_iiiiiiiiilt(ptr_t dest, const struct_iiiiiiiiilt_t* src);
 
 #endif // __CONVERTER_H_
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 9232fe99..ecd106cc 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -86,11 +86,13 @@
 #() fFpBp_ -> fFpB
 #() dFpBp_ -> dFpB
 #() iFuBLL_ -> iFuB
+#() iFprLL_ -> iFpB
 #() vFEip -> vFEip
 #() vFEpi -> vFEpi
 #() vFEpu -> vFEpu
 #() vFfpp -> vFfpp
 #() vFdpp -> vFdpp
+#() iFEip -> iFEip
 #() iFEpi -> iFEpi
 #() iFEpL -> iFEpL
 #() iFEpp -> iFEpp
@@ -122,6 +124,7 @@
 #() fFffp -> fFffp
 #() dFddd -> dFddd
 #() dFddp -> dFddp
+#() lFipL -> lFipL
 #() pFEip -> pFEip
 #() pFEpi -> pFEpi
 #() pFEpp -> pFEpp
@@ -154,7 +157,6 @@
 #() pFEppi -> pFEppi
 #() pFEppp -> pFEppp
 #() pFpiLL -> pFpiLL
-#() pFppuL -> pFppuL
 #() pFppLL -> pFppLL
 #() vFEpLLp -> vFEpLLp
 #() iFEppiV -> iFEppiV
@@ -201,6 +203,9 @@ wrappedlibc:
 - vFip:
 - vFpi:
 - vFpu:
+- iFip:
+  - getrlimit
+  - setrlimit
 - iFpp:
   - alphasort64
 - iFpV:
@@ -208,6 +213,8 @@ wrappedlibc:
 - UFUU:
 - pFip:
   - signal
+- pFpp:
+  - localtime_r
 - hFpp:
 - vFipV:
 - iFvpV:
diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h
index b50248eb..c6beb780 100644
--- a/src/wrapped32/generated/wrappedlibctypes32.h
+++ b/src/wrapped32/generated/wrappedlibctypes32.h
@@ -26,11 +26,13 @@ typedef void* (*pFL_t)(uintptr_t);
 typedef void (*vFip_t)(int32_t, void*);
 typedef void (*vFpi_t)(void*, int32_t);
 typedef void (*vFpu_t)(void*, uint32_t);
+typedef int32_t (*iFip_t)(int32_t, void*);
 typedef int32_t (*iFpp_t)(void*, void*);
 typedef int32_t (*iFpV_t)(void*, ...);
 typedef int64_t (*IFII_t)(int64_t, int64_t);
 typedef uint64_t (*UFUU_t)(uint64_t, uint64_t);
 typedef void* (*pFip_t)(int32_t, void*);
+typedef void* (*pFpp_t)(void*, void*);
 typedef uintptr_t (*hFpp_t)(void*, void*);
 typedef void (*vFipV_t)(int32_t, void*, ...);
 typedef int32_t (*iFvpV_t)(void, void*, ...);
@@ -54,8 +56,11 @@ typedef int32_t (*iFpuvvppp_t)(void*, uint32_t, void, void, void*, void*, void*)
 	GO(__close_nocancel, iFi_t) \
 	GO(__ctype_b_loc, pFv_t) \
 	GO(__errno_location, pFv_t) \
+	GO(getrlimit, iFip_t) \
+	GO(setrlimit, iFip_t) \
 	GO(alphasort64, iFpp_t) \
 	GO(signal, pFip_t) \
+	GO(localtime_r, pFpp_t) \
 	GO(__libc_init, vFpppp_t)
 
 #endif // __wrappedlibcTYPES32_H_
diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c
index 6f0f1383..259c4729 100644
--- a/src/wrapped32/generated/wrapper32.c
+++ b/src/wrapped32/generated/wrapper32.c
@@ -160,11 +160,13 @@ typedef int32_t (*iFHBp__t)(uintptr_t, struct_p_t*);
 typedef float (*fFpBp__t)(void*, struct_p_t*);
 typedef double (*dFpBp__t)(void*, struct_p_t*);
 typedef int32_t (*iFuBLL__t)(uint32_t, struct_LL_t*);
+typedef int32_t (*iFprLL__t)(void*, struct_LL_t*);
 typedef void (*vFEip_t)(x64emu_t*, int32_t, void*);
 typedef void (*vFEpi_t)(x64emu_t*, void*, int32_t);
 typedef void (*vFEpu_t)(x64emu_t*, void*, uint32_t);
 typedef void (*vFfpp_t)(float, void*, void*);
 typedef void (*vFdpp_t)(double, void*, void*);
+typedef int32_t (*iFEip_t)(x64emu_t*, int32_t, void*);
 typedef int32_t (*iFEpi_t)(x64emu_t*, void*, int32_t);
 typedef int32_t (*iFEpL_t)(x64emu_t*, void*, uintptr_t);
 typedef int32_t (*iFEpp_t)(x64emu_t*, void*, void*);
@@ -196,6 +198,7 @@ typedef float (*fFfff_t)(float, float, float);
 typedef float (*fFffp_t)(float, float, void*);
 typedef double (*dFddd_t)(double, double, double);
 typedef double (*dFddp_t)(double, double, void*);
+typedef intptr_t (*lFipL_t)(int32_t, void*, uintptr_t);
 typedef void* (*pFEip_t)(x64emu_t*, int32_t, void*);
 typedef void* (*pFEpi_t)(x64emu_t*, void*, int32_t);
 typedef void* (*pFEpp_t)(x64emu_t*, void*, void*);
@@ -228,7 +231,6 @@ typedef uintptr_t (*LFpLLh_t)(void*, uintptr_t, uintptr_t, uintptr_t);
 typedef void* (*pFEppi_t)(x64emu_t*, void*, void*, int32_t);
 typedef void* (*pFEppp_t)(x64emu_t*, void*, void*, void*);
 typedef void* (*pFpiLL_t)(void*, int32_t, uintptr_t, uintptr_t);
-typedef void* (*pFppuL_t)(void*, void*, uint32_t, uintptr_t);
 typedef void* (*pFppLL_t)(void*, void*, uintptr_t, uintptr_t);
 typedef void (*vFEpLLp_t)(x64emu_t*, void*, uintptr_t, uintptr_t, void*);
 typedef int32_t (*iFEppiV_t)(x64emu_t*, void*, void*, int32_t, void*);
@@ -344,11 +346,13 @@ void iFHBp__32(x64emu_t *emu, uintptr_t fcn) { iFHBp__t fn = (iFHBp__t)fcn; stru
 void fFpBp__32(x64emu_t *emu, uintptr_t fcn) { fFpBp__t fn = (fFpBp__t)fcn; struct_p_t arg_8; float fl = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL); 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__32(x64emu_t *emu, uintptr_t fcn) { dFpBp__t fn = (dFpBp__t)fcn; struct_p_t arg_8; double db = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL); 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 iFuBLL__32(x64emu_t *emu, uintptr_t fcn) { iFuBLL__t fn = (iFuBLL__t)fcn; struct_LL_t arg_8; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL); if (*(ptr_t*)(from_ptr((R_ESP + 8)))) to_struct_LL(*(ptr_t*)(from_ptr((R_ESP + 8))), &arg_8); }
+void iFprLL__32(x64emu_t *emu, uintptr_t fcn) { iFprLL__t fn = (iFprLL__t)fcn; struct_LL_t arg_8; from_struct_LL(&arg_8, *(ptr_t*)(from_ptr((R_ESP + 8)))); R_EAX = fn(from_ptriv(R_ESP + 4), *(ptr_t*)(from_ptr((R_ESP + 8))) ? &arg_8 : NULL); }
 void vFEip_32(x64emu_t *emu, uintptr_t fcn) { vFEip_t fn = (vFEip_t)fcn; fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8)); }
 void vFEpi_32(x64emu_t *emu, uintptr_t fcn) { vFEpi_t fn = (vFEpi_t)fcn; fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8)); }
 void vFEpu_32(x64emu_t *emu, uintptr_t fcn) { vFEpu_t fn = (vFEpu_t)fcn; fn(emu, from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8)); }
 void vFfpp_32(x64emu_t *emu, uintptr_t fcn) { vFfpp_t fn = (vFfpp_t)fcn; fn(from_ptri(float, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12)); }
 void vFdpp_32(x64emu_t *emu, uintptr_t fcn) { vFdpp_t fn = (vFdpp_t)fcn; fn(from_ptri(double, R_ESP + 4), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16)); }
+void iFEip_32(x64emu_t *emu, uintptr_t fcn) { iFEip_t fn = (iFEip_t)fcn; R_EAX = fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8)); }
 void iFEpi_32(x64emu_t *emu, uintptr_t fcn) { iFEpi_t fn = (iFEpi_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8)); }
 void iFEpL_32(x64emu_t *emu, uintptr_t fcn) { iFEpL_t fn = (iFEpL_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8))); }
 void iFEpp_32(x64emu_t *emu, uintptr_t fcn) { iFEpp_t fn = (iFEpp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8)); }
@@ -380,6 +384,7 @@ void fFfff_32(x64emu_t *emu, uintptr_t fcn) { fFfff_t fn = (fFfff_t)fcn; float f
 void fFffp_32(x64emu_t *emu, uintptr_t fcn) { fFffp_t fn = (fFffp_t)fcn; float fl = fn(from_ptri(float, R_ESP + 4), from_ptri(float, R_ESP + 8), from_ptriv(R_ESP + 12)); fpu_do_push(emu); ST0val = fl; }
 void dFddd_32(x64emu_t *emu, uintptr_t fcn) { dFddd_t fn = (dFddd_t)fcn; double db = fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12), from_ptri(double, R_ESP + 20)); fpu_do_push(emu); ST0val = db; }
 void dFddp_32(x64emu_t *emu, uintptr_t fcn) { dFddp_t fn = (dFddp_t)fcn; double db = fn(from_ptri(double, R_ESP + 4), from_ptri(double, R_ESP + 12), from_ptriv(R_ESP + 20)); fpu_do_push(emu); ST0val = db; }
+void lFipL_32(x64emu_t *emu, uintptr_t fcn) { lFipL_t fn = (lFipL_t)fcn; R_EAX = to_long(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), to_ulong(from_ptri(ulong_t, R_ESP + 12)))); }
 void pFEip_32(x64emu_t *emu, uintptr_t fcn) { pFEip_t fn = (pFEip_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8))); }
 void pFEpi_32(x64emu_t *emu, uintptr_t fcn) { pFEpi_t fn = (pFEpi_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8))); }
 void pFEpp_32(x64emu_t *emu, uintptr_t fcn) { pFEpp_t fn = (pFEpp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8))); }
@@ -412,7 +417,6 @@ void LFpLLh_32(x64emu_t *emu, uintptr_t fcn) { LFpLLh_t fn = (LFpLLh_t)fcn; R_EA
 void pFEppi_32(x64emu_t *emu, uintptr_t fcn) { pFEppi_t fn = (pFEppi_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); }
 void pFEppp_32(x64emu_t *emu, uintptr_t fcn) { pFEppp_t fn = (pFEppp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12))); }
 void pFpiLL_32(x64emu_t *emu, uintptr_t fcn) { pFpiLL_t fn = (pFpiLL_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), to_ulong(from_ptri(ulong_t, R_ESP + 12)), to_ulong(from_ptri(ulong_t, R_ESP + 16)))); }
-void pFppuL_32(x64emu_t *emu, uintptr_t fcn) { pFppuL_t fn = (pFppuL_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), to_ulong(from_ptri(ulong_t, R_ESP + 16)))); }
 void pFppLL_32(x64emu_t *emu, uintptr_t fcn) { pFppLL_t fn = (pFppLL_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), to_ulong(from_ptri(ulong_t, R_ESP + 12)), to_ulong(from_ptri(ulong_t, R_ESP + 16)))); }
 void vFEpLLp_32(x64emu_t *emu, uintptr_t fcn) { vFEpLLp_t fn = (vFEpLLp_t)fcn; fn(emu, from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), to_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptriv(R_ESP + 16)); }
 void iFEppiV_32(x64emu_t *emu, uintptr_t fcn) { iFEppiV_t fn = (iFEppiV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptrv(R_ESP + 16)); }
diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h
index f96f7a6a..ac92886d 100644
--- a/src/wrapped32/generated/wrapper32.h
+++ b/src/wrapped32/generated/wrapper32.h
@@ -126,11 +126,13 @@ void iFHBp__32(x64emu_t *emu, uintptr_t fnc);
 void fFpBp__32(x64emu_t *emu, uintptr_t fnc);
 void dFpBp__32(x64emu_t *emu, uintptr_t fnc);
 void iFuBLL__32(x64emu_t *emu, uintptr_t fnc);
+void iFprLL__32(x64emu_t *emu, uintptr_t fnc);
 void vFEip_32(x64emu_t *emu, uintptr_t fnc);
 void vFEpi_32(x64emu_t *emu, uintptr_t fnc);
 void vFEpu_32(x64emu_t *emu, uintptr_t fnc);
 void vFfpp_32(x64emu_t *emu, uintptr_t fnc);
 void vFdpp_32(x64emu_t *emu, uintptr_t fnc);
+void iFEip_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpi_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpL_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpp_32(x64emu_t *emu, uintptr_t fnc);
@@ -162,6 +164,7 @@ void fFfff_32(x64emu_t *emu, uintptr_t fnc);
 void fFffp_32(x64emu_t *emu, uintptr_t fnc);
 void dFddd_32(x64emu_t *emu, uintptr_t fnc);
 void dFddp_32(x64emu_t *emu, uintptr_t fnc);
+void lFipL_32(x64emu_t *emu, uintptr_t fnc);
 void pFEip_32(x64emu_t *emu, uintptr_t fnc);
 void pFEpi_32(x64emu_t *emu, uintptr_t fnc);
 void pFEpp_32(x64emu_t *emu, uintptr_t fnc);
@@ -194,7 +197,6 @@ void LFpLLh_32(x64emu_t *emu, uintptr_t fnc);
 void pFEppi_32(x64emu_t *emu, uintptr_t fnc);
 void pFEppp_32(x64emu_t *emu, uintptr_t fnc);
 void pFpiLL_32(x64emu_t *emu, uintptr_t fnc);
-void pFppuL_32(x64emu_t *emu, uintptr_t fnc);
 void pFppLL_32(x64emu_t *emu, uintptr_t fnc);
 void vFEpLLp_32(x64emu_t *emu, uintptr_t fnc);
 void iFEppiV_32(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c
index 926fcdb8..d7ade22b 100755
--- a/src/wrapped32/wrappedlibc.c
+++ b/src/wrapped32/wrappedlibc.c
@@ -35,6 +35,7 @@
 #include <getopt.h>
 #include <pwd.h>
 #include <locale.h>
+#include <sys/resource.h>
 
 #include "wrappedlibs.h"
 
@@ -56,6 +57,7 @@
 #include "bridge.h"
 #include "globalsymbols.h"
 #include "box32.h"
+#include "converter32.h"
 
 // need to undef all read / read64 stuffs!
 #undef pread
@@ -2037,6 +2039,36 @@ EXPORT unsigned long int my32___fdelt_chk (unsigned long int d)
 }
 #endif
 
+EXPORT int my32_getrlimit(x64emu_t* emu, int what, uint32_t* pr)
+{
+    struct rlimit64 l = {0};
+    int ret = getrlimit64(what, &l);
+    if(pr) {
+        pr[0] = (l.rlim_cur<0x100000000LL)?l.rlim_cur:0xffffffff;
+        pr[1] = (l.rlim_max<0x100000000LL)?l.rlim_max:0xffffffff;
+    }
+    return ret;
+}
+EXPORT int my32_setrlimit(x64emu_t* emu, int what, uint32_t* pr)
+{
+    struct rlimit64 l = {0};
+    l.rlim_cur = (pr[0]!=0xffffffff)?pr[0]:0xffffffffffffffffLL;
+    l.rlim_max = (pr[1]!=0xffffffff)?pr[1]:0xffffffffffffffffLL;
+    return setrlimit64(what, &l);
+}
+
+EXPORT void* my32_localtime_r(x64emu_t* emu, void* t, void* res)
+{
+    struct_L_t t_ = {0};
+    struct_iiiiiiiiilt_t res_ = {0};
+    if(t) from_struct_L(&t_, to_ptrv(t));
+    if(res) from_struct_iiiiiiiiilt(&res_, to_ptrv(res));
+    void* ret = localtime_r(t?((void*)&t_):NULL, res?((void*)&res_):NULL);
+    if(ret==&res_)
+        return res;
+    return ret;
+}
+
 #if 0
 EXPORT int32_t my32_getrandom(x64emu_t* emu, void* buf, uint32_t buflen, uint32_t flags)
 {
@@ -2275,10 +2307,7 @@ EXPORT int my32_alphasort64(x64emu_t* emu, ptr_t* d1_, ptr_t* d2_)
 EXPORT void* my32___ctype_b_loc(x64emu_t* emu)
 {
     const unsigned short** src =__ctype_b_loc();
-    if(src != emu->orig_ctype) {
-        memcpy(emu->libctype, *src-128, 384*sizeof(short));
-        emu->orig_ctype = src;
-    }
+    memcpy(emu->libctype, &((*src)[-128]), 384*sizeof(short));
     return &emu->libctype[128];
 }
 
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index a30ae524..45842e16 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -4,6 +4,8 @@
 
 // FILE* is h (because stdin/stdout/stderr might be 64bits, maybe other special file can be too)
 // locale_t needs special handling, with to_locale / from_locale (and is a / A)
+// struct utimbuf is: LL
+// struct tm is: iiiiiiiiilt
 
 // a64l
 //GO(abort, vFv)
@@ -554,7 +556,7 @@ GOW(getpt, iFv)
 //GO(getpwuid_r, iFuppup)
 //GOW(getresgid, iFppp)
 //GOW(getresuid, iFppp)
-GO(getrlimit, iFip)
+GOM(getrlimit, iFEip)
 GO(getrlimit64, iFip)
 // getrpcbyname
 // getrpcbyname_r
@@ -1025,7 +1027,7 @@ GOW(listen, iFii)
 // loc2 // type B
 //GOW(localeconv, pFv)
 //GO(localtime, pFp)
-//GOW(localtime_r, pFpp)
+GOWM(localtime_r, pFEpp)
 GO(lockf, iFiiu)
 GO(lockf64, iFiiI)
 // locs // type B
@@ -1081,7 +1083,7 @@ GOW(mallopt, iFii)  // Weak
 //GO(memchr, pFpiL)
 GO(memcmp, iFppL)
 GO(memcpy, pFppL)
-GO(__memcpy_chk, pFppuL)
+GO(__memcpy_chk, pFppLL)
 // memfrob
 //GO(memmem, pFpupu)
 GO(memmove, pFppL)
@@ -1500,7 +1502,7 @@ GOW(setregid, iFuu)
 GOW(setresgid, iFuuu)
 GOW(setresuid, iFuuu)
 GOW(setreuid, iFuu)
-GO(setrlimit, iFip) // needs wrapping?
+GOM(setrlimit, iFEip)
 GO(setrlimit64, iFip)
 // setrpcent
 // setservent
@@ -1860,7 +1862,7 @@ GO(__uselocale, aFa)
 // user2netname
 GO(usleep, iFu)
 // ustat
-//GO(utime, iFpp)
+GO(utime, iFprLL_)
 //GO(utimensat, iFippi)
 //GOW(utimes, iFpp)   //TODO: check, signature is int utimes(const char *filename, const struct timeval times[2]);
 //GOW(utmpname, iFp)
@@ -2023,7 +2025,7 @@ GOW(wmemmove, pFppL)
 // __woverflow
 //GOM(wprintf, iFEpV) //%%
 //GOM(__wprintf_chk, iFEipV) //%%
-//GOW(write, lFipL)
+GOW(write, lFipL)
 //GOW(__write, lFipL)
 //GOW(writev, lFipi)
 // wscanf