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.

137 lines
3.1 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Debugger engine extension helper library.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1999-2000.
  6. //
  7. //----------------------------------------------------------------------------
  8. #define DEBUG_NO_IMPLEMENTATION
  9. #include <engexts.h>
  10. PDEBUG_ADVANCED g_ExtAdvanced;
  11. PDEBUG_CLIENT g_ExtClient;
  12. PDEBUG_CONTROL g_ExtControl;
  13. PDEBUG_DATA_SPACES g_ExtData;
  14. PDEBUG_DATA_SPACES2 g_ExtData2;
  15. PDEBUG_REGISTERS g_ExtRegisters;
  16. PDEBUG_SYMBOLS g_ExtSymbols;
  17. PDEBUG_SYSTEM_OBJECTS g_ExtSystem;
  18. // Queries for all debugger interfaces.
  19. HRESULT
  20. ExtQuery(PDEBUG_CLIENT Client)
  21. {
  22. HRESULT Status;
  23. //
  24. // Required interfaces.
  25. //
  26. if ((Status = Client->QueryInterface(__uuidof(IDebugAdvanced),
  27. (void **)&g_ExtAdvanced)) != S_OK)
  28. {
  29. goto Fail;
  30. }
  31. if ((Status = Client->QueryInterface(__uuidof(IDebugControl),
  32. (void **)&g_ExtControl)) != S_OK)
  33. {
  34. goto Fail;
  35. }
  36. if ((Status = Client->QueryInterface(__uuidof(IDebugDataSpaces),
  37. (void **)&g_ExtData)) != S_OK)
  38. {
  39. goto Fail;
  40. }
  41. if ((Status = Client->QueryInterface(__uuidof(IDebugRegisters),
  42. (void **)&g_ExtRegisters)) != S_OK)
  43. {
  44. goto Fail;
  45. }
  46. if ((Status = Client->QueryInterface(__uuidof(IDebugSymbols),
  47. (void **)&g_ExtSymbols)) != S_OK)
  48. {
  49. goto Fail;
  50. }
  51. if ((Status = Client->QueryInterface(__uuidof(IDebugSystemObjects),
  52. (void **)&g_ExtSystem)) != S_OK)
  53. {
  54. goto Fail;
  55. }
  56. //
  57. // Optional interfaces.
  58. //
  59. if ((Status = Client->QueryInterface(__uuidof(IDebugDataSpaces2),
  60. (void **)&g_ExtData2)) != S_OK)
  61. {
  62. g_ExtData2 = NULL;
  63. }
  64. g_ExtClient = Client;
  65. return S_OK;
  66. Fail:
  67. ExtRelease();
  68. return Status;
  69. }
  70. // Cleans up all debugger interfaces.
  71. void
  72. ExtRelease(void)
  73. {
  74. g_ExtClient = NULL;
  75. EXT_RELEASE(g_ExtAdvanced);
  76. EXT_RELEASE(g_ExtControl);
  77. EXT_RELEASE(g_ExtData);
  78. EXT_RELEASE(g_ExtData2);
  79. EXT_RELEASE(g_ExtRegisters);
  80. EXT_RELEASE(g_ExtSymbols);
  81. EXT_RELEASE(g_ExtSystem);
  82. }
  83. // Normal output.
  84. void __cdecl
  85. ExtOut(PCSTR Format, ...)
  86. {
  87. va_list Args;
  88. va_start(Args, Format);
  89. g_ExtControl->OutputVaList(DEBUG_OUTPUT_NORMAL, Format, Args);
  90. va_end(Args);
  91. }
  92. // Error output.
  93. void __cdecl
  94. ExtErr(PCSTR Format, ...)
  95. {
  96. va_list Args;
  97. va_start(Args, Format);
  98. g_ExtControl->OutputVaList(DEBUG_OUTPUT_ERROR, Format, Args);
  99. va_end(Args);
  100. }
  101. // Warning output.
  102. void __cdecl
  103. ExtWarn(PCSTR Format, ...)
  104. {
  105. va_list Args;
  106. va_start(Args, Format);
  107. g_ExtControl->OutputVaList(DEBUG_OUTPUT_WARNING, Format, Args);
  108. va_end(Args);
  109. }
  110. // Verbose output.
  111. void __cdecl
  112. ExtVerb(PCSTR Format, ...)
  113. {
  114. va_list Args;
  115. va_start(Args, Format);
  116. g_ExtControl->OutputVaList(DEBUG_OUTPUT_VERBOSE, Format, Args);
  117. va_end(Args);
  118. }