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.

145 lines
3.5 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_DATA_SPACES3 g_ExtData3;
  16. PDEBUG_REGISTERS g_ExtRegisters;
  17. PDEBUG_SYMBOLS g_ExtSymbols;
  18. PDEBUG_SYSTEM_OBJECTS g_ExtSystem;
  19. // Queries for all debugger interfaces.
  20. HRESULT
  21. ExtQuery(PDEBUG_CLIENT Client)
  22. {
  23. HRESULT Status;
  24. //
  25. // Required interfaces.
  26. //
  27. if ((Status = Client->QueryInterface(__uuidof(IDebugAdvanced),
  28. (void **)&g_ExtAdvanced)) != S_OK)
  29. {
  30. goto Fail;
  31. }
  32. if ((Status = Client->QueryInterface(__uuidof(IDebugControl),
  33. (void **)&g_ExtControl)) != S_OK)
  34. {
  35. goto Fail;
  36. }
  37. if ((Status = Client->QueryInterface(__uuidof(IDebugDataSpaces),
  38. (void **)&g_ExtData)) != S_OK)
  39. {
  40. goto Fail;
  41. }
  42. if ((Status = Client->QueryInterface(__uuidof(IDebugRegisters),
  43. (void **)&g_ExtRegisters)) != S_OK)
  44. {
  45. goto Fail;
  46. }
  47. if ((Status = Client->QueryInterface(__uuidof(IDebugSymbols),
  48. (void **)&g_ExtSymbols)) != S_OK)
  49. {
  50. goto Fail;
  51. }
  52. if ((Status = Client->QueryInterface(__uuidof(IDebugSystemObjects),
  53. (void **)&g_ExtSystem)) != S_OK)
  54. {
  55. goto Fail;
  56. }
  57. //
  58. // Optional interfaces.
  59. //
  60. if ((Status = Client->QueryInterface(__uuidof(IDebugDataSpaces2),
  61. (void **)&g_ExtData2)) != S_OK)
  62. {
  63. g_ExtData2 = NULL;
  64. }
  65. if ((Status = Client->QueryInterface(__uuidof(IDebugDataSpaces3),
  66. (void **)&g_ExtData3)) != S_OK)
  67. {
  68. g_ExtData3 = NULL;
  69. }
  70. g_ExtClient = Client;
  71. return S_OK;
  72. Fail:
  73. ExtRelease();
  74. return Status;
  75. }
  76. // Cleans up all debugger interfaces.
  77. void
  78. ExtRelease(void)
  79. {
  80. g_ExtClient = NULL;
  81. EXT_RELEASE(g_ExtAdvanced);
  82. EXT_RELEASE(g_ExtControl);
  83. EXT_RELEASE(g_ExtData);
  84. EXT_RELEASE(g_ExtData2);
  85. EXT_RELEASE(g_ExtData3);
  86. EXT_RELEASE(g_ExtRegisters);
  87. EXT_RELEASE(g_ExtSymbols);
  88. EXT_RELEASE(g_ExtSystem);
  89. }
  90. // Normal output.
  91. void __cdecl
  92. ExtOut(PCSTR Format, ...)
  93. {
  94. va_list Args;
  95. va_start(Args, Format);
  96. g_ExtControl->OutputVaList(DEBUG_OUTPUT_NORMAL, Format, Args);
  97. va_end(Args);
  98. }
  99. // Error output.
  100. void __cdecl
  101. ExtErr(PCSTR Format, ...)
  102. {
  103. va_list Args;
  104. va_start(Args, Format);
  105. g_ExtControl->OutputVaList(DEBUG_OUTPUT_ERROR, Format, Args);
  106. va_end(Args);
  107. }
  108. // Warning output.
  109. void __cdecl
  110. ExtWarn(PCSTR Format, ...)
  111. {
  112. va_list Args;
  113. va_start(Args, Format);
  114. g_ExtControl->OutputVaList(DEBUG_OUTPUT_WARNING, Format, Args);
  115. va_end(Args);
  116. }
  117. // Verbose output.
  118. void __cdecl
  119. ExtVerb(PCSTR Format, ...)
  120. {
  121. va_list Args;
  122. va_start(Args, Format);
  123. g_ExtControl->OutputVaList(DEBUG_OUTPUT_VERBOSE, Format, Args);
  124. va_end(Args);
  125. }