Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.8 KiB

  1. #include "compatadmin.h"
  2. // Record the current exception handler.
  3. //CGrabException ExceptHandler;
  4. // Define support structure for WM_INITDIALOG
  5. typedef struct {
  6. LPTSTR szLine;
  7. LPTSTR szFile;
  8. LPTSTR szCause;
  9. LPTSTR szDesc;
  10. BOOL bException;
  11. } ASSERTSTRINGS, *PASSERTSTRINGS;
  12. // Prototype of dialog procedure.
  13. BOOL CALLBACK AssertDlg(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  14. // Main support function for the assert() macro.
  15. int _ASSERT(int nLine, LPCTSTR szFilename, LPCTSTR szAssert, LPCTSTR szDsc)
  16. {
  17. ASSERTSTRINGS Str;
  18. TCHAR szLine[40];
  19. TCHAR szFile[MAX_PATH_BUFFSIZE];
  20. TCHAR szCause[MAX_PATH_BUFFSIZE];
  21. TCHAR szDesc[MAX_PATH_BUFFSIZE];
  22. // Construct dialog text.
  23. wsprintf(szLine, TEXT("Line Number:\t%d"),nLine);
  24. wsprintf(szFile, TEXT("Filename:\t%s"),szFilename);
  25. wsprintf(szCause,TEXT("Cause:\t\t%s"),szAssert);
  26. wsprintf(szDesc, TEXT("Description:\t%s"),szDsc);
  27. Str.szLine = szLine;
  28. Str.szFile = szFile;
  29. Str.szCause = szCause;
  30. Str.szDesc = szDesc;
  31. // Determine if we're in an exception handler. We do this now rather
  32. // than WM_INITDIALOG time because USER32 has an exception handler,
  33. // and that causes us to throw up the exception handler all the time.
  34. // Since we don't throw the exception inside the dialog proc, that
  35. // would have us comparing against the wrong handler.
  36. Str.bException = ExceptHandler.InHandler();
  37. // Throw up the dialog to display the assertion.
  38. return DialogBoxParam(GetModuleHandle(NULL),MAKEINTRESOURCE(IDD_ASSERTION),NULL,(DLGPROC)AssertDlg,(LPARAM)&Str);
  39. }
  40. // Main dialog box procedure.
  41. BOOL CALLBACK AssertDlg(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  42. {
  43. switch ( uMsg ) {
  44. // Setup to display the dialog with the appropriate values.
  45. case WM_INITDIALOG:
  46. {
  47. PASSERTSTRINGS pStr = (PASSERTSTRINGS) lParam;
  48. // Update the strings
  49. SetDlgItemText(hDlg,IDC_LINE,pStr->szLine);
  50. SetDlgItemText(hDlg,IDC_FILE,pStr->szFile);
  51. SetDlgItemText(hDlg,IDC_CAUSE,pStr->szCause);
  52. SetDlgItemText(hDlg,IDC_DESC,pStr->szDesc);
  53. // Hide the exception button if it doesn't exist.
  54. if ( !pStr->bException )
  55. ShowWindow(GetDlgItem(hDlg,IDC_EXCEPTION),SW_HIDE);
  56. }
  57. break;
  58. // Process commands.
  59. case WM_COMMAND:
  60. switch ( LOWORD(wParam) ) {
  61. case IDC_BREAK:
  62. EndDialog(hDlg,ASSERT_BREAK);
  63. break;
  64. case IDC_ABORT:
  65. EndDialog(hDlg,ASSERT_ABORT);
  66. break;
  67. case IDC_EXCEPTION:
  68. EndDialog(hDlg,ASSERT_EXCEPT);
  69. break;
  70. case IDC_IGNORE:
  71. EndDialog(hDlg,ASSERT_IGNORE);
  72. break;
  73. }
  74. }
  75. return FALSE;
  76. }