about summary refs log tree commit diff stats
path: root/src/emu
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2021-07-17 18:03:23 +0200
committerptitSeb <sebastien.chev@gmail.com>2021-07-17 18:03:23 +0200
commit139d5128a0afbd86b0dae43f59f86e9c63e810b6 (patch)
tree434fcdd57587dddcfd3d342f0812692acf6bacb9 /src/emu
parent7b8bd8a2855b8c1f23057d0b0ae09b85d0120394 (diff)
downloadbox64-139d5128a0afbd86b0dae43f59f86e9c63e810b6.tar.gz
box64-139d5128a0afbd86b0dae43f59f86e9c63e810b6.zip
Made IRETQ to restore RSP and SS ([DYNAREC] too) (helps Wine64 exceptions handling)
Diffstat (limited to 'src/emu')
-rwxr-xr-xsrc/emu/x64run.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index 782ed520..2699897a 100755
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -46,6 +46,11 @@ int Run(x64emu_t *emu, int step)
 
     if(emu->quit)
         return 0;
+    if(R_RIP==0) {
+        emu->quit = 1;
+        printf_log(LOG_INFO, "Ask to run at NULL, quit silently\n");
+        return 0;
+    }
 
     //ref opcode: http://ref.x64asm.net/geek32.html#xA1
     printf_log(LOG_DEBUG, "Run X86 (%p), RIP=%p, Stack=%p\n", emu, (void*)R_RIP, (void*)R_RSP);
@@ -1067,6 +1072,10 @@ x64emurun:
             emu->segs[_CS] = Pop(emu)&0xffff;
             emu->segs_serial[_CS] = 0;
             emu->eflags.x64 = ((Pop(emu) & 0x3F7FD7)/* & (0xffff-40)*/ ) | 0x2; // mask off res2 and res3 and on res1
+            tmp64u = Pop(emu);  //RSP
+            emu->segs[_SS] = Pop(emu)&0xffff;
+            emu->segs_serial[_SS] = 0;
+            R_RSP= tmp64u;
             RESET_FLAGS(emu);
             goto fini;      // exit, to recompute CS if needed
             break;