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.

134 lines
2.7 KiB

  1. /*++
  2. Copyright (c) 200 Microsoft Corporation
  3. Module Name:
  4. assrt.cxx
  5. Abstract:
  6. assertion code used by BS_ASSERT
  7. Author:
  8. Revision History:
  9. Name Date Comments
  10. brianb 04/19/2000 created
  11. aoltean 06/20/2000 Adding VssSetDebugReport
  12. --*/
  13. extern "C" {
  14. #include <nt.h>
  15. #include <ntrtl.h>
  16. #include <nturtl.h>
  17. }
  18. #include <windows.h>
  19. #include <stdio.h>
  20. #undef ASSERT
  21. #include "vs_assert.hxx"
  22. #include "vs_trace.hxx"
  23. ////////////////////////////////////////////////////////////////////////
  24. // Standard foo for file name aliasing. This code block must be after
  25. // all includes of VSS header files.
  26. //
  27. #ifdef VSS_FILE_ALIAS
  28. #undef VSS_FILE_ALIAS
  29. #endif
  30. #define VSS_FILE_ALIAS "TRCASRTC"
  31. //
  32. ////////////////////////////////////////////////////////////////////////
  33. // No MP protection...
  34. static LONG g_lVssDebugReportFlags = VSS_DBG_TO_DEBUG_CONSOLE | VSS_DBG_MESSAGE_BOX;
  35. VOID
  36. AssertFail
  37. (
  38. IN LPCSTR FileName,
  39. IN UINT LineNumber,
  40. IN LPCSTR Condition
  41. )
  42. {
  43. int i;
  44. CHAR Title[4096];
  45. CHAR Msg[4096];
  46. DWORD dwCurrentProcessId = GetCurrentProcessId();
  47. DWORD dwCurrentThreadId = GetCurrentThreadId();
  48. if (g_lVssDebugReportFlags & VSS_DBG_TO_DEBUG_CONSOLE)
  49. {
  50. sprintf(
  51. Msg,
  52. "VSS(PID:%ld,TID:%ld): %s(%d): *** Assertion failure *** %s\n",
  53. dwCurrentProcessId,
  54. dwCurrentThreadId,
  55. FileName,
  56. LineNumber,
  57. Condition
  58. );
  59. ::OutputDebugStringA(Msg);
  60. /*
  61. ::DbgPrintEx(
  62. DPFLTR_VSS_ID,
  63. 1,
  64. Msg
  65. );
  66. */
  67. }
  68. if (g_lVssDebugReportFlags & VSS_DBG_MESSAGE_BOX)
  69. {
  70. LPSTR szCommandLine = GetCommandLineA();
  71. //
  72. // Use dll name as caption
  73. //
  74. sprintf(
  75. Title,
  76. "Volume Snapshots (PID:%ld,TID:%ld)",
  77. dwCurrentProcessId,
  78. dwCurrentThreadId
  79. );
  80. //
  81. // Print the assertion and the command line
  82. //
  83. sprintf(
  84. Msg,
  85. "Assertion failure at line %u in file %s: %s\n\nCommand line: %s\n\nHit Cancel to break into the debugger.",
  86. LineNumber,
  87. FileName,
  88. Condition,
  89. szCommandLine
  90. );
  91. i = MessageBoxA
  92. (
  93. NULL,
  94. Msg,
  95. Title,
  96. MB_SYSTEMMODAL | MB_ICONSTOP | MB_OKCANCEL | MB_SERVICE_NOTIFICATION
  97. );
  98. if(i == IDCANCEL)
  99. DebugBreak();
  100. }
  101. }
  102. void VssSetDebugReport( LONG lDebugReportFlags )
  103. {
  104. g_lVssDebugReportFlags = lDebugReportFlags;
  105. }