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.

548 lines
19 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. dav2kd.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 <dav2kd.h>
  19. /*
  20. * RDR2 global variables.
  21. *
  22. */
  23. LPSTR GlobalBool[] = {
  24. "mrxsmb!MRxSmbDeferredOpensEnabled",
  25. "mrxsmb!MRxSmbOplocksDisabled",
  26. 0};
  27. LPSTR GlobalShort[] = {0};
  28. LPSTR GlobalLong[] = {
  29. 0};
  30. LPSTR GlobalPtrs[] = {
  31. "mrxdav!RxExpCXR",
  32. "mrxdav!RxExpEXR",
  33. "mrxdav!RxExpAddr",
  34. "mrxdav!RxExpCode",
  35. "mrxdav!RxActiveContexts",
  36. "mrxdav!RxNetNameTable",
  37. "mrxdav!RxProcessorArchitecture",
  38. "mrxdav!RxBuildNumber",
  39. "mrxdav!RxPrivateBuild",
  40. "mrxsmb!SmbMmExchangesInUse",
  41. "mrxsmb!MRxSmbBuildNumber",
  42. "mrxsmb!MRxSmbPrivateBuild",
  43. 0};
  44. /*
  45. * IRP_CONTEXT debugging.
  46. *
  47. */
  48. FIELD_DESCRIPTOR RxContextFields[] =
  49. {
  50. FIELD3(FieldTypeUShort,RX_CONTEXT,NodeTypeCode),
  51. FIELD3(FieldTypeShort,RX_CONTEXT,NodeByteSize),
  52. FIELD3(FieldTypeULong,RX_CONTEXT,ReferenceCount),
  53. FIELD3(FieldTypeULong,RX_CONTEXT,SerialNumber),
  54. FIELD3(FieldTypeStruct,RX_CONTEXT,WorkQueueItem),
  55. FIELD3(FieldTypePointer,RX_CONTEXT,CurrentIrp),
  56. FIELD3(FieldTypePointer,RX_CONTEXT,CurrentIrpSp),
  57. FIELD3(FieldTypePointer,RX_CONTEXT,pFcb),
  58. FIELD3(FieldTypePointer,RX_CONTEXT,pFobx),
  59. //FIELD3(FieldTypePointer,RX_CONTEXT,pRelevantSrvOpen),
  60. FIELD3(FieldTypePointer,RX_CONTEXT,LastExecutionThread),
  61. #ifdef RDBSS_TRACKER
  62. FIELD3(FieldTypePointer,RX_CONTEXT,AcquireReleaseFcbTrackerX),
  63. #endif
  64. FIELD3(FieldTypePointer,RX_CONTEXT,MRxContext[2]),
  65. FIELD3(FieldTypeSymbol,RX_CONTEXT,ResumeRoutine),
  66. FIELD3(FieldTypePointer,RX_CONTEXT,RealDevice),
  67. FIELD3(FieldTypeULongFlags,RX_CONTEXT,Flags),
  68. FIELD3(FieldTypeChar,RX_CONTEXT,MajorFunction),
  69. FIELD3(FieldTypeChar,RX_CONTEXT,MinorFunction),
  70. FIELD3(FieldTypeULong,RX_CONTEXT,StoredStatus),
  71. FIELD3(FieldTypeStruct,RX_CONTEXT,SyncEvent),
  72. FIELD3(FieldTypeStruct,RX_CONTEXT,RxContextSerializationQLinks),
  73. FIELD3(FieldTypeStruct,RX_CONTEXT,Create),
  74. FIELD3(FieldTypeStruct,RX_CONTEXT,LowIoContext),
  75. FIELD3(FieldTypePointer,RX_CONTEXT,Create.NetNamePrefixEntry),
  76. FIELD3(FieldTypePointer,RX_CONTEXT,Create.pSrvCall),
  77. FIELD3(FieldTypePointer,RX_CONTEXT,Create.pNetRoot),
  78. FIELD3(FieldTypePointer,RX_CONTEXT,Create.pVNetRoot),
  79. //FIELD3(FieldTypePointer,RX_CONTEXT,Create.pSrvOpen),
  80. 0
  81. };
  82. /*
  83. * SRV_CALL debugging.
  84. *
  85. */
  86. //CODE.IMPROVEMENT we should have a fieldtype for prefixentry that
  87. // will print out the names
  88. FIELD_DESCRIPTOR SrvCallFields[] =
  89. {
  90. FIELD3(FieldTypeUShort,SRV_CALL,NodeTypeCode),
  91. FIELD3(FieldTypeShort,SRV_CALL,NodeByteSize),
  92. FIELD3(FieldTypeStruct,SRV_CALL,PrefixEntry),
  93. FIELD3(FieldTypeUnicodeString,SRV_CALL,PrefixEntry.Prefix),
  94. FIELD3(FieldTypePointer,SRV_CALL,Context),
  95. FIELD3(FieldTypePointer,SRV_CALL,Context2),
  96. FIELD3(FieldTypeULong,SRV_CALL,Flags),
  97. 0
  98. };
  99. /*
  100. * NET_ROOT debugging.
  101. *
  102. */
  103. FIELD_DESCRIPTOR NetRootFields[] =
  104. {
  105. FIELD3(FieldTypeUShort,NET_ROOT,NodeTypeCode),
  106. FIELD3(FieldTypeShort,NET_ROOT,NodeByteSize),
  107. FIELD3(FieldTypeULong,NET_ROOT,NodeReferenceCount),
  108. FIELD3(FieldTypeStruct,NET_ROOT,PrefixEntry),
  109. FIELD3(FieldTypeUnicodeString,NET_ROOT,PrefixEntry.Prefix),
  110. FIELD3(FieldTypeStruct,NET_ROOT,FcbTable),
  111. //FIELD3(FieldTypePointer,NET_ROOT,Dispatch),
  112. FIELD3(FieldTypePointer,NET_ROOT,Context),
  113. FIELD3(FieldTypePointer,NET_ROOT,Context2),
  114. FIELD3(FieldTypePointer,NET_ROOT,SrvCall),
  115. FIELD3(FieldTypeULong,NET_ROOT,Flags),
  116. 0
  117. };
  118. /*
  119. * V_NET_ROOT debugging.
  120. *
  121. */
  122. FIELD_DESCRIPTOR VNetRootFields[] =
  123. {
  124. FIELD3(FieldTypeUShort,V_NET_ROOT,NodeTypeCode),
  125. FIELD3(FieldTypeShort,V_NET_ROOT,NodeByteSize),
  126. FIELD3(FieldTypeULong,V_NET_ROOT,NodeReferenceCount),
  127. FIELD3(FieldTypeStruct,V_NET_ROOT,PrefixEntry),
  128. FIELD3(FieldTypeUnicodeString,V_NET_ROOT,PrefixEntry.Prefix),
  129. FIELD3(FieldTypeUnicodeString,V_NET_ROOT,NamePrefix),
  130. FIELD3(FieldTypePointer,V_NET_ROOT,Context),
  131. FIELD3(FieldTypePointer,V_NET_ROOT,Context2),
  132. FIELD3(FieldTypePointer,V_NET_ROOT,NetRoot),
  133. 0
  134. };
  135. /*
  136. * FCB debugging.
  137. *
  138. */
  139. FIELD_DESCRIPTOR FcbFields[] =
  140. {
  141. FIELD3(FieldTypeUShort,FCB,Header.NodeTypeCode),
  142. FIELD3(FieldTypeShort,FCB,Header.NodeByteSize),
  143. FIELD3(FieldTypeULong,FCB,NodeReferenceCount),
  144. FIELD3(FieldTypeULong,FCB,FcbState),
  145. FIELD3(FieldTypeULong,FCB,OpenCount),
  146. FIELD3(FieldTypeULong,FCB,UncleanCount),
  147. FIELD3(FieldTypePointer,FCB,Header.Resource),
  148. FIELD3(FieldTypePointer,FCB,Header.PagingIoResource),
  149. FIELD3(FieldTypeStruct,FCB,FcbTableEntry),
  150. FIELD3(FieldTypeUnicodeString,FCB,PrivateAlreadyPrefixedName),
  151. FIELD3(FieldTypePointer,FCB,VNetRoot),
  152. FIELD3(FieldTypePointer,FCB,NetRoot),
  153. FIELD3(FieldTypePointer,FCB,Context),
  154. FIELD3(FieldTypePointer,FCB,Context2),
  155. FIELD3(FieldTypeStruct,FCB,SrvOpenList),
  156. 0
  157. };
  158. FIELD_DESCRIPTOR FcbTableEntry[]=
  159. {
  160. FIELD3(FieldTypeUShort,RX_FCB_TABLE_ENTRY,NodeTypeCode),
  161. FIELD3(FieldTypeUShort,RX_FCB_TABLE_ENTRY,NodeByteSize),
  162. FIELD3(FieldTypeULong, RX_FCB_TABLE_ENTRY,HashValue),
  163. FIELD3(FieldTypeUnicodeString,RX_FCB_TABLE_ENTRY,Path),
  164. FIELD3(FieldTypeULong,RX_FCB_TABLE_ENTRY,HashLinks),
  165. FIELD3(FieldTypeLong,RX_FCB_TABLE_ENTRY,Lookups),
  166. 0
  167. };
  168. FIELD_DESCRIPTOR FcbTable[] =
  169. {
  170. FIELD3(FieldTypeUShort,RX_FCB_TABLE,NodeTypeCode),
  171. FIELD3(FieldTypeUShort,RX_FCB_TABLE,NodeByteSize),
  172. FIELD3(FieldTypeULong,RX_FCB_TABLE,Version),
  173. FIELD3(FieldTypeBoolean,RX_FCB_TABLE,CaseInsensitiveMatch),
  174. FIELD3(FieldTypeUShort,RX_FCB_TABLE,NumberOfBuckets),
  175. FIELD3(FieldTypeLong,RX_FCB_TABLE,Lookups),
  176. FIELD3(FieldTypeLong,RX_FCB_TABLE,FailedLookups),
  177. FIELD3(FieldTypeLong,RX_FCB_TABLE,Compares),
  178. FIELD3(FieldTypePointer,RX_FCB_TABLE,TableEntryForNull),
  179. FIELD3(FieldTypePointer,RX_FCB_TABLE,HashBuckets),
  180. 0
  181. };
  182. /*
  183. * SRV_OPEN debugging.
  184. *
  185. */
  186. FIELD_DESCRIPTOR SrvOpenFields[] =
  187. {
  188. FIELD3(FieldTypeShort,SRV_OPEN,NodeTypeCode),
  189. FIELD3(FieldTypeShort,SRV_OPEN,NodeByteSize),
  190. FIELD3(FieldTypeULong,SRV_OPEN,NodeReferenceCount),
  191. FIELD3(FieldTypePointer,SRV_OPEN,Fcb),
  192. FIELD3(FieldTypeULong,SRV_OPEN,Flags),
  193. 0
  194. };
  195. /*
  196. * FOBX debugging.
  197. *
  198. */
  199. FIELD_DESCRIPTOR FobxFields[] =
  200. {
  201. FIELD3(FieldTypeShort,FOBX,NodeTypeCode),
  202. FIELD3(FieldTypeShort,FOBX,NodeByteSize),
  203. FIELD3(FieldTypeULong,FOBX,NodeReferenceCount),
  204. FIELD3(FieldTypePointer,FOBX,SrvOpen),
  205. 0
  206. };
  207. #define SMBCE_ENTRY_FIELDS(__TYPE__) \
  208. FIELD3(FieldTypeULong,__TYPE__,Header.SwizzleCount), \
  209. FIELD3(FieldTypeChar,__TYPE__,Header.Flags), \
  210. FIELD3(FieldTypeLong,__TYPE__,Header.State),
  211. FIELD_DESCRIPTOR ServerEntryFields[] =
  212. {
  213. SMBCE_ENTRY_FIELDS(SMBCEDB_SERVER_ENTRY)
  214. FIELD3(FieldTypeUnicodeString,SMBCEDB_SERVER_ENTRY,Name),
  215. FIELD3(FieldTypeStruct,SMBCEDB_SERVER_ENTRY,Sessions),
  216. FIELD3(FieldTypeStruct,SMBCEDB_SERVER_ENTRY,NetRoots),
  217. FIELD3(FieldTypePointer,SMBCEDB_SERVER_ENTRY,pTransport),
  218. FIELD3(FieldTypeULong,SMBCEDB_SERVER_ENTRY,ServerStatus),
  219. FIELD3(FieldTypePointer,SMBCEDB_SERVER_ENTRY,pMidAtlas),
  220. FIELD3(FieldTypeStruct,SMBCEDB_SERVER_ENTRY,Server),
  221. FIELD3(FieldTypeUnicodeString,SMBCEDB_SERVER_ENTRY,DfsRootName),
  222. 0
  223. };
  224. FIELD_DESCRIPTOR SessionEntryFields[] =
  225. {
  226. SMBCE_ENTRY_FIELDS(SMBCEDB_SESSION_ENTRY)
  227. FIELD3(FieldTypePointer,SMBCEDB_SESSION_ENTRY,pServerEntry),
  228. FIELD3(FieldTypePointer,SMBCEDB_SESSION_ENTRY,pServerEntry),
  229. FIELD3(FieldTypeStruct,SMBCEDB_SESSION_ENTRY,Session),
  230. 0
  231. };
  232. FIELD_DESCRIPTOR NetRootEntryFields[] =
  233. {
  234. SMBCE_ENTRY_FIELDS(SMBCEDB_NET_ROOT_ENTRY)
  235. FIELD3(FieldTypeUnicodeString,SMBCEDB_NET_ROOT_ENTRY,Name),
  236. FIELD3(FieldTypePointer,SMBCEDB_NET_ROOT_ENTRY,pServerEntry),
  237. FIELD3(FieldTypePointer,SMBCEDB_NET_ROOT_ENTRY,pRdbssNetRoot),
  238. FIELD3(FieldTypeStruct,SMBCEDB_NET_ROOT_ENTRY,NetRoot),
  239. FIELD3(FieldTypeULong,SMBCEDB_NET_ROOT_ENTRY,NetRoot.sCscRootInfo.hShare),
  240. FIELD3(FieldTypeULong,SMBCEDB_NET_ROOT_ENTRY,NetRoot.sCscRootInfo.hRootDir),
  241. FIELD3(FieldTypeChar,SMBCEDB_NET_ROOT_ENTRY,NetRoot.CscEnabled),
  242. FIELD3(FieldTypeChar,SMBCEDB_NET_ROOT_ENTRY,NetRoot.CscShadowable),
  243. FIELD3(FieldTypeChar,SMBCEDB_NET_ROOT_ENTRY,NetRoot.Disconnected),
  244. 0
  245. };
  246. FIELD_DESCRIPTOR VNetRootContextFields[] =
  247. {
  248. SMBCE_ENTRY_FIELDS(SMBCE_V_NET_ROOT_CONTEXT)
  249. FIELD3(FieldTypePointer,SMBCE_V_NET_ROOT_CONTEXT,pRdbssVNetRoot),
  250. FIELD3(FieldTypePointer,SMBCE_V_NET_ROOT_CONTEXT,pServerEntry),
  251. FIELD3(FieldTypePointer,SMBCE_V_NET_ROOT_CONTEXT,pSessionEntry),
  252. FIELD3(FieldTypePointer,SMBCE_V_NET_ROOT_CONTEXT,pNetRootEntry),
  253. FIELD3(FieldTypeUShort,SMBCE_V_NET_ROOT_CONTEXT,Flags),
  254. FIELD3(FieldTypeULong,SMBCE_V_NET_ROOT_CONTEXT,TreeId),
  255. 0
  256. };
  257. FIELD_DESCRIPTOR ServerTransportFields[] =
  258. {
  259. FIELD3(FieldTypePointer,SMBCE_SERVER_TRANSPORT,pDispatchVector),
  260. FIELD3(FieldTypePointer,SMBCE_SERVER_TRANSPORT,pTransport),
  261. FIELD3(FieldTypeULong,SMBCE_SERVER_TRANSPORT,MaximumSendSize),
  262. 0
  263. };
  264. FIELD_DESCRIPTOR TransportFields[] =
  265. {
  266. FIELD3(FieldTypeStruct,SMBCE_TRANSPORT,RxCeTransport),
  267. FIELD3(FieldTypeStruct,SMBCE_TRANSPORT,RxCeAddress),
  268. FIELD3(FieldTypeULong,SMBCE_TRANSPORT,Priority),
  269. 0
  270. };
  271. #define EXCHANGE_FIELDS(__TYPE__) \
  272. FIELD3(FieldTypePointer,__TYPE__,RxContext), \
  273. FIELD3(FieldTypePointer,__TYPE__,SmbCeContext.pServerEntry), \
  274. FIELD3(FieldTypeULong,__TYPE__,Status), \
  275. FIELD3(FieldTypeULong,__TYPE__,SmbStatus), \
  276. FIELD3(FieldTypeUShort,__TYPE__,SmbCeState), \
  277. FIELD3(FieldTypeULong,__TYPE__,SmbCeFlags), \
  278. FIELD3(FieldTypeStruct,__TYPE__,WorkQueueItem),
  279. FIELD_DESCRIPTOR OrdinaryExchangeFields[] =
  280. {
  281. EXCHANGE_FIELDS(SMB_PSE_ORDINARY_EXCHANGE)
  282. FIELD3(FieldTypePointer,SMB_PSE_ORDINARY_EXCHANGE,StufferStateDbgPtr),
  283. FIELD3(FieldTypePointer,SMB_PSE_ORDINARY_EXCHANGE,DataPartialMdl),
  284. FIELD3(FieldTypeChar,SMB_PSE_ORDINARY_EXCHANGE,OpSpecificFlags),
  285. FIELD3(FieldTypeChar,SMB_PSE_ORDINARY_EXCHANGE,OpSpecificState),
  286. FIELD3(FieldTypeStruct,SMB_PSE_ORDINARY_EXCHANGE,ParseResumeState),
  287. FIELD3(FieldTypeUShortFlags,SMB_PSE_ORDINARY_EXCHANGE,Flags),
  288. FIELD3(FieldTypeULong,SMB_PSE_ORDINARY_EXCHANGE,MessageLength),
  289. FIELD3(FieldTypeSymbol,SMB_PSE_ORDINARY_EXCHANGE,ContinuationRoutine),
  290. FIELD3(FieldTypeULong,SMB_PSE_ORDINARY_EXCHANGE,StartEntryCount),
  291. FIELD3(FieldTypePointer,SMB_PSE_ORDINARY_EXCHANGE,AsyncResumptionRoutine),
  292. FIELD3(FieldTypeStruct,SMB_PSE_ORDINARY_EXCHANGE,ReadWrite),
  293. FIELD3(FieldTypeStruct,SMB_PSE_ORDINARY_EXCHANGE,AssociatedStufferState),
  294. 0
  295. };
  296. FIELD_DESCRIPTOR TransactExchangeFields[] =
  297. {
  298. EXCHANGE_FIELDS(SMB_TRANSACT_EXCHANGE)
  299. 0
  300. };
  301. typedef struct _ZZEXCHANGE {
  302. SMB_EXCHANGE;
  303. } ZZEXCHANGE, *PZZEXCHANGE;
  304. FIELD_DESCRIPTOR GeneralExchangeFields[] =
  305. {
  306. EXCHANGE_FIELDS(ZZEXCHANGE)
  307. 0
  308. };
  309. typedef struct _ZZSMB_HEADER {
  310. union {
  311. SMB_HEADER;
  312. NT_SMB_HEADER Nt;
  313. };
  314. } ZZSMB_HEADER, *PZZSMB_HEADER;
  315. FIELD_DESCRIPTOR SmbHeaderFields[] =
  316. {
  317. FIELD3(FieldTypeByte,ZZSMB_HEADER,Command),
  318. FIELD3(FieldTypeByte,ZZSMB_HEADER,ErrorClass),
  319. FIELD3(FieldTypeUShortUnaligned,ZZSMB_HEADER,Error),
  320. FIELD3(FieldTypeULongUnaligned,ZZSMB_HEADER,Nt.Status.NtStatus),
  321. FIELD3(FieldTypeByte,ZZSMB_HEADER,Flags),
  322. FIELD3(FieldTypeUShortUnaligned,ZZSMB_HEADER,Flags2),
  323. FIELD3(FieldTypeUShort,ZZSMB_HEADER,PidHigh),
  324. FIELD3(FieldTypeUShort,ZZSMB_HEADER,Pid),
  325. FIELD3(FieldTypeUShort,ZZSMB_HEADER,Tid),
  326. FIELD3(FieldTypeUShort,ZZSMB_HEADER,Uid),
  327. FIELD3(FieldTypeUShort,ZZSMB_HEADER,Mid),
  328. 0
  329. };
  330. FIELD_DESCRIPTOR StufferStateFields[] =
  331. {
  332. FIELD3(FieldTypeChar,SMBSTUFFER_BUFFER_STATE,SpecificProblem),
  333. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,RxContext),
  334. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,Exchange),
  335. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,HeaderMdl),
  336. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,HeaderPartialMdl),
  337. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,ActualBufferBase),
  338. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,BufferBase),
  339. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,BufferLimit),
  340. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,DataMdl),
  341. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,CurrentPosition),
  342. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,CurrentWct),
  343. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,CurrentBcc),
  344. FIELD3(FieldTypePointer,SMBSTUFFER_BUFFER_STATE,CurrentDataOffset),
  345. FIELD3(FieldTypeChar,SMBSTUFFER_BUFFER_STATE,PreviousCommand),
  346. FIELD3(FieldTypeChar,SMBSTUFFER_BUFFER_STATE,CurrentCommand),
  347. FIELD3(FieldTypeULong,SMBSTUFFER_BUFFER_STATE,FlagsCopy),
  348. FIELD3(FieldTypeULong,SMBSTUFFER_BUFFER_STATE,Flags2Copy),
  349. FIELD3(FieldTypeULong,SMBSTUFFER_BUFFER_STATE,DataSize),
  350. FIELD3(FieldTypeChar,SMBSTUFFER_BUFFER_STATE,Started),
  351. 0
  352. };
  353. //this enum is used in the definition of the structures that can be dumped....the order here
  354. //is not important, only that there is a definition for each dumpee structure.....
  355. typedef enum _STRUCTURE_IDS {
  356. StrEnum_RX_CONTEXT = 1,
  357. StrEnum_FCB,
  358. StrEnum_SRV_OPEN,
  359. StrEnum_FOBX,
  360. StrEnum_SRV_CALL,
  361. StrEnum_NET_ROOT,
  362. StrEnum_V_NET_ROOT,
  363. StrEnum_SMBCEDB_SERVER_ENTRY,
  364. StrEnum_SMBCEDB_SESSION_ENTRY,
  365. StrEnum_SMBCEDB_NET_ROOT_ENTRY,
  366. StrEnum_SMB_PSE_ORDINARY_EXCHANGE,
  367. StrEnum_SMB_TRANSACT_EXCHANGE,
  368. StrEnum_ZZEXCHANGE,
  369. StrEnum_SMBSTUFFER_BUFFER_STATE,
  370. StrEnum_SMBCE_TRANSPORT,
  371. StrEnum_SMBCE_SERVER_TRANSPORT,
  372. StrEnum_ZZSMB_HEADER,
  373. StrEnum_RX_FCB_TABLE_ENTRY,
  374. StrEnum_RX_FCB_TABLE,
  375. StrEnum_last
  376. };
  377. //
  378. // List of structs currently handled by the debugger extensions
  379. //
  380. STRUCT_DESCRIPTOR Structs[] =
  381. {
  382. STRUCT(RX_CONTEXT,RxContextFields,0xffff,RDBSS_NTC_RX_CONTEXT),
  383. STRUCT(FCB,FcbFields,0xeff0,RDBSS_STORAGE_NTC(0)),
  384. STRUCT(FCB,FcbFields,0xeff0,RDBSS_STORAGE_NTC(0xf0)),
  385. STRUCT(SRV_OPEN,SrvOpenFields,0xffff,RDBSS_NTC_SRVOPEN),
  386. STRUCT(FOBX,FobxFields,0xffff,RDBSS_NTC_FOBX),
  387. STRUCT(SRV_CALL,SrvCallFields,0xffff,RDBSS_NTC_SRVCALL),
  388. STRUCT(NET_ROOT,NetRootFields,0xffff,RDBSS_NTC_NETROOT),
  389. STRUCT(V_NET_ROOT,VNetRootFields,0xffff,RDBSS_NTC_V_NETROOT),
  390. STRUCT(SMBCEDB_SERVER_ENTRY,ServerEntryFields,0xffff,SMB_CONNECTION_ENGINE_NTC(SMBCEDB_OT_SERVER)),
  391. STRUCT(SMBCEDB_SESSION_ENTRY,SessionEntryFields,0xffff,SMB_CONNECTION_ENGINE_NTC(SMBCEDB_OT_SESSION)),
  392. STRUCT(SMBCEDB_NET_ROOT_ENTRY,NetRootEntryFields,0xffff,SMB_CONNECTION_ENGINE_NTC(SMBCEDB_OT_NETROOT)),
  393. STRUCT(SMB_PSE_ORDINARY_EXCHANGE,OrdinaryExchangeFields,0xffff,SMB_EXCHANGE_NTC(ORDINARY_EXCHANGE)),
  394. STRUCT(SMB_TRANSACT_EXCHANGE,TransactExchangeFields,0xffff,SMB_EXCHANGE_NTC(TRANSACT_EXCHANGE)),
  395. STRUCT(ZZEXCHANGE,GeneralExchangeFields,0xfff0,SMB_EXCHANGE_NTC(0)),
  396. STRUCT(SMBSTUFFER_BUFFER_STATE,StufferStateFields,0xffff,SMB_NTC_STUFFERSTATE),
  397. STRUCT(SMBCE_TRANSPORT,TransportFields,0x0,0xffff),
  398. STRUCT(SMBCE_SERVER_TRANSPORT,ServerTransportFields,0x0,0xffff),
  399. STRUCT(ZZSMB_HEADER,SmbHeaderFields,0x0,0xffff),
  400. STRUCT(RX_FCB_TABLE_ENTRY,FcbTableEntry,0xffff,RDBSS_NTC_FCB_TABLE_ENTRY),
  401. STRUCT(RX_FCB_TABLE,FcbTable,0xffff,RDBSS_NTC_FCB_TABLE),
  402. 0
  403. };
  404. ULONG_PTR FieldOffsetOfContextListEntryInRxC(){ return FIELD_OFFSET(RX_CONTEXT,ContextListEntry);}
  405. PCWSTR GetExtensionLibPerDebugeeArchitecture(ULONG DebugeeArchitecture){
  406. switch (DebugeeArchitecture) {
  407. case RX_PROCESSOR_ARCHITECTURE_INTEL:
  408. return L"kdextx86.dll";
  409. case RX_PROCESSOR_ARCHITECTURE_MIPS:
  410. return L"kdextmip.dll";
  411. case RX_PROCESSOR_ARCHITECTURE_ALPHA:
  412. return L"kdextalp.dll";
  413. case RX_PROCESSOR_ARCHITECTURE_PPC:
  414. return L"kdextppc.dll";
  415. default:
  416. return(NULL);
  417. }
  418. }
  419. //CODE.IMPROVEMENT it is ineficient to try to structure along the lines of "this routine knows
  420. // rxstructures" versus "this routine knows debugger extensions". also we
  421. // need a precomp.h
  422. BOOLEAN wGetData( ULONG_PTR dwAddress, PVOID ptr, ULONG size, IN PSZ type);
  423. VOID ReadRxContextFields(ULONG_PTR RxContext,PULONG_PTR pFcb,PULONG_PTR pThread, PULONG_PTR pMiniCtx2)
  424. {
  425. RX_CONTEXT RxContextBuffer;
  426. if (!wGetData(RxContext,&RxContextBuffer,sizeof(RxContextBuffer),"RxContextFieldss")) return;
  427. *pFcb = (ULONG_PTR)(RxContextBuffer.pFcb);
  428. *pThread = (ULONG_PTR)(RxContextBuffer.LastExecutionThread);
  429. *pMiniCtx2 = (ULONG_PTR)(RxContextBuffer.MRxContext[2]);
  430. }
  431. FOLLOWON_HELPER_RETURNS
  432. __FollowOnError (
  433. OUT PBYTE Buffer2,
  434. IN PBYTE followontext,
  435. ULONG LastId,
  436. ULONG Index)
  437. {
  438. if (LastId==0) {
  439. sprintf(Buffer2,"Cant dump a %s. no previous dump.\n",
  440. followontext,Index);
  441. } else {
  442. sprintf(Buffer2,"Cant dump a %s from a %s\n",
  443. followontext,Structs[Index].StructName);
  444. }
  445. return(FOLLOWONHELPER_ERROR);
  446. }
  447. #define FollowOnError(A) (__FollowOnError(Buffer2,A,p->IdOfLastDump,p->IndexOfLastDump))
  448. VOID dprintfsprintfbuffer(BYTE *Buffer);
  449. DECLARE_FOLLOWON_HELPER_CALLEE(FcbFollowOn)
  450. {
  451. //BYTE DbgBuf[200];
  452. //sprintf(DbgBuf,"top p,id=%08lx,%d",p,p->IdOfLastDump);
  453. //dprintfsprintfbuffer(DbgBuf);
  454. switch (p->IdOfLastDump) {
  455. case StrEnum_RX_CONTEXT:{
  456. PRX_CONTEXT RxContext = (PRX_CONTEXT)(&p->StructDumpBuffer[0]);
  457. sprintf(Buffer2," %08p\n",RxContext->pFcb);
  458. return(FOLLOWONHELPER_DUMP);
  459. }
  460. break;
  461. default:
  462. return FollowOnError("irp");
  463. }
  464. }