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.

1823 lines
57 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. dfskd.c
  5. Abstract:
  6. Dfs Kernel Debugger extension
  7. Author:
  8. Milan Shah (milans) 21-Aug-1995
  9. Revision History:
  10. 21-Aug-1995 Milans Created
  11. --*/
  12. #include <ntos.h>
  13. #include <nturtl.h>
  14. #include "ntverp.h"
  15. #include <windows.h>
  16. #include <wdbgexts.h>
  17. #include <stdlib.h>
  18. #include <string.h>
  19. #include <stdio.h>
  20. #include <windef.h>
  21. #include <tdi.h>
  22. #include <wincred.h>
  23. #include <ntddnfs.h> // For communicating with
  24. // the SMB Rdr
  25. #include <ntddmup.h> // For UNC registration
  26. #include <winnetwk.h> // For NETRESOURCE def'n
  27. #include <dfsfsctl.h> // Dfs FsControl Codes.
  28. #include <lmdfs.h> // DFS_INFO_X
  29. #include "nodetype.h"
  30. #include "dfsmrshl.h"
  31. #include "dfsfsctl.h"
  32. #include "pkt.h"
  33. #include "dfsstruc.h"
  34. #include "fcbsup.h"
  35. #include "fsctrl.h"
  36. #include "dnr.h"
  37. #include "lock.h"
  38. #include "mupstruc.h"
  39. #include "mupdata.h"
  40. #include <kdextlib.h>
  41. #include <stdlib.h>
  42. #define PRINTF dprintf
  43. #define FIELD_NAME_LENGTH 30
  44. #define NewLineForFields(FieldNo) \
  45. ((((FieldNo) % s_NoOfColumns) == 0) ? NewLine : FieldSeparator)
  46. char *NewLine = "\n";
  47. char *FieldSeparator = " ";
  48. BOOLEAN wGetData( ULONG_PTR dwAddress, PVOID ptr, ULONG size);
  49. BOOL wGetString( ULONG_PTR dwAddress, PSZ buf );
  50. BOOL wPrintStringW( IN LPSTR msg OPTIONAL, IN PUNICODE_STRING pStr, IN BOOL nl );
  51. BOOL wPrintStringA( IN LPSTR msg OPTIONAL, IN PANSI_STRING pStr, IN BOOL nl );
  52. BOOL wPrintLargeInt(LARGE_INTEGER *bigint);
  53. /*
  54. * Mup global variables.
  55. *
  56. */
  57. #define NO_SYMBOLS_MESSAGE \
  58. "Unable to get address of Mup!DfsData - do you have symbols?\n"
  59. LPSTR ExtensionNames[] = {
  60. "Mup debugger extensions",
  61. 0
  62. };
  63. LPSTR Extensions[] = {
  64. "DfsData - dumps Mup!DfsData",
  65. "Pkt - dumps the global Pkt",
  66. "FcbTable - dumps all the Dfs FCBs",
  67. "VcbList - dumps all the Vcbs & Dfs Device Objects (net used objects)",
  68. "DrtList - dumps all the Devless Roots (net used objects)",
  69. "OfflineList - dumps all the Offline Roots",
  70. "CredList - dumps all the defined Credentials",
  71. "SpecialTable - dumps the special table",
  72. "PrefixList - dumps all the mup prefixes",
  73. "Dump - dump a data structure. Type in 'mupkd.dump' for more info",
  74. 0
  75. };
  76. ENUM_VALUE_DESCRIPTOR DfsMachineStateEnum[] = {
  77. {DFS_UNKNOWN, "Dfs State Unknown"},
  78. {DFS_CLIENT, "Dfs Client"},
  79. {DFS_SERVER, "Dfs Server"},
  80. {DFS_ROOT_SERVER, "Dfs Root"},
  81. 0
  82. };
  83. /*
  84. * DFS_DATA
  85. *
  86. */
  87. FIELD_DESCRIPTOR DfsDataFields[] = {
  88. FIELD3(FieldTypeShort,DFS_DATA,NodeTypeCode),
  89. FIELD3(FieldTypeShort,DFS_DATA,NodeByteSize),
  90. FIELD3(FieldTypeStruct,DFS_DATA,VcbQueue),
  91. FIELD3(FieldTypeStruct,DFS_DATA,DeletedVcbQueue),
  92. FIELD3(FieldTypeStruct,DFS_DATA,DrtQueue),
  93. FIELD3(FieldTypeStruct,DFS_DATA,Credentials),
  94. FIELD3(FieldTypeStruct,DFS_DATA,DeletedCredentials),
  95. FIELD3(FieldTypeStruct,DFS_DATA,OfflineRoots),
  96. FIELD3(FieldTypePointer,DFS_DATA,DriverObject),
  97. FIELD3(FieldTypePointer,DFS_DATA,FileSysDeviceObject),
  98. FIELD3(FieldTypePointer,DFS_DATA,pProvider),
  99. FIELD3(FieldTypeULong,DFS_DATA,cProvider),
  100. FIELD3(FieldTypeULong,DFS_DATA,maxProvider),
  101. FIELD3(FieldTypeStruct,DFS_DATA,Resource),
  102. FIELD3(FieldTypeStruct,DFS_DATA,DfsLock),
  103. FIELD3(FieldTypePointer,DFS_DATA,OurProcess),
  104. FIELD3(FieldTypeUnicodeString,DFS_DATA,LogRootDevName),
  105. FIELD4(FieldTypeEnum,DFS_DATA,MachineState,DfsMachineStateEnum),
  106. FIELD3(FieldTypeStruct,DFS_DATA,Pkt),
  107. FIELD3(FieldTypeStruct,DFS_DATA,PktWritePending),
  108. FIELD3(FieldTypeStruct,DFS_DATA,PktReferralRequests),
  109. FIELD3(FieldTypePointer,DFS_DATA,FcbHashTable),
  110. 0
  111. };
  112. /*
  113. * DFS_PKT
  114. *
  115. */
  116. FIELD_DESCRIPTOR DfsPktFields[] = {
  117. FIELD3(FieldTypeUShort,DFS_PKT,NodeTypeCode),
  118. FIELD3(FieldTypeUShort,DFS_PKT,NodeByteSize),
  119. FIELD3(FieldTypeStruct,DFS_PKT,Resource),
  120. FIELD3(FieldTypeStruct,DFS_PKT,UseCountLock),
  121. FIELD3(FieldTypeULong,DFS_PKT,EntryCount),
  122. FIELD3(FieldTypeULong,DFS_PKT,EntryTimeToLive),
  123. FIELD3(FieldTypeStruct,DFS_PKT,EntryList),
  124. FIELD3(FieldTypeUnicodeString,DFS_PKT,DCName),
  125. FIELD3(FieldTypeUnicodeString,DFS_PKT,DomainNameFlat),
  126. FIELD3(FieldTypeUnicodeString,DFS_PKT,DomainNameDns),
  127. FIELD3(FieldTypeStruct,DFS_PKT,SpecialTable),
  128. FIELD3(FieldTypeStruct,DFS_PKT,PrefixTable),
  129. FIELD3(FieldTypeStruct,DFS_PKT,ShortPrefixTable),
  130. FIELD3(FieldTypeStruct,DFS_PKT,DSMachineTable),
  131. 0
  132. };
  133. /*
  134. * DFS_SPECIAL_TABLE
  135. *
  136. */
  137. FIELD_DESCRIPTOR DfsSpecialTableFields[] = {
  138. FIELD3(FieldTypeStruct,DFS_SPECIAL_TABLE,SpecialEntryList),
  139. FIELD3(FieldTypeULong,DFS_SPECIAL_TABLE,SpecialEntryCount),
  140. FIELD3(FieldTypeULong,DFS_SPECIAL_TABLE,TimeToLive),
  141. 0
  142. };
  143. /*
  144. * DFS_PKT_ENTRY
  145. *
  146. */
  147. BIT_MASK_DESCRIPTOR PktEntryType[] = {
  148. {PKT_ENTRY_TYPE_DFS, "Uplevel Volume"},
  149. {PKT_ENTRY_TYPE_MACHINE, "Machine Volume"},
  150. {PKT_ENTRY_TYPE_NONDFS, "Downlevel Volume"},
  151. {PKT_ENTRY_TYPE_SYSVOL, "Sysvol"},
  152. {PKT_ENTRY_TYPE_OUTSIDE_MY_DOM, "Inter-Domain Volume"},
  153. {PKT_ENTRY_TYPE_REFERRAL_SVC, "Referral Service (DC)"},
  154. {PKT_ENTRY_TYPE_PERMANENT, "Permanent Entry"},
  155. {PKT_ENTRY_TYPE_LOCAL,"Local Volume"},
  156. {PKT_ENTRY_TYPE_LOCAL_XPOINT,"Local Exit Point"},
  157. {PKT_ENTRY_TYPE_OFFLINE,"Offline Volume"},
  158. 0
  159. };
  160. FIELD_DESCRIPTOR DfsPktEntryFields[] = {
  161. FIELD3(FieldTypeUShort,DFS_PKT_ENTRY,NodeTypeCode),
  162. FIELD3(FieldTypeUShort,DFS_PKT_ENTRY,NodeByteSize),
  163. FIELD3(FieldTypeStruct,DFS_PKT_ENTRY,Link),
  164. FIELD4(FieldTypeDWordBitMask,DFS_PKT_ENTRY,Type,PktEntryType),
  165. FIELD3(FieldTypeULong,DFS_PKT_ENTRY,USN),
  166. FIELD3(FieldTypeUnicodeString,DFS_PKT_ENTRY,Id.Prefix),
  167. FIELD3(FieldTypeUnicodeString,DFS_PKT_ENTRY,Id.ShortPrefix),
  168. FIELD3(FieldTypeULong,DFS_PKT_ENTRY,Info.ServiceCount),
  169. FIELD3(FieldTypePointer,DFS_PKT_ENTRY,Info.ServiceList),
  170. FIELD3(FieldTypeULong,DFS_PKT_ENTRY,ExpireTime),
  171. FIELD3(FieldTypeULong,DFS_PKT_ENTRY,TimeToLive),
  172. FIELD3(FieldTypeULong,DFS_PKT_ENTRY,UseCount),
  173. FIELD3(FieldTypeULong,DFS_PKT_ENTRY,FileOpenCount),
  174. FIELD3(FieldTypePointer,DFS_PKT_ENTRY,ActiveService),
  175. FIELD3(FieldTypePointer,DFS_PKT_ENTRY,LocalService),
  176. FIELD3(FieldTypePointer,DFS_PKT_ENTRY,Superior),
  177. FIELD3(FieldTypeULong,DFS_PKT_ENTRY,SubordinateCount),
  178. FIELD3(FieldTypeStruct,DFS_PKT_ENTRY,SubordinateList),
  179. FIELD3(FieldTypeStruct,DFS_PKT_ENTRY,SiblingLink),
  180. FIELD3(FieldTypePointer,DFS_PKT_ENTRY,ClosestDC),
  181. FIELD3(FieldTypeStruct,DFS_PKT_ENTRY,ChildList),
  182. FIELD3(FieldTypeStruct,DFS_PKT_ENTRY,NextLink),
  183. FIELD3(FieldTypeStruct,DFS_PKT_ENTRY,PrefixTableEntry),
  184. 0
  185. };
  186. /*
  187. * DFS_SERVICE
  188. *
  189. */
  190. BIT_MASK_DESCRIPTOR ServiceType[] = {
  191. {DFS_SERVICE_TYPE_MASTER, "Master Svc"},
  192. {DFS_SERVICE_TYPE_READONLY, "Read-Only Svc"},
  193. {DFS_SERVICE_TYPE_LOCAL, "Local Svc"},
  194. {DFS_SERVICE_TYPE_REFERRAL, "Referral Svc"},
  195. {DFS_SERVICE_TYPE_ACTIVE, "Active Svc"},
  196. {DFS_SERVICE_TYPE_DOWN_LEVEL, "Down-level Svc"},
  197. {DFS_SERVICE_TYPE_COSTLIER, "Costlier than previous"},
  198. {DFS_SERVICE_TYPE_OFFLINE, "Svc Offline"},
  199. 0
  200. };
  201. BIT_MASK_DESCRIPTOR ServiceCapability[] = {
  202. {PROV_DFS_RDR, "Use Dfs Rdr"},
  203. {PROV_STRIP_PREFIX, "Strip Prefix (downlevel or local) Svc"},
  204. 0
  205. };
  206. FIELD_DESCRIPTOR DfsServiceFields[] = {
  207. FIELD4(FieldTypeDWordBitMask,DFS_SERVICE,Type,ServiceType),
  208. FIELD4(FieldTypeDWordBitMask,DFS_SERVICE,Capability,ServiceCapability),
  209. FIELD3(FieldTypeULong,DFS_SERVICE,ProviderId),
  210. FIELD3(FieldTypeUnicodeString,DFS_SERVICE,Name),
  211. FIELD3(FieldTypePointer,DFS_SERVICE,ConnFile),
  212. FIELD3(FieldTypePointer,DFS_SERVICE,pProvider),
  213. FIELD3(FieldTypeUnicodeString,DFS_SERVICE,Address),
  214. FIELD3(FieldTypePointer,DFS_SERVICE,pMachEntry),
  215. FIELD3(FieldTypeULong,DFS_SERVICE,Cost),
  216. 0
  217. };
  218. /*
  219. * DFS_MACHINE_ENTRY
  220. *
  221. */
  222. FIELD_DESCRIPTOR DfsMachineEntryFields[] = {
  223. FIELD3(FieldTypePointer,DFS_MACHINE_ENTRY,pMachine),
  224. FIELD3(FieldTypeUnicodeString,DFS_MACHINE_ENTRY,MachineName),
  225. FIELD3(FieldTypeULong,DFS_MACHINE_ENTRY,UseCount),
  226. FIELD3(FieldTypeULong,DFS_MACHINE_ENTRY,ConnectionCount),
  227. FIELD3(FieldTypePointer,DFS_MACHINE_ENTRY,AuthConn),
  228. FIELD3(FieldTypePointer,DFS_MACHINE_ENTRY,Credentials),
  229. 0
  230. };
  231. /*
  232. * DFS_SPECIAL_ENTRY
  233. *
  234. */
  235. FIELD_DESCRIPTOR DfsSpecialEntryFields[] = {
  236. FIELD3(FieldTypeShort,DFS_SPECIAL_ENTRY,NodeTypeCode),
  237. FIELD3(FieldTypeShort,DFS_SPECIAL_ENTRY,NodeByteSize),
  238. FIELD3(FieldTypeStruct,DFS_SPECIAL_ENTRY,Link),
  239. FIELD3(FieldTypeULong,DFS_SPECIAL_ENTRY,USN),
  240. FIELD3(FieldTypeULong,DFS_SPECIAL_ENTRY,UseCount),
  241. FIELD3(FieldTypeUnicodeString,DFS_SPECIAL_ENTRY,SpecialName),
  242. FIELD3(FieldTypeULong,DFS_SPECIAL_ENTRY,ExpandedCount),
  243. FIELD3(FieldTypeULong,DFS_SPECIAL_ENTRY,Active),
  244. FIELD3(FieldTypePointer,DFS_SPECIAL_ENTRY,ExpandedNames),
  245. FIELD3(FieldTypeBoolean,DFS_SPECIAL_ENTRY,NeedsExpansion),
  246. FIELD3(FieldTypeBoolean,DFS_SPECIAL_ENTRY,Stale),
  247. 0
  248. };
  249. /*
  250. * DFS_EXPANDED_NAME
  251. *
  252. */
  253. FIELD_DESCRIPTOR DfsExpandedNameFields[] = {
  254. FIELD3(FieldTypeUnicodeString,DFS_EXPANDED_NAME,ExpandedName),
  255. FIELD3(FieldTypeStruct,DFS_EXPANDED_NAME,Guid),
  256. 0
  257. };
  258. /*
  259. * DS_MACHINE
  260. *
  261. */
  262. FIELD_DESCRIPTOR DsMachineFields[] = {
  263. FIELD3(FieldTypeGuid,DS_MACHINE,guidSite),
  264. FIELD3(FieldTypeGuid,DS_MACHINE,guidMachine),
  265. FIELD3(FieldTypeULong,DS_MACHINE,grfFlags),
  266. FIELD3(FieldTypePWStr,DS_MACHINE,pwszShareName),
  267. FIELD3(FieldTypeULong,DS_MACHINE,cPrincipals),
  268. FIELD3(FieldTypePointer,DS_MACHINE,prgpwszPrincipals),
  269. FIELD3(FieldTypeULong,DS_MACHINE,cTransports),
  270. FIELD3(FieldTypeStruct,DS_MACHINE,rpTrans),
  271. 0
  272. };
  273. /*
  274. * PROVIDER_DEF
  275. *
  276. */
  277. FIELD_DESCRIPTOR ProviderDefFields[] = {
  278. FIELD3(FieldTypeUShort,PROVIDER_DEF,NodeTypeCode),
  279. FIELD3(FieldTypeUShort,PROVIDER_DEF,NodeByteSize),
  280. FIELD3(FieldTypeUShort,PROVIDER_DEF,eProviderId),
  281. FIELD4(FieldTypeDWordBitMask,PROVIDER_DEF,fProvCapability,ServiceCapability),
  282. FIELD3(FieldTypeUnicodeString,PROVIDER_DEF,DeviceName),
  283. FIELD3(FieldTypePointer,PROVIDER_DEF,DeviceObject),
  284. FIELD3(FieldTypePointer,PROVIDER_DEF,FileObject),
  285. 0
  286. };
  287. /*
  288. * DFS_PREFIX_TABLE
  289. *
  290. */
  291. FIELD_DESCRIPTOR DfsPrefixTableFields[] = {
  292. FIELD3(FieldTypeBoolean,DFS_PREFIX_TABLE,CaseSensitive),
  293. FIELD3(FieldTypePointer,DFS_PREFIX_TABLE,NamePageList.pFirstPage),
  294. FIELD3(FieldTypePointer,DFS_PREFIX_TABLE,NextEntry),
  295. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,RootEntry),
  296. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[0].NoOfEntries),
  297. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[0].SentinelEntry),
  298. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[1].NoOfEntries),
  299. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[1].SentinelEntry),
  300. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[2].NoOfEntries),
  301. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[2].SentinelEntry),
  302. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[3].NoOfEntries),
  303. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[3].SentinelEntry),
  304. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[4].NoOfEntries),
  305. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[4].SentinelEntry),
  306. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[5].NoOfEntries),
  307. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[5].SentinelEntry),
  308. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[6].NoOfEntries),
  309. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[6].SentinelEntry),
  310. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[7].NoOfEntries),
  311. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[7].SentinelEntry),
  312. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[8].NoOfEntries),
  313. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[8].SentinelEntry),
  314. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[9].NoOfEntries),
  315. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[9].SentinelEntry),
  316. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[10].NoOfEntries),
  317. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[10].SentinelEntry),
  318. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[11].NoOfEntries),
  319. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[11].SentinelEntry),
  320. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[12].NoOfEntries),
  321. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[12].SentinelEntry),
  322. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[13].NoOfEntries),
  323. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[13].SentinelEntry),
  324. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[14].NoOfEntries),
  325. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[14].SentinelEntry),
  326. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[15].NoOfEntries),
  327. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[15].SentinelEntry),
  328. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[16].NoOfEntries),
  329. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[16].SentinelEntry),
  330. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[17].NoOfEntries),
  331. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[17].SentinelEntry),
  332. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[18].NoOfEntries),
  333. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[18].SentinelEntry),
  334. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[19].NoOfEntries),
  335. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[19].SentinelEntry),
  336. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[20].NoOfEntries),
  337. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[20].SentinelEntry),
  338. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[21].NoOfEntries),
  339. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[21].SentinelEntry),
  340. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[22].NoOfEntries),
  341. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[22].SentinelEntry),
  342. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[23].NoOfEntries),
  343. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[23].SentinelEntry),
  344. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[24].NoOfEntries),
  345. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[24].SentinelEntry),
  346. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[25].NoOfEntries),
  347. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[25].SentinelEntry),
  348. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[26].NoOfEntries),
  349. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[26].SentinelEntry),
  350. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[27].NoOfEntries),
  351. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[27].SentinelEntry),
  352. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[28].NoOfEntries),
  353. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[28].SentinelEntry),
  354. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[29].NoOfEntries),
  355. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[29].SentinelEntry),
  356. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[30].NoOfEntries),
  357. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[30].SentinelEntry),
  358. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[31].NoOfEntries),
  359. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[31].SentinelEntry),
  360. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[32].NoOfEntries),
  361. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[32].SentinelEntry),
  362. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[33].NoOfEntries),
  363. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[33].SentinelEntry),
  364. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[34].NoOfEntries),
  365. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[34].SentinelEntry),
  366. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[35].NoOfEntries),
  367. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[35].SentinelEntry),
  368. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[36].NoOfEntries),
  369. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[36].SentinelEntry),
  370. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[37].NoOfEntries),
  371. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[37].SentinelEntry),
  372. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[38].NoOfEntries),
  373. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[38].SentinelEntry),
  374. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[39].NoOfEntries),
  375. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[39].SentinelEntry),
  376. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[40].NoOfEntries),
  377. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[40].SentinelEntry),
  378. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[41].NoOfEntries),
  379. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[41].SentinelEntry),
  380. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[42].NoOfEntries),
  381. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[42].SentinelEntry),
  382. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[43].NoOfEntries),
  383. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[43].SentinelEntry),
  384. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[44].NoOfEntries),
  385. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[44].SentinelEntry),
  386. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[45].NoOfEntries),
  387. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[45].SentinelEntry),
  388. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[46].NoOfEntries),
  389. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[46].SentinelEntry),
  390. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[47].NoOfEntries),
  391. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[47].SentinelEntry),
  392. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[48].NoOfEntries),
  393. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[48].SentinelEntry),
  394. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[49].NoOfEntries),
  395. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[49].SentinelEntry),
  396. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[50].NoOfEntries),
  397. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[50].SentinelEntry),
  398. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[51].NoOfEntries),
  399. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[51].SentinelEntry),
  400. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[52].NoOfEntries),
  401. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[52].SentinelEntry),
  402. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[53].NoOfEntries),
  403. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[53].SentinelEntry),
  404. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[54].NoOfEntries),
  405. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[54].SentinelEntry),
  406. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[55].NoOfEntries),
  407. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[55].SentinelEntry),
  408. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE,Buckets[56].NoOfEntries),
  409. FIELD3(FieldTypeStruct,DFS_PREFIX_TABLE,Buckets[56].SentinelEntry),
  410. 0
  411. };
  412. /*
  413. * DFS_PREFIX_TABLE_ENTRY
  414. *
  415. */
  416. FIELD_DESCRIPTOR DfsPrefixTableEntryFields[] = {
  417. FIELD3(FieldTypePointer,DFS_PREFIX_TABLE_ENTRY,pParentEntry),
  418. FIELD3(FieldTypePointer,DFS_PREFIX_TABLE_ENTRY,pNextEntry),
  419. FIELD3(FieldTypePointer,DFS_PREFIX_TABLE_ENTRY,pPrevEntry),
  420. FIELD3(FieldTypePointer,DFS_PREFIX_TABLE_ENTRY,pFirstChildEntry),
  421. FIELD3(FieldTypePointer,DFS_PREFIX_TABLE_ENTRY,pSiblingEntry),
  422. FIELD3(FieldTypeULong,DFS_PREFIX_TABLE_ENTRY,NoOfChildren),
  423. FIELD3(FieldTypeUnicodeString,DFS_PREFIX_TABLE_ENTRY,PathSegment),
  424. FIELD3(FieldTypePointer,DFS_PREFIX_TABLE_ENTRY,pData),
  425. 0
  426. };
  427. /*
  428. * DFS_FCB
  429. *
  430. */
  431. FIELD_DESCRIPTOR FcbFields[] = {
  432. FIELD3(FieldTypeUShort, DFS_FCB, NodeTypeCode),
  433. FIELD3(FieldTypeUShort, DFS_FCB, NodeByteSize),
  434. FIELD3(FieldTypePointer, DFS_FCB, Vcb),
  435. FIELD3(FieldTypeUnicodeString, DFS_FCB, FullFileName),
  436. FIELD3(FieldTypePointer, DFS_FCB, FileObject),
  437. FIELD3(FieldTypePointer, DFS_FCB, TargetDevice),
  438. FIELD3(FieldTypePointer, DFS_FCB, DfsMachineEntry),
  439. 0
  440. };
  441. /*
  442. * DFS_VCB
  443. *
  444. */
  445. BIT_MASK_DESCRIPTOR VcbStateFlagBits[] = {
  446. {VCB_STATE_FLAG_LOCKED, "Vcb Locked"},
  447. {VCB_STATE_FLAG_ALLOC_FCB, "Allocate Fcb"},
  448. 0
  449. };
  450. FIELD_DESCRIPTOR VcbFields[] = {
  451. FIELD3(FieldTypeUShort,DFS_VCB,NodeTypeCode),
  452. FIELD3(FieldTypeUShort,DFS_VCB,NodeByteSize),
  453. FIELD3(FieldTypeStruct,DFS_VCB,VcbLinks),
  454. FIELD4(FieldTypeDWordBitMask,DFS_VCB,VcbState,VcbStateFlagBits),
  455. FIELD3(FieldTypeUnicodeString,DFS_VCB,LogicalRoot),
  456. FIELD3(FieldTypeUnicodeString,DFS_VCB,LogRootPrefix),
  457. FIELD3(FieldTypePointer,DFS_VCB,Credentials),
  458. FIELD3(FieldTypeULong,DFS_VCB,DirectAccessOpenCount),
  459. FIELD3(FieldTypeStruct,DFS_VCB,ShareAccess),
  460. FIELD3(FieldTypeULong,DFS_VCB,OpenFileCount),
  461. FIELD3(FieldTypePointer,DFS_VCB,FileObjectWithVcbLocked),
  462. #ifdef TERMSRV
  463. FIELD3(FieldTypeULong,DFS_VCB,SessionID),
  464. #endif // TERMSRV
  465. FIELD3(FieldTypeULong,DFS_VCB,LogonID),
  466. 0
  467. };
  468. FIELD_DESCRIPTOR DrtFields[] = {
  469. FIELD3(FieldTypeUShort,DFS_DEVLESS_ROOT,NodeTypeCode),
  470. FIELD3(FieldTypeUShort,DFS_DEVLESS_ROOT,NodeByteSize),
  471. FIELD3(FieldTypeStruct,DFS_DEVLESS_ROOT,DrtLinks),
  472. FIELD3(FieldTypeUnicodeString,DFS_DEVLESS_ROOT,DevlessPath),
  473. FIELD3(FieldTypePointer,DFS_DEVLESS_ROOT,Credentials),
  474. #ifdef TERMSRV
  475. FIELD3(FieldTypeULong,DFS_DEVLESS_ROOT,SessionID),
  476. #endif // TERMSRV
  477. FIELD3(FieldTypeULong,DFS_DEVLESS_ROOT,LogonID),
  478. 0
  479. };
  480. FIELD_DESCRIPTOR OfflineRootFields[] = {
  481. FIELD3(FieldTypeUnicodeString,DFS_OFFLINE_SERVER,LogicalServerName),
  482. FIELD3(FieldTypeStruct,DFS_OFFLINE_SERVER,ListEntry),
  483. 0
  484. };
  485. FIELD_DESCRIPTOR KnownPrefixFields[] = {
  486. FIELD3(FieldTypeULong,KNOWN_PREFIX,BlockHeader.ReferenceCount),
  487. FIELD3(FieldTypeStruct,KNOWN_PREFIX,TableEntry),
  488. FIELD3(FieldTypeUnicodeString,KNOWN_PREFIX,Prefix),
  489. FIELD3(FieldTypeStruct,KNOWN_PREFIX,LastUsedTime),
  490. FIELD3(FieldTypeLargeInteger,KNOWN_PREFIX,LastUsedTime),
  491. FIELD3(FieldTypePointer,KNOWN_PREFIX,UncProvider),
  492. FIELD3(FieldTypeBoolean,KNOWN_PREFIX,InTable),
  493. FIELD3(FieldTypeBoolean,KNOWN_PREFIX,Active),
  494. 0
  495. };
  496. FIELD_DESCRIPTOR UncProviderFields[] = {
  497. FIELD3(FieldTypeULong,UNC_PROVIDER,BlockHeader.ReferenceCount),
  498. FIELD3(FieldTypeUnicodeString,UNC_PROVIDER,DeviceName),
  499. FIELD3(FieldTypeStruct,UNC_PROVIDER,Handle),
  500. FIELD3(FieldTypePointer,UNC_PROVIDER,DeviceObject),
  501. FIELD3(FieldTypePointer,UNC_PROVIDER,FileObject),
  502. FIELD3(FieldTypeULong,UNC_PROVIDER,Priority),
  503. FIELD3(FieldTypeBoolean,UNC_PROVIDER,MailslotsSupported),
  504. 0
  505. };
  506. /*
  507. * DFS_CREDENTIALS
  508. *
  509. */
  510. FIELD_DESCRIPTOR CredentialsFields[] = {
  511. FIELD3(FieldTypeStruct,DFS_CREDENTIALS,Link),
  512. FIELD3(FieldTypeULong,DFS_CREDENTIALS,Flags),
  513. FIELD3(FieldTypeULong,DFS_CREDENTIALS,RefCount),
  514. FIELD3(FieldTypeULong,DFS_CREDENTIALS,NetUseCount),
  515. FIELD3(FieldTypeUnicodeString,DFS_CREDENTIALS,ServerName),
  516. FIELD3(FieldTypeUnicodeString,DFS_CREDENTIALS,ShareName),
  517. FIELD3(FieldTypeUnicodeString,DFS_CREDENTIALS,DomainName),
  518. FIELD3(FieldTypeUnicodeString,DFS_CREDENTIALS,UserName),
  519. FIELD3(FieldTypeUnicodeString,DFS_CREDENTIALS,Password),
  520. #ifdef TERMSRV
  521. FIELD3(FieldTypeULong,DFS_CREDENTIALS,SessionID),
  522. #endif // TERMSRV
  523. FIELD3(FieldTypeULong,DFS_CREDENTIALS,LogonID),
  524. FIELD3(FieldTypeULong,DFS_CREDENTIALS, EaLength),
  525. FIELD3(FieldTypeStruct,DFS_CREDENTIALS,EaBuffer),
  526. 0
  527. };
  528. /*
  529. * DNR_CONTEXT
  530. *
  531. */
  532. ENUM_VALUE_DESCRIPTOR DnrStateEnum[] = {
  533. {DnrStateEnter, "DNR State Enter"},
  534. {DnrStateStart, "DNR State Start"},
  535. {DnrStateGetFirstDC, "DNR State GetFirstDC"},
  536. {DnrStateGetReferrals, "DNR State GetReferrals"},
  537. {DnrStateGetNextDC, "DNR State GetNextDC"},
  538. {DnrStateCompleteReferral, "DNR State CompleteReferral"},
  539. {DnrStateSendRequest, "DNR State SendRequest"},
  540. {DnrStatePostProcessOpen, "DNR State PostProcessOpen"},
  541. {DnrStateGetFirstReplica, "DNR State GetFirstReplica"},
  542. {DnrStateGetNextReplica, "DNR State GetNextReplica"},
  543. {DnrStateSvcListCheck, "DNR State SvcListCheck"},
  544. {DnrStateDone, "DNR State Done"},
  545. {DnrStateLocalCompletion, "DNR State LocalCompletion"},
  546. 0
  547. };
  548. FIELD_DESCRIPTOR DnrContextFields[] = {
  549. FIELD3(FieldTypeUShort, DNR_CONTEXT, NodeTypeCode),
  550. FIELD3(FieldTypeUShort, DNR_CONTEXT, NodeByteSize),
  551. FIELD4(FieldTypeEnum, DNR_CONTEXT, State, DnrStateEnum),
  552. FIELD3(FieldTypeStruct,DNR_CONTEXT,SecurityContext),
  553. FIELD3(FieldTypePointer,DNR_CONTEXT,pPktEntry),
  554. FIELD3(FieldTypeULong,DNR_CONTEXT,USN),
  555. FIELD3(FieldTypePointer,DNR_CONTEXT,pService),
  556. FIELD3(FieldTypePointer,DNR_CONTEXT,pProvider),
  557. FIELD3(FieldTypeUShort,DNR_CONTEXT,ProviderId),
  558. FIELD3(FieldTypePointer,DNR_CONTEXT,TargetDevice),
  559. FIELD3(FieldTypePointer,DNR_CONTEXT,AuthConn),
  560. FIELD3(FieldTypePointer,DNR_CONTEXT,DCConnFile),
  561. FIELD3(FieldTypePointer,DNR_CONTEXT,Credentials),
  562. FIELD3(FieldTypePointer,DNR_CONTEXT,pIrpContext),
  563. FIELD3(FieldTypePointer,DNR_CONTEXT,OriginalIrp),
  564. FIELD3(FieldTypeULong,DNR_CONTEXT,FinalStatus),
  565. FIELD3(FieldTypePointer,DNR_CONTEXT,FcbToUse),
  566. FIELD3(FieldTypePointer,DNR_CONTEXT,Vcb),
  567. FIELD3(FieldTypeUnicodeString,DNR_CONTEXT,FileName),
  568. FIELD3(FieldTypeUnicodeString,DNR_CONTEXT,RemainingPart),
  569. FIELD3(FieldTypeUnicodeString,DNR_CONTEXT,SavedFileName),
  570. FIELD3(FieldTypePointer,DNR_CONTEXT,SavedRelatedFileObject),
  571. FIELD3(FieldTypeStruct,DNR_CONTEXT,RSelectContext),
  572. FIELD3(FieldTypeStruct,DNR_CONTEXT,RDCSelectContext),
  573. FIELD3(FieldTypeULong,DNR_CONTEXT,ReferralSize),
  574. FIELD3(FieldTypeULong,DNR_CONTEXT,Attempts),
  575. FIELD3(FieldTypeBoolean,DNR_CONTEXT,ReleasePkt),
  576. FIELD3(FieldTypeBoolean,DNR_CONTEXT,DnrActive),
  577. FIELD3(FieldTypeBoolean,DNR_CONTEXT,GotReferral),
  578. FIELD3(FieldTypeBoolean,DNR_CONTEXT,FoundInconsistency),
  579. FIELD3(FieldTypeBoolean,DNR_CONTEXT,CalledDCLocator),
  580. FIELD3(FieldTypeBoolean,DNR_CONTEXT,Impersonate),
  581. FIELD3(FieldTypeBoolean,DNR_CONTEXT,NameAllocated),
  582. FIELD3(FieldTypePointer,DNR_CONTEXT,DeviceObject),
  583. 0
  584. };
  585. /*
  586. * REPL_SELECT_CONTEXT
  587. *
  588. */
  589. BIT_MASK_DESCRIPTOR ReplSelectFlagBits[] = {
  590. {REPL_UNINITIALIZED, "Uninitialized Context"},
  591. {REPL_SVC_IS_LOCAL, "Local Svc Selected"},
  592. {REPL_SVC_IS_REMOTE, "Remote Svc Selected"},
  593. {REPL_PRINCIPAL_SPECD, "Svc Principal Specified"},
  594. {REPL_NO_MORE_ENTRIES, "Svc List Exhausted"},
  595. 0
  596. };
  597. FIELD_DESCRIPTOR ReplSelectContextFields[] = {
  598. FIELD4(FieldTypeWordBitMask,REPL_SELECT_CONTEXT,Flags,ReplSelectFlagBits),
  599. FIELD3(FieldTypeULong,REPL_SELECT_CONTEXT,iFirstSvcIndex),
  600. FIELD3(FieldTypeULong,REPL_SELECT_CONTEXT,iSvcIndex),
  601. 0
  602. };
  603. STRUCT_DESCRIPTOR Structs[] = {
  604. STRUCT(DFS_DATA,DfsDataFields),
  605. STRUCT(DFS_PKT,DfsPktFields),
  606. STRUCT(DFS_PKT_ENTRY,DfsPktEntryFields),
  607. STRUCT(DFS_SERVICE,DfsServiceFields),
  608. STRUCT(DFS_MACHINE_ENTRY,DfsMachineEntryFields),
  609. STRUCT(DS_MACHINE,DsMachineFields),
  610. STRUCT(DFS_SPECIAL_ENTRY,DfsSpecialEntryFields),
  611. STRUCT(DFS_SPECIAL_TABLE,DfsSpecialTableFields),
  612. STRUCT(DFS_EXPANDED_NAME,DfsExpandedNameFields),
  613. STRUCT(PROVIDER_DEF,ProviderDefFields),
  614. STRUCT(DFS_FCB,FcbFields),
  615. STRUCT(DNR_CONTEXT,DnrContextFields),
  616. STRUCT(DFS_VCB,VcbFields),
  617. STRUCT(DFS_DEVLESS_ROOT,DrtFields),
  618. STRUCT(DFS_OFFLINE_SERVER,OfflineRootFields),
  619. STRUCT(DFS_CREDENTIALS,CredentialsFields),
  620. STRUCT(DFS_PREFIX_TABLE,DfsPrefixTableFields),
  621. STRUCT(DFS_PREFIX_TABLE_ENTRY,DfsPrefixTableEntryFields),
  622. STRUCT(KNOWN_PREFIX,KnownPrefixFields),
  623. STRUCT(UNC_PROVIDER,UncProviderFields),
  624. 0
  625. };
  626. /*
  627. * Dfs specific dump routines
  628. *
  629. */
  630. VOID
  631. dumplist(
  632. ULONG_PTR dwListEntryAddress,
  633. DWORD linkOffset,
  634. VOID (*dumpRoutine)(ULONG_PTR dwStructAddress)
  635. );
  636. VOID
  637. dumpPktEntry(
  638. ULONG_PTR dwAddress
  639. );
  640. VOID
  641. dumpFcb(
  642. ULONG_PTR dwAddress
  643. );
  644. VOID
  645. dumpVcb(
  646. ULONG_PTR dwAddress
  647. );
  648. VOID
  649. dumpDrt(
  650. ULONG_PTR dwAddress
  651. );
  652. VOID
  653. dumpOfflineRoots(
  654. ULONG_PTR dwAddress
  655. );
  656. VOID
  657. dumpPrefix(
  658. ULONG_PTR dwAddress
  659. );
  660. VOID
  661. dumpCredentials(
  662. ULONG_PTR dwAddress
  663. );
  664. BOOL
  665. dumpspecialtable(
  666. ULONG_PTR dwAddress
  667. );
  668. VOID
  669. dumpspecialentry(
  670. ULONG_PTR dwAddress
  671. );
  672. /*
  673. * dfsdata : Routine to dump the global dfs data structure
  674. *
  675. */
  676. BOOL
  677. dfsdata(
  678. ULONG_PTR dwCurrentPC,
  679. PWINDBG_EXTENSION_APIS lpExtensionApis,
  680. LPSTR lpArgumentString
  681. )
  682. {
  683. ULONG_PTR dwAddress;
  684. // SETCALLBACKS();
  685. dwAddress = (GetExpression)("Mup!DfsData");
  686. if (dwAddress) {
  687. DFS_DATA DfsData;
  688. if (wGetData( dwAddress, &DfsData, sizeof(DfsData) )) {
  689. PrintStructFields( dwAddress, &DfsData, DfsDataFields);
  690. } else {
  691. PRINTF( "Unable to read DfsData @ %08lx\n", dwAddress );
  692. }
  693. } else {
  694. PRINTF( NO_SYMBOLS_MESSAGE );
  695. }
  696. return( TRUE );
  697. }
  698. /*
  699. * pkt : Routine to dump the Dfs PKT data structure
  700. *
  701. */
  702. BOOL
  703. pkt(
  704. ULONG_PTR dwCurrentPC,
  705. PWINDBG_EXTENSION_APIS lpExtensionApis,
  706. LPSTR lpArgumentString
  707. )
  708. {
  709. ULONG_PTR dwAddress;
  710. // SETCALLBACKS();
  711. //
  712. // Figure out the address of the Pkt. This is an offset within
  713. // Mup!DfsData.
  714. //
  715. dwAddress = (GetExpression)("Mup!DfsData");
  716. if (dwAddress) {
  717. DFS_PKT pkt;
  718. dwAddress += FIELD_OFFSET(DFS_DATA, Pkt);
  719. if (wGetData(dwAddress,&pkt,sizeof(pkt))) {
  720. PrintStructFields( dwAddress, &pkt, DfsPktFields );
  721. dwAddress += FIELD_OFFSET(DFS_PKT, EntryList);
  722. dumplist(
  723. dwAddress,
  724. FIELD_OFFSET(DFS_PKT_ENTRY,Link),
  725. dumpPktEntry);
  726. }
  727. } else {
  728. PRINTF( NO_SYMBOLS_MESSAGE );
  729. }
  730. return( TRUE );
  731. }
  732. /*
  733. * specialtable : Routine to dump out the special table
  734. *
  735. */
  736. BOOL
  737. specialtable(
  738. ULONG_PTR dwCurrentPC,
  739. PWINDBG_EXTENSION_APIS lpExtensionApis,
  740. LPSTR lpArgumentString)
  741. {
  742. ULONG i;
  743. ULONG_PTR dwAddress;
  744. // SETCALLBACKS();
  745. //
  746. // Figure out the address of the Pkt. This is an offset within
  747. // dfs!DfsData.
  748. //
  749. dwAddress = (GetExpression)("Mup!DfsData");
  750. if (dwAddress) {
  751. dwAddress += FIELD_OFFSET(DFS_DATA, Pkt.SpecialTable);
  752. PRINTF("SpecialTable@0x%x\n", dwAddress);
  753. return dumpspecialtable(dwAddress);
  754. } else {
  755. PRINTF( NO_SYMBOLS_MESSAGE );
  756. }
  757. return(TRUE);
  758. }
  759. /*
  760. * dumpPktEntry : Routine suitable as argument for dumplist; used to dump
  761. * list of pkt entries.
  762. *
  763. */
  764. VOID
  765. dumpPktEntry(
  766. ULONG_PTR dwAddress
  767. )
  768. {
  769. DFS_PKT_ENTRY pktEntry;
  770. if (wGetData(dwAddress, &pktEntry, sizeof(DFS_PKT_ENTRY))) {
  771. PRINTF("\n--- Pkt Entry @ %08lx\n", dwAddress);
  772. wPrintStringW("Prefix : ", &pktEntry.Id.Prefix, TRUE);
  773. wPrintStringW("ShortPrefix : ", &pktEntry.Id.ShortPrefix, TRUE);
  774. //
  775. // Print the local service, if any
  776. //
  777. if (pktEntry.LocalService != NULL) {
  778. DFS_SERVICE Svc;
  779. PRINTF( " Local Svc @%08lx : ",pktEntry.LocalService);
  780. if (wGetData( (ULONG_PTR)pktEntry.LocalService, &Svc, sizeof(Svc))) {
  781. wPrintStringW("Storage Id = ", &Svc.Address, TRUE);
  782. } else {
  783. PRINTF("Storage Id = ?\n");
  784. }
  785. }
  786. //
  787. // Now, print the service list
  788. //
  789. if (pktEntry.Info.ServiceCount != 0) {
  790. ULONG i;
  791. for (i = 0; i < pktEntry.Info.ServiceCount; i++) {
  792. DFS_SERVICE Svc;
  793. ULONG_PTR dwServiceAddress;
  794. if (CheckControlC())
  795. return;
  796. dwServiceAddress =
  797. (ULONG_PTR)(pktEntry.Info.ServiceList) +
  798. i * sizeof(DFS_SERVICE);
  799. PRINTF( " Service %d @%08lx : ",i, dwServiceAddress);
  800. if (wGetData(dwServiceAddress, &Svc, sizeof(Svc))) {
  801. wPrintStringW( "Address =", &Svc.Address, TRUE );
  802. } else {
  803. PRINTF("Address = ?\n");
  804. }
  805. }
  806. }
  807. } else {
  808. PRINTF("Unable to get Pkt Entry @%08lx\n", dwAddress);
  809. }
  810. }
  811. BOOL
  812. dumpspecialtable(
  813. ULONG_PTR dwAddress)
  814. {
  815. ULONG i;
  816. DFS_SPECIAL_TABLE SpecialTable;
  817. LIST_ENTRY ListEntry;
  818. if (wGetData(dwAddress,&SpecialTable,sizeof(DFS_SPECIAL_TABLE))) {
  819. ULONG nEntries = SpecialTable.SpecialEntryCount;
  820. PRINTF("\n--- Special Table @ %08lx\n", dwAddress);
  821. PrintStructFields( dwAddress, &SpecialTable, DfsSpecialTableFields );
  822. dwAddress += FIELD_OFFSET(DFS_SPECIAL_TABLE, SpecialEntryList);
  823. dumplist(
  824. dwAddress,
  825. FIELD_OFFSET(DFS_SPECIAL_ENTRY,Link),
  826. dumpspecialentry);
  827. } else {
  828. PRINTF( NO_SYMBOLS_MESSAGE );
  829. }
  830. return TRUE;
  831. }
  832. /*
  833. * dumpspecialentry : Routine suitable as argument to dumplist; used to dump list of
  834. * special entries
  835. *
  836. */
  837. VOID
  838. dumpspecialentry(
  839. ULONG_PTR dwAddress
  840. )
  841. {
  842. ULONG_PTR dwName;
  843. ULONG i;
  844. DFS_EXPANDED_NAME ExpName;
  845. DFS_SPECIAL_ENTRY specialentry;
  846. if (wGetData( dwAddress, &specialentry, sizeof(specialentry))) {
  847. PRINTF("\ndfs_special_entry @ %08lx\n", dwAddress);
  848. PrintStructFields( dwAddress, &specialentry, DfsSpecialEntryFields );
  849. dwName = (ULONG_PTR) specialentry.ExpandedNames;
  850. for (i = 0; i < specialentry.ExpandedCount; i++) {
  851. if (CheckControlC())
  852. return;
  853. wGetData(dwName, &ExpName, sizeof(DFS_EXPANDED_NAME));
  854. wPrintStringW("\t\tName:", &ExpName.ExpandedName, TRUE);
  855. dwName += sizeof(DFS_EXPANDED_NAME);
  856. }
  857. } else {
  858. PRINTF("\nUnable to read specialentry @ %08lx\n", dwAddress);
  859. }
  860. }
  861. /*
  862. * prefixhash : Routine to compute hash of path component
  863. *
  864. */
  865. BOOL
  866. prefixhash(
  867. ULONG_PTR dwCurrentPC,
  868. PWINDBG_EXTENSION_APIS lpExtensionApis,
  869. LPSTR lpArgumentString
  870. )
  871. {
  872. DWORD BucketNo = 0;
  873. LPSTR lpPath;
  874. // SETCALLBACKS();
  875. if ((lpArgumentString == NULL) || (*lpArgumentString == 0)) {
  876. PRINTF("Usage: prefixhash <path-component>\n");
  877. } else {
  878. lpPath = lpArgumentString;
  879. while (*lpPath != 0)
  880. {
  881. WCHAR wc;
  882. wc = (*lpPath < 'a')
  883. ? (WCHAR) *lpPath
  884. : ((*lpPath < 'z')
  885. ? (WCHAR) (*lpPath - 'a' + 'A')
  886. : (WCHAR) *lpPath);
  887. BucketNo *= 131;
  888. BucketNo += wc;
  889. lpPath++;
  890. }
  891. BucketNo = BucketNo % NO_OF_HASH_BUCKETS;
  892. PRINTF("Hash for <%s> is %d\n", lpArgumentString, BucketNo);
  893. }
  894. return( TRUE );
  895. }
  896. /*
  897. * fcbtable : Routine to dump the dfs fcb hash table
  898. *
  899. */
  900. BOOL
  901. fcbtable(
  902. ULONG_PTR dwCurrentPC,
  903. PWINDBG_EXTENSION_APIS lpExtensionApis,
  904. LPSTR lpArgumentString
  905. )
  906. {
  907. ULONG_PTR dwAddress;
  908. // SETCALLBACKS();
  909. //
  910. // Figure out the address of the Pkt. This is an offset withing
  911. // Mup!DfsData.
  912. //
  913. dwAddress = (GetExpression)("Mup!DfsData");
  914. if (dwAddress) {
  915. DFS_DATA DfsData;
  916. if (wGetData(dwAddress, &DfsData, sizeof(DFS_DATA))) {
  917. FCB_HASH_TABLE FcbTable;
  918. dwAddress = (ULONG_PTR) DfsData.FcbHashTable;
  919. if (wGetData(dwAddress, &FcbTable, sizeof(FCB_HASH_TABLE))) {
  920. ULONG i, cBuckets;
  921. ULONG_PTR dwListHeadAddress;
  922. cBuckets = FcbTable.HashMask + 1;
  923. dwListHeadAddress =
  924. dwAddress + FIELD_OFFSET(FCB_HASH_TABLE, HashBuckets);
  925. PRINTF(
  926. "+++ Fcb Hash Table @ %08lx (%d Buckets) +++\n",
  927. dwAddress, cBuckets);
  928. for (i = 0; i < cBuckets; i++) {
  929. if (CheckControlC())
  930. return TRUE;
  931. PRINTF( "--- Bucket(%d)\n", i );
  932. dumplist(
  933. dwListHeadAddress,
  934. FIELD_OFFSET(DFS_FCB, HashChain),
  935. dumpFcb);
  936. dwListHeadAddress += sizeof(LIST_ENTRY);
  937. }
  938. PRINTF("--- Fcb Hash Table @ %08lx ---\n", dwAddress);
  939. } else {
  940. PRINTF( "Unable to read FcbTable @%08lx\n", dwAddress );
  941. }
  942. } else {
  943. PRINTF( "Unable to read DfsData @%08lx\n", dwAddress);
  944. }
  945. } else {
  946. PRINTF( NO_SYMBOLS_MESSAGE );
  947. }
  948. return( TRUE );
  949. }
  950. /*
  951. * dumpFcb : Routine suitable as argument to dumplist; used to dump list of
  952. * Fcbs
  953. *
  954. */
  955. VOID
  956. dumpFcb(
  957. ULONG_PTR dwAddress
  958. )
  959. {
  960. DFS_FCB fcb;
  961. if (wGetData( dwAddress, &fcb, sizeof(fcb))) {
  962. PRINTF("\nFcb @ %08lx\n", dwAddress);
  963. PrintStructFields( dwAddress, &fcb, FcbFields );
  964. } else {
  965. PRINTF("\nUnable to read Fcb @ %08lx\n", dwAddress);
  966. }
  967. }
  968. /*
  969. * vcblist : Routine to dump out all the Dfs VCBs (ie, all the Dfs Device
  970. * object descriptors).
  971. *
  972. */
  973. BOOL
  974. vcblist(
  975. ULONG_PTR dwCurrentPC,
  976. PWINDBG_EXTENSION_APIS lpExtensionApis,
  977. LPSTR lpArgumentString
  978. )
  979. {
  980. ULONG_PTR dwAddress;
  981. // SETCALLBACKS();
  982. //
  983. // Figure out the address of the Pkt. This is an offset withing
  984. // Mup!DfsData.
  985. //
  986. dwAddress = (GetExpression)("Mup!DfsData");
  987. if (dwAddress) {
  988. dwAddress += FIELD_OFFSET(DFS_DATA, VcbQueue);
  989. dumplist(
  990. dwAddress,
  991. FIELD_OFFSET(DFS_VCB,VcbLinks),
  992. dumpVcb);
  993. } else {
  994. PRINTF( NO_SYMBOLS_MESSAGE );
  995. }
  996. return( TRUE );
  997. }
  998. /*
  999. * prefixlist : Routine to dump out all the mup prefixes
  1000. *
  1001. */
  1002. BOOL
  1003. prefixlist(
  1004. ULONG_PTR dwCurrentPC,
  1005. PWINDBG_EXTENSION_APIS lpExtensionApis,
  1006. LPSTR lpArgumentString
  1007. )
  1008. {
  1009. ULONG_PTR dwAddress;
  1010. // SETCALLBACKS();
  1011. //
  1012. // Figure out the address of the Pkt. This is an offset withing
  1013. // Mup!DfsData.
  1014. //
  1015. dwAddress = (GetExpression)("Mup!MupPrefixList");
  1016. if (dwAddress) {
  1017. dumplist(
  1018. dwAddress,
  1019. FIELD_OFFSET(KNOWN_PREFIX,ListEntry),
  1020. dumpPrefix);
  1021. } else {
  1022. PRINTF( NO_SYMBOLS_MESSAGE );
  1023. }
  1024. return( TRUE );
  1025. }
  1026. /*
  1027. * dumpDeviceObject
  1028. */
  1029. void
  1030. dumpDeviceObject(
  1031. ULONG_PTR dwAddress)
  1032. {
  1033. ULONG_PTR dwTempAddress;
  1034. OBJECT_HEADER obhd;
  1035. OBJECT_HEADER_NAME_INFO obni;
  1036. dwTempAddress = dwAddress - FIELD_OFFSET(OBJECT_HEADER, Body);
  1037. if (wGetData(dwTempAddress, &obhd, sizeof(obhd))) {
  1038. if (obhd.NameInfoOffset != 0) {
  1039. dwTempAddress -= obhd.NameInfoOffset;
  1040. if (wGetData(dwTempAddress, &obni, sizeof(obni))) {
  1041. wPrintStringW(
  1042. " Device Name: ",
  1043. &obni.Name,
  1044. TRUE);
  1045. } else {
  1046. PRINTF("Unable to read Name Info @%08lx\n", dwTempAddress);
  1047. }
  1048. } else {
  1049. PRINTF("\tDevice Name: NULL\n");
  1050. }
  1051. } else {
  1052. PRINTF("Unable to read Object Header @%08lx\n", dwTempAddress);
  1053. }
  1054. }
  1055. void
  1056. dumpVcb(
  1057. ULONG_PTR dwAddress)
  1058. {
  1059. ULONG_PTR dwLogicalRootAddress;
  1060. DFS_VCB vcb;
  1061. dwLogicalRootAddress =
  1062. dwAddress - FIELD_OFFSET(LOGICAL_ROOT_DEVICE_OBJECT, Vcb);
  1063. if (wGetData(dwAddress, &vcb, sizeof(vcb))) {
  1064. PRINTF("+++ Vcb @%08lx : Logical Root Device Object @%08lx +++\n",
  1065. dwAddress, dwLogicalRootAddress);
  1066. PrintStructFields(dwAddress, &vcb, VcbFields);
  1067. dumpDeviceObject( dwLogicalRootAddress );
  1068. PRINTF("--- Vcb @%08lx : Logical Root Device Object @%08lx ---\n",
  1069. dwAddress, dwLogicalRootAddress);
  1070. } else {
  1071. PRINTF("Unable to read Vcb @%08lx\n",dwAddress);
  1072. }
  1073. }
  1074. void
  1075. dumpPrefix(
  1076. ULONG_PTR dwAddress)
  1077. {
  1078. KNOWN_PREFIX knownprefix;
  1079. if (wGetData(dwAddress, &knownprefix, sizeof(knownprefix))) {
  1080. PRINTF("+++ KnownPrefix @%08lx +++\n", dwAddress);
  1081. PrintStructFields(dwAddress, &knownprefix, KnownPrefixFields);
  1082. PRINTF("+++ KnownPrefix @%08lx +++\n", dwAddress);
  1083. } else {
  1084. PRINTF("Unable to read knownprefix @%08lx\n",dwAddress);
  1085. }
  1086. }
  1087. /*
  1088. * credList - dump global list of user credentials
  1089. *
  1090. */
  1091. BOOL
  1092. credlist(
  1093. ULONG_PTR dwCurrentPC,
  1094. PWINDBG_EXTENSION_APIS lpExtensionApis,
  1095. LPSTR lpArgumentString
  1096. )
  1097. {
  1098. ULONG_PTR dwAddress;
  1099. // SETCALLBACKS();
  1100. //
  1101. // Figure out the address of the Pkt. This is an offset withing
  1102. // Mup!DfsData.
  1103. //
  1104. dwAddress = (GetExpression)("Mup!DfsData");
  1105. if (dwAddress) {
  1106. dwAddress += FIELD_OFFSET(DFS_DATA, Credentials);
  1107. dumplist(
  1108. dwAddress,
  1109. FIELD_OFFSET(DFS_CREDENTIALS,Link),
  1110. dumpCredentials);
  1111. } else {
  1112. PRINTF( NO_SYMBOLS_MESSAGE );
  1113. }
  1114. return( TRUE );
  1115. }
  1116. /*
  1117. * dumpCredentials : Routine suitable as argument to dumplist; used to dump
  1118. * a list of DFS_CREDENTIALs.
  1119. */
  1120. void
  1121. dumpCredentials(
  1122. ULONG_PTR dwAddress)
  1123. {
  1124. DFS_CREDENTIALS creds;
  1125. if (wGetData(dwAddress, &creds, sizeof(creds))) {
  1126. PRINTF("+++ Credentials @%08lx +++\n", dwAddress);
  1127. PrintStructFields(dwAddress, &creds, CredentialsFields);
  1128. PRINTF("--- Credentials @%08lx ---\n", dwAddress);
  1129. } else {
  1130. PRINTF("Unable to read Credentials @%08lx\n",dwAddress);
  1131. }
  1132. }
  1133. /*
  1134. * dumplist : A general-purpose routine to dump a list of structures
  1135. *
  1136. */
  1137. VOID
  1138. dumplist(
  1139. ULONG_PTR dwListEntryAddress,
  1140. DWORD linkOffset,
  1141. VOID (*dumpRoutine)(ULONG_PTR dwStructAddress)
  1142. )
  1143. {
  1144. LIST_ENTRY listHead, listNext;
  1145. //
  1146. // Get the value in the LIST_ENTRY at dwAddress
  1147. //
  1148. PRINTF( "Dumping list @ %08lx\n", dwListEntryAddress );
  1149. if (wGetData(dwListEntryAddress, &listHead, sizeof(LIST_ENTRY))) {
  1150. ULONG_PTR dwNextLink = (ULONG_PTR) listHead.Flink;
  1151. if (dwNextLink == 0) {
  1152. PRINTF( "Uninitialized list!\n" );
  1153. } else if (dwNextLink == dwListEntryAddress) {
  1154. PRINTF( "Empty list!\n" );
  1155. } else {
  1156. while( dwNextLink != dwListEntryAddress) {
  1157. ULONG_PTR dwStructAddress;
  1158. if (CheckControlC())
  1159. return;
  1160. dwStructAddress = dwNextLink - linkOffset;
  1161. dumpRoutine(dwStructAddress);
  1162. if (wGetData( dwNextLink, &listNext, sizeof(LIST_ENTRY))) {
  1163. dwNextLink = (ULONG_PTR) listNext.Flink;
  1164. } else {
  1165. PRINTF( "Unable to get next item @%08lx\n", dwNextLink );
  1166. break;
  1167. }
  1168. }
  1169. }
  1170. } else {
  1171. PRINTF("Unable to read list head @ %08lx\n", dwListEntryAddress);
  1172. }
  1173. }
  1174. /*
  1175. * drtlist : Routine to dump out all the Dfs Devless Roots
  1176. *
  1177. */
  1178. BOOL
  1179. drtlist(
  1180. ULONG_PTR dwCurrentPC,
  1181. PWINDBG_EXTENSION_APIS lpExtensionApis,
  1182. LPSTR lpArgumentString
  1183. )
  1184. {
  1185. ULONG_PTR dwAddress;
  1186. // SETCALLBACKS();
  1187. //
  1188. // Figure out the address of the Pkt. This is an offset withing
  1189. // Mup!DfsData.
  1190. //
  1191. dwAddress = (GetExpression)("Mup!DfsData");
  1192. if (dwAddress) {
  1193. dwAddress += FIELD_OFFSET(DFS_DATA, DrtQueue);
  1194. dumplist(
  1195. dwAddress,
  1196. FIELD_OFFSET(DFS_DEVLESS_ROOT,DrtLinks),
  1197. dumpDrt);
  1198. } else {
  1199. PRINTF( NO_SYMBOLS_MESSAGE );
  1200. }
  1201. return( TRUE );
  1202. }
  1203. void
  1204. dumpDrt(
  1205. ULONG_PTR dwAddress)
  1206. {
  1207. DFS_DEVLESS_ROOT drt;
  1208. if (wGetData(dwAddress, &drt, sizeof(drt))) {
  1209. PRINTF("+++ Drt @%08lx : +++\n",
  1210. dwAddress);
  1211. PrintStructFields(dwAddress, &drt, DrtFields);
  1212. PRINTF("--- Drt @%08lx : ---\n",
  1213. dwAddress);
  1214. } else {
  1215. PRINTF("Unable to read Drt @%08lx\n",dwAddress);
  1216. }
  1217. }
  1218. BOOL
  1219. offlinelist(
  1220. ULONG_PTR dwCurrentPC,
  1221. PWINDBG_EXTENSION_APIS lpExtensionApis,
  1222. LPSTR lpArgumentString
  1223. )
  1224. {
  1225. ULONG_PTR dwAddress;
  1226. // SETCALLBACKS();
  1227. //
  1228. // Figure out the address of the Pkt. This is an offset withing
  1229. // Mup!DfsData.
  1230. //
  1231. dwAddress = (GetExpression)("Mup!DfsData");
  1232. if (dwAddress) {
  1233. dwAddress += FIELD_OFFSET(DFS_DATA, OfflineRoots);
  1234. dumplist(
  1235. dwAddress,
  1236. FIELD_OFFSET(DFS_OFFLINE_SERVER,ListEntry),
  1237. dumpOfflineRoots);
  1238. } else {
  1239. PRINTF( NO_SYMBOLS_MESSAGE );
  1240. }
  1241. return( TRUE );
  1242. }
  1243. VOID
  1244. dumpOfflineRoots(
  1245. ULONG_PTR dwAddress)
  1246. {
  1247. DFS_OFFLINE_SERVER srv;
  1248. if (wGetData(dwAddress, &srv, sizeof(srv))) {
  1249. PRINTF("+++ OfflineRoot @%08lx : +++\n",
  1250. dwAddress);
  1251. PrintStructFields(dwAddress, &srv, OfflineRootFields);
  1252. PRINTF("--- Drt @%08lx : ---\n",
  1253. dwAddress);
  1254. } else {
  1255. PRINTF("Unable to read Srv @%08lx\n",dwAddress);
  1256. }
  1257. }
  1258. VOID
  1259. PrintStructFields( ULONG_PTR dwAddress, VOID *ptr, FIELD_DESCRIPTOR *pFieldDescriptors )
  1260. {
  1261. int i;
  1262. WCHAR wszBuffer[80];
  1263. // Display the fields in the struct.
  1264. for( i=0; pFieldDescriptors->Name; i++, pFieldDescriptors++ ) {
  1265. // Indentation to begin the struct display.
  1266. PRINTF( " " );
  1267. if( strlen( pFieldDescriptors->Name ) > FIELD_NAME_LENGTH ) {
  1268. PRINTF( "%-17s...%s ", pFieldDescriptors->Name, pFieldDescriptors->Name+strlen(pFieldDescriptors->Name)-10 );
  1269. } else {
  1270. PRINTF( "%-30s ", pFieldDescriptors->Name );
  1271. }
  1272. switch( pFieldDescriptors->FieldType ) {
  1273. case FieldTypeByte:
  1274. case FieldTypeChar:
  1275. PRINTF( "%-16d%s",
  1276. *(BYTE *)(((char *)ptr) + pFieldDescriptors->Offset ),
  1277. NewLineForFields(i) );
  1278. break;
  1279. case FieldTypeBoolean:
  1280. PRINTF( "%-16s%s",
  1281. *(BOOLEAN *)(((char *)ptr) + pFieldDescriptors->Offset ) ? "TRUE" : "FALSE",
  1282. NewLineForFields(i));
  1283. break;
  1284. case FieldTypeBool:
  1285. PRINTF( "%-16s%s",
  1286. *(BOOLEAN *)(((char *)ptr) + pFieldDescriptors->Offset ) ? "TRUE" : "FALSE",
  1287. NewLineForFields(i));
  1288. break;
  1289. case FieldTypePointer:
  1290. PRINTF( "%-16X%s",
  1291. *(ULONG *)(((char *)ptr) + pFieldDescriptors->Offset ),
  1292. NewLineForFields(i) );
  1293. break;
  1294. case FieldTypeULong:
  1295. case FieldTypeLong:
  1296. PRINTF( "%-16d%s",
  1297. *(ULONG *)(((char *)ptr) + pFieldDescriptors->Offset ),
  1298. NewLineForFields(i) );
  1299. break;
  1300. case FieldTypeShort:
  1301. PRINTF( "%-16X%s",
  1302. *(SHORT *)(((char *)ptr) + pFieldDescriptors->Offset ),
  1303. NewLineForFields(i) );
  1304. break;
  1305. case FieldTypeUShort:
  1306. PRINTF( "%-16X%s",
  1307. *(USHORT *)(((char *)ptr) + pFieldDescriptors->Offset ),
  1308. NewLineForFields(i) );
  1309. break;
  1310. case FieldTypeGuid:
  1311. PrintGuid( (GUID *)(((char *)ptr) + pFieldDescriptors->Offset) );
  1312. PRINTF( NewLine );
  1313. break;
  1314. case FieldTypePWStr:
  1315. if (wGetString( (ULONG_PTR)(((char *)ptr) + pFieldDescriptors->Offset), (char *)wszBuffer )) {
  1316. PRINTF( "%ws", wszBuffer );
  1317. } else {
  1318. PRINTF( "Unable to get string at %08lx", (ULONG_PTR)(((char *)ptr) + pFieldDescriptors->Offset));
  1319. }
  1320. PRINTF( NewLine );
  1321. break;
  1322. case FieldTypeUnicodeString:
  1323. wPrintStringW( NULL, (UNICODE_STRING *)(((char *)ptr) + pFieldDescriptors->Offset ), 0 );
  1324. PRINTF( NewLine );
  1325. break;
  1326. case FieldTypeAnsiString:
  1327. wPrintStringA( NULL, (ANSI_STRING *)(((char *)ptr) + pFieldDescriptors->Offset ), 0 );
  1328. PRINTF( NewLine );
  1329. break;
  1330. case FieldTypeSymbol:
  1331. {
  1332. UCHAR SymbolName[ 200 ];
  1333. ULONG Displacement;
  1334. PVOID sym = (PVOID)(*(ULONG *)(((char *)ptr) + pFieldDescriptors->Offset ));
  1335. GetSymbol(sym, SymbolName, (ULONG_PTR *)&Displacement );
  1336. PRINTF( "%-16s%s",
  1337. SymbolName,
  1338. NewLineForFields(i) );
  1339. }
  1340. break;
  1341. case FieldTypeEnum:
  1342. {
  1343. ULONG EnumValue;
  1344. ENUM_VALUE_DESCRIPTOR *pEnumValueDescr;
  1345. // Get the associated numerical value.
  1346. EnumValue = *((ULONG *)((BYTE *)ptr + pFieldDescriptors->Offset));
  1347. if ((pEnumValueDescr = pFieldDescriptors->AuxillaryInfo.pEnumValueDescriptor)
  1348. != NULL) {
  1349. //
  1350. // An auxilary textual description of the value is
  1351. // available. Display it instead of the numerical value.
  1352. //
  1353. LPSTR pEnumName = NULL;
  1354. while (pEnumValueDescr->EnumName != NULL) {
  1355. if (EnumValue == pEnumValueDescr->EnumValue) {
  1356. pEnumName = pEnumValueDescr->EnumName;
  1357. break;
  1358. }
  1359. pEnumValueDescr++;
  1360. }
  1361. if (pEnumName != NULL) {
  1362. PRINTF( "%-16s ", pEnumName );
  1363. } else {
  1364. PRINTF( "%-4d (%-10s) ", EnumValue,"Unknown!");
  1365. }
  1366. } else {
  1367. //
  1368. // No auxilary information is associated with the ehumerated type
  1369. // print the numerical value.
  1370. //
  1371. PRINTF( "%-16d",EnumValue);
  1372. }
  1373. PRINTF( NewLineForFields(i) );
  1374. }
  1375. break;
  1376. case FieldTypeByteBitMask:
  1377. case FieldTypeWordBitMask:
  1378. case FieldTypeDWordBitMask:
  1379. {
  1380. BOOL fFirstFlag;
  1381. ULONG BitMaskValue;
  1382. BIT_MASK_DESCRIPTOR *pBitMaskDescr;
  1383. BitMaskValue = *((ULONG *)((BYTE *)ptr + pFieldDescriptors->Offset));
  1384. PRINTF("%-8x ", BitMaskValue);
  1385. PRINTF( NewLineForFields(i) );
  1386. pBitMaskDescr = pFieldDescriptors->AuxillaryInfo.pBitMaskDescriptor;
  1387. fFirstFlag = TRUE;
  1388. if (BitMaskValue != 0 && pBitMaskDescr != NULL) {
  1389. while (pBitMaskDescr->BitmaskName != NULL) {
  1390. if ((BitMaskValue & pBitMaskDescr->BitmaskValue) != 0) {
  1391. if (fFirstFlag) {
  1392. fFirstFlag = FALSE;
  1393. PRINTF(" ( %-s", pBitMaskDescr->BitmaskName);
  1394. } else {
  1395. PRINTF( " |\n" );
  1396. PRINTF(" %-s", pBitMaskDescr->BitmaskName);
  1397. }
  1398. }
  1399. pBitMaskDescr++;
  1400. }
  1401. PRINTF(" )");
  1402. PRINTF( NewLineForFields(i) );
  1403. }
  1404. }
  1405. break;
  1406. case FieldTypeStruct:
  1407. PRINTF( "@%-15X%s",
  1408. (dwAddress + pFieldDescriptors->Offset ),
  1409. NewLineForFields(i) );
  1410. break;
  1411. case FieldTypeLargeInteger:
  1412. wPrintLargeInt( (LARGE_INTEGER *)(((char *)ptr) + pFieldDescriptors->Offset) );
  1413. PRINTF( NewLine );
  1414. break;
  1415. case FieldTypeFileTime:
  1416. default:
  1417. dprintf( "Unrecognized field type %c for %s\n", pFieldDescriptors->FieldType, pFieldDescriptors->Name );
  1418. break;
  1419. }
  1420. }
  1421. }
  1422. #define NAME_DELIMITER '@'
  1423. #define INVALID_INDEX 0xffffffff
  1424. #define MIN(x,y) ((x) < (y) ? (x) : (y))
  1425. ULONG SearchStructs(LPSTR lpArgument)
  1426. {
  1427. ULONG i = 0;
  1428. STRUCT_DESCRIPTOR *pStructs = Structs;
  1429. ULONG NameIndex = INVALID_INDEX;
  1430. ULONG ArgumentLength = strlen(lpArgument);
  1431. BOOLEAN fAmbiguous = FALSE;
  1432. while ((pStructs->StructName != 0)) {
  1433. ULONG StructLength;
  1434. StructLength = strlen(pStructs->StructName);
  1435. if (StructLength >= ArgumentLength) {
  1436. int Result = _strnicmp(
  1437. lpArgument,
  1438. pStructs->StructName,
  1439. ArgumentLength);
  1440. if (Result == 0) {
  1441. if (StructLength == ArgumentLength) {
  1442. // Exact match. They must mean this struct!
  1443. fAmbiguous = FALSE;
  1444. NameIndex = i;
  1445. break;
  1446. } else if (NameIndex != INVALID_INDEX) {
  1447. // We have encountered duplicate matches. Print out the
  1448. // matching strings and let the user disambiguate.
  1449. fAmbiguous = TRUE;
  1450. break;
  1451. } else {
  1452. NameIndex = i;
  1453. }
  1454. }
  1455. }
  1456. pStructs++;i++;
  1457. }
  1458. if (fAmbiguous) {
  1459. PRINTF("Ambigous Name Specification -- The following structs match\n");
  1460. PRINTF("%s\n",Structs[NameIndex].StructName);
  1461. PRINTF("%s\n",Structs[i].StructName);
  1462. while (pStructs->StructName != 0) {
  1463. if (_strnicmp(lpArgument,
  1464. pStructs->StructName,
  1465. MIN(strlen(pStructs->StructName),ArgumentLength)) == 0) {
  1466. PRINTF("%s\n",pStructs->StructName);
  1467. }
  1468. pStructs++;
  1469. }
  1470. PRINTF("Dumping Information for %s\n",Structs[NameIndex].StructName);
  1471. }
  1472. return(NameIndex);
  1473. }
  1474. VOID DisplayStructs()
  1475. {
  1476. STRUCT_DESCRIPTOR *pStructs = Structs;
  1477. PRINTF("The following structs are handled .... \n");
  1478. while (pStructs->StructName != 0) {
  1479. PRINTF("\t%s\n",pStructs->StructName);
  1480. pStructs++;
  1481. }
  1482. }
  1483. #define NAME_DELIMITERS "@"
  1484. DECLARE_API( dump )
  1485. {
  1486. ULONG_PTR dwAddress;
  1487. //SETCALLBACKS();
  1488. if( args && *args ) {
  1489. // Parse the argument string to determine the structure to be displayed.
  1490. // Scan for the NAME_DELIMITER ( '@' ).
  1491. LPSTR lpName = (PSTR)args;
  1492. LPSTR lpArgs = strpbrk(args, NAME_DELIMITERS);
  1493. ULONG Index;
  1494. if (lpArgs) {
  1495. //
  1496. // The specified command is of the form
  1497. // dump <name>@<address expr.>
  1498. //
  1499. // Locate the matching struct for the given name. In the case
  1500. // of ambiguity we seek user intervention for disambiguation.
  1501. //
  1502. // We do an inplace modification of the argument string to
  1503. // facilitate matching.
  1504. //
  1505. *lpArgs = '\0';
  1506. for (;*lpName==' ';) { lpName++; } //skip leading blanks
  1507. Index = SearchStructs(lpName);
  1508. //
  1509. // Let us restore the original value back.
  1510. //
  1511. *lpArgs = NAME_DELIMITER;
  1512. if (INVALID_INDEX != Index) {
  1513. BYTE DataBuffer[512];
  1514. dwAddress = GetExpression( ++lpArgs );
  1515. if (wGetData(dwAddress,DataBuffer,Structs[Index].StructSize)) {
  1516. PRINTF(
  1517. "++++++++++++++++ %s@%lx ++++++++++++++++\n",
  1518. Structs[Index].StructName,
  1519. dwAddress);
  1520. PrintStructFields(
  1521. dwAddress,
  1522. &DataBuffer,
  1523. Structs[Index].FieldDescriptors);
  1524. PRINTF(
  1525. "---------------- %s@%lx ----------------\n",
  1526. Structs[Index].StructName,
  1527. dwAddress);
  1528. } else {
  1529. PRINTF("Error reading Memory @ %lx\n",dwAddress);
  1530. }
  1531. } else {
  1532. // No matching struct was found. Display the list of
  1533. // structs currently handled.
  1534. DisplayStructs();
  1535. }
  1536. } else {
  1537. //
  1538. // The command is of the form
  1539. // dump <name>
  1540. //
  1541. // Currently we do not handle this. In future we will map it to
  1542. // the name of a global variable and display it if required.
  1543. //
  1544. DisplayStructs();
  1545. }
  1546. } else {
  1547. //
  1548. // display the list of structs currently handled.
  1549. //
  1550. DisplayStructs();
  1551. }
  1552. return;
  1553. }