about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-12-12 13:34:59 +0100
committerptitSeb <sebastien.chev@gmail.com>2024-12-12 13:34:59 +0100
commit7e5aa3e7c6bd3cf2b998be55c3668e36ffb1d7d1 (patch)
tree8ac921fbe245ceeae8bec82b3d71cd18ee371eb9 /src
parentc7afc0b3dfea38e34b7c082fa200978707138036 (diff)
downloadbox64-7e5aa3e7c6bd3cf2b998be55c3668e36ffb1d7d1.tar.gz
box64-7e5aa3e7c6bd3cf2b998be55c3668e36ffb1d7d1.zip
[BOX32][WRAPPER] Added a few more 32bits wrapped function to libc
Diffstat (limited to 'src')
-rw-r--r--src/wrapped32/generated/functions_list.txt3
-rw-r--r--src/wrapped32/generated/wrappedlibctypes32.h2
-rw-r--r--src/wrapped32/generated/wrapper32.c2
-rw-r--r--src/wrapped32/generated/wrapper32.h1
-rwxr-xr-xsrc/wrapped32/wrappedlibc.c53
-rwxr-xr-xsrc/wrapped32/wrappedlibc_private.h6
6 files changed, 45 insertions, 22 deletions
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 8322b096..3d14b2c1 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -1141,6 +1141,7 @@
 #() iFEpLpp -> iFEpLpp
 #() iEEpLpV -> iEEpLpV
 #() iFEpLpV -> iFEpLpV
+#() iEEppii -> iEEppii
 #() iFEpplp -> iFEpplp
 #() iEEpppi -> iEEpppi
 #() iEEpppp -> iEEpppp
@@ -1853,6 +1854,7 @@ wrappedlibc:
   - __ctype_toupper_loc
   - __errno_location
   - __res_state
+  - getpwent
   - localeconv
 - pFv:
   - __h_errno_location
@@ -1993,6 +1995,7 @@ wrappedlibc:
 - iEpuiL:
 - iEpLpp:
 - iEpLpV:
+- iEppii:
 - iEpppp:
   - getaddrinfo
 - iESipp:
diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h
index 449d737e..e24906e9 100644
--- a/src/wrapped32/generated/wrappedlibctypes32.h
+++ b/src/wrapped32/generated/wrappedlibctypes32.h
@@ -102,6 +102,7 @@ typedef int32_t (*iEpipV_t)(void*, int32_t, void*, ...);
 typedef int32_t (*iEpuiL_t)(void*, uint32_t, int32_t, uintptr_t);
 typedef int32_t (*iEpLpp_t)(void*, uintptr_t, void*, void*);
 typedef int32_t (*iEpLpV_t)(void*, uintptr_t, void*, ...);
+typedef int32_t (*iEppii_t)(void*, void*, int32_t, int32_t);
 typedef int32_t (*iEpppp_t)(void*, void*, void*, void*);
 typedef int32_t (*iESipp_t)(void*, int32_t, void*, void*);
 typedef int32_t (*iESipV_t)(void*, int32_t, void*, ...);
@@ -150,6 +151,7 @@ typedef int32_t (*iEpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void
 	GO(__ctype_toupper_loc, pEv_t) \
 	GO(__errno_location, pEv_t) \
 	GO(__res_state, pEv_t) \
+	GO(getpwent, pEv_t) \
 	GO(localeconv, pEv_t) \
 	GO(__h_errno_location, pFv_t) \
 	GO(getpwuid, pEu_t) \
diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c
index f8741198..f13a719e 100644
--- a/src/wrapped32/generated/wrapper32.c
+++ b/src/wrapped32/generated/wrapper32.c
@@ -1232,6 +1232,7 @@ typedef int32_t (*iEEpLpp_t)(x64emu_t*, void*, uintptr_t, void*, void*);
 typedef int32_t (*iFEpLpp_t)(x64emu_t*, void*, uintptr_t, void*, void*);
 typedef int32_t (*iEEpLpV_t)(x64emu_t*, void*, uintptr_t, void*, void*);
 typedef int32_t (*iFEpLpV_t)(x64emu_t*, void*, uintptr_t, void*, void*);
+typedef int32_t (*iEEppii_t)(x64emu_t*, void*, void*, int32_t, int32_t);
 typedef int32_t (*iFEpplp_t)(x64emu_t*, void*, void*, intptr_t, void*);
 typedef int32_t (*iEEpppi_t)(x64emu_t*, void*, void*, void*, int32_t);
 typedef int32_t (*iEEpppp_t)(x64emu_t*, void*, void*, void*, void*);
@@ -2931,6 +2932,7 @@ void iEEpLpp_32(x64emu_t *emu, uintptr_t fcn) { iEEpLpp_t fn = (iEEpLpp_t)fcn; e
 void iFEpLpp_32(x64emu_t *emu, uintptr_t fcn) { iFEpLpp_t fn = (iFEpLpp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16)); }
 void iEEpLpV_32(x64emu_t *emu, uintptr_t fcn) { iEEpLpV_t fn = (iEEpLpV_t)fcn; errno = emu->libc_err; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptrv(R_ESP + 16)); emu->libc_err = errno; }
 void iFEpLpV_32(x64emu_t *emu, uintptr_t fcn) { iFEpLpV_t fn = (iFEpLpV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptrv(R_ESP + 16)); }
