To test this problem I have written a minimal windows application. If I force an access violation in the WM_PAINT handler this exception never gets to the debug
As a workaround I remove all registered exception handlers in my window procedure. Quite ugly.
LRESULT CALLBACK window_proc(
HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
// get thread information block
NT_TIB* tib;
__asm {
mov EAX, FS:[18h]
mov [tib], EAX
}
// old exception handler list
_EXCEPTION_REGISTRATION_RECORD* old_exception_handler = tib->ExceptionList;
// remove all exception handler with exception of the default handler
while( tib->ExceptionList->Next != (_EXCEPTION_REGISTRATION_RECORD*)-1 ) {
tib->ExceptionList = tib->ExceptionList->Next;
}
LRESULT result = DefWindowProc( hwnd, uMsg, wParam, lParam );
// restore old exception handler
tib->ExceptionList = old_exception_handler;
return result;
}