about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/wrapped32/generated/functions_list.txt5
-rw-r--r--src/wrapped32/generated/wrappedlibctypes32.h3
-rw-r--r--src/wrapped32/generated/wrapper32.c4
-rw-r--r--src/wrapped32/generated/wrapper32.h2
-rwxr-xr-xsrc/wrapped32/wrappedlibc.c27
-rwxr-xr-xsrc/wrapped32/wrappedlibc_private.h4
6 files changed, 39 insertions, 6 deletions
diff --git a/src/wrapped32/generated/functions_list.txt b/src/wrapped32/generated/functions_list.txt
index 91d44b61..ef74009e 100644
--- a/src/wrapped32/generated/functions_list.txt
+++ b/src/wrapped32/generated/functions_list.txt
@@ -604,7 +604,6 @@
 #() pFEXi -> pFEXi
 #() pFEXL -> pFEXL
 #() pFEXp -> pFEXp
-#() pEipi -> pEipi
 #() pEipL -> pEipL
 #() pFipp -> pFipp
 #() pFulu -> pFulu
@@ -927,6 +926,7 @@
 #() LFXCii -> LFXCii
 #() LFXLuu -> LFXLuu
 #() LFXpLp -> LFXpLp
+#() pEEipi -> pEEipi
 #() pFEupp -> pFEupp
 #() pEEpii -> pEEpii
 #() pFEpip -> pFEpip
@@ -1765,6 +1765,7 @@ wrappedlibc:
 - iEp:
   - posix_spawn_file_actions_destroy
   - posix_spawn_file_actions_init
+  - shmdt
   - sysinfo
 - iEO:
 - uEp:
@@ -1890,6 +1891,8 @@ wrappedlibc:
   - writev
 - lEipL:
 - lEppL:
+- pEipi:
+  - shmat
 - pEpii:
 - pEpII:
 - pEpLL:
diff --git a/src/wrapped32/generated/wrappedlibctypes32.h b/src/wrapped32/generated/wrappedlibctypes32.h
index 8b97cddd..d2bb36e1 100644
--- a/src/wrapped32/generated/wrappedlibctypes32.h
+++ b/src/wrapped32/generated/wrappedlibctypes32.h
@@ -79,6 +79,7 @@ typedef int32_t (*iESpV_t)(void*, void*, ...);
 typedef intptr_t (*lEipi_t)(int32_t, void*, int32_t);
 typedef intptr_t (*lEipL_t)(int32_t, void*, uintptr_t);
 typedef intptr_t (*lEppL_t)(void*, void*, uintptr_t);
+typedef void* (*pEipi_t)(int32_t, void*, int32_t);
 typedef void* (*pEpii_t)(void*, int32_t, int32_t);
 typedef void* (*pEpII_t)(void*, int64_t, int64_t);
 typedef void* (*pEpLL_t)(void*, uintptr_t, uintptr_t);
