I finally cracked it down.
- Use the
set_terminate()
function to register a handler for every thread
- In you main function(), make it impossible for external DLLs (event Windows') to successfully call
SetUnhandledExceptionFilter()
. A great article on how to do that here: http://www.debuginfo.com/articles/debugfilters.html#overwrite .
- As for the handle itself, it is quite straightforward:
void Terminate()
{
OutputDebugStringA("Terminate\r\n");
RaiseException(0xE0000010, EXCEPTION_NONCONTINUABLE, 0, 0);
}
Calling RaiseException()
like the above example is enough to make the process crash and produce my mush desired dump.
Just so you know, the problem I was having was:
- The IPHelper Windows API loads dynamically another Windows DLL
- This DLL uses Windows own version of the C runtime (MSVCRT instead of MSVCRT90)
- The new C++ runtime calls
SetUnhandledExceptionFilter()
on startup to catch C++ exceptions. Since the latest filter for C++ exceptions is the one who gets to call the handle set by set_terminate(), my handle wasn't called.