default rel section .text extern MessageBoxA handler: sub rsp,40 mov rcx,0 lea rdx,[text] lea r8,[caption] mov r9,1 ; MB_OKCANCEL call MessageBoxA sub eax,1 ; incidentally suits as return value ; for exception handler add rsp,40 ret global main main: xor rax,rax mov rax,QWORD[rax] ; cause exception ret main_end: text: db 'OK to rethrow, CANCEL to generate core dump',0 caption:db 'SEGV',0 section .pdata rdata align=4 dd main wrt ..imagebase dd main_end wrt ..imagebase dd xmain wrt ..imagebase section .xdata rdata align=8 xmain: db 9,0,0,0 dd handler wrt ..imagebase section .drectve info db '