flat assembler
Message board for the users of flat assembler.

Index > Windows > Structured exception handling

Author
Thread Post new topic Reply to topic
afw2004



Joined: 16 Jun 2005
Posts: 49
Location: Kharkov, Ukraine
afw2004 17 Aug 2006, 08:27
To use SEH I written following code:

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?
Post 17 Aug 2006, 08:27
View user's profile Send private message ICQ Number Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 17 Aug 2006, 12:50
the "proc" macro uses ebp to address local variables and arguments, so you can modify ESP as you want.
Post 17 Aug 2006, 12:50
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.