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.

183 lines
3.8 KiB

  1. /*++
  2. Copyright (c) 1993 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. Author:
  9. Environment:
  10. User Mode
  11. --*/
  12. #include <wanhelp.h>
  13. //
  14. // globals
  15. //
  16. EXT_API_VERSION ApiVersion = { 3, 5, EXT_API_VERSION_NUMBER, 0 };
  17. WINDBG_EXTENSION_APIS ExtensionApis;
  18. ULONG STeip;
  19. ULONG STebp;
  20. ULONG STesp;
  21. USHORT SavedMajorVersion;
  22. USHORT SavedMinorVersion;
  23. VOID UnicodeToAnsi(PWSTR pws,PSTR ps, ULONG cbLength);
  24. CHAR Name[1024];
  25. PSTR gApiDescriptions[] =
  26. {
  27. "help - What do you think your reading?\n",
  28. "ndiswancb - Dump the contents of the main NdisWan control structure\n",
  29. "enumwanadaptercb - Dump the head of the WanAdapterCB list\n",
  30. "wanadaptercb - Dump the contents of a Wan Miniport Adapter structure\n",
  31. "enumadaptercb - Dump the head of the AdapterCB list\n",
  32. "adaptercb - Dump the contents of a NdisWan Adapter structure\n",
  33. "connectiontable - Dump the connetion table\n",
  34. "bundlecb - Dump the bundlecb\n",
  35. "linkcb - Dump the linkcb\n",
  36. "protocolcb - Dump the protocolcb\n",
  37. "wanpacket - Dump the wanpacket\n",
  38. "ndispacket - Dump the ndispacket\n",
  39. };
  40. #define MAX_APIS 12
  41. //
  42. // THESE ARE NEEDED FOR THE KDEXT DLLs
  43. //
  44. BOOLEAN
  45. DllInit(
  46. HANDLE hModule,
  47. DWORD dwReason,
  48. DWORD dwReserved
  49. )
  50. {
  51. switch (dwReason) {
  52. case DLL_THREAD_ATTACH:
  53. DbgBreakPoint();
  54. break;
  55. case DLL_THREAD_DETACH:
  56. break;
  57. case DLL_PROCESS_DETACH:
  58. break;
  59. case DLL_PROCESS_ATTACH:
  60. break;
  61. }
  62. return TRUE;
  63. }
  64. //
  65. // THESE ARE NEEDED FOR THE KDEXT DLLs
  66. //
  67. VOID
  68. WinDbgExtensionDllInit(
  69. PWINDBG_EXTENSION_APIS lpExtensionApis,
  70. USHORT MajorVersion,
  71. USHORT MinorVersion
  72. )
  73. {
  74. ExtensionApis = *lpExtensionApis;
  75. SavedMajorVersion = MajorVersion;
  76. SavedMinorVersion = MinorVersion;
  77. return;
  78. }
  79. //
  80. // THESE ARE NEEDED FOR THE KDEXT DLLs
  81. //
  82. DECLARE_API( version )
  83. {
  84. #if DBG
  85. PCHAR DebuggerType = "Checked";
  86. #else
  87. PCHAR DebuggerType = "Free";
  88. #endif
  89. dprintf( "%s Extension dll for Build %d debugging %s kernel for Build %d\n",
  90. DebuggerType,
  91. VER_PRODUCTBUILD,
  92. SavedMajorVersion == 0x0c ? "Checked" : "Free",
  93. SavedMinorVersion
  94. );
  95. }
  96. //
  97. // THESE ARE NEEDED FOR THE KDEXT DLLs
  98. //
  99. VOID
  100. CheckVersion(
  101. VOID
  102. )
  103. {
  104. #if DBG
  105. if ((SavedMajorVersion != 0x0c) || (SavedMinorVersion != VER_PRODUCTBUILD)) {
  106. dprintf("\r\n*** Extension DLL(%d Checked) does not match target system(%d %s)\r\n\r\n",
  107. VER_PRODUCTBUILD, SavedMinorVersion, (SavedMajorVersion==0x0f) ? "Free" : "Checked" );
  108. }
  109. #else
  110. if ((SavedMajorVersion != 0x0f) || (SavedMinorVersion != VER_PRODUCTBUILD)) {
  111. dprintf("\r\n*** Extension DLL(%d Free) does not match target system(%d %s)\r\n\r\n",
  112. VER_PRODUCTBUILD, SavedMinorVersion, (SavedMajorVersion==0x0f) ? "Free" : "Checked" );
  113. }
  114. #endif
  115. }
  116. LPEXT_API_VERSION
  117. ExtensionApiVersion(
  118. VOID
  119. )
  120. {
  121. return &ApiVersion;
  122. }
  123. /*++
  124. Try and keep an accurate list of commands.
  125. --*/
  126. DECLARE_API(help)
  127. {
  128. UINT c;
  129. if (0 == args[0]) {
  130. for (c = 0; c < MAX_APIS; c++)
  131. dprintf(gApiDescriptions[c]);
  132. return;
  133. }
  134. }
  135. VOID
  136. UnicodeToAnsi(
  137. PWSTR pws,
  138. PSTR ps,
  139. ULONG cbLength
  140. )
  141. {
  142. PSTR Dest = ps;
  143. PWSTR Src = pws;
  144. ULONG Length = cbLength;
  145. dprintf("Enter UnicodeToAnsi\n");
  146. while (Length--) {
  147. *Dest++ = (CHAR)*Src++;
  148. }
  149. dprintf("Exit UnicodeToAnsi\n");
  150. }