From 617fd69bcc04eedef76b41e5dba68e9c1e54f890 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Sun, 13 Oct 2024 11:19:19 +0200 Subject: [BOX32] Reworked alignment for 32bits stacks --- src/tools/callback.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/tools/callback.c') diff --git a/src/tools/callback.c b/src/tools/callback.c index e0df5cfc..3c58bc6e 100644 --- a/src/tools/callback.c +++ b/src/tools/callback.c @@ -25,7 +25,7 @@ uint64_t RunFunction(uintptr_t fnc, int nargs, ...) Push_32(emu, R_RBP); // push ebp R_RBP = R_ESP; // mov ebp, esp - R_ESP -= nargs*4; // need to push in reverse order + R_ESP -= nargs*4+(4-(nargs&3))*4; // need to push in reverse order ptr_t *p = (ptr_t*)from_ptrv(R_ESP); @@ -141,6 +141,7 @@ uint64_t RunFunctionFmt(uintptr_t fnc, const char* fmt, ...) Push_32(emu, R_EBP); // push ebp R_RBP = R_ESP; // mov ebp, esp sizeof_ptr = sizeof(ptr_t); + align = (4-(nargs&3))&3; } else #endif { @@ -336,7 +337,7 @@ uint64_t RunFunctionWithEmu(x64emu_t *emu, int QuitOnLongJump, uintptr_t fnc, in Push_32(emu, R_RBP); // push ebp R_RBP = R_ESP; // mov ebp, esp - R_ESP -= nargs*4; // need to push in reverse order + R_ESP -= nargs*4 + ((4-(nargs&3))&3)*4; // need to push in reverse order ptr_t *p = (ptr_t*)from_ptrv(R_ESP); -- cgit 1.4.1