That Structured Exception Handling macros dont work. Typing

TRY
...
FINALLY
...
ENDF

and nothing happens if there is an exception like access violation that kills the prog the FINALLY part wil NOT be executed. :(
Posted on 2002-05-21 13:47:22 by Jayrome
Worked for me under win2000:



.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib

include seh.inc

.code

start:

TRY
mov ebx,0BFF70000h ; Try to write in kernel (will
mov eax,012345678h ; generate an exception)
xchg eax,[ebx]
FINALLY
invoke MessageBox, 0, 0, 0, 0
ENDF

invoke ExitProcess, 0

end start


The only problem is that you can only put one CATCH block per procedure. The macros need to be modified to something like @@handler&count to make the labels unique. Don't know enough about masm macros to code all the changes.
Posted on 2002-05-22 15:47:29 by grv575
I used an Win API call when trying to process some bitmap data and it just made an Access Violation after which my app shut down without the FINALLY block. :mad:
Posted on 2002-05-23 03:06:41 by Jayrome
Check your stack. Remember all the exception handler is doing is pushing the address of @@handler:, so that when an exception occurs , that's the label where execution continues.

Try enclosing all your api calls with PrintDword esp and make sure the values match before and after the call. If any of the api calls use C calling convention, make sure you use either the invoke macro or correct the stack after the call.

Then again the exception handler might only work on the code you write (which is surrounded by the TRY block) and not on the code within an api function. Not too sure.
Posted on 2002-05-23 08:07:10 by grv575