about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-10-07 10:45:31 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-10-07 10:45:31 +0200
commit82c7d45c4b9ab85f718a4693ac08265f03bf0321 (patch)
tree908bcce6c2a7b05bd1f2baaadb2dc4cadd6e1b82 /src
parentf81677278f6bbe387e20f7b9f642f8dcbef12387 (diff)
downloadbox64-82c7d45c4b9ab85f718a4693ac08265f03bf0321.tar.gz
box64-82c7d45c4b9ab85f718a4693ac08265f03bf0321.zip
[BOX32] Added a couple of 32bits function to libc
Diffstat (limited to 'src')
-rw-r--r--src/libtools/libc_net32.c78
-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_private.h4
6 files changed, 92 insertions, 2 deletions
diff --git a/src/libtools/libc_net32.c b/src/libtools/libc_net32.c
index 73e660e6..cdbffeed 100644
--- a/src/libtools/libc_net32.c
+++ b/src/libtools/libc_net32.c
@@ -151,6 +151,84 @@ EXPORT void* my32_gethostbyname(x64emu_t* emu, const char* a)
     return &ret;
 }
 
+EXPORT int my32_gethostbyname_r(x64emu_t* emu, void* name, struct i386_hostent* ret, void* buff, size_t buflen, ptr_t* result, int* h_err)
+{
+    struct hostent ret_l = {0};
+    struct hostent *result_l = NULL;
+    int r = gethostbyname_r(name, &ret_l, buff, buflen, &result_l, h_err);
+    if(!result_l)
+        *result = 0;
+    else
+        *result = to_ptrv(ret);
+    // convert result, all memory allocated should be in program space
+    if(result_l) {
+        ret->h_name = to_cstring(result_l->h_name);
+        ret->h_addrtype = result_l->h_addrtype;
+        ret->h_length = result_l->h_length;
+        int idx = 0;
+        ret->h_aliases = to_ptrv(result_l->h_aliases);
+        if(result_l->h_aliases) {
+            char** p = result_l->h_aliases;
+            ptr_t* strings = from_ptrv(ret->h_aliases);
+            while(*p) {
+                strings[idx++] = to_cstring(*p);
+                ++p;
+            }
+            strings[idx++] = 0;
+        }
+        ret->h_addr_list = to_ptrv(result_l->h_addr_list);
+        if(result_l->h_addr_list) {
+            char** p = result_l->h_addr_list;
+            ptr_t* strings = from_ptrv(ret->h_addr_list);
+            while(*p) {
+                strings[idx++] = to_ptrv(*p);
+                ++p;
+            }   
+            strings[idx++] = 0;
+        }
+    }
+    return r;
+}
+
+EXPORT int my32_gethostbyaddr_r(x64emu_t* emu, void* addr, uint32_t len, int type, struct i386_hostent* ret, void* buff, size_t buflen, ptr_t* result, int* h_err)
+{
+    struct hostent ret_l = {0};
+    struct hostent *result_l = NULL;
+    int r = gethostbyaddr_r(addr, len, type, &ret_l, buff, buflen, &result_l, h_err);
+    if(!result_l)
+        *result = 0;
+    else
+        *result = to_ptrv(ret);
+    // convert result, all memory allocated should be in program space
+    if(result_l) {
+        ret->h_name = to_cstring(result_l->h_name);
+        ret->h_addrtype = result_l->h_addrtype;
+        ret->h_length = result_l->h_length;
+        int idx = 0;
+        ret->h_aliases = to_ptrv(result_l->h_aliases);
+        if(result_l->h_aliases) {
+            char** p = result_l->h_aliases;
+            ptr_t* strings = from_ptrv(ret->h_aliases);
+            while(*p) {
+                strings[idx++] = to_cstring(*p);
+                ++p;
+            }
+            strings[idx++] = 0;
+        }
+        ret->h_addr_list = to_ptrv(result_l->h_addr_list);
+        if(result_l->h_addr_list) {
+            char** p = result_l->h_addr_list;
+            ptr_t* strings = from_ptrv(ret->h_addr_list);
+            while(*p) {
+                strings[idx++] = to_ptrv(*p);
+                ++p;
+            }   
+            strings[idx++] = 0;
+        }
+    }
+    return r;
+}
+
 struct i386_ifaddrs
 {
   ptr_t     ifa_next;   // struct ifaddrs *
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 1a870e15..53372ea4 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -1170,6 +1170,7 @@
 #() vFXppiiii -> vFXppiiii
 #() iFEpLiipV -> iFEpLiipV
 #() iFEpLiLpV -> iFEpLiLpV
+#() iFEpppupp -> iFEpppupp
 #() iFEpppppp -> iFEpppppp
 #() iFEXLpiiL -> iFEXLpiiL
 #() iFEXLpppp -> iFEXLpppp
@@ -1237,6 +1238,7 @@
 #() iFEpippppp -> iFEpippppp
 #() iFEpLiLppp -> iFEpLiLppp
 #() iFuiiiiuup -> iFuiiiiuup
+#() iFpuippupp -> iFpuippupp
 #() iFXuupuupp -> iFXuupuupp
 #() iFXLpipppp -> iFXLpipppp
 #() iFXLppLpip -> iFXLppLpip
@@ -1628,6 +1630,8 @@ wrappedlibc:
 - iFpLvvpp:
 - iFpLiipV:
 - iFpLiLpV:
+- iFpppupp:
+  - gethostbyname_r
 - iFpppppp:
   - posix_spawn
 - pFpLiiiI:
diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h
index 78cd3c1e..fd4c086c 100644
--- a/src/wrapped32/generated/wrappedlibctypes32.h
+++ b/src/wrapped32/generated/wrappedlibctypes32.h
@@ -97,6 +97,7 @@ typedef void* (*pFppLLp_t)(void*, void*, uintptr_t, uintptr_t, void*);
 typedef int32_t (*iFpLvvpp_t)(void*, uintptr_t, void, void, void*, void*);
 typedef int32_t (*iFpLiipV_t)(void*, uintptr_t, int32_t, int32_t, void*, ...);
 typedef int32_t (*iFpLiLpV_t)(void*, uintptr_t, int32_t, uintptr_t, void*, ...);
+typedef int32_t (*iFpppupp_t)(void*, void*, void*, uint32_t, void*, void*);
 typedef int32_t (*iFpppppp_t)(void*, void*, void*, void*, void*, void*);
 typedef void* (*pFpLiiiI_t)(void*, uintptr_t, int32_t, int32_t, int32_t, int64_t);
 typedef void* (*pFpLiiil_t)(void*, uintptr_t, int32_t, int32_t, int32_t, intptr_t);
@@ -163,6 +164,7 @@ typedef int32_t (*iFpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void
 	GO(getpwuid_r, iFuppLp_t) \
 	GO(getgrnam_r, iFpppLp_t) \
 	GO(getpwnam_r, iFpppLp_t) \
+	GO(gethostbyname_r, iFpppupp_t) \
 	GO(posix_spawn, iFpppppp_t)
 
 #endif // __wrappedlibcTYPES32_H_
diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c
index 593ffc65..69daae50 100644
--- a/src/wrapped32/generated/wrapper32.c
+++ b/src/wrapped32/generated/wrapper32.c
@@ -1260,6 +1260,7 @@ typedef void (*vFXpiipii_t)(void*, void*, int32_t, int32_t, void*, int32_t, int3
 typedef void (*vFXppiiii_t)(void*, void*, void*, int32_t, int32_t, int32_t, int32_t);
 typedef int32_t (*iFEpLiipV_t)(x64emu_t*, void*, uintptr_t, int32_t, int32_t, void*, void*);
 typedef int32_t (*iFEpLiLpV_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, void*, void*);
+typedef int32_t (*iFEpppupp_t)(x64emu_t*, void*, void*, void*, uint32_t, void*, void*);
 typedef int32_t (*iFEpppppp_t)(x64emu_t*, void*, void*, void*, void*, void*, void*);
 typedef int32_t (*iFEXLpiiL_t)(x64emu_t*, void*, uintptr_t, void*, int32_t, int32_t, uintptr_t);
 typedef int32_t (*iFEXLpppp_t)(x64emu_t*, void*, uintptr_t, void*, void*, void*, void*);
@@ -1327,6 +1328,7 @@ typedef void (*vFXLppiipi_t)(void*, uintptr_t, void*, void*, int32_t, int32_t, v
 typedef int32_t (*iFEpippppp_t)(x64emu_t*, void*, int32_t, void*, void*, void*, void*, void*);
 typedef int32_t (*iFEpLiLppp_t)(x64emu_t*, void*, uintptr_t, int32_t, uintptr_t, void*, void*, void*);
 typedef int32_t (*iFuiiiiuup_t)(uint32_t, int32_t, int32_t, int32_t, int32_t, uint32_t, uint32_t, void*);
+typedef int32_t (*iFpuippupp_t)(void*, uint32_t, int32_t, void*, void*, uint32_t, void*, void*);
 typedef int32_t (*iFXuupuupp_t)(void*, uint32_t, uint32_t, void*, uint32_t, uint32_t, void*, void*);
 typedef int32_t (*iFXLpipppp_t)(void*, uintptr_t, void*, int32_t, void*, void*, void*, void*);
 typedef int32_t (*iFXLppLpip_t)(void*, uintptr_t, void*, void*, uintptr_t, void*, int32_t, void*);
@@ -2654,6 +2656,7 @@ void vFXpiipii_32(x64emu_t *emu, uintptr_t fcn) { vFXpiipii_t fn = (vFXpiipii_t)
 void vFXppiiii_32(x64emu_t *emu, uintptr_t fcn) { vFXppiiii_t fn = (vFXppiiii_t)fcn; fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(int32_t, R_ESP + 24), from_ptri(int32_t, R_ESP + 28)); }
 void iFEpLiipV_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiipV_t fn = (iFEpLiipV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptrv(R_ESP + 24)); }
 void iFEpLiLpV_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiLpV_t fn = (iFEpLiLpV_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptriv(R_ESP + 20), from_ptrv(R_ESP + 24)); }
+void iFEpppupp_32(x64emu_t *emu, uintptr_t fcn) { iFEpppupp_t fn = (iFEpppupp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptri(uint32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
 void iFEpppppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpppppp_t fn = (iFEpppppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
 void iFEXLpiiL_32(x64emu_t *emu, uintptr_t fcn) { iFEXLpiiL_t fn = (iFEXLpiiL_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ulong(from_ptri(ulong_t, R_ESP + 24))); }
 void iFEXLpppp_32(x64emu_t *emu, uintptr_t fcn) { iFEXLpppp_t fn = (iFEXLpppp_t)fcn; R_EAX = fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24)); }
@@ -2721,6 +2724,7 @@ void vFXLppiipi_32(x64emu_t *emu, uintptr_t fcn) { vFXLppiipi_t fn = (vFXLppiipi
 void iFEpippppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpippppp_t fn = (iFEpippppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28)); }
 void iFEpLiLppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpLiLppp_t fn = (iFEpLiLppp_t)fcn; R_EAX = fn(emu, from_ptriv(R_ESP + 4), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12), from_ulong(from_ptri(ulong_t, R_ESP + 16)), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28)); }
 void iFuiiiiuup_32(x64emu_t *emu, uintptr_t fcn) { iFuiiiiuup_t fn = (iFuiiiiuup_t)fcn; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptri(int32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptri(uint32_t, R_ESP + 28), from_ptriv(R_ESP + 32)); }
+void iFpuippupp_32(x64emu_t *emu, uintptr_t fcn) { iFpuippupp_t fn = (iFpuippupp_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptriv(R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32)); }
 void iFXuupuupp_32(x64emu_t *emu, uintptr_t fcn) { iFXuupuupp_t fn = (iFXuupuupp_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptri(uint32_t, R_ESP + 20), from_ptri(uint32_t, R_ESP + 24), from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32)); }
 void iFXLpipppp_32(x64emu_t *emu, uintptr_t fcn) { iFXLpipppp_t fn = (iFXLpipppp_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptri(int32_t, R_ESP + 16), from_ptriv(R_ESP + 20), from_ptriv(R_ESP + 24), from_ptriv(R_ESP + 28), from_ptriv(R_ESP + 32)); }
 void iFXLppLpip_32(x64emu_t *emu, uintptr_t fcn) { iFXLppLpip_t fn = (iFXLppLpip_t)fcn; R_EAX = fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16), from_ulong(from_ptri(ulong_t, R_ESP + 20)), from_ptriv(R_ESP + 24), from_ptri(int32_t, R_ESP + 28), from_ptriv(R_ESP + 32)); }
diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h
index 49078aac..78bde902 100644
--- a/src/wrapped32/generated/wrapper32.h
+++ b/src/wrapped32/generated/wrapper32.h
@@ -1211,6 +1211,7 @@ void vFXpiipii_32(x64emu_t *emu, uintptr_t fnc);
 void vFXppiiii_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpLiipV_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpLiLpV_32(x64emu_t *emu, uintptr_t fnc);
+void iFEpppupp_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpppppp_32(x64emu_t *emu, uintptr_t fnc);
 void iFEXLpiiL_32(x64emu_t *emu, uintptr_t fnc);
 void iFEXLpppp_32(x64emu_t *emu, uintptr_t fnc);
@@ -1278,6 +1279,7 @@ void vFXLppiipi_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpippppp_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpLiLppp_32(x64emu_t *emu, uintptr_t fnc);
 void iFuiiiiuup_32(x64emu_t *emu, uintptr_t fnc);
+void iFpuippupp_32(x64emu_t *emu, uintptr_t fnc);
 void iFXuupuupp_32(x64emu_t *emu, uintptr_t fnc);
 void iFXLpipppp_32(x64emu_t *emu, uintptr_t fnc);
 void iFXLppLpip_32(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index d9ebbde0..75eb218f 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -495,11 +495,11 @@ GOM(getgrnam_r, iFEpppLp)
 GOW(getgroups, iFip)
 // __getgroups_chk
 //GO(gethostbyaddr, pFpui)
-//GO(gethostbyaddr_r, iFpuippupp)
+GO(gethostbyaddr_r, iFpuippupp)
 GOM(gethostbyname, pFEp)
 //GO(gethostbyname2, pFpi)
 //GO(gethostbyname2_r, iFpippupp)
-//GO(gethostbyname_r, iFpppupp)
+GOM(gethostbyname_r, iFEpppupp)
 //GO(gethostent, pFv)
 //GO(gethostent_r, iFppupp)
 // gethostid