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.

248 lines
4.3 KiB

  1. /*++
  2. Copyright (c) 1998 Microsoft Corporation
  3. Module Name:
  4. ndis.c - DbgExtension Structure information specific to NDIS.SYS
  5. Abstract:
  6. Revision History:
  7. Who When What
  8. -------- -------- ----------------------------------------------
  9. josephj 04-26-98 Created
  10. Notes:
  11. --*/
  12. #include "precomp.h"
  13. //#include <ndis.h>
  14. //#include <ndismini.h>
  15. enum
  16. {
  17. typeid_NDIS_MINIPORT_BLOCK,
  18. typeid_NDIS_M_DRIVER_BLOCK
  19. };
  20. extern TYPE_INFO *g_rgTypes[];
  21. //
  22. // STRUCTURES CONCERNING TYPE "NDIS_MINIPORT_BLOCK"
  23. //
  24. STRUCT_FIELD_INFO rgfi_NDIS_MINIPORT_BLOCK[] =
  25. {
  26. {
  27. "NullValue",
  28. FIELD_OFFSET(NDIS_MINIPORT_BLOCK, NullValue),
  29. FIELD_SIZE(NDIS_MINIPORT_BLOCK, NullValue)
  30. },
  31. {
  32. NULL
  33. }
  34. };
  35. TYPE_INFO type_NDIS_MINIPORT_BLOCK = {
  36. "NDIS_MINIPORT_BLOCK",
  37. "mpb",
  38. typeid_NDIS_MINIPORT_BLOCK,
  39. fTYPEINFO_ISLIST, // Flags
  40. sizeof(NDIS_MINIPORT_BLOCK),
  41. rgfi_NDIS_MINIPORT_BLOCK,
  42. FIELD_OFFSET(NDIS_MINIPORT_BLOCK, NextMiniport) // offset to next pointer.
  43. };
  44. //
  45. // STRUCTURES CONCERNING TYPE "NDIS_M_DRIVER_BLOCK"
  46. //
  47. STRUCT_FIELD_INFO rgfi_NDIS_M_DRIVER_BLOCK[] =
  48. {
  49. {
  50. "MiniportQueue",
  51. FIELD_OFFSET(NDIS_M_DRIVER_BLOCK, MiniportQueue),
  52. FIELD_SIZE(NDIS_M_DRIVER_BLOCK, MiniportQueue)
  53. },
  54. {
  55. NULL
  56. }
  57. };
  58. TYPE_INFO type_NDIS_M_DRIVER_BLOCK = {
  59. "NDIS_M_DRIVER_BLOCK",
  60. "mdb",
  61. typeid_NDIS_M_DRIVER_BLOCK,
  62. fTYPEINFO_ISLIST, // Flags
  63. sizeof(NDIS_M_DRIVER_BLOCK),
  64. rgfi_NDIS_M_DRIVER_BLOCK,
  65. FIELD_OFFSET(NDIS_M_DRIVER_BLOCK, NextDriver) // offset to next pointer.
  66. };
  67. TYPE_INFO *g_rgNDIS_Types[] =
  68. {
  69. &type_NDIS_MINIPORT_BLOCK,
  70. &type_NDIS_M_DRIVER_BLOCK,
  71. NULL
  72. };
  73. GLOBALVAR_INFO g_rgNDIS_Globals[] =
  74. {
  75. //
  76. // Check out aac.c for examples of how to add information about global
  77. // structures...
  78. //
  79. {
  80. NULL
  81. }
  82. };
  83. UINT_PTR
  84. NDIS_ResolveAddress(
  85. TYPE_INFO *pType
  86. );
  87. NAMESPACE NDIS_NameSpace = {
  88. g_rgNDIS_Types,
  89. g_rgNDIS_Globals,
  90. NDIS_ResolveAddress
  91. };
  92. void
  93. NdisCmdHandler(
  94. DBGCOMMAND *pCmd
  95. );
  96. void
  97. do_ndis(PCSTR args)
  98. {
  99. DBGCOMMAND *pCmd = Parse(args, &NDIS_NameSpace);
  100. if (pCmd)
  101. {
  102. DumpCommand(pCmd);
  103. DoCommand(pCmd, NdisCmdHandler);
  104. FreeCommand(pCmd);
  105. pCmd = NULL;
  106. }
  107. return;
  108. }
  109. //mdb list= (PNDIS_M_DRIVER_BLOCK)GetExpression("ndis!ndisMiniDriverList");
  110. void
  111. NdisCmdHandler(
  112. DBGCOMMAND *pCmd
  113. )
  114. {
  115. MyDbgPrintf("Handler called \n");
  116. }
  117. UINT_PTR
  118. NDIS_ResolveAddress(
  119. TYPE_INFO *pType
  120. )
  121. {
  122. UINT_PTR uAddr = 0;
  123. UINT uOffset = 0;
  124. BOOLEAN fRet = FALSE;
  125. UINT_PTR uParentAddress = 0;
  126. // NDIS!ndisMiniDriverList
  127. static UINT_PTR uAddr_ndisMiniDriverList;
  128. //
  129. // If this type has a parent (container) type, we will use the containing
  130. // type's cached address if its available, else we'll resolve the
  131. // containers type. The root types are globals -- we do an
  132. // expression evaluation for them.
  133. //
  134. switch(pType->uTypeID)
  135. {
  136. case typeid_NDIS_M_DRIVER_BLOCK:
  137. //
  138. // We pick up the global ndisMiniDriverList address if we haven't
  139. // already...
  140. //
  141. if (!uAddr_ndisMiniDriverList)
  142. {
  143. uAddr_ndisMiniDriverList =
  144. dbgextGetExpression("ndis!ndisMiniDriverList");
  145. }
  146. uAddr = uAddr_ndisMiniDriverList;
  147. if (uAddr)
  148. {
  149. fRet = TRUE;
  150. }
  151. break;
  152. case typeid_NDIS_MINIPORT_BLOCK:
  153. //
  154. //
  155. //
  156. uParentAddress = type_NDIS_M_DRIVER_BLOCK.uCachedAddress;
  157. if (!uParentAddress)
  158. {
  159. uParentAddress = NDIS_ResolveAddress(&type_NDIS_M_DRIVER_BLOCK);
  160. }
  161. if (uParentAddress)
  162. {
  163. uOffset = FIELD_OFFSET(NDIS_M_DRIVER_BLOCK, MiniportQueue);
  164. fRet = dbgextReadUINT_PTR(
  165. uParentAddress + uOffset,
  166. &uAddr,
  167. "NDIS_M_DRIVER_BLOCK::MiniportQueue"
  168. );
  169. #if 1
  170. MyDbgPrintf(
  171. "fRet = %lu; uParentOff=0x%lx uAddr=0x%lx[0x%lx]\n",
  172. fRet,
  173. uParentAddress+uOffset,
  174. uAddr,
  175. *(UINT_PTR*)(uParentAddress+uOffset)
  176. );
  177. #endif // 0
  178. }
  179. break;
  180. default:
  181. MYASSERT(FALSE);
  182. break;
  183. }
  184. if (!fRet)
  185. {
  186. uAddr = 0;
  187. }
  188. MyDbgPrintf("ResolveAddress[%s] returns 0x%08lx\n", pType->szName, uAddr);
  189. return uAddr;
  190. }