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.

773 lines
24 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. rdr2kd.c
  5. Abstract:
  6. Redirector Kernel Debugger extension
  7. Author:
  8. Balan Sethu Raman (SethuR) 11-May-1994
  9. Revision History:
  10. 11-Nov-1994 SethuR Created
  11. --*/
  12. #include "rx.h" // NT network file system driver include file
  13. #include "ntddnfs2.h" // new stuff device driver definitions
  14. #include "smbmrx.h" // smbmini rdr global include file
  15. #include <string.h>
  16. #include <stdio.h>
  17. #include <kdextlib.h>
  18. #include <rdr2kd.h>
  19. VOID
  20. DumpAStruct (
  21. ULONG_PTR dwAddress,
  22. STRUCT_DESCRIPTOR *pStruct);
  23. VOID
  24. MyDprintf(PCSTR, ULONG_PTR);
  25. ULONG
  26. MyCheckControlC(VOID);
  27. ULONG_PTR
  28. MyGetExpression(PCSTR);
  29. /*
  30. * RDR2 global variables.
  31. *
  32. */
  33. LPSTR GlobalBool[] = {
  34. "mrxsmb!MRxSmbDeferredOpensEnabled",
  35. "mrxsmb!MRxSmbOplocksDisabled",
  36. 0};
  37. LPSTR GlobalShort[] = {0};
  38. LPSTR GlobalLong[] = {
  39. 0};
  40. LPSTR GlobalPtrs[] = {
  41. "rdbss!RxExpCXR",
  42. "rdbss!RxExpEXR",
  43. "rdbss!RxExpAddr",
  44. "rdbss!RxExpCode",
  45. "rdbss!RxActiveContexts",
  46. "rdbss!RxNetNameTable",
  47. "rdbss!RxProcessorArchitecture",
  48. "rdbss!RxBuildNumber",
  49. "rdbss!RxPrivateBuild",
  50. "mrxsmb!SmbMmExchangesInUse",
  51. "mrxsmb!MRxSmbBuildNumber",
  52. "mrxsmb!MRxSmbPrivateBuild",
  53. 0};
  54. /*
  55. * IRP_CONTEXT debugging.
  56. *
  57. */
  58. FIELD_DESCRIPTOR RxContextFields[] =
  59. {
  60. FIELD3(FieldTypeUShort,RX_CONTEXT,NodeTypeCode),
  61. FIELD3(FieldTypeShort,RX_CONTEXT,NodeByteSize),
  62. FIELD3(FieldTypeULong,RX_CONTEXT,ReferenceCount),
  63. FIELD3(FieldTypeULong,RX_CONTEXT,SerialNumber),
  64. FIELD3(FieldTypeStruct,RX_CONTEXT,WorkQueueItem),
  65. FIELD3(FieldTypePointer,RX_CONTEXT,CurrentIrp),
  66. FIELD3(FieldTypePointer,RX_CONTEXT,CurrentIrpSp),
  67. FIELD3(FieldTypePointer,RX_CONTEXT,pFcb),
  68. FIELD3(FieldTypePointer,RX_CONTEXT,pFobx),
  69. //FIELD3(FieldTypePointer,RX_CONTEXT,pRelevantSrvOpen),
  70. FIELD3(FieldTypePointer,RX_CONTEXT,LastExecutionThread),
  71. #ifdef RDBSS_TRACKER
  72. FIELD3(FieldTypePointer,RX_CONTEXT,AcquireReleaseFcbTrackerX),
  73. #endif
  74. FIELD3(FieldTypePointer,RX_CONTEXT,MRxContext[2]),
  75. FIELD3(FieldTypeSymbol,RX_CONTEXT,ResumeRoutine),
  76. FIELD3(FieldTypePointer,RX_CONTEXT,RealDevice),
  77. FIELD3(FieldTypeULongFlags,RX_CONTEXT,Flags),
  78. FIELD3(FieldTypeChar,RX_CONTEXT,MajorFunction),
  79. FIELD3(FieldTypeChar,RX_CONTEXT,MinorFunction),
  80. FIELD3(FieldTypeULong,RX_CONTEXT,StoredStatus),
  81. FIELD3(FieldTypeStruct,RX_CONTEXT,SyncEvent),
  82. FIELD3(FieldTypeStruct,RX_CONTEXT,RxContextSerializationQLinks),
  83. FIELD3(FieldTypeStruct,RX_CONTEXT,Create),
  84. FIELD3(FieldTypeStruct,RX_CONTEXT,LowIoContext),
  85. FIELD3(FieldTypePointer,RX_CONTEXT,Create.NetNamePrefixEntry),
  86. FIELD3(FieldTypePointer,RX_CONTEXT,Create.pSrvCall),
  87. FIELD3(FieldTypePointer,RX_CONTEXT,Create.pNetRoot),
  88. FIELD3(FieldTypePointer,RX_CONTEXT,Create.pVNetRoot),
  89. //FIELD3(FieldTypePointer,RX_CONTEXT,Create.pSrvOpen),
  90. 0
  91. };
  92. /*
  93. * SRV_CALL debugging.
  94. *
  95. */
  96. //CODE.IMPROVEMENT we should have a fieldtype for prefixentry that
  97. // will print out the names
  98. FIELD_DESCRIPTOR SrvCallFields[] =
  99. {
  100. FIELD3(FieldTypeUShort,SRV_CALL,NodeTypeCode),
  101. FIELD3(FieldTypeShort,SRV_CALL,NodeByteSize),
  102. FIELD3(FieldTypeStruct,SRV_CALL,PrefixEntry),
  103. FIELD3(FieldTypeUnicodeString,SRV_CALL,PrefixEntry.Prefix),
  104. FIELD3(FieldTypePointer,SRV_CALL,Context),
  105. FIELD3(FieldTypePointer,SRV_CALL,Context2),
  106. FIELD3(FieldTypeULong,SRV_CALL,Flags),
  107. 0
  108. };
  109. /*
  110. * NET_ROOT debugging.
  111. *
  112. */
  113. FIELD_DESCRIPTOR NetRootFields[] =
  114. {
  115. FIELD3(FieldTypeUShort,NET_ROOT,NodeTypeCode),
  116. FIELD3(FieldTypeShort,NET_ROOT,NodeByteSize),
  117. FIELD3(FieldTypeULong,NET_ROOT,NodeReferenceCount),
  118. FIELD3(FieldTypeStruct,NET_ROOT,PrefixEntry),
  119. FIELD3(FieldTypeUnicodeString,NET_ROOT,PrefixEntry.Prefix),
  120. FIELD3(FieldTypeStruct,NET_ROOT,FcbTable),
  121. //FIELD3(FieldTypePointer,NET_ROOT,Dispatch),
  122. FIELD3(FieldTypePointer,NET_ROOT,Context),
  123. FIELD3(FieldTypePointer,NET_ROOT,Context2),
  124. FIELD3(FieldTypePointer,NET_ROOT,SrvCall),
  125. FIELD3(FieldTypeULong,NET_ROOT,Flags),
  126. 0
  127. };
  128. /*
  129. * V_NET_ROOT debugging.
  130. *
  131. */
  132. FIELD_DESCRIPTOR VNetRootFields[] =
  133. {
  134. FIELD3(FieldTypeUShort,V_NET_ROOT,NodeTypeCode),
  135. FIELD3(FieldTypeShort,V_NET_ROOT,NodeByteSize),
  136. FIELD3(FieldTypeULong,V_NET_ROOT,NodeReferenceCount),
  137. FIELD3(FieldTypeStruct,V_NET_ROOT,PrefixEntry),
  138. FIELD3(FieldTypeUnicodeString,V_NET_ROOT,PrefixEntry.Prefix),
  139. FIELD3(FieldTypeUnicodeString,V_NET_ROOT,NamePrefix),
  140. FIELD3(FieldTypePointer,V_NET_ROOT,Context),
  141. FIELD3(FieldTypePointer,V_NET_ROOT,Context2),
  142. FIELD3(FieldTypePointer,V_NET_ROOT,NetRoot),
  143. 0
  144. };
  145. /*
  146. * FCB debugging.
  147. *
  148. */
  149. FIELD_DESCRIPTOR FcbFields[] =
  150. {
  151. FIELD3(FieldTypeUShort,FCB,Header.NodeTypeCode),
  152. FIELD3(FieldTypeShort,FCB,Header.NodeByteSize),
  153. FIELD3(FieldTypeULong,FCB,NodeReferenceCount),
  154. FIELD3(FieldTypeULong,FCB,FcbState),
  155. FIELD3(FieldTypeULong,FCB,OpenCount),
  156. FIELD3(FieldTypeULong,FCB,UncleanCount),
  157. FIELD3(FieldTypePointer,FCB,Header.Resource),
  158. FIELD3(FieldTypePointer,FCB,Header.PagingIoResource),
  159. FIELD3(FieldTypeStruct,FCB,FcbTableEntry),
  160. FIELD3(FieldTypeUnicodeString,FCB,PrivateAlreadyPrefixedName),
  161. FIELD3(FieldTypePointer,FCB,VNetRoot),
  162. FIELD3(FieldTypePointer,FCB,NetRoot),
  163. FIELD3(FieldTypePointer,FCB,Context),
  164. FIELD3(FieldTypePointer,FCB,Context2),
  165. FIELD3(FieldTypeStruct,FCB,SrvOpenList),
  166. 0
  167. };
  168. FIELD_DESCRIPTOR FcbTableEntry[]=
  169. {
  170. FIELD3(FieldTypeUShort,RX_FCB_TABLE_ENTRY,NodeTypeCode),
  171. FIELD3(FieldTypeUShort,RX_FCB_TABLE_ENTRY,NodeByteSize),
  172. FIELD3(FieldTypeULong, RX_FCB_TABLE_ENTRY,HashValue),
  173. FIELD3(FieldTypeUnicodeString,RX_FCB_TABLE_ENTRY,Path),
  174. FIELD3(FieldTypeULong,RX_FCB_TABLE_ENTRY,HashLinks),
  175. FIELD3(FieldTypeLong,RX_FCB_TABLE_ENTRY,Lookups),
  176. 0
  177. };
  178. FIELD_DESCRIPTOR FcbTable[] =
  179. {
  180. FIELD3(FieldTypeUShort,RX_FCB_TABLE,NodeTypeCode),
  181. FIELD3(FieldTypeUShort,RX_FCB_TABLE,NodeByteSize),
  182. FIELD3(FieldTypeULong,RX_FCB_TABLE,Version),
  183. FIELD3(FieldTypeBoolean,RX_FCB_TABLE,CaseInsensitiveMatch),
  184. FIELD3(FieldTypeUShort,RX_FCB_TABLE,NumberOfBuckets),
  185. FIELD3(FieldTypeLong,RX_FCB_TABLE,Lookups),
  186. FIELD3(FieldTypeLong,RX_FCB_TABLE,FailedLookups),
  187. FIELD3(FieldTypeLong,RX_FCB_TABLE,Compares),
  188. FIELD3(FieldTypePointer,RX_FCB_TABLE,TableEntryForNull),
  189. FIELD3(FieldTypePointer,RX_FCB_TABLE,HashBuckets),
  190. 0
  191. };
  192. /*
  193. * SRV_OPEN debugging.
  194. *
  195. */
  196. FIELD_DESCRIPTOR SrvOpenFields[] =
  197. {
  198. FIELD3(FieldTypeShort,SRV_OPEN,NodeTypeCode),
  199. FIELD3(FieldTypeShort,SRV_OPEN,NodeByteSize),
  200. FIELD3(FieldTypeULong,SRV_OPEN,NodeReferenceCount),
  201. FIELD3(FieldTypePointer,SRV_OPEN,Fcb),
  202. FIELD3(FieldTypeULong,SRV_OPEN,Flags),
  203. 0
  204. };
  205. /*
  206. * FOBX debugging.
  207. *
  208. */
  209. FIELD_DESCRIPTOR FobxFields[] =
  210. {
  211. FIELD3(FieldTypeShort,FOBX,NodeTypeCode),
  212. FIELD3(FieldTypeShort,FOBX,NodeByteSize),
  213. FIELD3(FieldTypeULong,FOBX,NodeReferenceCount),
  214. FIELD3(FieldTypePointer,FOBX,SrvOpen),
  215. 0
  216. };
  217. #define SMBCE_ENTRY_FIELDS(__TYPE__) \
  218. FIELD3(FieldTypeULong,__TYPE__,Header.SwizzleCount), \
  219. FIELD3(FieldTypeChar,__TYPE__,Header.Flags), \
  220. FIELD3(FieldTypeLong,__TYPE__,Header.State),
  221. FIELD_DESCRIPTOR ServerEntryFields[] =
  222. {
  223. SMBCE_ENTRY_FIELDS(SMBCEDB_SERVER_ENTRY)
  224. FIELD3(FieldTypeUnicodeString,SMBCEDB_SERVER_ENTRY,Name),
  225. FIELD3(FieldTypeUnicodeString,SMBCEDB_SERVER_ENTRY,DomainName),
  226. FIELD3(FieldTypeStruct,SMBCEDB_SERVER_ENTRY,Sessions),
  227. FIELD3(FieldTypeStruct,SMBCEDB_SERVER_ENTRY,NetRoots),
  228. FIELD3(FieldTypeStruct,SMBCEDB_SERVER_ENTRY,VNetRootContexts),
  229. FIELD3(FieldTypePointer,SMBCEDB_SERVER_ENTRY,pTransport),
  230. FIELD3(FieldTypeULong,SMBCEDB_SERVER_ENTRY,ServerStatus),
  231. FIELD3(FieldTypePointer,SMBCEDB_SERVER_ENTRY,pMidAtlas),
  232. FIELD3(FieldTypeStruct,SMBCEDB_SERVER_ENTRY,Server),
  233. FIELD3(FieldTypeUnicodeString,SMBCEDB_SERVER_ENTRY,DfsRootName),
  234. FIELD3(FieldTypeUnicodeString,SMBCEDB_SERVER_ENTRY,DnsName),
  235. 0
  236. };
  237. FIELD_DESCRIPTOR SessionEntryFields[] =
  238. {
  239. SMBCE_ENTRY_FIELDS(SMBCEDB_SESSION_ENTRY)
  240. FIELD3(FieldTypePointer,SMBCEDB_SESSION_ENTRY,pServerEntry),
  241. FIELD3(FieldTypePointer,SMBCEDB_SESSION_ENTRY,pServerEntry),
  242. FIELD3(FieldTypeStruct,SMBCEDB_SESSION_ENTRY,Session),
  243. FIELD3(FieldTypeUnicodeString,SMBCEDB_SESSION_ENTRY,pNetRootName),
  244. 0
  245. };
  246. FIELD_DESCRIPTOR NetRootEntryFields[] =
  247. {
  248. SMBCE_ENTRY_FIELDS(SMBCEDB_NET_ROOT_ENTRY)
  249. FIELD3(FieldTypeUnicodeString,SMBCEDB_NET_ROOT_ENTRY,Name),
  250. FIELD3(FieldTypePointer,SMBCEDB_NET_ROOT_ENTRY,pServerEntry),
  251. FIELD3(FieldTypePointer,SMBCEDB_NET_ROOT_ENTRY,pRdbssNetRoot),
  252. FIELD3(FieldTypeStruct,SMBCEDB_NET_ROOT_ENTRY,NetRoot),
  253. FIELD3(FieldTypeBoolean,SMBCEDB_NET_ROOT_ENTRY,NetRoot.DfsAware),
  254. FIELD3(FieldTypeULong,SMBCEDB_NET_ROOT_ENTRY,NetRoot.sCscRootInfo.hShare),
  255. FIELD3(FieldTypeULong,SMBCEDB_NET_ROOT_ENTRY,NetRoot.sCscRootInfo.hRootDir),
  256. FIELD3(FieldTypeChar,SMBCEDB_NET_ROOT_ENTRY,NetRoot.CscEnabled),
  257. FIELD3(FieldTypeChar,SMBCEDB_NET_ROOT_ENTRY,NetRoot.CscShadowable),
  258. FIELD3(FieldTypeBoolean,SMBCEDB_NET_ROOT_ENTRY,NetRoot.Disconnected),
  259. 0
  260. };
  261. FIELD_DESCRIPTOR VNetRootContextFields[] =
  262. {
  263. SMBCE_ENTRY_FIELDS(SMBCE_V_NET_ROOT_CONTEXT)
  264. FIELD3(FieldTypePointer,SMBCE_V_NET_ROOT_CONTEXT,pRdbssVNetRoot),
  265. FIELD3(FieldTypePointer,SMBCE_V_NET_ROOT_CONTEXT,pServerEntry),
  266. FIELD3(FieldTypePointer,SMBCE_V_NET_ROOT_CONTEXT,pSessionEntry),
  267. FIELD3(FieldTypePointer,SMBCE_V_NET_ROOT_CONTEXT,pNetRootEntry),
  268. FIELD3(FieldTypeUShort,SMBCE_V_NET_ROOT_CONTEXT,Flags),
  269. FIELD3(FieldTypeULong,SMBCE_V_NET_ROOT_CONTEXT,TreeId),
  270. 0
  271. };
  272. FIELD_DESCRIPTOR ServerTransportFields[] =
  273. {
  274. FIELD3(FieldTypePointer,SMBCE_SERVER_TRANSPORT,pDispatchVector),
  275. FIELD3(FieldTypePointer,SMBCE_SERVER_TRANSPORT,pTransport),
  276. FIELD3(FieldTypeULong,SMBCE_SERVER_TRANSPORT,MaximumSendSize),
  277. 0
  278. };
  279. FIELD_DESCRIPTOR TransportFields[] =
  280. {
  281. FIELD3(FieldTypeStruct,SMBCE_TRANSPORT,RxCeTransport),
  282. FIELD3(FieldTypeStruct,SMBCE_TRANSPORT,RxCeAddress),
  283. FIELD3(FieldTypeULong,SMBCE_TRANSPORT,Priority),
  284. 0
  285. };
  286. #define EXCHANGE_FIELDS(__TYPE__) \
  287. FIELD3(FieldTypePointer,__TYPE__,RxContext), \
  288. FIELD3(FieldTypePointer,__TYPE__,SmbCeContext.pServerEntry), \
  289. FIELD3(FieldTypeULong,__TYPE__,Status), \
  290. FIELD3(FieldTypeULong,__TYPE__,SmbStatus), \
  291. FIELD3(FieldTypeUShort,__TYPE__,SmbCeState), \
  292. FIELD3(FieldTypeULong,__TYPE__,SmbCeFlags), \
  293. FIELD3(FieldTypeStruct,__TYPE__,WorkQueueItem),
  294. FIELD_DESCRIPTOR OrdinaryExchangeFields[] =
  295. {
  296. EXCHANGE_FIELDS(SMB_PSE_ORDINARY_EXCHANGE)
  297. FIELD3(FieldTypePointer,SMB_PSE_ORDINARY_EXCHANGE,StufferStateDbgPtr),
  298. FIELD3(FieldTypePointer,SMB_PSE_ORDINARY_EXCHANGE,DataPartialMdl),
  299. FIELD3(FieldTypeChar,SMB_PSE_ORDINARY_EXCHANGE,OpSpecificFlags),
  300. FIELD3(FieldTypeChar,SMB_PSE_ORDINARY_EXCHANGE,OpSpecificState),
  301. FIELD3(FieldTypeStruct,SMB_PSE_ORDINARY_EXCHANGE,ParseResumeState),
  302. FIELD3(FieldTypeUShortFlags,SMB_PSE_ORDINARY_EXCHANGE,Flags),
  303. FIELD3(FieldTypeULong,SMB_PSE_ORDINARY_EXCHANGE,MessageLength),
  304. FIELD3(FieldTypeSymbol,SMB_PSE_ORDINARY_EXCHANGE,ContinuationRoutine),
  305. FIELD3(FieldTypeULong,SMB_PSE_ORDINARY_EXCHANGE,StartEntryCount),
  306. FIELD3(FieldTypePointer,SMB_PSE_ORDINARY_EXCHANGE,AsyncResumptionRoutine),
  307. FIELD3(FieldTypeStruct,SMB_PSE_ORDINARY_EXCHANGE,ReadWrite),
  308. FIELD3(FieldTypeStruct,SMB_PSE_ORDINARY_EXCHANGE,AssociatedStufferState),
  309. 0
  310. };
  311. FIELD_DESCRIPTOR TransactExchangeFields[] =
  312. {
  313. EXCHANGE_FIELDS(SMB_TRANSACT_EXCHANGE)
  314. 0
  315. };
  316. typedef struct _ZZEXCHANGE {
  317. SMB_EXCHANGE;
  318. } ZZEXCHANGE, *PZZEXCHANGE;
  319. FIELD_DESCRIPTOR GeneralExchangeFields[] =
  320. {
  321. EXCHANGE_FIELDS(ZZEXCHANGE)
  322. 0
  323. };
  324. typedef struct _ZZSMB_HEADER {
  325. union {
  326. SMB_HEADER;
  327. NT_SMB_HEADER Nt;
  328. };
  329. } ZZSMB_HEADER, *PZZSMB_HEADER;
  330. FIELD_DESCRIPTOR SmbHeaderFields[] =
  331. {
  332. FIELD3(FieldTypeByte,ZZSMB_HEADER,Command),
  333. FIELD3(FieldTypeByte,ZZSMB_HEADER,ErrorClass),
  334. FIELD3(FieldTypeUShortUnaligned,ZZSMB_HEADER,Error),
  335. FIELD3(FieldTypeULongUnaligned,ZZSMB_HEADER,Nt.Status.NtStatus),
  336. FIELD3(FieldTypeByte,ZZSMB_HEADER,Flags),
  337. FIELD3(FieldTypeUShortUnaligned,ZZSMB_HEADER,Flags2),
  338. FIELD3(FieldTypeUShort,ZZSMB_HEADER,PidHigh),
  339. FIELD3(FieldTypeUShort,ZZSMB_HEADER,Pid),
  340. FIELD3(FieldTypeUShort,ZZSMB_HEADER,Tid),
  341. FIELD3(FieldTypeUShort,ZZSMB_HEADER,Uid),
  342. FIELD3(FieldTypeUShort,ZZSMB_HEADER,Mid),
  343. 0
  344. };
  345. FIELD_DESCRIPTOR StufferStateFields[] =
  346. {
  347. FIELD3(FieldTypeChar,SMBSTUFFER_BUFFER_STATE,SpecificProblem),
  348. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,RxContext),
  349. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,Exchange),
  350. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,HeaderMdl),
  351. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,HeaderPartialMdl),
  352. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,ActualBufferBase),
  353. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,BufferBase),
  354. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,BufferLimit),
  355. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,DataMdl),
  356. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,CurrentPosition),
  357. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,CurrentWct),
  358. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,CurrentBcc),
  359. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,CurrentDataOffset),
  360. FIELD3(FieldTypeChar,SMBSTUFFER_BUFFER_STATE,PreviousCommand),
  361. FIELD3(FieldTypeChar,SMBSTUFFER_BUFFER_STATE,CurrentCommand),
  362. FIELD3(FieldTypeULong,SMBSTUFFER_BUFFER_STATE,FlagsCopy),
  363. FIELD3(FieldTypeULong,SMBSTUFFER_BUFFER_STATE,Flags2Copy),
  364. FIELD3(FieldTypeULong,SMBSTUFFER_BUFFER_STATE,DataSize),
  365. FIELD3(FieldTypeChar,SMBSTUFFER_BUFFER_STATE,Started),
  366. 0
  367. };
  368. FIELD_DESCRIPTOR IrpList[] =
  369. {
  370. FIELD3(FieldTypePointer,RX_IRP_LIST_ITEM,pIrp),
  371. FIELD3(FieldTypePointer,RX_IRP_LIST_ITEM,CopyDataBuffer),
  372. FIELD3(FieldTypeULong,RX_IRP_LIST_ITEM,Completed),
  373. 0
  374. };
  375. //this enum is used in the definition of the structures that can be dumped....the order here
  376. //is not important, only that there is a definition for each dumpee structure.....
  377. typedef enum _STRUCTURE_IDS {
  378. StrEnum_RX_CONTEXT = 1,
  379. StrEnum_FCB,
  380. StrEnum_SRV_OPEN,
  381. StrEnum_FOBX,
  382. StrEnum_SRV_CALL,
  383. StrEnum_NET_ROOT,
  384. StrEnum_V_NET_ROOT,
  385. StrEnum_SMBCEDB_SERVER_ENTRY,
  386. StrEnum_SMBCEDB_SESSION_ENTRY,
  387. StrEnum_SMBCEDB_NET_ROOT_ENTRY,
  388. StrEnum_SMBCE_V_NET_ROOT_CONTEXT,
  389. StrEnum_SMB_PSE_ORDINARY_EXCHANGE,
  390. StrEnum_SMB_TRANSACT_EXCHANGE,
  391. StrEnum_ZZEXCHANGE,
  392. StrEnum_SMBSTUFFER_BUFFER_STATE,
  393. StrEnum_SMBCE_TRANSPORT,
  394. StrEnum_SMBCE_SERVER_TRANSPORT,
  395. StrEnum_ZZSMB_HEADER,
  396. StrEnum_RX_FCB_TABLE_ENTRY,
  397. StrEnum_RX_FCB_TABLE,
  398. StrEnum_RX_IRP_LIST_ITEM,
  399. StrEnum_last
  400. };
  401. //
  402. // List of structs currently handled by the debugger extensions
  403. //
  404. STRUCT_DESCRIPTOR Structs[] =
  405. {
  406. STRUCT(RX_CONTEXT,RxContextFields,0xffff,RDBSS_NTC_RX_CONTEXT),
  407. STRUCT(FCB,FcbFields,0xeff0,RDBSS_STORAGE_NTC(0)),
  408. STRUCT(FCB,FcbFields,0xeff0,RDBSS_STORAGE_NTC(0xf0)),
  409. STRUCT(SRV_OPEN,SrvOpenFields,0xffff,RDBSS_NTC_SRVOPEN),
  410. STRUCT(FOBX,FobxFields,0xffff,RDBSS_NTC_FOBX),
  411. STRUCT(SRV_CALL,SrvCallFields,0xffff,RDBSS_NTC_SRVCALL),
  412. STRUCT(NET_ROOT,NetRootFields,0xffff,RDBSS_NTC_NETROOT),
  413. STRUCT(V_NET_ROOT,VNetRootFields,0xffff,RDBSS_NTC_V_NETROOT),
  414. STRUCT(SMBCEDB_SERVER_ENTRY,ServerEntryFields,0xffff,SMB_CONNECTION_ENGINE_NTC(SMBCEDB_OT_SERVER)),
  415. STRUCT(SMBCEDB_SESSION_ENTRY,SessionEntryFields,0xffff,SMB_CONNECTION_ENGINE_NTC(SMBCEDB_OT_SESSION)),
  416. STRUCT(SMBCEDB_NET_ROOT_ENTRY,NetRootEntryFields,0xffff,SMB_CONNECTION_ENGINE_NTC(SMBCEDB_OT_NETROOT)),
  417. STRUCT(SMBCE_V_NET_ROOT_CONTEXT,VNetRootContextFields,0xffff,SMB_CONNECTION_ENGINE_NTC(SMBCEDB_OT_VNETROOTCONTEXT)),
  418. STRUCT(SMB_PSE_ORDINARY_EXCHANGE,OrdinaryExchangeFields,0xffff,SMB_EXCHANGE_NTC(ORDINARY_EXCHANGE)),
  419. STRUCT(SMB_TRANSACT_EXCHANGE,TransactExchangeFields,0xffff,SMB_EXCHANGE_NTC(TRANSACT_EXCHANGE)),
  420. STRUCT(ZZEXCHANGE,GeneralExchangeFields,0xfff0,SMB_EXCHANGE_NTC(0)),
  421. STRUCT(SMBSTUFFER_BUFFER_STATE,StufferStateFields,0xffff,SMB_NTC_STUFFERSTATE),
  422. STRUCT(SMBCE_TRANSPORT,TransportFields,0x0,0xffff),
  423. STRUCT(SMBCE_SERVER_TRANSPORT,ServerTransportFields,0x0,0xffff),
  424. STRUCT(ZZSMB_HEADER,SmbHeaderFields,0x0,0xffff),
  425. STRUCT(RX_FCB_TABLE_ENTRY,FcbTableEntry,0xffff,RDBSS_NTC_FCB_TABLE_ENTRY),
  426. STRUCT(RX_FCB_TABLE,FcbTable,0xffff,RDBSS_NTC_FCB_TABLE),
  427. STRUCT(RX_IRP_LIST_ITEM,IrpList,0x0,0xffff),
  428. 0
  429. };
  430. ULONG_PTR FieldOffsetOfContextListEntryInRxC(){ return FIELD_OFFSET(RX_CONTEXT,ContextListEntry);}
  431. PCWSTR GetExtensionLibPerDebugeeArchitecture(ULONG DebugeeArchitecture){
  432. switch (DebugeeArchitecture) {
  433. case RX_PROCESSOR_ARCHITECTURE_INTEL:
  434. return L"kdextx86.dll";
  435. case RX_PROCESSOR_ARCHITECTURE_MIPS:
  436. return L"kdextmip.dll";
  437. case RX_PROCESSOR_ARCHITECTURE_ALPHA:
  438. return L"kdextalp.dll";
  439. case RX_PROCESSOR_ARCHITECTURE_PPC:
  440. return L"kdextppc.dll";
  441. default:
  442. return(NULL);
  443. }
  444. }
  445. //CODE.IMPROVEMENT it is poor to try to structure along the lines of "this routine knows
  446. // rxstructures" versus "this routine knows debugger extensions". also we
  447. // need a precomp.h
  448. BOOLEAN wGetData( ULONG_PTR dwAddress, PVOID ptr, ULONG size, IN PSZ type);
  449. VOID ReadRxContextFields(ULONG_PTR RxContext,PULONG_PTR pFcb,PULONG_PTR pThread, PULONG_PTR pMiniCtx2)
  450. {
  451. RX_CONTEXT RxContextBuffer;
  452. if (!wGetData(RxContext,&RxContextBuffer,sizeof(RxContextBuffer),"RxContextFieldss")) return;
  453. *pFcb = (ULONG_PTR)(RxContextBuffer.pFcb);
  454. *pThread = (ULONG_PTR)(RxContextBuffer.LastExecutionThread);
  455. *pMiniCtx2 = (ULONG_PTR)(RxContextBuffer.MRxContext[2]);
  456. }
  457. FOLLOWON_HELPER_RETURNS
  458. __FollowOnError (
  459. OUT PBYTE Buffer2,
  460. IN PBYTE followontext,
  461. ULONG LastId,
  462. ULONG Index)
  463. {
  464. if (LastId==0) {
  465. sprintf(Buffer2,"Cant dump a %s. no previous dump.\n",
  466. followontext,Index);
  467. } else {
  468. sprintf(Buffer2,"Cant dump a %s from a %s\n",
  469. followontext,Structs[Index].StructName);
  470. }
  471. return(FOLLOWONHELPER_ERROR);
  472. }
  473. #define FollowOnError(A) (__FollowOnError(Buffer2,A,p->IdOfLastDump,p->IndexOfLastDump))
  474. VOID dprintfsprintfbuffer(BYTE *Buffer);
  475. DECLARE_FOLLOWON_HELPER_CALLEE(FcbFollowOn)
  476. {
  477. //BYTE DbgBuf[200];
  478. //sprintf(DbgBuf,"top p,id=%08lx,%d",p,p->IdOfLastDump);
  479. //dprintfsprintfbuffer(DbgBuf);
  480. switch (p->IdOfLastDump) {
  481. case StrEnum_RX_CONTEXT:{
  482. PRX_CONTEXT RxContext = (PRX_CONTEXT)(&p->StructDumpBuffer[0]);
  483. sprintf(Buffer2," %08p\n",RxContext->pFcb);
  484. return(FOLLOWONHELPER_DUMP);
  485. }
  486. break;
  487. default:
  488. return FollowOnError("irp");
  489. }
  490. }
  491. VOID
  492. DumpList(
  493. ULONG_PTR dwListEntryAddress,
  494. DWORD linkOffset,
  495. VOID (*dumpRoutine)(ULONG_PTR dwStructAddress, STRUCT_DESCRIPTOR *pStruct),
  496. STRUCT_DESCRIPTOR *pStruct
  497. )
  498. {
  499. LIST_ENTRY listHead, listNext;
  500. //
  501. // Get the value in the LIST_ENTRY at dwAddress
  502. //
  503. MyDprintf( "Dumping list @ %08lx\n", dwListEntryAddress );
  504. if (wGetData(dwListEntryAddress, &listHead, sizeof(LIST_ENTRY),"")) {
  505. ULONG_PTR dwNextLink = (ULONG_PTR) listHead.Flink;
  506. if (dwNextLink == 0) {
  507. MyDprintf( "Uninitialized list!\n", 0 );
  508. } else if (dwNextLink == dwListEntryAddress) {
  509. MyDprintf( "Empty list!\n", 0);
  510. } else {
  511. while( dwNextLink != dwListEntryAddress) {
  512. ULONG_PTR dwStructAddress;
  513. if (MyCheckControlC())
  514. return;
  515. dwStructAddress = dwNextLink - linkOffset;
  516. dumpRoutine(dwStructAddress, pStruct);
  517. if (wGetData( dwNextLink, &listNext, sizeof(LIST_ENTRY),"")) {
  518. dwNextLink = (ULONG_PTR) listNext.Flink;
  519. } else {
  520. MyDprintf( "Unable to get next item @%08lx\n", dwNextLink );
  521. break;
  522. }
  523. }
  524. }
  525. } else {
  526. MyDprintf("Unable to read list head @ %08lx\n", dwListEntryAddress);
  527. }
  528. }
  529. //
  530. // All the DoXXXlist routines could be collapsed into one routine, but I
  531. // have left them separate in case future changes are structure-specific.
  532. //
  533. VOID
  534. DoServerlist(ULONG_PTR dwAddress)
  535. {
  536. ULONG i;
  537. BOOLEAN fFound = FALSE;
  538. for (i = 0; Structs[i].StructName != NULL; i++) {
  539. if (strcmp("SMBCEDB_SERVER_ENTRY", Structs[i].StructName) == 0) {
  540. fFound = TRUE;
  541. break;
  542. }
  543. }
  544. if (fFound == FALSE)
  545. return;
  546. DumpList(
  547. dwAddress,
  548. FIELD_OFFSET(SMBCEDB_SERVER_ENTRY, ServersList),
  549. DumpAStruct,
  550. &Structs[i]);
  551. }
  552. VOID
  553. DoNetRootlist(ULONG_PTR dwAddress)
  554. {
  555. ULONG i;
  556. BOOLEAN fFound = FALSE;
  557. for (i = 0; Structs[i].StructName != NULL; i++) {
  558. if (strcmp("SMBCEDB_NET_ROOT_ENTRY", Structs[i].StructName) == 0) {
  559. fFound = TRUE;
  560. break;
  561. }
  562. }
  563. if (fFound == FALSE)
  564. return;
  565. DumpList(
  566. dwAddress,
  567. FIELD_OFFSET(SMBCEDB_NET_ROOT_ENTRY, NetRootsList),
  568. DumpAStruct,
  569. &Structs[i]);
  570. }
  571. VOID
  572. DoSessionlist(ULONG_PTR dwAddress)
  573. {
  574. ULONG i;
  575. BOOLEAN fFound = FALSE;
  576. for (i = 0; Structs[i].StructName != NULL; i++) {
  577. if (strcmp("SMBCEDB_SESSION_ENTRY", Structs[i].StructName) == 0) {
  578. fFound = TRUE;
  579. break;
  580. }
  581. }
  582. if (fFound == FALSE)
  583. return;
  584. DumpList(
  585. dwAddress,
  586. FIELD_OFFSET(SMBCEDB_SESSION_ENTRY, SessionsList),
  587. DumpAStruct,
  588. &Structs[i]);
  589. }
  590. VOID
  591. DoVNetRootContextlist(ULONG_PTR dwAddress)
  592. {
  593. ULONG i;
  594. BOOLEAN fFound = FALSE;
  595. for (i = 0; Structs[i].StructName != NULL; i++) {
  596. if (strcmp("SMBCE_V_NET_ROOT_CONTEXT", Structs[i].StructName) == 0) {
  597. fFound = TRUE;
  598. break;
  599. }
  600. }
  601. if (fFound == FALSE)
  602. return;
  603. DumpList(
  604. dwAddress,
  605. FIELD_OFFSET(SMBCE_V_NET_ROOT_CONTEXT, ListEntry),
  606. DumpAStruct,
  607. &Structs[i]);
  608. }
  609. VOID
  610. DoCscFcbsList(ULONG_PTR dwAddress)
  611. {
  612. ULONG i;
  613. BOOLEAN fFound = FALSE;
  614. for (i = 0; Structs[i].StructName != NULL; i++) {
  615. if (strcmp("FCB", Structs[i].StructName) == 0) {
  616. fFound = TRUE;
  617. break;
  618. }
  619. }
  620. if (fFound == FALSE)
  621. return;
  622. DumpList(
  623. dwAddress,
  624. FIELD_OFFSET(MRX_SMB_FCB, ShadowReverseTranslationLinks),
  625. DumpAStruct,
  626. &Structs[i]);
  627. }
  628. VOID
  629. DoRxIrpsList(ULONG_PTR dwAddress)
  630. {
  631. ULONG i;
  632. BOOLEAN fFound = FALSE;
  633. for (i = 0; Structs[i].StructName != NULL; i++) {
  634. if (strcmp("RX_IRP_LIST_ITEM", Structs[i].StructName) == 0) {
  635. fFound = TRUE;
  636. break;
  637. }
  638. }
  639. if (fFound == FALSE)
  640. return;
  641. DumpList(
  642. dwAddress,
  643. FIELD_OFFSET(RX_IRP_LIST_ITEM, IrpsList),
  644. DumpAStruct,
  645. &Structs[i]);
  646. }