1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
.386
.model flat, stdcall
extern windowsHandler:near
extern x86SEHCleanup:near
extern RtlUnwind@16:near
x86SafeSEH proto
.SAFESEH x86SafeSEH
x86HandleException proto
x86Unwind proto C
.code
x86SafeSEH proc
jmp windowsHandler
x86SafeSEH endp
x86HandleException proc
;; Restore the EH chain.
ASSUME FS:NOTHING
mov DWORD PTR fs:[0], ecx
ASSUME FS:ERROR
;; Return to
push edx
;; Exception, param 3
push eax
;; Current part, param 2
push ebx
;; EH frame, param 1
push ecx
call x86SEHCleanup
;; Remove parameters
add esp, 12
;; Consume the last push.
ret
x86HandleException endp
x86Unwind proc C
push ebp
mov ebp, esp
;; RtlUnwind does not save registers... We need to do that!
;; These are the callee-saved registers we need to care about.
push ebx
push edi
push esi
push 0
push DWORD PTR [ebp+8]
push x86UnwindResume
push DWORD PTR [ebp+12]
call RtlUnwind@16
x86UnwindResume:
pop esi
pop edi
pop ebx
mov ebp, esp
pop ebp
ret
x86Unwind endp
end
|