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 debugger. If started without debugger the access violation also does not show up. Usually you should get the Windows Error Reporting dialog.
Digging a bit deeper it seems that something in user32.dll catches all incoming exceptions. Is this normal behavior? Can I control this somehow? Isn't catching all exceptions a security risk? At least it is annoying as hell.
This is with a 32- and 64-bit application on Vista 64. On XP the exception seems to be handled as expected. Other windows messages have the same problem. Maybe all of them?
The WM_PAINT
handler:
case WM_PAINT:
hdc = BeginPaint(hWnd, &ps);
*(int*)0 = 0;
EndPaint(hWnd, &ps);
break;
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; }
It's a known defect. Check the hotfix. http://support.microsoft.com/kb/976038
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With