none
How to catch a Unhandled Exception Dialog through win32 api RRS feed

  • Question

  • I'm developing a Record/Replay tool for WinForm applications. So I launch the application I'm going to test (AUT) from a process object and then monitor the application through the Win32 API.
    I've been able to detect dialog windows by checking a window classname and verifying if it's "#32770" (I'm yet to know the meaning of this value).
    What I'm not being able to detect is when the standard dialog for a Unhandled Exception is thrown. I've checked the classname and it's the same as the application. Since I have no access to the source code I'm not able no use the UnhandledException event of AppDomain.
    So, how can I detect these dialogs through the Win32 API?

    thanks,
    José Tavares
    Tuesday, April 7, 2009 10:33 AM

Answers

  • #32770 is the window class name of every native Windows dialog, displayed through the CreateDialog() or CreateDialogIndirect() API function.  It is not sufficient to distinguish a crash dialog, .NET functions like MessageBox.Show() and OpenFileDialog.ShowDialog() will also display a dialog with that class name.

    The only way to filter it is to enumerate the child controls of the dialog with EnumChildWindows() and GetDlgCtrlID().  Use Spy++ to find out what you need to look for.  If the crash is displayed with a message box, like they'd normally would, you've got a problem.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, April 13, 2009 9:22 AM
    Tuesday, April 7, 2009 10:47 AM
    Moderator

All replies

  • #32770 is the window class name of every native Windows dialog, displayed through the CreateDialog() or CreateDialogIndirect() API function.  It is not sufficient to distinguish a crash dialog, .NET functions like MessageBox.Show() and OpenFileDialog.ShowDialog() will also display a dialog with that class name.

    The only way to filter it is to enumerate the child controls of the dialog with EnumChildWindows() and GetDlgCtrlID().  Use Spy++ to find out what you need to look for.  If the crash is displayed with a message box, like they'd normally would, you've got a problem.
    Hans Passant.
    • Marked as answer by Zhi-Xin Ye Monday, April 13, 2009 9:22 AM
    Tuesday, April 7, 2009 10:47 AM
    Moderator
  • ...
    If the crash is displayed with a message box, like they'd normally would, you've got a problem.
    Hans Passant.
    It's exactly these types of crashes that I want to be able to detect. Using Spy++ gave me the idea to try to identify it through their childs, i.e. if the window has buttons Details, Continue and Quit I assume this is a UnhandledExection window and close it through Quit and log the message. It will not work always but I think the risk of conflict is to little.

    José Tavares

    Tuesday, April 7, 2009 11:04 AM
  • That's the dialog that is displayed by the ThreadExceptionDialog class in response to a Application.ThreadException.  That's not a #32770 dialog.  It has a standard Windows Forms class name, resembling something like WindowsForms10.Window.8.app.0.378734a.  Just like any other Form window.
    Hans Passant.
    Tuesday, April 7, 2009 12:56 PM
    Moderator