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.

158 lines
3.0 KiB

  1. /*++
  2. Module Name:
  3. wmiext.cxx
  4. Abstract:
  5. This module contains the default ntsd debugger extensions for
  6. Author:
  7. Ivan Brugiolo 17-05-2000
  8. Revision History:
  9. --*/
  10. #include "wmiexts.h"
  11. # undef DBG_ASSERT
  12. /************************************************************
  13. * Debugger Utility Functions
  14. ************************************************************/
  15. WINDBG_EXTENSION_APIS ExtensionApis;
  16. HANDLE ExtensionCurrentProcess;
  17. USHORT g_MajorVersion;
  18. USHORT g_MinorVersion;
  19. BOOL gChkTarget = FALSE;
  20. BOOL g_KD = FALSE;
  21. DWORD g_AddressSize = sizeof(ULONG_PTR);
  22. BOOL g_bUnextend = FALSE;
  23. /************************************************************
  24. * The WinDBG required Export
  25. ************************************************************/
  26. LPEXT_API_VERSION
  27. ExtensionApiVersion(
  28. void
  29. )
  30. /*++
  31. Function Description:
  32. Windbg calls this function to match between the version of windbg and the
  33. extension. If the versions doesn't match, windbg will not load the
  34. extension.
  35. --*/
  36. {
  37. static EXT_API_VERSION ApiVersion =
  38. #ifdef KDEXT_64BIT
  39. { 5, 0, EXT_API_VERSION_NUMBER64, 0 };
  40. #else
  41. { 5, 0, EXT_API_VERSION_NUMBER, 0 };
  42. #endif
  43. return &ApiVersion;
  44. }
  45. void
  46. WinDbgExtensionDllInit(
  47. PWINDBG_EXTENSION_APIS lpExtensionApis,
  48. USHORT MajorVersion,
  49. USHORT MinorVersion
  50. )
  51. /*++
  52. Function Description:
  53. When windbg loads the extension, it first call this function. You can
  54. perform various intialization here.
  55. Arguments:
  56. lpExtensionApis - A structure that contains the callbacks to functions that
  57. I can use to do standard operation. I must store this in a global
  58. variable called 'ExtensionApis'.
  59. MajorVersion - Indicates if target machine is running checked build or
  60. free.
  61. 0x0C - Checked build.
  62. 0x0F - Free build.
  63. MinorVersion - The Windows NT build number (for example, 1381 for NT4).
  64. --*/
  65. {
  66. ExtensionApis = *lpExtensionApis;
  67. g_MajorVersion = MajorVersion;
  68. g_MinorVersion = MinorVersion;
  69. gChkTarget = MajorVersion == 0x0c ? TRUE : FALSE;
  70. #ifdef KDEXT_64BIT
  71. KDDEBUGGER_DATA64 KdDebuggerData;
  72. #else
  73. KDDEBUGGER_DATA32 KdDebuggerData;
  74. #endif
  75. KdDebuggerData.Header.OwnerTag = KDBG_TAG;
  76. KdDebuggerData.Header.Size = sizeof( KdDebuggerData );
  77. if (Ioctl( IG_GET_DEBUGGER_DATA, &KdDebuggerData, sizeof( KdDebuggerData ) ))
  78. {
  79. g_KD = 1;
  80. }
  81. if (sizeof(ULONG64) == sizeof(ULONG_PTR)) //IsPtr64())
  82. {
  83. g_AddressSize = 8;
  84. g_bUnextend = FALSE;
  85. }
  86. else
  87. {
  88. g_AddressSize = 4;
  89. g_bUnextend = TRUE;
  90. }
  91. }
  92. void
  93. CheckVersion( void )
  94. /*++
  95. Function Description:
  96. This function is called before every command. It gives the extension
  97. a chance to compare between the versions of the target and the extension.
  98. In this demo, I don't do much with that.
  99. --*/
  100. {
  101. return;
  102. }