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.

172 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1993-2000 Microsoft Corporation
  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. These declarations and code should be moved into a header file.
  9. The declarations should have an optional "extern" in front of them.
  10. The code should be made __inline to avoid having multiple copies of it.
  11. N.B.: There are currently 80 copies of this code in the tree.
  12. Author:
  13. Wesley Witt (wesw) 26-Aug-1993
  14. Glenn Peterson (glennp) 22-Mar-2000: Trimmed down version from \nt\base\tools\kdexts2
  15. Environment:
  16. User Mode
  17. --*/
  18. //
  19. // globals
  20. //
  21. WINDBG_EXTENSION_APIS ExtensionApis;
  22. #define KDEXTS_EXTERN
  23. #include "kdExts.h"
  24. #undef KDEXTS_EXTERN
  25. static USHORT SavedMajorVersion;
  26. static USHORT SavedMinorVersion;
  27. DllInit(
  28. HANDLE hModule,
  29. DWORD dwReason,
  30. DWORD dwReserved
  31. )
  32. {
  33. #if 0
  34. switch (dwReason) {
  35. case DLL_THREAD_ATTACH:
  36. break;
  37. case DLL_THREAD_DETACH:
  38. break;
  39. case DLL_PROCESS_DETACH:
  40. break;
  41. case DLL_PROCESS_ATTACH:
  42. break;
  43. }
  44. #endif
  45. return TRUE;
  46. }
  47. VOID
  48. WinDbgExtensionDllInit(
  49. PWINDBG_EXTENSION_APIS64 lpExtensionApis,
  50. USHORT MajorVersion,
  51. USHORT MinorVersion
  52. )
  53. {
  54. ExtensionApis = *lpExtensionApis;
  55. SavedMajorVersion = MajorVersion;
  56. SavedMinorVersion = MinorVersion;
  57. return;
  58. }
  59. VOID
  60. wmiTraceDllInit(
  61. PWINDBG_EXTENSION_APIS64 lpExtensionApis,
  62. USHORT MajorVersion,
  63. USHORT MinorVersion
  64. )
  65. {
  66. ExtensionApis = *lpExtensionApis;
  67. SavedMajorVersion = MajorVersion;
  68. SavedMinorVersion = MinorVersion;
  69. return;
  70. }
  71. VOID
  72. CheckVersion(
  73. VOID
  74. )
  75. {
  76. }
  77. BOOLEAN
  78. IsCheckedBuild(
  79. PBOOLEAN Checked
  80. )
  81. {
  82. BOOLEAN result;
  83. result = FALSE;
  84. if (HaveDebuggerData ()) {
  85. result = TRUE;
  86. *Checked = (KernelVersionPacket.MajorVersion == 0xc) ;
  87. }
  88. return (result);
  89. }
  90. LPEXT_API_VERSION
  91. ExtensionApiVersion(
  92. VOID
  93. )
  94. {
  95. static EXT_API_VERSION ApiVersion = { (VER_PRODUCTVERSION_W >> 8),
  96. (VER_PRODUCTVERSION_W & 0xff),
  97. EXT_API_VERSION_NUMBER64, 0 };
  98. return (&ApiVersion);
  99. }
  100. BOOL
  101. HaveDebuggerData(
  102. VOID
  103. )
  104. {
  105. static int havedata = 0;
  106. if (havedata == 0) {
  107. if (!Ioctl (IG_GET_KERNEL_VERSION, &KernelVersionPacket, sizeof(KernelVersionPacket))) {
  108. havedata = 2;
  109. } else if (KernelVersionPacket.MajorVersion == 0) {
  110. havedata = 2;
  111. } else {
  112. havedata = 1;
  113. }
  114. }
  115. return ((havedata == 1) &&
  116. ((KernelVersionPacket.Flags & DBGKD_VERS_FLAG_DATA) != 0));
  117. }
  118. USHORT
  119. TargetMachineType(
  120. VOID
  121. )
  122. {
  123. if (HaveDebuggerData()) {
  124. return (KernelVersionPacket.MachineType);
  125. } else {
  126. dprintf("Error - Cannot get Kernel Version.\n");
  127. }
  128. return 0;
  129. }