@@ -134,6 +135,7 @@ typedef int32_t (*iEpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void
 	GO(__close_nocancel, iEi_t) \
 	GO(posix_spawn_file_actions_destroy, iEp_t) \
 	GO(posix_spawn_file_actions_init, iEp_t) \
+	GO(shmdt, iEp_t) \
 	GO(sysinfo, iEp_t) \
 	GO(getwc, uES_t) \
 	GO(__sysconf, lEi_t) \
@@ -198,6 +200,7 @@ typedef int32_t (*iEpLiLppp_t)(void*, uintptr_t, int32_t, uintptr_t, void*, void
 	GO(recvmsg, lEipi_t) \
 	GO(sendmsg, lEipi_t) \
 	GO(writev, lEipi_t) \
+	GO(shmat, pEipi_t) \
 	GO(__realpath_chk, pEppi_t) \
 	GO(__strtold_l, KEpBp_a_t) \
 	GO(strtold_l, KEpBp_a_t) \
diff --git a/src/wrapped32/generated/wrapper32.c b/src/wrapped32/generated/wrapper32.c
index e3b50c97..c337ac67 100644
--- a/src/wrapped32/generated/wrapper32.c
+++ b/src/wrapped32/generated/wrapper32.c
@@ -695,7 +695,6 @@ typedef void* (*pFEpX_t)(x64emu_t*, void*, void*);
 typedef void* (*pFEXi_t)(x64emu_t*, void*, int32_t);
 typedef void* (*pFEXL_t)(x64emu_t*, void*, uintptr_t);
 typedef void* (*pFEXp_t)(x64emu_t*, void*, void*);
-typedef void* (*pEipi_t)(int32_t, void*, int32_t);
 typedef void* (*pEipL_t)(int32_t, void*, uintptr_t);
 typedef void* (*pFipp_t)(int32_t, void*, void*);
 typedef void* (*pFulu_t)(uint32_t, intptr_t, uint32_t);
@@ -1018,6 +1017,7 @@ typedef uintptr_t (*LEppLa_t)(void*, void*, uintptr_t, void*);
 typedef uintptr_t (*LFXCii_t)(void*, uint8_t, int32_t, int32_t);
 typedef uintptr_t (*LFXLuu_t)(void*, uintptr_t, uint32_t, uint32_t);
 typedef uintptr_t (*LFXpLp_t)(void*, void*, uintptr_t, void*);
+typedef void* (*pEEipi_t)(x64emu_t*, int32_t, void*, int32_t);
 typedef void* (*pFEupp_t)(x64emu_t*, uint32_t, void*, void*);
 typedef void* (*pEEpii_t)(x64emu_t*, void*, int32_t, int32_t);
 typedef void* (*pFEpip_t)(x64emu_t*, void*, int32_t, void*);
@@ -2348,7 +2348,6 @@ void pFEpX_32(x64emu_t *emu, uintptr_t fcn) { pFEpX_t fn = (pFEpX_t)fcn; R_EAX =
 void pFEXi_32(x64emu_t *emu, uintptr_t fcn) { pFEXi_t fn = (pFEXi_t)fcn; R_EAX = to_ptrv(fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ptri(int32_t, R_ESP + 8))); }
 void pFEXL_32(x64emu_t *emu, uintptr_t fcn) { pFEXL_t fn = (pFEXL_t)fcn; R_EAX = to_ptrv(fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)))); }
 void pFEXp_32(x64emu_t *emu, uintptr_t fcn) { pFEXp_t fn = (pFEXp_t)fcn; R_EAX = to_ptrv(fn(emu, getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8))); }
-void pEipi_32(x64emu_t *emu, uintptr_t fcn) { pEipi_t fn = (pEipi_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); emu->libc_err = errno; }
 void pEipL_32(x64emu_t *emu, uintptr_t fcn) { pEipL_t fn = (pEipL_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)))); emu->libc_err = errno; }
 void pFipp_32(x64emu_t *emu, uintptr_t fcn) { pFipp_t fn = (pFipp_t)fcn; R_EAX = to_ptrv(fn(from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12))); }
 void pFulu_32(x64emu_t *emu, uintptr_t fcn) { pFulu_t fn = (pFulu_t)fcn; R_EAX = to_ptrv(fn(from_ptri(uint32_t, R_ESP + 4), from_long(from_ptri(long_t, R_ESP + 8)), from_ptri(uint32_t, R_ESP + 12))); }
@@ -2671,6 +2670,7 @@ void LEppLa_32(x64emu_t *emu, uintptr_t fcn) { LEppLa_t fn = (LEppLa_t)fcn; errn
 void LFXCii_32(x64emu_t *emu, uintptr_t fcn) { LFXCii_t fn = (LFXCii_t)fcn; R_EAX = to_ulong(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptri(uint8_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12), from_ptri(int32_t, R_ESP + 16))); }
 void LFXLuu_32(x64emu_t *emu, uintptr_t fcn) { LFXLuu_t fn = (LFXLuu_t)fcn; R_EAX = to_ulong(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ulong(from_ptri(ulong_t, R_ESP + 8)), from_ptri(uint32_t, R_ESP + 12), from_ptri(uint32_t, R_ESP + 16))); }
 void LFXpLp_32(x64emu_t *emu, uintptr_t fcn) { LFXpLp_t fn = (LFXpLp_t)fcn; R_EAX = to_ulong(fn(getDisplay(from_ptriv(R_ESP + 4)), from_ptriv(R_ESP + 8), from_ulong(from_ptri(ulong_t, R_ESP + 12)), from_ptriv(R_ESP + 16))); }
+void pEEipi_32(x64emu_t *emu, uintptr_t fcn) { pEEipi_t fn = (pEEipi_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(emu, from_ptri(int32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); emu->libc_err = errno; }
 void pFEupp_32(x64emu_t *emu, uintptr_t fcn) { pFEupp_t fn = (pFEupp_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptri(uint32_t, R_ESP + 4), from_ptriv(R_ESP + 8), from_ptriv(R_ESP + 12))); }
 void pEEpii_32(x64emu_t *emu, uintptr_t fcn) { pEEpii_t fn = (pEEpii_t)fcn; errno = emu->libc_err; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptri(int32_t, R_ESP + 12))); emu->libc_err = errno; }
 void pFEpip_32(x64emu_t *emu, uintptr_t fcn) { pFEpip_t fn = (pFEpip_t)fcn; R_EAX = to_ptrv(fn(emu, from_ptriv(R_ESP + 4), from_ptri(int32_t, R_ESP + 8), from_ptriv(R_ESP + 12))); }
