about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2024-08-30 18:54:16 +0200
committerptitSeb <sebastien.chev@gmail.com>2024-08-30 18:54:16 +0200
commit723b94da053b15dcea48130e820a34fc8509381e (patch)
treedfc1a78da82bd9f4b0266830fa80c4c5dbbbfc8b /src
parent7ecdced4860d12b8f484e0b222d08192be4a56eb (diff)
downloadbox64-723b94da053b15dcea48130e820a34fc8509381e.tar.gz
box64-723b94da053b15dcea48130e820a34fc8509381e.zip
[BOX32] More 32bits wrapped function and fixes
Diffstat (limited to 'src')
-rw-r--r--src/emu/x86syscall_32.c2
-rwxr-xr-xsrc/include/myalign32.h13
-rw-r--r--src/wrapped32/generated/functions_list.txt6
-rw-r--r--src/wrapped32/generated/wrappedlibctypes32.h4
-rw-r--r--src/wrapped32/generated/wrapper32.c8
-rw-r--r--src/wrapped32/generated/wrapper32.h4
-rwxr-xr-xsrc/wrapped32/wrappedlibc.c46
-rwxr-xr-xsrc/wrapped32/wrappedlibc_private.h22
8 files changed, 92 insertions, 13 deletions
diff --git a/src/emu/x86syscall_32.c b/src/emu/x86syscall_32.c
index cae7b40b..58bcb5bb 100644
--- a/src/emu/x86syscall_32.c
+++ b/src/emu/x86syscall_32.c
@@ -152,7 +152,7 @@ static const scwrap_t syscallwrap[] = {
     //{ 256, __NR_epoll_wait, 4 },
     //{ 265, __NR_clock_gettime, 2 },
     //{ 266, __NR_clock_getres, 2 },
-    //{ 270, __NR_tgkill, 3 },
+    { 270, __NR_tgkill, 3 },
     //{ 271, __NR_utimes, 2 },
     //{ 291, __NR_inotify_init, 0},
     //{ 292, __NR_inotify_add_watch, 3},
diff --git a/src/include/myalign32.h b/src/include/myalign32.h
index b7d67016..7e9c3a6c 100755
--- a/src/include/myalign32.h
+++ b/src/include/myalign32.h
@@ -427,4 +427,17 @@ void unalignNGValue(void* value, my_GValue_t* v, int n);
 int of_convert32(int a);
 int of_unconvert32(int a);
 
+struct i386_addrinfo
+{
+  int ai_flags;
+  int ai_family;
+  int ai_socktype;
+  int ai_protocol;
+  uint32_t ai_addrlen;
+  ptr_t ai_addr;	    // struct sockaddr *
+  ptr_t ai_canonname;   // char *
+  ptr_t ai_next;        // struct addrinfo *
+} __attribute__((packed));
+
+
 #endif//__MY_ALIGN32__H_
\ No newline at end of file
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 3d46842c..23e13945 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -110,6 +110,7 @@
 #() iFiII -> iFiII
 #() iFiuu -> iFiuu
 #() iFiLN -> iFiLN
+#() iFipu -> iFipu
 #() iFipp -> iFipp
 #() iFuii -> iFuii
 #() iFuip -> iFuip
@@ -120,6 +121,7 @@
 #() iFpiu -> iFpiu
 #() iFpip -> iFpip
 #() iFpuu -> iFpuu
+#() iFpLi -> iFpLi
 #() iFpLL -> iFpLL
 #() iFppu -> iFppu
 #() iFppL -> iFppL
@@ -163,6 +165,7 @@
 #() iFiiII -> iFiiII
 #() iFiuui -> iFiuui
 #() iFhpiL -> iFhpiL
+#() lFipLi -> lFipLi
 #() LFpLLh -> LFpLLh
 #() pFEppi -> pFEppi
 #() pFEppp -> pFEppp
@@ -174,6 +177,7 @@
 #() iFEppiV -> iFEppiV
 #() iFEpppi -> iFEpppi
 #() iFEpppp -> iFEpppp
+#() iFiiipu -> iFiiipu
 #() iFiLLLL -> iFiLLLL
 #() iFEBh_ppp -> iFEBppp
 #() iFEpippp -> iFEpippp
@@ -201,6 +205,7 @@ wrappedldlinux:
 wrappedlibc:
 - vFv:
 - vFp:
+  - freeaddrinfo
 - iFv:
 - iFi:
   - __close_nocancel
@@ -251,6 +256,7 @@ wrappedlibc:
 - iFLLLL:
 - iFppiV:
 - iFpppp:
+  - getaddrinfo
 - iFhvpV:
 - iFpippp:
 - iFpLppp:
diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h
index 12cc4e30..002b0f01 100644
--- a/src/wrapped32/generated/wrappedlibctypes32.h
+++ b/src/wrapped32/generated/wrappedlibctypes32.h
@@ -59,6 +59,7 @@ typedef int32_t (*iFpippppp_t)(void*, int32_t, void*, void*, void*, void*, void*
 typedef int32_t (*iFpuvvppp_t)(void*, uint32_t, void, void, void*, void*, void*);
 
 #define SUPER() ADDED_FUNCTIONS() \
+	GO(freeaddrinfo, vFp_t) \
 	GO(__close_nocancel, iFi_t) \
 	GO(__ctype_b_loc, pFv_t) \
 	GO(__ctype_tolower_loc, pFv_t) \
@@ -70,6 +71,7 @@ typedef int32_t (*iFpuvvppp_t)(void*, uint32_t, void, void, void*, void*, void*)
 	GO(signal, pFip_t) \
 	GO(gmtime_r, pFpp_t) \
 	GO(localtime_r, pFpp_t) \
-	GO(__libc_init, vFpppp_t)
+	GO(__libc_init, vFpppp_t) \
+	GO(getaddrinfo, iFpppp_t)
 
 #endif // __wrappedlibcTYPES32_H_
diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c
index 0e2addd8..3a41d9e2 100644
--- a/src/wrapped32/generated/wrapper32.c
+++ b/src/wrapped32/generated/wrapper32.c
@@ -184,6 +184,7 @@ typedef int32_t (*iFiiO_t)(int32_t, int32_t, int32_t);
 typedef int32_t (*iFiII_t)(int32_t, int64_t, int64_t);
 typedef int32_t (*iFiuu_t)(int32_t, uint32_t, uint32_t);
 typedef int32_t (*iFiLN_t)(int32_t, uintptr_t, ...);
+typedef int32_t (*iFipu_t)(int32_t, void*, uint32_t);
 typedef int32_t (*iFipp_t)(int32_t, void*, void*);
 typedef int32_t (*iFuii_t)(uint32_t, int32_t, int32_t);
 typedef int32_t (*iFuip_t)(uint32_t, int32_t, void*);
@@ -194,6 +195,7 @@ typedef int32_t (*iFupp_t)(uint32_t, void*, void*);
 typedef int32_t (*iFpiu_t)(void*, int32_t, uint32_t);
 typedef int32_t (*iFpip_t)(void*, int32_t, void*);
 typedef int32_t (*iFpuu_t)(void*, uint32_t, uint32_t);
+typedef int32_t (*iFpLi_t)(void*, uintptr_t, int32_t);
 typedef int32_t (*iFpLL_t)(void*, uintptr_t, uintptr_t);
 typedef int32_t (*iFppu_t)(void*, void*, uint32_t);
 typedef int32_t (*iFppL_t)(void*, void*, uintptr_t);
@@ -237,6 +239,7 @@ typedef int32_t (*iFiiiN_t)(int32_t, int32_t, int32_t, ...);
 typedef int32_t (*iFiiII_t)(int32_t, int32_t, int64_t, int64_t);
 typedef int32_t (*iFiuui_t)(int32_t, uint32_t, uint32_t, int32_t);
 typedef int32_t (*iFhpiL_t)(uintptr_t, void*, int32_t, uintptr_t);
+typedef intptr_t (*lFipLi_t)(int32_t, void*, uintptr_t, int32_t);
 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*);
@@ -248,6 +251,7 @@ typedef void (*vFEpLLp_t)(x64emu_t*, void*, uintptr_t, uintptr_t, void*);
 typedef int32_t (*iFEppiV_t)(x64emu_t*, void*, void*, int32_t, void*);
 typedef int32_t (*iFEpppi_t)(x64emu_t*, void*, void*, void*, int32_t);
 typedef int32_t (*iFEpppp_t)(x64emu_t*, void*, void*, void*, void*);
+typedef int32_t (*iFiiipu_t)(int32_t, int32_t, int32_t, void*, uint32_t);
 typedef int32_t (*iFiLLLL_t)(int32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t);
 typedef int32_t (*iFEBh_ppp_t)(x64emu_t*, struct_h_t*, void*, void*, void*);
 typedef int32_t (*iFEpippp_t)(x64emu_t*, void*, int32_t, void*, void*, void*);
@@ -384,6 +388,7 @@ void iFiiO_32(x64emu_t *emu, uintptr_t fcn) { iFiiO_t fn = (iFiiO_t)fcn; R_EAX =
 void iFiII_32(x64emu_t *emu, uintptr_t fcn) { iFiII_t fn = (iFiII_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int64_t, R_ESP + 8), from_ptri(int64_t, R_ESP + 16)); }
 void iFiuu_32(x64emu_t *emu, uintptr_t fcn) { iFiuu_t fn = (iFiuu_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); }
 void iFiLN_32(x64emu_t *emu, uintptr_t fcn) { iFiLN_t fn = (iFiLN_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptriv(R_ESP + 12)); }
+void iFipu_32(x64emu_t *emu, uintptr_t fcn) { iFipu_t fn = (iFipu_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); }
 void iFipp_32(x64emu_t *emu, uintptr_t fcn) { iFipp_t fn = (iFipp_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12)); }
 void iFuii_32(x64emu_t *emu, uintptr_t fcn) { iFuii_t fn = (iFuii_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)); }
 void iFuip_32(x64emu_t *emu, uintptr_t fcn) { iFuip_t fn = (iFuip_t)fcn; R_EAX = fn(from_ptri(uint32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12)); }
