Hi Kevin,
Thanks for your code. Checking the object module with Agner Fog's objconv tool, I saw that the stack was balanced after calling MessageBoxTimeoutA. This should not happen as MessageBoxTimeoutA is a STDCALL function. The code is built as 32-bit in this case.
_main PROC NEAR
push 4000
push 0
push 69699
push offset @1044
push offset @1043
push 0
call _MessageBoxTimeoutA
add esp, 24
push eax
push offset @1042
call _printf
add esp, 8
xor eax, eax
ret
_main ENDP
The solution is inserting the __stdcall statment just before MessageBoxTimeoutA :
/*long __stdcall MessageBoxTimeoutA (HWND, char*, char*, int, int, int);*/
long __stdcall MessageBoxTimeoutA (HWND hwnd,char* Txt,char* Title,int MBType,int Langid,int Milliseconds)
{
typedef int (__stdcall *MBTYPEDEF)(HWND, char *, char *, long, int, int);
static MBTYPEDEF MsgBoxTimeout;
static int Result;
HMODULE HMOD_USER32 = LoadLibrary("user32.dll");
MsgBoxTimeout = (MBTYPEDEF)GetProcAddress(HMOD_USER32, "MessageBoxTimeoutA");
Result=MsgBoxTimeout(hwnd,Txt,Title,MBType,Langid,Milliseconds);
return Result;
}
Objconv reports now the correct output :
_main PROC NEAR
push 4000
push 0
push 69699
push offset @104
push offset @104
push 0
call _MessageBoxTimeoutA@24 ; no stack balance after the call to MessageBoxTimeoutA
push eax
push offset @1042
call _printf
add esp, 8
xor eax, eax
ret
_main ENDP