+void iEEppii_32(x64emu_t *emu, uintptr_t fcn) { iEEppii_t fn = (iEEppii_t)fcn; errno = emu->libc_err; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); emu->libc_err = errno; }
 void iFEpplp_32(x64emu_t *emu, uintptr_t fcn) { iFEpplp_t fn = (iFEpplp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_long(from_ptri(long_t, R_ESP + 12)), from_ptriv(R_ESP + 16)); }
 void iEEpppi_32(x64emu_t *emu, uintptr_t fcn) { iEEpppi_t fn = (iEEpppi_t)fcn; errno = emu->libc_err; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); emu->libc_err = errno; }
 void iEEpppp_32(x64emu_t *emu, uintptr_t fcn) { iEEpppp_t fn = (iEEpppp_t)fcn; errno = emu->libc_err; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16)); emu->libc_err = errno; }
diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h
index 1f0997b7..4c691e8d 100644
--- a/src/wrapped32/generated/wrapper32.h
+++ b/src/wrapped32/generated/wrapper32.h
@@ -1182,6 +1182,7 @@ void iEEpLpp_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpLpp_32(x64emu_t *emu, uintptr_t fnc);
 void iEEpLpV_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpLpV_32(x64emu_t *emu, uintptr_t fnc);
+void iEEppii_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpplp_32(x64emu_t *emu, uintptr_t fnc);
 void iEEpppi_32(x64emu_t *emu, uintptr_t fnc);
 void iEEpppp_32(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c
index 49bd525c..1456d4db 100755
--- a/src/wrapped32/wrappedlibc.c
+++ b/src/wrapped32/wrappedlibc.c
@@ -232,15 +232,15 @@ static void* findftwFct(void* fct)
     printf_log(LOG_NONE, "Warning, no more slot for libc ftw callback\n");
     return NULL;
 }
-
+#endif
 // ftw64
 #define GO(A)   \