@@ -394,6 +399,7 @@ void iFupp_32(x64emu_t *emu, uintptr_t fcn) { iFupp_t fn = (iFupp_t)fcn; R_EAX =
 void iFpiu_32(x64emu_t *emu, uintptr_t fcn) { iFpiu_t fn = (iFpiu_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); }
 void iFpip_32(x64emu_t *emu, uintptr_t fcn) { iFpip_t fn = (iFpip_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12)); }
 void iFpuu_32(x64emu_t *emu, uintptr_t fcn) { iFpuu_t fn = (iFpuu_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); }
+void iFpLi_32(x64emu_t *emu, uintptr_t fcn) { iFpLi_t fn = (iFpLi_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(int32_t, R_ESP + 12)); }
 void iFpLL_32(x64emu_t *emu, uintptr_t fcn) { iFpLL_t fn = (iFpLL_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), to_ulong(from_ptri(ulong_t, R_ESP + 12))); }
 void iFppu_32(x64emu_t *emu, uintptr_t fcn) { iFppu_t fn = (iFppu_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(uint32_t, R_ESP + 12)); }
 void iFppL_32(x64emu_t *emu, uintptr_t fcn) { iFppL_t fn = (iFppL_t)fcn; R_EAX = fn(from_ptriv(R_ESP + 4), from_ptriv(R_ESP + 8), to_ulong(from_ptri(ulong_t, R_ESP + 12))); }
