Should an application calling MessageBoxA() always terminate by ExitProcess() instead of normal function epilogue?
I've trouble understanding why the "MessageBox
"-program below hangs after executing the ret
instruction on Windows 10 x64.
Debugging the program under GDB, it seems like the Win32 function NtUserSetCursor
is the reason for the behavior, i.e., after executing the ret 0x4
instruction nothing happens.
0x779c2440 in ?? ()
=> 0x779c2440: ff 25 18 12 a5 77 jmp DWORD PTR ds:0x77a51218
(gdb)
0x6c417000 in ?? ()
=> 0x6c417000: ea 09 70 41 6c 33 00 jmp 0x33:0x6c417009
(gdb)
0x7476262c in win32u!NtUserSetCursor () from C:\WINDOWS\SysWoW64\win32u.dll
=> 0x7476262c <win32u!NtUserSetCursor+12>: c2 04 00 ret 0x4
However, if I exit the program using the ExitProcess
there are no problems.
Should an application using the MessageBoxA
function always terminate by ExitProcess
?
Program:
BITS 32
extern _MessageBoxA@16
section .data
_szTitle: db "This is a test", 0x00
_szMsg: db "Hello World!", 0x00
section .text
global _start
_start:
push ebp
mov ebp, esp
push 0x00
push _szTitle
push _szMsg
push 0x00
call _MessageBoxA@16
leave
ret
Assembled and linked:
C:\Users\nlykkei\Desktop>nasm -f win32 test.asm
C:\Users\nlykkei\Desktop>ld -o test.exe test.obj "C:\dev\lib\User32.Lib" --entry _start