To use SEH I written following code:
LABEL test_seh_scopetable
dd -1, test_seh_filter1, test_seh_except1
proc test_seh
push -1
push test_seh_scopetable
push [__except_handler3]; exported by msvcrt.dll
mov eax,[fs:00]
push eax
mov [fs:00],eax; register exception handler
locals .var1:mytype, .var2:mytype
.try1:
mov DWORD [ebp-4],0; set try level
sub eax,eax
mov eax,[eax]; NULL pointer exception raised
mov DWORD [ebp-4],-1; restore try level
jmp test_seh_end_try1
test_seh_filter1:
mov eax,1
retn
test_seh_except1:
mov esp,[ebp-18h]; restore stack pointer
invoke MessageBox ...
; some other processing
mov DWORD [ebp-4],-1; restore try level
test_seh_end_try1:
mov ecx,[ebp-10h]
mov [fs:00],ecx; restore default exception handler
ret
endp
Question: Is it correct to declare local variables after some push instruction other than 'push ebp' generated by 'proc' macro? Is [.var1] and [.var2] point to currect memory locations in such case?