Leaked source code of windows server 2003
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.

125 lines
3.7 KiB

  1. //=--------------------------------------------------------------------------=
  2. // Debug.Cpp
  3. //=--------------------------------------------------------------------------=
  4. // Copyright 1995 Microsoft Corporation. All Rights Reserved.
  5. //
  6. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  7. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  8. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  9. // PARTICULAR PURPOSE.
  10. //=--------------------------------------------------------------------------=
  11. //
  12. // contains various methods that will only really see any use in DEBUG builds
  13. //
  14. #include "stdafx.h" // not really used here, but NT Build env. doesn't like
  15. // some files in a dir to have pre-comp hdrs & some not
  16. #ifdef _DEBUG
  17. #include "IPServer.H"
  18. #include <stdlib.h>
  19. //=--------------------------------------------------------------------------=
  20. // Private Constants
  21. //---------------------------------------------------------------------------=
  22. //
  23. static char szFormat[] = "%s\nFile %s, Line %d";
  24. static char szFormat2[] = "%s\n%s\nFile %s, Line %d";
  25. LPSTR Deb_lpszAssertInfo = NULL;
  26. #define _SERVERNAME_ "Viaduct"
  27. static char szTitle[] = _SERVERNAME_ " Assertion (Abort = UAE, Retry = INT 3, Ignore = Continue)";
  28. //=--------------------------------------------------------------------------=
  29. // Local functions
  30. //=--------------------------------------------------------------------------=
  31. int NEAR _IdMsgBox(LPSTR pszText, LPSTR pszTitle, UINT mbFlags);
  32. //=--------------------------------------------------------------------------=
  33. // DisplayAssert
  34. //=--------------------------------------------------------------------------=
  35. // Display an assert message box with the given pszMsg, pszAssert, source
  36. // file name, and line number. The resulting message box has Abort, Retry,
  37. // Ignore buttons with Abort as the default. Abort does a FatalAppExit;
  38. // Retry does an int 3 then returns; Ignore just returns.
  39. //
  40. VOID DisplayAssert
  41. (
  42. LPSTR pszMsg,
  43. LPSTR pszAssert,
  44. LPSTR pszFile,
  45. UINT line
  46. )
  47. {
  48. char szMsg[250 * 2];
  49. LPSTR lpszText;
  50. lpszText = pszMsg; // Assume no file & line # info
  51. // If C file assert, where you've got a file name and a line #
  52. //
  53. if (pszFile) {
  54. // Was additional information supplied?
  55. //
  56. if (Deb_lpszAssertInfo) {
  57. // Then format the assert nicely, using this additional information:
  58. //
  59. wsprintf(szMsg, szFormat2, (pszMsg&&*pszMsg) ? pszMsg : pszAssert, Deb_lpszAssertInfo, pszFile, line);
  60. Deb_lpszAssertInfo = NULL;
  61. } else {
  62. // Then format the assert nicely without the extra information:
  63. //
  64. wsprintf(szMsg, szFormat, (pszMsg&&*pszMsg) ? pszMsg : pszAssert, pszFile, line);
  65. }
  66. lpszText = szMsg;
  67. }
  68. // Put up a dialog box
  69. //
  70. switch (_IdMsgBox(lpszText, szTitle, MB_ICONHAND|MB_ABORTRETRYIGNORE|MB_SYSTEMMODAL)) {
  71. case IDABORT:
  72. FatalAppExit(0, lpszText);
  73. return;
  74. case IDRETRY:
  75. // call the win32 api to break us.
  76. //
  77. DebugBreak();
  78. return;
  79. }
  80. return;
  81. }
  82. //=---------------------------------------------------------------------------=
  83. // Beefed-up version of WinMessageBox.
  84. //=---------------------------------------------------------------------------=
  85. //
  86. int NEAR _IdMsgBox
  87. (
  88. LPSTR pszText,
  89. LPSTR pszTitle,
  90. UINT mbFlags
  91. )
  92. {
  93. HWND hwndActive;
  94. int id;
  95. hwndActive = GetActiveWindow();
  96. id = MessageBox(hwndActive, pszText, pszTitle, mbFlags);
  97. return id;
  98. }
  99. #endif // DEBUG