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.

89 lines
2.5 KiB

  1. //----------------------------------------------------------------------------
  2. //
  3. // Generic routines and initialization code.
  4. //
  5. // Copyright (C) Microsoft Corporation, 2000-2001.
  6. //
  7. //----------------------------------------------------------------------------
  8. #include "dbgexts.h"
  9. PDEBUG_CLIENT2 g_ExtClient;
  10. PDEBUG_CONTROL2 g_ExtControl;
  11. PDEBUG_DATA_SPACES2 g_ExtData;
  12. PDEBUG_REGISTERS g_ExtRegisters;
  13. PDEBUG_SYMBOLS2 g_ExtSymbols;
  14. PDEBUG_SYSTEM_OBJECTS2 g_ExtSystem;
  15. // Queries for all debugger interfaces.
  16. HRESULT
  17. ExtQuery(PDEBUG_CLIENT Client)
  18. {
  19. HRESULT Status;
  20. if ((Status = Client->QueryInterface(__uuidof(IDebugClient2),
  21. (void **)&g_ExtClient)) != S_OK ||
  22. (Status = Client->QueryInterface(__uuidof(IDebugControl2),
  23. (void **)&g_ExtControl)) != S_OK ||
  24. (Status = Client->QueryInterface(__uuidof(IDebugDataSpaces2),
  25. (void **)&g_ExtData)) != S_OK ||
  26. (Status = Client->QueryInterface(__uuidof(IDebugRegisters),
  27. (void **)&g_ExtRegisters)) != S_OK ||
  28. (Status = Client->QueryInterface(__uuidof(IDebugSymbols2),
  29. (void **)&g_ExtSymbols)) != S_OK ||
  30. (Status = Client->QueryInterface(__uuidof(IDebugSystemObjects2),
  31. (void **)&g_ExtSystem)) != S_OK)
  32. {
  33. ExtRelease();
  34. return Status;
  35. }
  36. return S_OK;
  37. }
  38. // Cleans up all debugger interfaces.
  39. void
  40. ExtRelease(void)
  41. {
  42. EXT_RELEASE(g_ExtClient);
  43. EXT_RELEASE(g_ExtControl);
  44. EXT_RELEASE(g_ExtData);
  45. EXT_RELEASE(g_ExtRegisters);
  46. EXT_RELEASE(g_ExtSymbols);
  47. EXT_RELEASE(g_ExtSystem);
  48. }
  49. void __cdecl
  50. ExtOut(PCSTR Format, ...)
  51. {
  52. va_list Args;
  53. va_start(Args, Format);
  54. g_ExtControl->OutputVaList(DEBUG_OUTPUT_NORMAL, Format, Args);
  55. va_end(Args);
  56. }
  57. void __cdecl
  58. ExtErr(PCSTR Format, ...)
  59. {
  60. va_list Args;
  61. va_start(Args, Format);
  62. g_ExtControl->OutputVaList(DEBUG_OUTPUT_ERROR, Format, Args);
  63. va_end(Args);
  64. }
  65. void
  66. ExtExec(PCSTR Command)
  67. {
  68. g_ExtControl->Execute(DEBUG_OUTCTL_ALL_CLIENTS, Command,
  69. DEBUG_EXECUTE_DEFAULT);
  70. }
  71. extern "C" HRESULT CALLBACK
  72. DebugExtensionInitialize(PULONG Version, PULONG Flags)
  73. {
  74. *Version = DEBUG_EXTENSION_VERSION(1, 0);
  75. *Flags = 0;
  76. return S_OK;
  77. }