diff --git a/src/wrapped32/generated/wrapper32.h b/src/wrapped32/generated/wrapper32.h
index cdd1382d..c30933a9 100644
--- a/src/wrapped32/generated/wrapper32.h
+++ b/src/wrapped32/generated/wrapper32.h
@@ -645,7 +645,6 @@ void pFEpX_32(x64emu_t *emu, uintptr_t fnc);
 void pFEXi_32(x64emu_t *emu, uintptr_t fnc);
 void pFEXL_32(x64emu_t *emu, uintptr_t fnc);
 void pFEXp_32(x64emu_t *emu, uintptr_t fnc);
-void pEipi_32(x64emu_t *emu, uintptr_t fnc);
 void pEipL_32(x64emu_t *emu, uintptr_t fnc);
 void pFipp_32(x64emu_t *emu, uintptr_t fnc);
 void pFulu_32(x64emu_t *emu, uintptr_t fnc);
@@ -968,6 +967,7 @@ void LEppLa_32(x64emu_t *emu, uintptr_t fnc);
 void LFXCii_32(x64emu_t *emu, uintptr_t fnc);
 void LFXLuu_32(x64emu_t *emu, uintptr_t fnc);
 void LFXpLp_32(x64emu_t *emu, uintptr_t fnc);
+void pEEipi_32(x64emu_t *emu, uintptr_t fnc);
 void pFEupp_32(x64emu_t *emu, uintptr_t fnc);
 void pEEpii_32(x64emu_t *emu, uintptr_t fnc);
 void pFEpip_32(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped32/wrappedlibc.c b/src/wrapped32/wrappedlibc.c
index e4bfbaf8..49bd525c 100755
--- a/src/wrapped32/wrappedlibc.c
+++ b/src/wrapped32/wrappedlibc.c
@@ -40,6 +40,8 @@
 #include <sys/sysinfo.h>
 #include <sys/time.h>
 #include <regex.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
 
 #include "wrappedlibs.h"
 
@@ -3138,6 +3140,31 @@ EXPORT void my32_regfree(x64emu_t* emu, void* p)
     regfree(&p_l);
 }
 
+EXPORT void* my32_shmat(x64emu_t*emu, int shmid, void* shmaddr, int flags)
+{
+    size_t sz = 0;
+    {
+        // get the size of the shmmemory
+        struct shmid_ds ds = {0};
+        if(shmctl(shmid, IPC_STAT, &ds)>=0)
+            sz = ds.shm_segsz;
+    }
+    if(!shmaddr) {
+        shmaddr = find31bitBlockNearHint(shmaddr, sz, 0);
+    }
+    void* ret = shmat(shmid, shmaddr, flags);
+    /*if(ret!=MAP_FAILED) {
+        would need to keep size somewhere, there is no way to get it back when doing shmdt
+        setProtection_mmap(ret, sz, (flags&SHM_RDONLY)?PROT_READ:(PROT_READ|PROT_WRITE));
+    }*/
+    return ret;
+}
+
+EXPORT int my32_shmdt(x64emu_t* emu, void* addr)
+{
+    return shmdt(addr);
+}
+
 #if 0
 #ifndef __NR_memfd_create
 #define MFD_CLOEXEC		    0x0001U
diff --git a/src/wrapped32/wrappedlibc_private.h b/src/wrapped32/wrappedlibc_private.h
index 247c20f3..307bbff8 100755
--- a/src/wrapped32/wrappedlibc_private.h
+++ b/src/wrapped32/wrappedlibc_private.h
@@ -1543,9 +1543,9 @@ GOW(setvbuf, iESpiL)
 //GO(setxattr, iEpppui)
 // sgetspent
 // sgetspent_r  // Weak
-GOW(shmat, pEipi)
+GOWM(shmat, pEEipi)
 GOW(shmctl, iEiip)
-GOW(shmdt, iEp)
+GOWM(shmdt, iEEp)
 GOW(shmget, iEiLi)
 GOW(shutdown, iEii)
 GOWM(sigaction, iEEipp)    //%%