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.

169 lines
3.4 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1993 - 1999
  3. Module Name:
  4. kdexts.c
  5. Abstract:
  6. This file contains the generic routines and initialization code
  7. for the kernel debugger extensions dll.
  8. Author:
  9. Wesley Witt (wesw) 26-Aug-1993
  10. Environment:
  11. User Mode
  12. --*/
  13. #include "pch.h"
  14. #pragma hdrstop
  15. #include <ntverp.h>
  16. #include <imagehlp.h>
  17. //
  18. // globals
  19. //
  20. EXT_API_VERSION ApiVersion = {
  21. (VER_PRODUCTVERSION_W >> 8),
  22. (VER_PRODUCTVERSION_W & 0xff),
  23. EXT_API_VERSION_NUMBER,
  24. 0
  25. };
  26. WINDBG_EXTENSION_APIS ExtensionApis;
  27. ULONG STeip;
  28. ULONG STebp;
  29. ULONG STesp;
  30. USHORT SavedMajorVersion;
  31. USHORT SavedMinorVersion;
  32. DllInit(
  33. HANDLE hModule,
  34. DWORD dwReason,
  35. DWORD dwReserved
  36. )
  37. {
  38. switch (dwReason) {
  39. case DLL_THREAD_ATTACH:
  40. break;
  41. case DLL_THREAD_DETACH:
  42. break;
  43. case DLL_PROCESS_DETACH:
  44. break;
  45. case DLL_PROCESS_ATTACH:
  46. break;
  47. }
  48. return TRUE;
  49. }
  50. #if 0
  51. // BUGBUG REMOVE ?
  52. VOID
  53. WinDbgExtensionDllInit(
  54. PWINDBG_EXTENSION_APIS lpExtensionApis,
  55. USHORT MajorVersion,
  56. USHORT MinorVersion
  57. )
  58. {
  59. ExtensionApis = *lpExtensionApis;
  60. SavedMajorVersion = MajorVersion;
  61. SavedMinorVersion = MinorVersion;
  62. return;
  63. }
  64. VOID
  65. CheckVersion(
  66. VOID
  67. )
  68. {
  69. #if DBG
  70. if ((SavedMajorVersion != 0x0c) || (SavedMinorVersion != VER_PRODUCTBUILD)) {
  71. dprintf("\r\n*** Extension DLL(%d Checked) does not match target system(%d %s)\r\n\r\n",
  72. VER_PRODUCTBUILD, SavedMinorVersion, (SavedMajorVersion==0x0f) ? "Free" : "Checked" );
  73. }
  74. #else
  75. if ((SavedMajorVersion != 0x0f) || (SavedMinorVersion != VER_PRODUCTBUILD)) {
  76. dprintf("\r\n*** Extension DLL(%d Free) does not match target system(%d %s)\r\n\r\n",
  77. VER_PRODUCTBUILD, SavedMinorVersion, (SavedMajorVersion==0x0f) ? "Free" : "Checked" );
  78. }
  79. #endif
  80. }
  81. LPEXT_API_VERSION ExtensionApiVersion(VOID)
  82. {
  83. return &ApiVersion;
  84. }
  85. #endif
  86. extern "C" HRESULT CALLBACK DebugExtensionInitialize(PULONG Version, PULONG Flags)
  87. {
  88. IDebugClient *DebugClient;
  89. IDebugControl *DebugControl;
  90. HRESULT Hr;
  91. *Version = DEBUG_EXTENSION_VERSION(1, 0);
  92. *Flags = 0;
  93. if ((Hr = DebugCreate(__uuidof(IDebugClient),
  94. (void **)&DebugClient)) != S_OK)
  95. {
  96. return Hr;
  97. }
  98. if ((Hr = DebugClient->QueryInterface(__uuidof(IDebugControl),
  99. (void **)&DebugControl)) != S_OK)
  100. {
  101. return Hr;
  102. }
  103. ExtensionApis.nSize = sizeof (ExtensionApis);
  104. if ((Hr = DebugControl->GetWindbgExtensionApis64(&ExtensionApis)) != S_OK) {
  105. return Hr;
  106. }
  107. DebugControl->Release();
  108. DebugClient->Release();
  109. return S_OK;
  110. }
  111. extern "C" void CALLBACK DebugExtensionUninitialize(void)
  112. {
  113. }
  114. DECLARE_API( version )
  115. {
  116. #if DBG
  117. PCHAR DebuggerType = "Checked";
  118. #else
  119. PCHAR DebuggerType = "Free";
  120. #endif
  121. dprintf( "%s Extension dll for Build %d debugging %s kernel for Build %d\n",
  122. DebuggerType,
  123. VER_PRODUCTBUILD,
  124. SavedMajorVersion == 0x0c ? "Checked" : "Free",
  125. SavedMinorVersion
  126. );
  127. return S_OK;
  128. }