; Listing7-2.asm ; ; A program that demonstrates exception-handling ; failure in a program that properly sets up the ; stack. option casemap:none .nolist include aoalib.inc includelib aoalib.lib .list .const ; Program title: align word ttlStr byte "Listing 7-2", 0 .code align 8 qword ? ;Also for hot patching goodSEHFunc proc frame ; start of prolog db 48h ;REX prefix for hot patching. push rbp ; save previous frame pointer .pushreg rbp ; encode unwind info mov rbp, rsp ; set new frame pointer .setframe rbp, 0 ; encode frame pointer sub rsp, 40h .allocstack 40h .endprolog xor rax, rax mov rax, [rax] ; cause exception ; Epilog: lea rsp, [rbp] pop rbp ret goodSEHFunc endp ;-------------------------------------------------- ; ; Here is the main assembly language function. public asmMain align 8 qword ? ;For hot patching asmMain proc frame db 48h ;REX prefix for hot patching. push rbp ; save previous frame pointer .pushreg rbp ; encode unwind info mov rbp, rsp ; set new frame pointer .setframe rbp, 0 ; encode frame pointer sub rsp, 400h .allocstack 400h .endprolog call goodSEHFunc lea rsp, [rbp] pop rbp ret asmMain endp end