joe wrote
Not at all. Those are asynchronous/OOB errors and the C++ machinery
is not designed to interact with that.
SEH is a Microsoft thing that is orthogonal to C++ exceptions.
Well apologize again if I was ambiguous, but I did not say that C++
(trylevel only, syncronous) exception frames were designed to work (persay)
with SEH (trylevel and scopetables asyncronous).
Again to try and make it clearer, " all " exception mechanisms in a
MS VS windows app (with the exception possibly of NET JIT code, I
don't know about that ) run on ( but expands beyond ) the basic Frame
handler chain found at FS:[0] . Granted the compiler adds much more
unwind and trylevel code but it all functions on top of the basic chained
system of installed handler frames at FS:[0]
You can have both in the C++ exceptions and SEH exceptions in the same
program but the compiler won't let you have both in the same function.
In fact every windows app (mfc included ) has an SEH _try and _except
in the WinMainCRTStartup( ) code to cover the call to your compiler's
winmain (or console main ) function. This covers the whole windows app
for any SEH exception if not handled by your app's code. This CRT startup
function is where the final handler ( the Unhandled Exception dialog
with an option to send to MS ) kicks in " if " you have not handled it before
it gets to there. If you have not handled it with a specific C++ ,
catch( DivideByZero& E ) or a catch(...) or an SEH _except or with
SetUnhandledExceptionFilter( YourCustomFilter);
This CRT startup is in every MS VS windows app whether you use
C++ try catch or not or use both SEH in one function and C++ another.
Here the difference in stack frames
MS VC C++'s (try catch) Frame
ebp-C [ebp-C] [ebp-8] [ebp-4] [ebp-0] ebp-0
| PrevFrame|Handler | TryLevel |CallerEBP | FrameEBP
Frame-> [Frm +0] [Frm+4] [Frm+8h] [Frm+Ch] <-Frm+Ch
MS VC CRT's (SEH _try _except) Frame (also CRT final handler)
ebp-10 [ebp-10] [ebp-C] [ebp-8] [ebp-4] [ebp-0] ebp-0
PrevFrame | Handler|ScopeTable|TryLevel|CallerEBP|FrameEBP
Framer->[Frm+0] [Frm+4] [Frm+8h] [Frm+Ch] [Frm+10h]<-Frm+10h
Scopetable[0] PrevTryLevel: @ FFFFFFFF (always preceeds a trylevel 0)
CRTFilterFunc: @ 00401CA8 (depends on compile)
CRT__except block: @ 00401CC3 (depends on compile)
Win32 OS system final Handler's Frame (the basic frame) covers all processes
started and will surface when say an assembler program with no CRT startup
has an exception.
| PrevFrame|Handler |
Framer->[ Frm+0] [ Frm+4]
If a compiler (or you if you write your own custom handler) wants to do
exceptions on win32 it must play by the frame rules since when an exception
occurs the system walks the chain and calls each (and every handler ) up until
a handler is found that will handle the exception, when that is found based on
it's return, the system then calls each frame again ( if it is on the stack below
the frame that agreed to handle the E ) with the flag set to unwind.
--------------------------------
// pasted right out of my version of CRT0.C //
wWinMainCRTStartup()
{
/*
* Guard the remainder of the initialization code and the call
* to user's main, or WinMain, function in a __try/__except
* statement.
*/
__try
{
......
......
exit(mainret); // you will come here if normal exit OR you
// handled any exception but still exited.
}
// This is CRTs final handler frame, here if exception not handled.
__except ( _XcptFilter(GetExceptionCode(), GetExceptionInformation()) )
{
/*
* Should never reach here
*/
_exit( GetExceptionCode() );
} /* end of try - except */
}