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.

87 lines
2.3 KiB

  1. //***************************************************************************
  2. //
  3. // Copyright � Microsoft Corporation. All rights reserved.
  4. //
  5. // AssertBreak.cpp
  6. //
  7. // Purpose: AssertBreak macro definition
  8. //
  9. //***************************************************************************
  10. #include "precomp.h"
  11. #if defined(_DEBUG) || defined(DEBUG)
  12. #include <polarity.h>
  13. #include <assertbreak.h>
  14. #ifdef UTILLIB
  15. #include <cregcls.h>
  16. #endif
  17. #include <chstring.h>
  18. #include <malloc.h>
  19. #include <cnvmacros.h>
  20. ////////////////////////////////////////////////////////////////////////
  21. //
  22. // Function: assert_break
  23. //
  24. // Debug Helper function for displaying a message box
  25. //
  26. // Inputs: const char* pszReason - Reason for the failure.
  27. // const char* pszFilename - Filename
  28. // int nLine - Line Number
  29. //
  30. // Outputs: None.
  31. //
  32. // Return: None.
  33. //
  34. // Comments: None.
  35. //
  36. ////////////////////////////////////////////////////////////////////////
  37. void WINAPI assert_break( LPCWSTR pszReason, LPCWSTR pszFileName, int nLine )
  38. {
  39. DWORD t_dwFlag = 0; //
  40. #ifdef UTILLIB
  41. CRegistry t_Reg;
  42. if(t_Reg.Open(HKEY_LOCAL_MACHINE,
  43. L"SOFTWARE\\Microsoft\\WBEM\\CIMOM",
  44. KEY_READ) == ERROR_SUCCESS)
  45. {
  46. // see if we can find the flag
  47. if((t_Reg.GetCurrentKeyValue(L"IgnoreAssert", t_dwFlag) != ERROR_SUCCESS))
  48. {
  49. t_dwFlag = 0;
  50. }
  51. }
  52. #endif
  53. if (t_dwFlag == 0)
  54. {
  55. CHString strAssert;
  56. strAssert.Format( L"Assert Failed\n\n[%s:%d]\n\n%s\n\nBreak into Debugger?", pszFileName, nLine, pszReason );
  57. // Set the MB flags correctly depending on which OS we are running on, since in NT we may
  58. // be running as a System Service, in which case we need to ensure we have the
  59. // MB_SERVICE_NOTIFICATION flag on, or the message box may not actually display.
  60. DWORD dwFlags = MB_YESNO | MB_ICONSTOP;
  61. dwFlags |= MB_SERVICE_NOTIFICATION;
  62. // Now display the message box.
  63. int iRet = MessageBoxW( NULL, strAssert, L"Assertion Failed!", dwFlags);
  64. #ifdef DBG
  65. if (iRet == IDYES)
  66. {
  67. DebugBreak();
  68. }
  69. #endif
  70. }
  71. }
  72. #endif