@@ -437,6 +443,7 @@ void iFiiiN_32(x64emu_t *emu, uintptr_t fcn) { iFiiiN_t fn = (iFiiiN_t)fcn; R_EA
 void iFiiII_32(x64emu_t *emu, uintptr_t fcn) { iFiiII_t fn = (iFiiII_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int64_t, R_ESP + 12), from_ptri(int64_t, R_ESP + 20)); }
 void iFiuui_32(x64emu_t *emu, uintptr_t fcn) { iFiuui_t fn = (iFiuui_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(uint32_t, R_ESP + 8), from_ptri(uint32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16)); }
 void iFhpiL_32(x64emu_t *emu, uintptr_t fcn) { iFhpiL_t fn = (iFhpiL_t)fcn; R_EAX = fn(from_hash(from_ptri(ptr_t, R_ESP + 4)), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12), to_ulong(from_ptri(ulong_t, R_ESP + 16))); }
+void lFipLi_32(x64emu_t *emu, uintptr_t fcn) { lFipLi_t fn = (lFipLi_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)), from_ptri(int32_t, R_ESP + 16))); }
 void LFpLLh_32(x64emu_t *emu, uintptr_t fcn) { LFpLLh_t fn = (LFpLLh_t)fcn; R_EAX = to_ulong(fn(from_ptriv(R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), to_ulong(from_ptri(ulong_t, R_ESP + 12)), from_hash(from_ptri(ptr_t, R_ESP + 16)))); }
 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))); }
