about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-09-04 12:19:43 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-09-04 12:19:43 +0200
commite8e966cd802f94f6b4012c820ad590bbd78b4a55 (patch)
tree1c30d16b78e0bea6c1be80ad2888b6215ea308ed /src
parent8b80cc328f6501119bacfc1c19a1080d493f5093 (diff)
downloadbox64-e8e966cd802f94f6b4012c820ad590bbd78b4a55.tar.gz
box64-e8e966cd802f94f6b4012c820ad590bbd78b4a55.zip
Added wrapped iopl that answer 'unsuported operation' for now
Diffstat (limited to 'src')
-rw-r--r--src/wrapped/generated/functions_list.txt3
-rw-r--r--src/wrapped/generated/wrappedlibctypes.h2
-rw-r--r--src/wrapped/generated/wrapper.c2
-rw-r--r--src/wrapped/generated/wrapper.h1
-rwxr-xr-xsrc/wrapped/wrappedlibc.c19
-rwxr-xr-xsrc/wrapped/wrappedlibc_private.h2
6 files changed, 28 insertions, 1 deletions
diff --git a/src/wrapped/generated/functions_list.txt b/src/wrapped/generated/functions_list.txt
index aac9090e..7ff63ed0 100644
--- a/src/wrapped/generated/functions_list.txt
+++ b/src/wrapped/generated/functions_list.txt
@@ -111,6 +111,7 @@
 #() vFpS
 #() vFSi
 #() cFpp
+#() iFEi
 #() iFEp
 #() iFwp
 #() iFii
@@ -1649,6 +1650,8 @@ wrappedlibc:
 - iFv:
   - fork
   - vfork
+- iFi:
+  - iopl
 - iFp:
   - _setjmp
   - getcontext
diff --git a/src/wrapped/generated/wrappedlibctypes.h b/src/wrapped/generated/wrappedlibctypes.h
index 78962777..1cd6cfec 100644
--- a/src/wrapped/generated/wrappedlibctypes.h
+++ b/src/wrapped/generated/wrappedlibctypes.h
@@ -14,6 +14,7 @@
 typedef void (*vFv_t)(void);
 typedef void (*vFp_t)(void*);
 typedef int64_t (*iFv_t)(void);
+typedef int64_t (*iFi_t)(int64_t);
 typedef int64_t (*iFp_t)(void*);
 typedef intptr_t (*lFv_t)(void);
 typedef uintptr_t (*LFL_t)(uintptr_t);
