about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-09-03 20:19:21 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-09-03 20:19:34 +0200
commit9eaaaaa1e3cf29487810924b02e6ec6f3ddbe811 (patch)
treec2467e8b18feb42da7f2b2c1b31f148ee1d2f538 /src
parent115707a0f1bcba3cd0e46780b2360012a7677c12 (diff)
downloadbox64-9eaaaaa1e3cf29487810924b02e6ec6f3ddbe811.tar.gz
box64-9eaaaaa1e3cf29487810924b02e6ec6f3ddbe811.zip
[BOX32] Added some more 32bits wrapped function to libc
Diffstat (limited to 'src')
-rw-r--r--src/wrapped32/generated/functions_list.txt4
-rw-r--r--src/wrapped32/generated/wrappedlibctypes32.h2
-rw-r--r--src/wrapped32/generated/wrapper32.c4
-rw-r--r--src/wrapped32/generated/wrapper32.h2
-rwxr-xr-xsrc/wrapped32/wrappedlibc.c24
-rwxr-xr-xsrc/wrapped32/wrappedlibc_private.h22
6 files changed, 47 insertions, 11 deletions
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 0d6a205d..56d9921b 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -93,6 +93,7 @@
 #() pFEv -> pFEv
 #() pFEu -> pFEu
 #() pFEp -> pFEp
+#() pFES -> pFES
 #() pFia -> pFia
 #() pFLL -> pFLL
 #() pFpi -> pFpi
@@ -163,6 +164,7 @@
 #() lFipL -> lFipL
 #() lFlpi -> lFlpi
 #() LFpip -> LFpip
+#() LFppL -> LFppL
 #() pFEip -> pFEip
 #() pFEpi -> pFEpi
 #() pFEpp -> pFEpp
@@ -317,6 +319,8 @@ wrappedlibc:
   - gethostbyname
   - gmtime
   - localtime
+- pFS:
+  - getmntent
 - vFip:
 - vFpi:
 - vFpu:
diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h
index a98bb4c3..cd100f40 100644
--- a/src/wrapped32/generated/wrappedlibctypes32.h
+++ b/src/wrapped32/generated/wrappedlibctypes32.h
@@ -28,6 +28,7 @@ typedef void* (*pFv_t)(void);
 typedef void* (*pFu_t)(uint32_t);
 typedef void* (*pFL_t)(uintptr_t);
 typedef void* (*pFp_t)(void*);
+typedef void* (*pFS_t)(void*);
 typedef void (*vFip_t)(int32_t, void*);
 typedef void (*vFpi_t)(void*, int32_t);
 typedef void (*vFpu_t)(void*, uint32_t);
@@ -103,6 +104,7 @@ typedef int32_t (*iFpuvvppp_t)(void*, uint32_t, void, void, void*, void*, void*)
 	GO(gethostbyname, pFp_t) \
 	GO(gmtime, pFp_t) \
 	GO(localtime, pFp_t) \
+	GO(getmntent, pFS_t) \
 	GO(futimes, iFip_t) \
 	GO(getrlimit, iFip_t) \
 	GO(setrlimit, iFip_t) \
diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c
index 3c0036a6..3112219a 100644
--- a/src/wrapped32/generated/wrapper32.c
+++ b/src/wrapped32/generated/wrapper32.c
@@ -180,6 +180,7 @@ typedef uintptr_t (*LFpp_t)(void*, void*);
 typedef void* (*pFEv_t)(x64emu_t*);
 typedef void* (*pFEu_t)(x64emu_t*, uint32_t);
 typedef void* (*pFEp_t)(x64emu_t*, void*);
+typedef void* (*pFES_t)(x64emu_t*, void*);
 typedef void* (*pFia_t)(int32_t, void*);
 typedef void* (*pFLL_t)(uintptr_t, uintptr_t);
 typedef void* (*pFpi_t)(void*, int32_t);
@@ -250,6 +251,7 @@ typedef double (*dFddp_t)(double, double, void*);
 typedef intptr_t (*lFipL_t)(int32_t, void*, uintptr_t);
 typedef intptr_t (*lFlpi_t)(intptr_t, void*, int32_t);
 typedef uintptr_t (*LFpip_t)(void*, int32_t, void*);
+typedef uintptr_t (*LFppL_t)(void*, 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*);
@@ -462,6 +464,7 @@ void LFpp_32(x64emu_t *emu, uintptr_t fcn) { LFpp_t fn = (LFpp_t)fcn; R_EAX = to
 void pFEv_32(x64emu_t *emu, uintptr_t fcn) { pFEv_t fn = (pFEv_t)fcn; R_EAX = to_ptrv(fn(emu)); }
 void pFEu_32(x64emu_t *emu, uintptr_t fcn) { pFEu_t fn = (pFEu_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptri(uint32_t, R_ESP + 4))); }
 void pFEp_32(x64emu_t *emu, uintptr_t fcn) { pFEp_t fn = (pFEp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4))); }
