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.

180 lines
4.0 KiB

  1. //depot/Lab01_N/drivers/storage/kdext/minipkd/kdext.cpp#1 - add change 1876 (text)
  2. /*++
  3. Copyright (C) Microsoft Corporation, 1993 - 1999
  4. Module Name:
  5. kdexts.c
  6. Abstract:
  7. This file contains the generic routines and initialization code
  8. for the kernel debugger extensions dll.
  9. Author:
  10. Wesley Witt (wesw) 26-Aug-1993
  11. Environment:
  12. User Mode
  13. --*/
  14. #include "pch.h"
  15. #pragma hdrstop
  16. #include <ntverp.h>
  17. WINDBG_EXTENSION_APIS ExtensionApis;
  18. PDEBUG_ADVANCED g_ExtAdvanced;
  19. PDEBUG_CLIENT g_ExtClient;
  20. PDEBUG_CONTROL g_ExtControl;
  21. PDEBUG_DATA_SPACES g_ExtData;
  22. PDEBUG_REGISTERS g_ExtRegisters;
  23. PDEBUG_SYMBOLS g_ExtSymbols;
  24. PDEBUG_SYSTEM_OBJECTS g_ExtSystem;
  25. // Queries for all debugger interfaces.
  26. extern "C" HRESULT
  27. ExtQuery(PDEBUG_CLIENT Client)
  28. {
  29. HRESULT Status;
  30. if ((Status = Client->QueryInterface(__uuidof(IDebugAdvanced),
  31. (void **)&g_ExtAdvanced)) != S_OK)
  32. {
  33. goto Fail;
  34. }
  35. if ((Status = Client->QueryInterface(__uuidof(IDebugControl),
  36. (void **)&g_ExtControl)) != S_OK)
  37. {
  38. goto Fail;
  39. }
  40. if ((Status = Client->QueryInterface(__uuidof(IDebugDataSpaces),
  41. (void **)&g_ExtData)) != S_OK)
  42. {
  43. goto Fail;
  44. }
  45. if ((Status = Client->QueryInterface(__uuidof(IDebugRegisters),
  46. (void **)&g_ExtRegisters)) != S_OK)
  47. {
  48. goto Fail;
  49. }
  50. if ((Status = Client->QueryInterface(__uuidof(IDebugSymbols),
  51. (void **)&g_ExtSymbols)) != S_OK)
  52. {
  53. goto Fail;
  54. }
  55. if ((Status = Client->QueryInterface(__uuidof(IDebugSystemObjects),
  56. (void **)&g_ExtSystem)) != S_OK)
  57. {
  58. goto Fail;
  59. }
  60. g_ExtClient = Client;
  61. return S_OK;
  62. Fail:
  63. ExtRelease();
  64. return Status;
  65. }
  66. // Cleans up all debugger interfaces.
  67. void
  68. ExtRelease(void)
  69. {
  70. g_ExtClient = NULL;
  71. EXT_RELEASE(g_ExtAdvanced);
  72. EXT_RELEASE(g_ExtControl);
  73. EXT_RELEASE(g_ExtData);
  74. EXT_RELEASE(g_ExtRegisters);
  75. EXT_RELEASE(g_ExtSymbols);
  76. EXT_RELEASE(g_ExtSystem);
  77. }
  78. // Normal output.
  79. void __cdecl
  80. ExtOut(PCSTR Format, ...)
  81. {
  82. va_list Args;
  83. va_start(Args, Format);
  84. g_ExtControl->OutputVaList(DEBUG_OUTPUT_NORMAL, Format, Args);
  85. va_end(Args);
  86. }
  87. // Error output.
  88. void __cdecl
  89. ExtErr(PCSTR Format, ...)
  90. {
  91. va_list Args;
  92. va_start(Args, Format);
  93. g_ExtControl->OutputVaList(DEBUG_OUTPUT_ERROR, Format, Args);
  94. va_end(Args);
  95. }
  96. // Warning output.
  97. void __cdecl
  98. ExtWarn(PCSTR Format, ...)
  99. {
  100. va_list Args;
  101. va_start(Args, Format);
  102. g_ExtControl->OutputVaList(DEBUG_OUTPUT_WARNING, Format, Args);
  103. va_end(Args);
  104. }
  105. // Verbose output.
  106. void __cdecl
  107. ExtVerb(PCSTR Format, ...)
  108. {
  109. va_list Args;
  110. va_start(Args, Format);
  111. g_ExtControl->OutputVaList(DEBUG_OUTPUT_VERBOSE, Format, Args);
  112. va_end(Args);
  113. }
  114. extern "C" HRESULT CALLBACK DebugExtensionInitialize(PULONG Version, PULONG Flags)
  115. {
  116. IDebugClient *DebugClient;
  117. IDebugControl *DebugControl;
  118. HRESULT Hr;
  119. *Version = DEBUG_EXTENSION_VERSION(1, 0);
  120. *Flags = 0;
  121. if ((Hr = DebugCreate(__uuidof(IDebugClient),
  122. (void **)&DebugClient)) != S_OK)
  123. {
  124. return Hr;
  125. }
  126. if ((Hr = DebugClient->QueryInterface(__uuidof(IDebugControl),
  127. (void **)&DebugControl)) != S_OK)
  128. {
  129. return Hr;
  130. }
  131. ExtensionApis.nSize = sizeof (ExtensionApis);
  132. if ((Hr = DebugControl->GetWindbgExtensionApis64(&ExtensionApis)) != S_OK) {
  133. return Hr;
  134. }
  135. DebugControl->Release();
  136. DebugClient->Release();
  137. return S_OK;
  138. }
  139. extern "C" void CALLBACK
  140. DebugExtensionUninitialize(void)
  141. {
  142. // g_ExcepCallbacks.Uninitialize();
  143. // g_FnProfCallbacks.Uninitialize();
  144. }