-static uintptr_t my32_ftw64_fct_##A = 0;                      \
-static int my32_ftw64_##A(void* fpath, void* sb, int flag)    \
-{                                                           \
-    struct i386_stat64 i386st;                              \
-    UnalignStat64(sb, &i386st);                             \
-    return (int)RunFunction(my_context, my32_ftw64_fct_##A, 3, fpath, &i386st, flag);  \
+static uintptr_t my32_ftw64_fct_##A = 0;                                            \
+static int my32_ftw64_##A(void* fpath, void* sb, int flag)                          \
+{                                                                                   \
+    struct i386_stat64 i386st;                                                      \
+    UnalignStat64_32(sb, &i386st);                                                  \
+    return (int)RunFunctionFmt(my32_ftw64_fct_##A, "ppi", fpath, &i386st, flag);    \
 }
 SUPER()
 #undef GO
@@ -256,7 +256,7 @@ static void* findftw64Fct(void* fct)
     printf_log(LOG_NONE, "Warning, no more slot for libc ftw64 callback\n");
     return NULL;
 }
-
+#if 0
 // nftw
 #define GO(A)   \
 static uintptr_t my32_nftw_fct_##A = 0;                                   \
@@ -280,15 +280,15 @@ static void* findnftwFct(void* fct)
     printf_log(LOG_NONE, "Warning, no more slot for libc nftw callback\n");
     return NULL;
 }
-
+#endif
 // nftw64
 #define GO(A)   \
-static uintptr_t my32_nftw64_fct_##A = 0;                                     \
-static int my32_nftw64_##A(void* fpath, void* sb, int flag, void* ftwbuff)    \
-{                                                                           \
-    struct i386_stat64 i386st;                                              \
-    UnalignStat64(sb, &i386st);                                             \
-    return (int)RunFunction(my_context, my32_nftw64_fct_##A, 4, fpath, &i386st, flag, ftwbuff);   \
+static uintptr_t my32_nftw64_fct_##A = 0;                                                   \
+static int my32_nftw64_##A(void* fpath, void* sb, int flag, void* ftwbuff)                  \
+{                                                                                           \
+    struct i386_stat64 i386st;                                                              \
+    UnalignStat64_32(sb, &i386st);                                                          \
+    return (int)RunFunctionFmt(my32_nftw64_fct_##A, "ppip", fpath, &i386st, flag, ftwbuff); \
 }
 SUPER()
 #undef GO
@@ -304,7 +304,7 @@ static void* findnftw64Fct(void* fct)
     printf_log(LOG_NONE, "Warning, no more slot for libc nftw64 callback\n");
     return NULL;
 }
-
+#if 0
 // globerr
 #define GO(A)   \
 static uintptr_t my32_globerr_fct_##A = 0;                                        \
@@ -1700,8 +1700,6 @@ EXPORT long my32_readv(x64emu_t* emu, int fd, struct i386_iovec* iov, int niov)
     return readv(fd, vec, niov);
 }
 
-#if 0
-
 EXPORT int my32_ftw64(x64emu_t* emu, void* filename, void* func, int descriptors)
 {
     return ftw64(filename, findftw64Fct(func), descriptors);
@@ -1711,7 +1709,7 @@ EXPORT int32_t my32_nftw64(x64emu_t* emu, void* pathname, void* B, int32_t nopen
 {
     return nftw64(pathname, findnftw64Fct(B), nopenfd, flags);
 }
-#endif
+
 EXPORT int32_t my32_execv(x64emu_t* emu, const char* path, ptr_t argv[])
 {
     int self = isProcSelf(path, "exe");
@@ -2230,6 +2228,23 @@ EXPORT int my32_getpwuid_r(x64emu_t* emu, uint32_t uid, struct i386_passwd* pwd,
     return ret;
 }
 
+EXPORT void* my32_getpwent(x64emu_t* emu)
+{
+    static struct i386_passwd ret;
+    struct passwd* p = getpwent();
+    if(p) {
+        ret.pw_name = to_cstring(p->pw_name);
+        ret.pw_passwd = to_cstring(p->pw_passwd);
+        ret.pw_uid = p->pw_uid;
+        ret.pw_gid = p->pw_gid;
+        ret.pw_gecos = to_cstring(p->pw_gecos);
+        ret.pw_dir = to_cstring(p->pw_dir);
+        ret.pw_shell = to_cstring(p->pw_shell);
+        return &ret;
+    }
+    return NULL;
+}
+
 EXPORT int my32_getgrnam_r(x64emu_t* emu, const char* name, struct i386_group *grp, char *buf, size_t buflen, ptr_t* result)
 {
     struct group _result = {0};
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index d3b78680..cdbf64da 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -436,7 +436,7 @@ GOW(ftruncate64, iEiI)
 //GOM(fts_read, pEEp)      //%%
 // fts_set
 //GOM(ftw, iEEppi)         //%%
-//GOM(ftw64, iEEppi)       //%%
+GOM(ftw64, iEEppi)       //%%
 GOW(funlockfile, vFS)
 GOM(futimens, iEEip)
 GOWM(futimes, iEEip)
@@ -562,7 +562,7 @@ GOM(getprotobyname, pEEp)
 GOW(getpt, iEv)
 // getpublickey
 // getpw    // Weak
-//GO(getpwent, pEv)
+GOM(getpwent, pEEv)
 // getpwent_r
 GOM(getpwnam, pEEp)
 GOM(getpwnam_r, iEEpppLp)
@@ -1162,7 +1162,7 @@ GOW(newlocale, aEipa)
 GO(__newlocale, aEipa)
 // nfsservctl
 //GOM(nftw, iEEppii)       //%%
-//GOM(nftw64, iEEppii)     //%%
+GOM(nftw64, iEEppii)     //%%
 //GOW(ngettext, pEppu)
 GO(nice, iEi)
 // _nl_default_dirname   // type R