@@ -81,6 +82,7 @@ typedef int64_t (*iFpippppp_t)(void*, int64_t, void*, void*, void*, void*, void*
 	GO(__cxa_finalize, vFp_t) \
 	GO(fork, iFv_t) \
 	GO(vfork, iFv_t) \
+	GO(iopl, iFi_t) \
 	GO(_setjmp, iFp_t) \
 	GO(getcontext, iFp_t) \
 	GO(setcontext, iFp_t) \
diff --git a/src/wrapped/generated/wrapper.c b/src/wrapped/generated/wrapper.c
index dde83290..60359ed8 100644
--- a/src/wrapped/generated/wrapper.c
+++ b/src/wrapped/generated/wrapper.c
@@ -145,6 +145,7 @@ typedef void (*vFpp_t)(void*, void*);
 typedef void (*vFpS_t)(void*, void*);
 typedef void (*vFSi_t)(void*, int64_t);
 typedef int8_t (*cFpp_t)(void*, void*);
+typedef int64_t (*iFEi_t)(x64emu_t*, int64_t);
 typedef int64_t (*iFEp_t)(x64emu_t*, void*);
 typedef int64_t (*iFwp_t)(int16_t, void*);
 typedef int64_t (*iFii_t)(int64_t, int64_t);
@@ -1673,6 +1674,7 @@ void vFpp(x64emu_t *emu, uintptr_t fcn) { vFpp_t fn = (vFpp_t)fcn; fn((void*)R_R
 void vFpS(x64emu_t *emu, uintptr_t fcn) { vFpS_t fn = (vFpS_t)fcn; fn((void*)R_RDI, io_convert((void*)R_RSI)); }
 void vFSi(x64emu_t *emu, uintptr_t fcn) { vFSi_t fn = (vFSi_t)fcn; fn(io_convert((void*)R_RDI), (int64_t)R_RSI); }
 void cFpp(x64emu_t *emu, uintptr_t fcn) { cFpp_t fn = (cFpp_t)fcn; R_RAX=fn((void*)R_RDI, (void*)R_RSI); }
+void iFEi(x64emu_t *emu, uintptr_t fcn) { iFEi_t fn = (iFEi_t)fcn; R_RAX=(int64_t)fn(emu, (int64_t)R_RDI); }
 void iFEp(x64emu_t *emu, uintptr_t fcn) { iFEp_t fn = (iFEp_t)fcn; R_RAX=(int64_t)fn(emu, (void*)R_RDI); }
 void iFwp(x64emu_t *emu, uintptr_t fcn) { iFwp_t fn = (iFwp_t)fcn; R_RAX=(int64_t)fn((int16_t)R_RDI, (void*)R_RSI); }
 void iFii(x64emu_t *emu, uintptr_t fcn) { iFii_t fn = (iFii_t)fcn; R_RAX=(int64_t)fn((int64_t)R_RDI, (int64_t)R_RSI); }
diff --git a/src/wrapped/generated/wrapper.h b/src/wrapped/generated/wrapper.h
index 4b30ecc0..30f0638e 100644
--- a/src/wrapped/generated/wrapper.h
+++ b/src/wrapped/generated/wrapper.h
@@ -144,6 +144,7 @@ void vFpp(x64emu_t *emu, uintptr_t fnc);
 void vFpS(x64emu_t *emu, uintptr_t fnc);
 void vFSi(x64emu_t *emu, uintptr_t fnc);
 void cFpp(x64emu_t *emu, uintptr_t fnc);
+void iFEi(x64emu_t *emu, uintptr_t fnc);
 void iFEp(x64emu_t *emu, uintptr_t fnc);
 void iFwp(x64emu_t *emu, uintptr_t fnc);
 void iFii(x64emu_t *emu, uintptr_t fnc);
diff --git a/src/wrapped/wrappedlibc.c b/src/wrapped/wrappedlibc.c
index fdd2ca89..5a6237ff 100755
--- a/src/wrapped/wrappedlibc.c
+++ b/src/wrapped/wrappedlibc.c
@@ -65,6 +65,7 @@ const char* libcName = "libc.so.6";
 
 static library_t* my_lib = NULL;
 
+typedef int (*iFi_t)(int);
 typedef int (*iFL_t)(unsigned long);
 typedef void (*vFpp_t)(void*, void*);
 typedef void (*vFipp_t)(int32_t, void*, void*);
@@ -2453,6 +2454,24 @@ EXPORT void my_backtrace_symbols_fd(x64emu_t* emu, uintptr_t* buffer, int size,
     }
 }
 
+EXPORT int my_iopl(x64emu_t* emu, int level)
+{
+    // Set I/O permission (so access IN/OUT opcodes) Default is 0. Can Set to 0..3
+    // set permission for all 65536 ports addresses
+    // note ioperm can set individual permission
+    /*static iFi_t real_iopl = NULL;
+    static int searched = 0;
+    if(!searched) {
+        searched = 1;
+        real_iopl = (iFi_t)dlsym(my_lib, "iopl");
+    }
+    if(real_iopl)
+        return real_iopl(level);*/
+    // For now, lets just return "unsupported"
+    errno = ENOSYS;
+    return -1;
+}
+
 EXPORT char** my_environ = NULL;
 EXPORT char** my__environ = NULL;
 EXPORT char** my___environ = NULL;  // all aliases
diff --git a/src/wrapped/wrappedlibc_private.h b/src/wrapped/wrappedlibc_private.h
index aa2611d6..275d89de 100755
--- a/src/wrapped/wrappedlibc_private.h
+++ b/src/wrapped/wrappedlibc_private.h
@@ -821,7 +821,7 @@ DATA(_IO_list_all, sizeof(void*))
 //GO(_IO_padn, 
 //GO(_IO_peekc_locked, 
 GO(ioperm, iFLLi)
-GO(iopl, iFi)
+GOM(iopl, iFEi)     //Not always present
 //GO(_IO_popen, 
 //GO(_IO_printf, 
 //GO(_IO_proc_close,