I write simple code to handling with SEH. First I install handler, next whern handle is called, it change IP to safe place - usually finally part.
mov esi, [argv(.pContext)]
mov edi, [argv(.pErr)]
mov ebx, [edi+ERR.safe_place]
mov [esi+CONTEXT.Eip],ebx
ERR structure (is anywhere defined in .inc?) I augment by "safe_place" field:
NASMX_STRUC ERR
NASMX_RESERVE prev, uint32_t, 1
NASMX_RESERVE handler, uint32_t, 1
NASMX_RESERVE safe_place, uint32_t, 1
NASMX_ENDSTRUC
It works, but I don't know how handle nested try-catch statement in one function, for instance:
void Function1( void )
{
// Set up 3 nested _try levels (thereby forcing 3 scopetable entries)
_try
{
_try
{
_try
{
WalkSEHFrames(); // Now show all the exception frames
}
_except( EXCEPTION_CONTINUE_SEARCH )
{
}
}
_except( EXCEPTION_CONTINUE_SEARCH )
{
}
}
_except( EXCEPTION_CONTINUE_SEARCH )
{
}
}