about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-03-08 20:48:08 +0100
committerptitSeb <sebastien.chev@gmail.com>2021-03-08 20:48:08 +0100
commitd93a243738e98a58a97d6be7959f171e8b23f155 (patch)
treeec4ec3661dcae6398dd4bc59584d8262e076d43a /src
parentfa24bbd96ad1c2c13fe5f87a90c9a2f9fa8c77a1 (diff)
downloadbox64-d93a243738e98a58a97d6be7959f171e8b23f155.tar.gz
box64-d93a243738e98a58a97d6be7959f171e8b23f155.zip
Added a few more libc wrapped functions
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt2
-rw-r--r--src/wrapped/generated/wrapper.c4
-rw-r--r--src/wrapped/generated/wrapper.h2
-rwxr-xr-xsrc/wrapped/wrappedlibc.c68
-rwxr-xr-xsrc/wrapped/wrappedlibc_private.h14
5 files changed, 39 insertions, 51 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index 6c05edc8..0021ec6b 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -225,6 +225,7 @@
 #() fFffp
 #() dFddd
 #() dFddp
+#() lFipL
 #() LFpii
 #() pFEip
 #() pFEpi
@@ -307,6 +308,7 @@
 #() iFEppi
 #() iFEppp
 #() iFEppV
+#() iFEpOu
 #() iFiiii
 #() iFiiiu
 #() iFippi
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index 6f731c8d..e55bd3c8 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -258,6 +258,7 @@ typedef float (*fFfff_t)(float, float, float);
 typedef float (*fFffp_t)(float, float, void*);
 typedef double (*dFddd_t)(double, double, double);
 typedef double (*dFddp_t)(double, double, void*);
+typedef intptr_t (*lFipL_t)(int32_t, void*, uintptr_t);
 typedef uintptr_t (*LFpii_t)(void*, int32_t, int32_t);
 typedef void* (*pFEip_t)(x64emu_t*, int32_t, void*);
 typedef void* (*pFEpi_t)(x64emu_t*, void*, int32_t);
@@ -340,6 +341,7 @@ typedef int32_t (*iFEpip_t)(x64emu_t*, void*, int32_t, void*);
 typedef int32_t (*iFEppi_t)(x64emu_t*, void*, void*, int32_t);
 typedef int32_t (*iFEppp_t)(x64emu_t*, void*, void*, void*);
 typedef int32_t (*iFEppV_t)(x64emu_t*, void*, void*, void*);
+typedef int32_t (*iFEpOu_t)(x64emu_t*, void*, int32_t, uint32_t);
 typedef int32_t (*iFiiii_t)(int32_t, int32_t, int32_t, int32_t);
 typedef int32_t (*iFiiiu_t)(int32_t, int32_t, int32_t, uint32_t);
 typedef int32_t (*iFippi_t)(int32_t, void*, void*, int32_t);