@@ -448,6 +455,7 @@ void vFEpLLp_32(x64emu_t *emu, uintptr_t fcn) { vFEpLLp_t fn = (vFEpLLp_t)fcn; f
 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)); }
 void iFEpppi_32(x64emu_t *emu, uintptr_t fcn) { iFEpppi_t fn = (iFEpppi_t)fcn; 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)); }
 void iFEpppp_32(x64emu_t *emu, uintptr_t fcn) { iFEpppp_t fn = (iFEpppp_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)); }
+void iFiiipu_32(x64emu_t *emu, uintptr_t fcn) { iFiiipu_t fn = (iFiiipu_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptriv(R_ESP + 16), from_ptri(uint32_t, R_ESP + 20)); }
 void iFiLLLL_32(x64emu_t *emu, uintptr_t fcn) { iFiLLLL_t fn = (iFiLLLL_t)fcn; R_EAX = fn(from_ptri(int32_t, R_ESP + 4), to_ulong(from_ptri(ulong_t, R_ESP + 8)), to_ulong(from_ptri(ulong_t, R_ESP + 12)), to_ulong(from_ptri(ulong_t, R_ESP + 16)), to_ulong(from_ptri(ulong_t, R_ESP + 20))); }
 void iFEBh_ppp_32(x64emu_t *emu, uintptr_t fcn) { iFEBh_ppp_t fn = (iFEBh_ppp_t)fcn; struct_h_t arg_4; R_EAX = fn(emu, *(ptr_t*)(from_ptr((R_ESP + 4))) ? &arg_4 : NULL, from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12), from_ptriv(R_ESP + 16)); if (*(ptr_t*)(from_ptr((R_ESP + 4)))) to_struct_h(*(ptr_t*)(from_ptr((R_ESP + 4))), &arg_4); }
 void iFEpippp_32(x64emu_t *emu, uintptr_t fcn) { iFEpippp_t fn = (iFEpippp_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)); }
diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h
index d92b89e4..2688f112 100644
--- a/src/wrapped32/generated/wrapper32.h
+++ b/src/wrapped32/generated/wrapper32.h
@@ -150,6 +150,7 @@ void iFiiO_32(x64emu_t *emu, uintptr_t fnc);
 void iFiII_32(x64emu_t *emu, uintptr_t fnc);
 void iFiuu_32(x64emu_t *emu, uintptr_t fnc);
 void iFiLN_32(x64emu_t *emu, uintptr_t fnc);
+void iFipu_32(x64emu_t *emu, uintptr_t fnc);
 void iFipp_32(x64emu_t *emu, uintptr_t fnc);
 void iFuii_32(x64emu_t *emu, uintptr_t fnc);
 void iFuip_32(x64emu_t *emu, uintptr_t fnc);
