In the MSVC compiler, C ++ exceptions are copied to the native environment to exclude Windows (SEH, Structured Exception Handling). There is a rather large impedance mismatch, although the concept of an exception filter does not have a good match in C ++. By the time the catch handler catches the exception, the SEH exception is already being processed and the stack is unwound. Information EXCEPTION_POINTERS - gonzo. Exception filters actually exist because they filter for a specific type that you want to catch, however they are automatically generated by the compiler. There is no reasonable C ++ syntax to make them useful.
You need to plunge into compiler support for handling SEH exceptions. Use the keywords __try, __except ( __finally optional), and your filter will catch the exception code for C ++ exception, 0xe04d5343 ("MSC"). However, you lose the ability to catch a certain type of C ++ exception that is in a CRT without a source. Put a C ++ try inside __try to fix this, so your __except only sees exceptions that C ++ code hasn't filtered.
Using SetUnhandledExceptionFilter () is another way to do this btw, you really should consider it valid as the ultimate support for any unhandled exception, regardless of code location. This is the best way to create a failed drive mini drive. And last but not least, creating a mini-drive of a failed application inside the process itself is not the best approach. There are many chances that this will not work; the state of the process can be badly damaged. One of the failure modes has a process lock. It is unlikely, given that heap damage is a very common cause of a crash. Correct this with a "defensive process", use a named event to signal it to create a mini-drive. Your exception filter should only set an event that always works.
source share