@@ -1076,6 +1078,7 @@ void fFfff(x64emu_t *emu, uintptr_t fcn) { fFfff_t fn = (fFfff_t)fcn; emu->xmm[0
 void fFffp(x64emu_t *emu, uintptr_t fcn) { fFffp_t fn = (fFffp_t)fcn; emu->xmm[0].f[0]=fn(emu->xmm[0].f[0], emu->xmm[1].f[0], (void*)R_RDI); }
 void dFddd(x64emu_t *emu, uintptr_t fcn) { dFddd_t fn = (dFddd_t)fcn; emu->xmm[0].d[0]=fn(emu->xmm[0].d[0], emu->xmm[1].d[0], emu->xmm[2].d[0]); }
 void dFddp(x64emu_t *emu, uintptr_t fcn) { dFddp_t fn = (dFddp_t)fcn; emu->xmm[0].d[0]=fn(emu->xmm[0].d[0], emu->xmm[1].d[0], (void*)R_RDI); }
+void lFipL(x64emu_t *emu, uintptr_t fcn) { lFipL_t fn = (lFipL_t)fcn; R_RAX=(intptr_t)fn((int32_t)R_RDI, (void*)R_RSI, (uintptr_t)R_RDX); }
 void LFpii(x64emu_t *emu, uintptr_t fcn) { LFpii_t fn = (LFpii_t)fcn; R_RAX=(uintptr_t)fn((void*)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX); }
 void pFEip(x64emu_t *emu, uintptr_t fcn) { pFEip_t fn = (pFEip_t)fcn; R_RAX=(uintptr_t)fn(emu, (int32_t)R_RDI, (void*)R_RSI); }
 void pFEpi(x64emu_t *emu, uintptr_t fcn) { pFEpi_t fn = (pFEpi_t)fcn; R_RAX=(uintptr_t)fn(emu, (void*)R_RDI, (int32_t)R_RSI); }
@@ -1158,6 +1161,7 @@ void iFEpip(x64emu_t *emu, uintptr_t fcn) { iFEpip_t fn = (iFEpip_t)fcn; R_RAX=f
 void iFEppi(x64emu_t *emu, uintptr_t fcn) { iFEppi_t fn = (iFEppi_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (int32_t)R_RDX); }
 void iFEppp(x64emu_t *emu, uintptr_t fcn) { iFEppp_t fn = (iFEppp_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)R_RDX); }
 void iFEppV(x64emu_t *emu, uintptr_t fcn) { iFEppV_t fn = (iFEppV_t)fcn; R_RAX=fn(emu, (void*)R_RDI, (void*)R_RSI, (void*)(R_RSP + 8)); }
+void iFEpOu(x64emu_t *emu, uintptr_t fcn) { iFEpOu_t fn = (iFEpOu_t)fcn; R_RAX=fn(emu, (void*)R_RDI, of_convert((int32_t)R_RSI), (uint32_t)R_RDX); }
 void iFiiii(x64emu_t *emu, uintptr_t fcn) { iFiiii_t fn = (iFiiii_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (int32_t)R_RCX); }
 void iFiiiu(x64emu_t *emu, uintptr_t fcn) { iFiiiu_t fn = (iFiiiu_t)fcn; R_RAX=fn((int32_t)R_RDI, (int32_t)R_RSI, (int32_t)R_RDX, (uint32_t)R_RCX); }
 void iFippi(x64emu_t *emu, uintptr_t fcn) { iFippi_t fn = (iFippi_t)fcn; R_RAX=fn((int32_t)R_RDI, (void*)R_RSI, (void*)R_RDX, (int32_t)R_RCX); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index 84d00bb1..7d0feb6d 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -255,6 +255,7 @@ void fFfff(x64emu_t *emu, uintptr_t fnc);
 void fFffp(x64emu_t *emu, uintptr_t fnc);
 void dFddd(x64emu_t *emu, uintptr_t fnc);
 void dFddp(x64emu_t *emu, uintptr_t fnc);
+void lFipL(x64emu_t *emu, uintptr_t fnc);
 void LFpii(x64emu_t *emu, uintptr_t fnc);
 void pFEip(x64emu_t *emu, uintptr_t fnc);
 void pFEpi(x64emu_t *emu, uintptr_t fnc);
@@ -337,6 +338,7 @@ void iFEpip(x64emu_t *emu, uintptr_t fnc);
 void iFEppi(x64emu_t *emu, uintptr_t fnc);
 void iFEppp(x64emu_t *emu, uintptr_t fnc);
 void iFEppV(x64emu_t *emu, uintptr_t fnc);
+void iFEpOu(x64emu_t *emu, uintptr_t fnc);
 void iFiiii(x64emu_t *emu, uintptr_t fnc);
 void iFiiiu(x64emu_t *emu, uintptr_t fnc);
 void iFippi(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index 52826426..f097a437 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -1413,7 +1413,7 @@ EXPORT int32_t my_open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mo
     return ret;
 }
 EXPORT int32_t my___open(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mode) __attribute__((alias("my_open")));
-#if 0
+
 #ifdef DYNAREC
 static int hasDBFromAddress(uintptr_t addr)
 {
@@ -1422,28 +1422,28 @@ static int hasDBFromAddress(uintptr_t addr)
 }
 #endif
 
-EXPORT int32_t my_read(int fd, void* buf, uint32_t count)
-{
-    int ret = read(fd, buf, count);
-#ifdef DYNAREC
-    if(ret!=count && ret>0) {
-        // continue reading...
-        void* p = buf+ret;
-        if(hasDBFromAddress((uintptr_t)p)) {
-            // allow writing the whole block (this happens with HalfLife, libMiles load code directly from .mix and other file like that)
-            unprotectDB((uintptr_t)p, count-ret);
-            int l;
-            do {
-                l = read(fd, p, count-ret); 
-                if(l>0) {
-                    p+=l; ret+=l;
-                }
-            } while(l>0);
-        }
-    }
-#endif
-    return ret;
-}
+//EXPORT int32_t my_read(int fd, void* buf, uint32_t count)
+//{
+//    int ret = read(fd, buf, count);
+//#ifdef DYNAREC
+//    if(ret!=count && ret>0) {
+//        // continue reading...
+//        void* p = buf+ret;
+//        if(hasDBFromAddress((uintptr_t)p)) {
+//            // allow writing the whole block (this happens with HalfLife, libMiles load code directly from .mix and other file like that)
+//            unprotectDB((uintptr_t)p, count-ret);
+//            int l;
+//            do {
+//                l = read(fd, p, count-ret); 
+//                if(l>0) {
+//                    p+=l; ret+=l;
+//                }
+//            } while(l>0);
+//        }
+//    }
+//#endif
+//    return ret;
+//}
 
 EXPORT int32_t my_open64(x64emu_t* emu, void* pathname, int32_t flags, uint32_t mode)
 {
@@ -1579,27 +1579,7 @@ EXPORT FILE* my_fopen64(x64emu_t* emu, const char* path, const char* mode)
 }
 
 
-EXPORT int my_mkstemps64(x64emu_t* emu, char* template, int suffixlen)
-{
-    library_t* lib = my_lib;
-    if(!lib) return 0;
-    void* f = dlsym(lib->priv.w.lib, "mkstemps64");
-    if(f)
-        return ((iFpi_t)f)(template, suffixlen);
-    // implement own version...
-    // TODO: check size of template, and if really XXXXXX is there
-    char* fname = strdup(template);
-    do {
-        strcpy(fname, template);
-        char num[8];
-        sprintf(num, "%06d", rand()%999999);
-        memcpy(fname+strlen(fname)-suffixlen-6, num, 6);
-    } while(!FileExist(fname, -1));
-    int ret = open64(fname, O_EXCL);
-    free(fname);
-    return ret;
-}
-
+#if 0
 EXPORT int32_t my_ftw(x64emu_t* emu, void* pathname, void* B, int32_t nopenfd)
 {
     static iFppi_t f = NULL;
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index 7b27c6fe..4a1da239 100755
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -321,8 +321,8 @@ GOW(_Exit, vFi)
 //GOW(ferror, 
 //GOW(ferror_unlocked, 
 //GO(fexecve, 
-//GOW(fflush, 
-//GOW(fflush_unlocked, 
+GOW(fflush, iFp)
+GO(fflush_unlocked, iFp)
 //GO(__ffs, 
 //GO(ffs, 
 //GOW(ffsl, 
@@ -367,8 +367,8 @@ GOW(_Exit, vFi)
 //GO(fmemopen, 
 //GO(fmtmsg, 
 //GO(fnmatch, 
-//GO(fopen, 
-//GOW(fopen64, 
+GOM(fopen, pFEpp)
+GOM(fopen64, pFEpp)  // Weak
 //GO(fopencookie, 
 //GO(__fork, 
 GOM(fork, iFEv) // Weak
@@ -1258,7 +1258,7 @@ GOW(nl_langinfo_l, pFup)
 //GOW(open, 
 //GO(__open_2, 
 //GOW(__open64, 
-//GOW(open64, 
+GOM(open64, iFEpOu) //Weak
 //GO(__open64_2, 
 //GO(__open64_nocancel, 
 //GOW(openat, 
@@ -1451,8 +1451,8 @@ GOW(puts, iFp)
 //GO(rcmd, 
 //GO(rcmd_af, 
 //DATAB(__rcmd_errstr, 
-//GO(__read, 
-//GO(read, 
+GOW(__read, lFipL)
+GO(read, lFipL)
 //GOW(readahead, 
 //GO(__read_chk, 
 //GOW(readdir,