@@ -160,6 +161,7 @@ void iFupp_32(x64emu_t *emu, uintptr_t fnc);
 void iFpiu_32(x64emu_t *emu, uintptr_t fnc);
 void iFpip_32(x64emu_t *emu, uintptr_t fnc);
 void iFpuu_32(x64emu_t *emu, uintptr_t fnc);
+void iFpLi_32(x64emu_t *emu, uintptr_t fnc);
 void iFpLL_32(x64emu_t *emu, uintptr_t fnc);
 void iFppu_32(x64emu_t *emu, uintptr_t fnc);
 void iFppL_32(x64emu_t *emu, uintptr_t fnc);
@@ -203,6 +205,7 @@ void iFiiiN_32(x64emu_t *emu, uintptr_t fnc);
 void iFiiII_32(x64emu_t *emu, uintptr_t fnc);
 void iFiuui_32(x64emu_t *emu, uintptr_t fnc);
 void iFhpiL_32(x64emu_t *emu, uintptr_t fnc);
+void lFipLi_32(x64emu_t *emu, uintptr_t fnc);
 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);
@@ -214,6 +217,7 @@ void vFEpLLp_32(x64emu_t *emu, uintptr_t fnc);
 void iFEppiV_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpppi_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpppp_32(x64emu_t *emu, uintptr_t fnc);
