Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/wrapped/wrappedlibc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4099,6 +4099,19 @@ EXPORT void my_exit(x64emu_t* emu, int code)
emu->flags.quitonexit = 2;
return;
}
if(emu->size_stack && emu->init_stack) {
uintptr_t sp = R_RSP;
uintptr_t stack_lo = (uintptr_t)emu->init_stack;
uintptr_t stack_hi = stack_lo + emu->size_stack;
if(sp < stack_lo || sp > stack_hi) {
printf_log(LOG_INFO, "exit(%d) called from alternate stack "
"(RSP=%p, main stack=%p--%p), converting to emu quit\n",
code, (void*)sp, (void*)stack_lo, (void*)stack_hi);
emu->quit = 1;
R_EAX = code;
return;
}
}
emu->quit = 1;
box64_exit_code = code;
endBox64();
Expand Down
Loading