diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2024-10-13 11:19:19 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2024-10-13 11:19:19 +0200 |
| commit | 617fd69bcc04eedef76b41e5dba68e9c1e54f890 (patch) | |
| tree | 10f7077326da96d2d4a94c63da1298af60080cea /src | |
| parent | 5fcd9d45a3e6f35a197d2c6be951b811cb1cb36c (diff) | |
| download | box64-617fd69bcc04eedef76b41e5dba68e9c1e54f890.tar.gz box64-617fd69bcc04eedef76b41e5dba68e9c1e54f890.zip | |
[BOX32] Reworked alignment for 32bits stacks
Diffstat (limited to 'src')
| -rwxr-xr-x | src/libtools/threads32.c | 1 | ||||
| -rw-r--r-- | src/tools/callback.c | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/libtools/threads32.c b/src/libtools/threads32.c index 0ba81b77..067a4861 100755 --- a/src/libtools/threads32.c +++ b/src/libtools/threads32.c @@ -140,6 +140,7 @@ static void* pthread_routine(void* p) R_EBP = R_ESP; // MOV BP, SP R_ESP -= 32; // guard area R_ESP &=~15; + R_ESP -= 3*4; // prepare alignment Push_32(emu, to_ptrv(et->arg)); PushExit_32(emu); R_EIP = to_ptr(et->fnc); 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); |