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.

129 lines
3.7 KiB

  1. ////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // debug.c
  4. //
  5. ////////////////////////////////////////////////////////////////////////////////
  6. #include "priv.h"
  7. #pragma hdrstop
  8. #ifdef DEBUG
  9. #ifndef WINNT
  10. #include <windows.h>
  11. //#include <stdlib.h>
  12. //#include <stdio.h>
  13. #include "debug.h"
  14. #endif
  15. void
  16. _Assert
  17. (DWORD dw, LPSTR lpszExp, LPSTR lpszFile, DWORD dwLine)
  18. {
  19. DWORD dwT;
  20. TCHAR lpszT[256];
  21. wsprintf (lpszT, TEXT("Assertion %hs Failed.\n\n%hs, line# %ld\n\nYes to continue, No to debug, Cancel to exit"), lpszExp, lpszFile, dwLine);
  22. dwT = MessageBox (GetFocus(), lpszT, TEXT("Assertion Failed!"), MB_YESNOCANCEL);
  23. switch (dwT)
  24. {
  25. case IDCANCEL :
  26. //exit (1);
  27. FatalExit(1);
  28. case IDNO :
  29. DebugTrap;
  30. }
  31. }
  32. void
  33. _AssertSz
  34. (DWORD dw, LPSTR lpszExp, LPTSTR lpsz, LPSTR lpszFile, DWORD dwLine)
  35. {
  36. DWORD dwT;
  37. TCHAR lpszT[512];
  38. wsprintf (lpszT, TEXT("Assertion %hs Failed.\n\n%s\n%hs, line# %ld\n\nYes to continue, No to debug, Cancel to exit"), lpszExp, lpsz, lpszFile, dwLine);
  39. dwT = MessageBox (GetFocus(), lpszT, TEXT("Assertion Failed!"), MB_YESNOCANCEL);
  40. switch (dwT)
  41. {
  42. case IDCANCEL:
  43. //exit (1);
  44. FatalExit(1);
  45. case IDNO :
  46. DebugTrap;
  47. }
  48. }
  49. #ifdef LOTS_O_DEBUG
  50. #include <windows.h>
  51. #include <winerror.h>
  52. #include <oleauto.h>
  53. #include "debug.h"
  54. void
  55. _DebugHr
  56. (HRESULT hr, LPTSTR lpszFile, DWORD dwLine)
  57. {
  58. TCHAR lpstzT[512];
  59. switch (hr) {
  60. case S_OK :
  61. return;
  62. case STG_E_INVALIDNAME:
  63. wsprintf (lpstzT, TEXT("\tBogus filename\n\n%s, line# %ld\n"),lpszFile, dwLine);
  64. break;
  65. case STG_E_INVALIDFUNCTION :
  66. wsprintf (lpstzT, TEXT("\tInvalid Function\n\n%s, line# %ld\n"),lpszFile, dwLine);
  67. break;
  68. case STG_E_FILENOTFOUND:
  69. wsprintf (lpstzT, TEXT("\tFile not found\n\n%s, line# %ld\n"),lpszFile, dwLine);
  70. break;
  71. case STG_E_INVALIDFLAG:
  72. wsprintf (lpstzT, TEXT("\tBogus flag\n\n%s, line# %ld\n"),lpszFile, dwLine);
  73. break;
  74. case STG_E_INVALIDPOINTER:
  75. wsprintf (lpstzT, TEXT("\tBogus pointer\n\n%s, line# %ld\n"),lpszFile, dwLine);
  76. break;
  77. case STG_E_ACCESSDENIED:
  78. wsprintf (lpstzT, TEXT("\tAccess Denied\n\n%s, line# %ld\n"),lpszFile, dwLine);
  79. break;
  80. case STG_E_INSUFFICIENTMEMORY :
  81. case E_OUTOFMEMORY :
  82. wsprintf (lpstzT, TEXT("\tInsufficient Memory\n\n%s, line# %ld\n"),lpszFile, dwLine);
  83. break;
  84. case E_INVALIDARG :
  85. wsprintf (lpstzT, TEXT("\tInvalid argument\n\n%s, line# %ld\n"),lpszFile, dwLine);
  86. break;
  87. case TYPE_E_UNKNOWNLCID:
  88. wsprintf (lpstzT, TEXT("\tUnknown LCID\n\n%s, line# %ld\n"),lpszFile, dwLine);
  89. break;
  90. case TYPE_E_CANTLOADLIBRARY:
  91. wsprintf (lpstzT, TEXT("\tCan't load typelib or dll\n\n%s, line# %ld\n"),lpszFile, dwLine);
  92. break;
  93. case TYPE_E_INVDATAREAD:
  94. wsprintf (lpstzT, TEXT("\tCan't read file\n\n%s, line# %ld\n"),lpszFile, dwLine);
  95. break;
  96. case TYPE_E_INVALIDSTATE:
  97. wsprintf (lpstzT, TEXT("\tTypelib couldn't be opened\n\n%s, line# %ld\n"),lpszFile, dwLine);
  98. break;
  99. case TYPE_E_IOERROR:
  100. wsprintf (lpstzT, TEXT("\tI/O error\n\n%s, line# %ld\n"),lpszFile, dwLine);
  101. break;
  102. default:
  103. wsprintf (lpstzT, TEXT("\tUnknown HRESULT %lx (%ld) \n\n%s, line# %ld\n"),hr, hr, lpszFile, dwLine);
  104. }
  105. MessageBox (GetFocus(), lpstzT, NULL, MB_OK);
  106. return;
  107. }
  108. void
  109. _DebugGUID (GUID g)
  110. {
  111. TCHAR lpsz[200];
  112. wsprintf (lpsz, TEXT("GUID is: %lx-%hx-%hx-%hx%hx-%hx%hx%hx%hx%hx%hx"),
  113. g.Data1, g.Data2, g.Data3, g.Data4[0], g.Data4[1], g.Data4[2], g.Data4[3],
  114. g.Data4[4], g.Data4[5], g.Data4[6], g.Data4[7]);
  115. DebugSz (lpsz);
  116. }
  117. #endif // LOTS_O_DEBUG
  118. #endif // DEBUG