+void iFiiipu_32(x64emu_t *emu, uintptr_t fnc);
 void iFiLLLL_32(x64emu_t *emu, uintptr_t fnc);
 void iFEBh_ppp_32(x64emu_t *emu, uintptr_t fnc);
 void iFEpippp_32(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c
index 5e67f57e..a32780e7 100755
--- a/src/wrapped32/wrappedlibc.c
+++ b/src/wrapped32/wrappedlibc.c
@@ -37,6 +37,8 @@
 #include <locale.h>
 #include <sys/resource.h>
 #include <sys/statvfs.h>
+#include <sys/socket.h>
+#include <netdb.h>
 
 #include "wrappedlibs.h"
 
@@ -2307,6 +2309,50 @@ EXPORT int my32_getopt_long_only(int argc, char* const argv[], const char* optst
 }
 #endif
 
+EXPORT int my32_getaddrinfo(x64emu_t* emu, void* node, void* service, struct i386_addrinfo* hints, ptr_t* res)
+{
+    struct addrinfo* hints_ = (struct addrinfo*)hints;  // only first part is used, wich is identical
+    struct addrinfo* p = {0};
+    int ret = getaddrinfo(node, service, hints_, &p);
+    if(!ret && p) {
+        // counting the number of "next"
+        struct addrinfo* p2 = p;
+        int idx = 0;
+        while(p2) {++idx; p2 = p2->ai_next;}
+        // doing the malloc!
+        void* r = box_malloc(idx*sizeof(struct i386_addrinfo)+sizeof(void*));
+        ptr_t p3 = to_ptrv(r);
+        *res = p3;
+        p2 = p;
+        for(int i=0; i<idx; ++i) {
+            struct i386_addrinfo* dest = (struct i386_addrinfo*)from_ptrv(p3);
+            p3+=sizeof(struct i386_addrinfo);
+            if(!i) {
+                *(void**)from_ptrv(p3) = p;
+                p3+=sizeof(void*);
+            }
+            dest->ai_flags = p2->ai_flags;
+            dest->ai_family = p2->ai_family;
+            dest->ai_socktype = p2->ai_socktype;
+            dest->ai_protocol = p2->ai_protocol;
+            dest->ai_addrlen = p2->ai_addrlen;
+            dest->ai_addr = to_ptrv(p2->ai_addr);
+            dest->ai_canonname = to_cstring(p2->ai_canonname);
+            p2 = p2->ai_next;
+            dest->ai_next = p2?p3:0;
+        }
+    } else
+        *res = 0;
+    return ret;
+}
+
+EXPORT void my32_freeaddrinfo(x64emu_t* emu, void* a) {
+    if(!a) return;
+    void* orig = *(void**)(a+sizeof(struct i386_addrinfo));
+    freeaddrinfo(orig);
+    box_free(a);
+}
+
 EXPORT int my32_alphasort64(x64emu_t* emu, ptr_t* d1_, ptr_t* d2_)
 {
     const struct dirent64* d1 = NULL;
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index cc9df49f..cdfd36dc 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -97,7 +97,7 @@ GOM(alphasort64, iFEpp)
 //GOW(bcmp, iFppL)
 //GO(bcopy, vFppL)
 // bdflush
-//GOW(bind, iFipu)
+GOW(bind, iFipu)
 // bindresvport
 //GOW(bindtextdomain, pFpp)
 //GOW(bind_textdomain_codeset, pFpp)
@@ -157,8 +157,8 @@ GO(closelog, vFv)
 //GO(__cmsg_nxthdr, pFpp)
 //GO(confstr, uFipu)
 // __confstr_chk
-//GOW(connect, iFipu)
-//GOW(__connect, iFipu)
+GOW(connect, iFipu)
+GOW(__connect, iFipu)
 // copysign // Weak
 // copysignf    // Weak
 // copysignl    // Weak
@@ -385,7 +385,7 @@ GOW(fread, LFpLLh)
 //GO(fread_unlocked, uFpuup)
 //GO(__fread_unlocked_chk, uFpuuup)
 GO(free, vFp)
-//GO(freeaddrinfo, vFp)
+GOM(freeaddrinfo, vFEp)
 //DATAV(__free_hook, 4)
 //GO(freeifaddrs, vFp)
 GOW(freelocale, vFA)
@@ -446,7 +446,7 @@ GOM(__fxstat64, iFEiip)     //%% need reaalign of struct stat64
 // __gconv_get_cache
 // __gconv_get_modules_db
 // gcvt
-//GO(getaddrinfo, iFpppp)
+GOM(getaddrinfo, iFEpppp)
 // getaliasbyname
 // getaliasbyname_r
 // getaliasent
@@ -577,7 +577,7 @@ GO(getrlimit64, iFip)
 // getservent
 //GO(getservent_r, iFppup)
 GO(getsid, uFu)
-//GOW(getsockname, iFipp)
+GOW(getsockname, iFipp)
 //GOW(getsockopt, iFiiipp)
 // getsourcefilter
 //GO(getspent, pFv)
@@ -1230,8 +1230,8 @@ GOW(pause, iFv)
 // pmap_rmtcall
 // pmap_set
 // pmap_unset
-//GOW(poll, iFpui)    // poll have an array of struct as 1st argument
-//GO(__poll, iFpui)
+GOW(poll, iFpLi)    // poll have an array of struct as 1st argument
+GO(__poll, iFpLi)
 //GO(popen, pFpp)
 GO(posix_fadvise, iFiuui)
 GO(posix_fadvise64, iFiuui)
@@ -1357,7 +1357,7 @@ GO(__realpath_chk, pFppu)
 // re_comp  // Weak
 // re_compile_fastmap   // Weak
 //GOW(re_compile_pattern, pFpup)
-//GO(recv, lFipLi)
+GO(recv, lFipLi)
 //GO(__recv_chk, iFipuui)
 //GOW(recvfrom, lFipLipp)
 // __recvfrom_chk
@@ -1456,7 +1456,7 @@ GO(semctl, iFiiiN)
 GOW(semget, iFuii)
 //GOW(semop, iFipL)
 //GO(semtimedop, iFipup)
-//GOW(send, lFipLi)
+GOW(send, lFipLi)
 // __send   // Weak
 //GO(sendfile, lFiipL)
 //GO(sendfile64, lFiipL)
@@ -1508,7 +1508,7 @@ GO(setrlimit64, iFip)
 // setrpcent
 // setservent
 GOW(setsid, iFv)
-//GOW(setsockopt, iFiiipu)
+GOW(setsockopt, iFiiipu)
 // setsourcefilter
 GO(setspent, vFv)
 // setstate // Weak