+void pFES_32(x64emu_t *emu, uintptr_t fcn) { pFES_t fn = (pFES_t)fcn; R_EAX = to_ptrv(fn(emu, io_convert32(from_ptriv(R_ESP + 4)))); }
 void pFia_32(x64emu_t *emu, uintptr_t fcn) { pFia_t fn = (pFia_t)fcn; R_EAX = to_ptrv(fn(from_ptri(int32_t, R_ESP + 4), from_locale(from_ptri(ptr_t, R_ESP + 8)))); }
 void pFLL_32(x64emu_t *emu, uintptr_t fcn) { pFLL_t fn = (pFLL_t)fcn; R_EAX = to_ptrv(fn(to_ulong(from_ptri(ulong_t, R_ESP + 4)), to_ulong(from_ptri(ulong_t, R_ESP + 8)))); }
 void pFpi_32(x64emu_t *emu, uintptr_t fcn) { pFpi_t fn = (pFpi_t)fcn; R_EAX = to_ptrv(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8))); }
@@ -532,6 +535,7 @@ void dFddp_32(x64emu_t *emu, uintptr_t fcn) { dFddp_t fn = (dFddp_t)fcn; double
 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 lFlpi_32(x64emu_t *emu, uintptr_t fcn) { lFlpi_t fn = (lFlpi_t)fcn; R_EAX = to_long(fn(to_long(from_ptri(long_t, R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); }
 void LFpip_32(x64emu_t *emu, uintptr_t fcn) { LFpip_t fn = (LFpip_t)fcn; R_EAX = to_ulong(fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12))); }
+void LFppL_32(x64emu_t *emu, uintptr_t fcn) { LFppL_t fn = (LFppL_t)fcn; R_EAX = to_ulong(fn(from_ptriv(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))); }
diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h
index e0cb6c0b..f06a690f 100644
--- a/src/wrapped32/generated/wrapper32.h
+++ b/src/wrapped32/generated/wrapper32.h
@@ -133,6 +133,7 @@ void LFpp_32(x64emu_t *emu, uintptr_t fnc);
 void pFEv_32(x64emu_t *emu, uintptr_t fnc);
 void pFEu_32(x64emu_t *emu, uintptr_t fnc);
 void pFEp_32(x64emu_t *emu, uintptr_t fnc);
+void pFES_32(x64emu_t *emu, uintptr_t fnc);
 void pFia_32(x64emu_t *emu, uintptr_t fnc);
 void pFLL_32(x64emu_t *emu, uintptr_t fnc);
 void pFpi_32(x64emu_t *emu, uintptr_t fnc);
@@ -203,6 +204,7 @@ void dFddp_32(x64emu_t *emu, uintptr_t fnc);
 void lFipL_32(x64emu_t *emu, uintptr_t fnc);
 void lFlpi_32(x64emu_t *emu, uintptr_t fnc);
 void LFpip_32(x64emu_t *emu, uintptr_t fnc);
+void LFppL_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);
diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c
index 2f2aa554..f3153674 100755
--- a/src/wrapped32/wrappedlibc.c
+++ b/src/wrapped32/wrappedlibc.c
@@ -34,6 +34,7 @@
 #include <locale.h>
 #include <sys/resource.h>
 #include <sys/statvfs.h>
+#include <mntent.h>
 
 #include "wrappedlibs.h"
 
@@ -2581,6 +2582,29 @@ EXPORT int my32_readlinkat(x64emu_t* emu, int fd, void* path, void* buf, size_t
     return readlinkat(fd, path, buf, bufsize);
 }
 
+struct i386_mntent {
+    ptr_t mnt_fsname;   // char *
+    ptr_t mnt_dir;      // char *
+    ptr_t mnt_type;     // char *
+    ptr_t mnt_opts;     // char *
+    int   mnt_freq;
+    int   mnt_passno;
+};
+
+EXPORT void* my32_getmntent(x64emu_t* emu, void* f)
+{
+    static struct i386_mntent ret;
+    struct mntent* r = getmntent(f);
+    if(!r) return NULL;
+    ret.mnt_fsname = to_cstring(r->mnt_fsname);
+    ret.mnt_dir = to_cstring(r->mnt_dir);
+    ret.mnt_type = to_cstring(r->mnt_type);
+    ret.mnt_opts = to_cstring(r->mnt_opts);
+    ret.mnt_freq = r->mnt_freq;
+    ret.mnt_passno = r->mnt_passno;
+    return &ret;
+}
+
 EXPORT void* my32_mmap(x64emu_t* emu, void *addr, size_t length, int prot, int flags, int fd, int offset)
 {
     if(prot&PROT_WRITE) 
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index 176a2492..45a2b96d 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -235,7 +235,7 @@ GO(__duplocale, aFa)
 // endfsent
 GO(endgrent, vFv)
 GO(endhostent, vFv)
-//GOW(endmntent, iFp)
+GOW(endmntent, iFS)
 // __endmntent
 // endnetent
 // endnetgrent
@@ -510,7 +510,7 @@ GOM(getifaddrs, iFEbp_)
 //GO(getlogin, pFv)
 //GO(getlogin_r, iFpu)
 // __getlogin_r_chk
-//GO(getmntent, pFp)
+GOM(getmntent, pFES)
 // __getmntent_r
 //GOW(getmntent_r, pFpppi)
 // getmsg
@@ -1073,7 +1073,7 @@ GOW(mbsnrtowcs, LFpbp_LLp)
 // __mbsnrtowcs_chk
 GOW(mbsrtowcs, LFpbp_Lp)
 // __mbsrtowcs_chk
-//GO(mbstowcs, LFppL)
+GO(mbstowcs, LFppL)
 // __mbstowcs_chk
 //GO(mbtowc, iFppL)
 // mcheck
@@ -1109,7 +1109,7 @@ GO(mkfifo, iFpu)
 //GO(mkostemp, iFpi)
 //GO(mkostemp64, iFpi)
 GO(mkstemp, iFp)
-//GO(mkstemp64, iFp)
+GO(mkstemp64, iFp)
 //GO(mktemp, pFp)
 GO(mktime, LFriiiiiiiiilt_)
 GO(mlock, iFpL)
@@ -1220,7 +1220,7 @@ GOW(opendir, pFp)
 //GO(__overflow, iFpi)
 //GO(parse_printf_format, uFpup)
 // passwd2des
-//GOW(pathconf, iFpi)
+GOW(pathconf, iFpi)
 GOW(pause, iFv)
 GO(pclose, iFS)
 //GO(perror, vFp)
@@ -1294,7 +1294,7 @@ GOW(putc, iFip)
 GO(putchar, iFi)
 GO(putchar_unlocked, iFi)
 //GO(putc_unlocked, iFip)
-//GO(putenv, iFp)
+GO(putenv, iFp)
 // putgrent
 // putmsg
 // putpmsg
@@ -1493,7 +1493,7 @@ GOM(_setjmp, iFEp) //%%
 GO(setlocale, tFip)
 // setlogin
 GO(setlogmask, iFi)
-//GOW(setmntent, pFpp)
+GOW(setmntent, SFpp)
 // __setmntent
 // setnetent
 // setnetgrent
@@ -1607,7 +1607,7 @@ DATAM(stdout, 4)
 // stime
 //GO(stpcpy, pFpp)
 // __stpcpy
-//GO(__stpcpy_chk, pFppL)
+GO(__stpcpy_chk, pFppL)
 // __stpcpy_small
 //GOW(stpncpy, pFppL)
 //GO(__stpncpy, pFppL)
@@ -1932,7 +1932,7 @@ GOW(wcrtomb, LFpip)
 GOW(wcscasecmp, iFpp)
 // __wcscasecmp_l
 //GOW(wcscasecmp_l, iFppp)
-//GOW(wcscat, pFpp)
+GOW(wcscat, pFpp)
 //GO(__wcscat_chk, pFppu)
 //GO(wcschr, pFpi)
 // wcschrnul    // Weak
@@ -1964,7 +1964,7 @@ GOW(wcsnrtombs, LFpBp_LLp)
 //GOW(wcsrtombs, uFppup)
 // __wcsrtombs_chk
 //GO(wcsspn, uFpp)
-//GO(wcsstr, pFpp)
+GO(wcsstr, pFpp)
 //GO(wcstod, dFpp)
 //GO(__wcstod_internal, dFppi)
 // __wcstod_l
@@ -1987,7 +1987,7 @@ GO(wcstoll, IFpBp_i)
 // __wcstoll_internal
 // __wcstoll_l
 // wcstoll_l    // Weak
-//GO(wcstombs, uFppu)
+GO(wcstombs, LFppL)
 // __wcstombs_chk
 // wcstoq   // Weak
 //GO(wcstoul, iFppi)