0

Say you have the following global exception handlers/filters:

LONG WINAPI UnhandledExceptionFilter(PEXCEPTION_POINTERS exception)
{
    return EXCEPTION_CONTINUE_SEARCH;
}

LONG WINAPI VectoredExceptionHandler(PEXCEPTION_POINTERS exception)
{
    return EXCEPTION_CONTINUE_SEARCH;
}

Called using:

SetUnhandledExceptionFilter(UnhandledExceptionFilter);
AddVectoredExceptionHandler(1, VectoredExceptionHandler);

I might have a separate thread throw an exception back to the main thread that I use to set the filter or handler...but in the logic for UnhandledExceptionFilter and VectoredExceptionHandler, how do I get the HANDLE to the thread that threw the exception?

Alexandru
  • 12,264
  • 17
  • 113
  • 208
  • 4
    The callback is made on the same thread that suffered the exception, so it is simply OpenThread with GetCurrentThreadId to get a handle. "Throw an exception back to the main thread" is meaningless, exceptions cannot hop across threads. – Hans Passant Mar 19 '14 at 14:58
  • @HansPassant Why does the stack partially unwind itself after a global exception occurs, especially if a separate thread throws an exception? (see http://stackoverflow.com/questions/22487887/why-doesnt-stack-walking-work-properly-when-using-setunhandledexceptionfilter/22489045?noredirect=1#comment34231884_22489045) – Alexandru Mar 19 '14 at 15:03
  • http://meta.stackexchange.com/questions/43478/exit-strategies-for-chameleon-questions – Hans Passant Mar 19 '14 at 15:07
  • @HansPassant I've tried asking you this before. This is an aside from this question, but its important. Do you want me to start a new question? Because the answers I received at http://stackoverflow.com/questions/22487887/why-doesnt-stack-walking-work-properly-when-using-setunhandledexceptionfilter/22489045?noredirect=1#comment34231884_22489045 are just insufficient and don't lead me to producing a true stack tracer. :( I don't know where to turn. I've read a lot of your answers on here that disprove upvoted and accepted answers on Stack, especially around SEH and C++ exception handling... – Alexandru Mar 19 '14 at 15:12
  • @HansPassant See http://stackoverflow.com/questions/22510758/how-do-you-prevent-stack-unwinding-from-a-child-thread if you'd like to provide your two cents. – Alexandru Mar 19 '14 at 15:37

0 Answers0