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.

195 lines
6.5 KiB

  1. 4/1/1998 JosephJ
  2. Yesterday I quite successfully set things up so that the kd extensions could
  3. be tested as a simple console app. The code in main.c emulates kd from
  4. the point of view of the extension dll. It works remarkably well.
  5. The memory read/write operations simply read/write memory.
  6. I don't know how kd decides which operations are exported by the dll --
  7. does it simply try to do a getprocaddress for anything the user types
  8. in?
  9. 4/1/1998 JosephJ
  10. Plan of action:
  11. 1. Write code which hex-dumps all the fields of the ARPC_GLOBALS structure.
  12. 2. Fill out the ARPC_CLOBALS description structures.
  13. 3. Write basic command parser.
  14. 4. Add commands to dump globals
  15. // !aac ? d
  16. // !aac help
  17. !aac dr <type> <address> . <field> L <count> <flags>
  18. !aac dr <type> [index] . <field> L <count> <flags>
  19. !aac dg <name> . <field>
  20. !aac dr if[*].*handle*
  21. 01234444: ARPC_INTERFACE[0]
  22. 09890000: [32] .NDISHandle = 02349880
  23. 09890000: [36] .IFHandle = 02349880
  24. 01234444: ARPC_INTERFACE[1]
  25. 09890000: [32] .NDISHandle = 02349880
  26. 09890000: [36] .IFHandle = 02349880
  27. 01234444: ARPC_INTERFACE[2]
  28. 09890000: [32] .NDISHandle = 02349880
  29. 09890000: [36] .IFHandle = 02349880
  30. 4/8/1998 JosephJ
  31. tok_try_force_to_ident(BOOL fPrefixStart, TOKEN *pTok)
  32. //
  33. // This gets called when an identifier is expected -- so we see if this
  34. // particular token can be interpreted as in identifier. Some examples
  35. // of when we can do this:
  36. // dt if.*20334 <--- the "20334" could be part of an identifier, because
  37. // of the * prefix.
  38. //
  39. // dt L.help <--- both "L" and "help" would have been parsed as
  40. // keywords, but here they are intended to be
  41. // identifiers.
  42. // dt abc.def <--- abc and def would have been parsed as numbers (they
  43. // are valid hex numbers), but are intended to be
  44. // identifiers.
  45. 4/26/1998 JosephJ
  46. Change command structure:
  47. !aac i <--- dumps atmarpc interface structure
  48. !ndis mpb <--- dumps ndis NDIS_MINIPORT_BLOCK structure
  49. !ndis mpb <--- dumps ndis M_DRIVER_BLOCK structure
  50. Variations:
  51. !acc i 0xf00998009 <-- dump interface at this address
  52. !aac i <-- dump interface at last cached interface address,
  53. if there is one, else dump list of all interface
  54. pointers.
  55. !aac i[*] <--- list of all interfaces (if it makes sense)
  56. !aac i[2] <--- dump 3rd (zerobased) interface
  57. !aac i.*list* <-- as before.
  58. List walking support...
  59. WalkList(
  60. TYPE_INFO *pType,
  61. UINT_PTR uStartAddress,
  62. UINT uNextOffset,
  63. UINT uStartIndex,
  64. UINT uEndIndex,
  65. DBGCMD *pCmd,
  66. NODEFUNC pFunc
  67. );
  68. The above function will visit each node in the list in turn,
  69. reading just the next pointers. It calls pFunc for each list node
  70. between uStartIndex and uEndIndex. It terminates under the first of
  71. the following conditions:
  72. * Null pointer
  73. * ReadMemoryError
  74. * Read past uEndIndex
  75. * pFunc returns FALSE
  76. 5/7/1998 To Do
  77. Support following:
  78. a -- last-specified adapter
  79. i -- last-specified interface
  80. a[*] -- adapter list
  81. i[*] -- interface list
  82. DoCommand -- makeing it more flexable:
  83. Add TypeProc to TYPE_INFO: generic func to handle customization:
  84. -- print summary information
  85. Add ResolveAddress function to DoCommand
  86. -- resolve address
  87. Add UINT_PTR uLastPtr -- cache of last address used with this type.
  88. 5/31/1998 JosephJ Support for dumping flags
  89. typedef struct
  90. {
  91. UINT Mask;
  92. UINT Value;
  93. char *szName;
  94. } FLAGINFO;
  95. FLAGINFO rgFlagInfo[] =
  96. {
  97. {AA_IPMC_AE_GEN_STATE_MASK, AA_IPMC_AE_VALID, "AA_IPMC_AE_VALID"},
  98. {AA_IPMC_AE_GEN_STATE_MASK, AA_IPMC_AE_INVALID, "AA_IPMC_AE_INVALID"},
  99. {AA_IPMC_AE_GEN_STATE_MASK, AA_IPMC_AE_TERMINATING,
  100. "AA_IPMC_AE_TERMINATING"},
  101. {AA_IPMC_AE_CONN_STATE_MASK, AA_IPMC_AE_CONN_DISCONNECTED,
  102. "AA_IPMC_AE_CONN_DISCONNECTED"}
  103. {0,0,NULL} // must be last.
  104. };
  105. DumpFlags(dwFlags, rgFlagInfo)
  106. {
  107. FLAGIONFO *pFI = rgFlagInfo;
  108. for(;pFI->szName; pFI++)
  109. {
  110. if ((dwFlags & pFI->Mask) == pFI->Value)
  111. {
  112. DbgPrintf(" szName");
  113. }
  114. }
  115. DbgPrintf("\n");
  116. }
  117. Above scheme can deal with traditional enums and 1-bit flags as well.
  118. 6/1/1998 JosephJ Perl script
  119. .h + annotations -> intermediate_form -> source
  120. annotations == allow special cases, so that the generated source
  121. does not have to be modified by hand. This allows easy updating.
  122. generating code to dump flags:
  123. annotation file identifies flag types:
  124. (default mask =
  125. flag
  126. {
  127. {MASK
  128. }
  129. Automatic conversion for:
  130. * enum
  131. * Flags matching a regex pattern: eg
  132. AA_IPMC_AE_*
  133. flag: type=enum/macro
  134. enum {enum_name};
  135. macroflag{mask, flag_pattern}
  136. 7/9/1998 JosephJ
  137. Generic list dumping syntax
  138. !aac void {1-3@45}.$b25@52 21343434
  139. Dumps a 25-byte section at offset 0x52, for list elements 1 to 3. The
  140. next pointer is at offset 0x45. Starting address is 21343434.
  141. So:
  142. $bnnn means nnn bytes
  143. @xxx means byte offset xxx
  144. $bnnn@xxx means nnn butes at byte offset xxx
  145. Other $ global type definitions:
  146. $sz null terminated string
  147. $szz multisz stringox
  148. $wsz unicode null terminated string
  149. $s35 35-byte long ansi string
  150. $ws35 35-char long unicode string
  151. $dw35 35 dwords
  152. $w35 35 16-bit words
  153. $pv pointer
  154. Some examples ...
  155. !aac a -- dumps the most recently referenced adapter (1st time, it will dump the 1st adapter in the global adapter list).
  156. !aac a 0x80001092 -- dumps the adapter at the specified address.
  157. !aac i -- dumps the most recently referenced interface (1st time, it will dump the 1st interface of the 1st adapter).
  158. !aac i.*list* -- dumps all fields of the most recently referenced interface stucture which match the pattern "*list*"
  159. !aac ae[*].RefCount -- dumps the ip addreses of all the atm entries of the most recently referenced interface (yes, you can substitute any field name or pattern like "*Ref*" for "RefCount").
  160. !aac ip[*].IPAddress -- dumps the ref counts of all the ip address of the most recently reference atm entry.
  161. !aac ip[1] -- dumps the next ip structure in the list of ip structures for an atm entry (so you can step through the list items by successively calling !aac ip[1]).
  162. !aac vc[*] -- dumps the vc list for the most recently referenced atm entry.
  163. The dumping formats are terrible -- I'll clean it up and provide more type-friendly output format over time.