about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2025-05-29 17:41:36 +0800
committerGitHub <noreply@github.com>2025-05-29 11:41:36 +0200
commit67b15f09cfdde0053be16c99ebbf5db20e61c1e5 (patch)
tree6a3bbe89cfd172eac56b3bb016f3d807a510970e /src
parenta0693590bd9c84844bfa767ffe51d7da916df3d5 (diff)
downloadbox64-67b15f09cfdde0053be16c99ebbf5db20e61c1e5.tar.gz
box64-67b15f09cfdde0053be16c99ebbf5db20e61c1e5.zip
[WOW64] Added more missing pieces and the interpreter works (#2682)
* [WOW64] Added more missing pieces and the interpreter works

Ported from AndreRH/hangover

* review
Diffstat (limited to 'src')
-rw-r--r--src/dynarec/arm64/dynarec_arm64_00.c6
-rw-r--r--src/emu/x64run.c6
-rw-r--r--src/os/emit_signal_wine.c54
-rw-r--r--src/os/os_wine.c8
4 files changed, 61 insertions, 13 deletions
diff --git a/src/dynarec/arm64/dynarec_arm64_00.c b/src/dynarec/arm64/dynarec_arm64_00.c
index 59a4c5e3..6feae03c 100644
--- a/src/dynarec/arm64/dynarec_arm64_00.c
+++ b/src/dynarec/arm64/dynarec_arm64_00.c
@@ -2646,14 +2646,14 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
             break;
         case 0xCD:
             u8 = F8;
-#ifdef _WIN32
+            #ifdef _WIN32
             NOTEST(x1);
             SMEND();
             GETIP(addr);
             STORE_XEMU_CALL(xRIP);
             MOV32w(x1, u8);
             LDRx_U12(xR8, xEmu, offsetof(x64emu_t, win64_teb));
-            CALL_S(x86Int, -1);
+            CALL_S(native_int, -1);
             LOAD_XEMU_CALL(xRIP);
             TABLE64(x3, addr); // expected return address
             CMPSx_REG(xRIP, x3);
@@ -2664,7 +2664,7 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
             LOAD_XEMU_REM();
             jump_to_epilog(dyn, 0, xRIP, ninst);
             break;
-#endif
+            #endif
             if(box64_wine && (u8==0x2D || u8==0x2C || u8==0x29)) {
                 INST_NAME("INT 29/2c/2d");
                 // lets do nothing
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index aaf27b18..078a7ea9 100644
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -1531,6 +1531,11 @@ x64emurun:
             break;
         case 0xCD:                      /* INT n */
             tmp8u = F8;
+            #ifdef _WIN32
+            EmitInterruption(emu, tmp8u, (void*)R_RIP);
+            STEP;
+            addr = R_RIP;
+            #else
             // this is a privilege opcode...
             if(box64_wine && tmp8u==0x2D) {
                 // lets ignore the INT 2D
@@ -1567,6 +1572,7 @@ x64emurun:
                 STEP2;
                 #endif
             }
+            #endif
             break;
         case 0xCE:                      /* INTO */
             if(!rex.is32bits) {
diff --git a/src/os/emit_signal_wine.c b/src/os/emit_signal_wine.c
index 0539a818..ef0a0f65 100644
--- a/src/os/emit_signal_wine.c
+++ b/src/os/emit_signal_wine.c
@@ -1,22 +1,64 @@
+/*
+ * Copyright 2022-2025 André Zwing
+ * Copyright 2023 Alexandre Julliard
+ */
+#include <signal.h>
+#include <windows.h>
+#include <winternl.h>
+
 #include "x64emu.h"
+#include "debug.h"
 #include "custommem.h"
+#include "wine/compiler.h"
 
 void EmitSignal(x64emu_t* emu, int sig, void* addr, int code)
 {
-    // FIXME
+    EXCEPTION_RECORD rec;
+
+    switch (sig) {
+        case SIGILL:
+            printf_log(LOG_DEBUG, "SIGILL at %p with code %d\n", addr, code);
+            rec.ExceptionCode = STATUS_ILLEGAL_INSTRUCTION;
+            break;
+        case SIGSEGV:
+            printf_log(LOG_DEBUG, "SIGSEGV at %p with code %d\n", addr, code);
+            rec.ExceptionCode = STATUS_ACCESS_VIOLATION;
+            break;
+        default:
+            printf_log(LOG_INFO, "Warning, unknown signal %d at %p with code %d\n", sig, addr, code);
+            rec.ExceptionCode = STATUS_ACCESS_VIOLATION;
+            break;
+    }
+    rec.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
+    rec.ExceptionRecord = NULL;
+    rec.ExceptionAddress = addr;
+    rec.NumberParameters = 0;
+    RtlRaiseException(&rec);
 }
 
 void CheckExec(x64emu_t* emu, uintptr_t addr)
 {
-    // FIXME
 }
 
-void EmitInterruption(x64emu_t* emu, int num, void* addr)
+void EmitDiv0(x64emu_t* emu, void* addr, int code)
 {
-    // FIXME
+    EXCEPTION_RECORD rec;
+    rec.ExceptionCode = EXCEPTION_INT_DIVIDE_BY_ZERO;
+    rec.ExceptionFlags = EXCEPTION_NONCONTINUABLE;
+    rec.ExceptionRecord = NULL;
+    rec.ExceptionAddress = addr;
+    rec.NumberParameters = 0;
+    RtlRaiseException(&rec);
 }
 
-void EmitDiv0(x64emu_t* emu, void* addr, int code)
+void EmuInt3(void* emu, void* addr)
 {
-    // FIXME
+    EXCEPTION_RECORD rec;
+
+    rec.ExceptionCode = STATUS_BREAKPOINT;
+    rec.ExceptionFlags = 0;
+    rec.ExceptionRecord = NULL;
+    rec.ExceptionAddress = addr;
+    rec.NumberParameters = 0;
+    RtlRaiseException(&rec);
 }
diff --git a/src/os/os_wine.c b/src/os/os_wine.c
index 937371c7..83be99b2 100644
--- a/src/os/os_wine.c
+++ b/src/os/os_wine.c
@@ -5,6 +5,7 @@
 #include <winternl.h>
 
 #include "os.h"
+#include "debug.h"
 #include "wine/debug.h"
 
 #define HandleToULong(h) ((ULONG)(ULONG_PTR)(h))
@@ -39,22 +40,21 @@ void* GetSeg43Base()
 
 void* GetSegmentBase(uint32_t desc)
 {
-    // FIXME
+    printf_log(LOG_NONE, "GetSegmentBase NYI\n");
     return NULL;
 }
 
-void EmuInt3(void* emu, void* addr) { }
 void* EmuFork(void* emu, int forktype) { return NULL; }
 
 
 void EmuX64Syscall(void* emu)
 {
-    // FIXME
+    printf_log(LOG_NONE, "EmuX64Syscall NYI\n");
 }
 
 void EmuX86Syscall(void* emu)
 {
-    // FIXME
+    printf_log(LOG_NONE, "EmuX86Syscall NYI\n");
 }
 
 const char* GetBridgeName(void* p)