I wanted to catch SEH exception globally i.e. if a SEH exception occurs in a thread of an object of ClassB called in ClassA, is it possible to catch the SEH exception in Main (ClassA instance is called in Main)?
I have been using SetUnhandledExceptionFilter in Main to catch these SEH exceptions but I failed to catch for this case particularly. Since there are multiple classes and program is multi-threaded, I am looking for options to catch it on a global level. (Note: The compiler has been set to /EHa flag.)
MyUnhandledExceptionFilter(Exception ptr){
//Handle SEH exception
}
ClassA
{
//Some stuff ...
ClassB objB.DoSomething();
}
ClassB{
DoSomething(){
CreateThread(Threadfunc)
};
ThreadFunc(){
//SEH exception occurs;
}
}
int main(){
SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
try
{
ClassA objA::run();
}
catch(exception ex){
//Log here
}
}
Have a look at Vectored Exception Handling:
For example: