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.

490 lines
9.7 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. DumpSup.c
  5. Abstract:
  6. This module implements a collection of data structure dump routines
  7. for debugging the Named Pipe file system
  8. Author:
  9. Gary Kimura [GaryKi] 21-Aug-1990
  10. Revision History:
  11. --*/
  12. #include "NpProcs.h"
  13. #ifdef NPDBG
  14. VOID NpDumpEventTableEntry(IN PEVENT_TABLE_ENTRY Ptr);
  15. VOID NpDumpDataQueue(IN PDATA_QUEUE Ptr);
  16. VOID NpDumpDataEntry(IN PDATA_ENTRY Ptr);
  17. VOID NpDump(IN PVOID Ptr);
  18. VOID NpDumpVcb(IN PVCB Ptr);
  19. VOID NpDumpRootDcb(IN PROOT_DCB Ptr);
  20. VOID NpDumpFcb(IN PFCB Ptr);
  21. VOID NpDumpCcb(IN PCCB Ptr);
  22. VOID NpDumpNonpagedCcb(IN PNONPAGED_CCB Ptr);
  23. VOID NpDumpRootDcbCcb(IN PROOT_DCB_CCB Ptr);
  24. ULONG NpDumpCurrentColumn;
  25. #define DumpNewLine() { \
  26. DbgPrint("\n"); \
  27. NpDumpCurrentColumn = 1; \
  28. }
  29. #define DumpLabel(Label,Width) { \
  30. ULONG i; \
  31. CHAR _Str[20]; \
  32. for(i=0;i<2;i++) { _Str[i] = UCHAR_SP;} \
  33. strncpy(&_Str[2],#Label,Width); \
  34. for(i=strlen(_Str);i<Width;i++) {_Str[i] = UCHAR_SP;} \
  35. _Str[Width] = '\0'; \
  36. DbgPrint("%s", _Str); \
  37. }
  38. #define DumpField(Field) { \
  39. if ((NpDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
  40. NpDumpCurrentColumn += 18 + 9 + 9; \
  41. DumpLabel(Field,18); \
  42. DbgPrint(":%8lx", Ptr->Field); \
  43. DbgPrint(" "); \
  44. }
  45. #define DumpListEntry(Links) { \
  46. if ((NpDumpCurrentColumn + 18 + 9 + 9) > 80) {DumpNewLine();} \
  47. NpDumpCurrentColumn += 18 + 9 + 9; \
  48. DumpLabel(Links,18); \
  49. DbgPrint(":%8lx", Ptr->Links.Flink); \
  50. DbgPrint(":%8lx", Ptr->Links.Blink); \
  51. }
  52. #define DumpName(Field,Width) { \
  53. ULONG i; \
  54. WCHAR _String[64]; \
  55. if ((NpDumpCurrentColumn + 18 + Width) > 80) {DumpNewLine();} \
  56. NpDumpCurrentColumn += 18 + Width; \
  57. DumpLabel(Field,18); \
  58. for(i=0;i<Width/2;i++) {_String[i] = Ptr->Field[i];} \
  59. _String[Width] = '\0'; \
  60. DbgPrint("%s", _String); \
  61. }
  62. #define TestForNull(Name) { \
  63. if (Ptr == NULL) { \
  64. DbgPrint("%s - Cannot dump a NULL pointer\n", Name); \
  65. return; \
  66. } \
  67. }
  68. VOID NpDumpEventTableEntry (
  69. IN PEVENT_TABLE_ENTRY Ptr
  70. )
  71. {
  72. TestForNull ("NpDumpEventTableEntry");
  73. DumpNewLine ();
  74. DbgPrint ("EventTableEntry@ %08lx", (Ptr));
  75. DumpNewLine ();
  76. DumpField (Ccb);
  77. DumpField (NamedPipeEnd);
  78. DumpField (EventHandle);
  79. DumpField (Event);
  80. DumpField (KeyValue);
  81. DumpField (Process);
  82. DumpNewLine ();
  83. return;
  84. }
  85. VOID NpDumpDataQueue (
  86. IN PDATA_QUEUE Ptr
  87. )
  88. {
  89. PDATA_ENTRY Entry;
  90. TestForNull ("NpDumpDataQueue");
  91. DumpNewLine ();
  92. DbgPrint ("DataQueue@ %08lx", (Ptr));
  93. DumpNewLine ();
  94. DumpField (QueueState);
  95. DumpField (BytesInQueue);
  96. DumpField (EntriesInQueue);
  97. DumpField (Quota);
  98. DumpField (QuotaUsed);
  99. DumpField (FrontOfQueue);
  100. DumpField (EndOfQueue);
  101. DumpField (NextByteOffset);
  102. DumpNewLine ();
  103. for (Entry = Ptr->FrontOfQueue;
  104. Entry != NULL;
  105. Entry = Entry->Next) {
  106. NpDumpDataEntry( Entry );
  107. }
  108. return;
  109. }
  110. VOID NpDumpDataEntry (
  111. IN PDATA_ENTRY Ptr
  112. )
  113. {
  114. TestForNull ("NpDumpDataEntry");
  115. DumpNewLine ();
  116. DbgPrint ("DataEntry@ %08lx", (Ptr));
  117. DumpNewLine ();
  118. DumpField (DataEntryType);
  119. DumpField (From);
  120. DumpField (Next);
  121. DumpField (Irp);
  122. DumpField (DataSize);
  123. DumpField (DataPointer);
  124. DumpField (SecurityClientContext);
  125. DumpNewLine ();
  126. return;
  127. }
  128. VOID NpDump (
  129. IN PVOID Ptr
  130. )
  131. /*++
  132. Routine Description:
  133. This routine determines the type of internal record reference by ptr and
  134. calls the appropriate dump routine.
  135. Arguments:
  136. Ptr - Supplies the pointer to the record to be dumped
  137. Return Value:
  138. None
  139. --*/
  140. {
  141. TestForNull("NpDump");
  142. //
  143. // We'll switch on the node type code
  144. //
  145. switch (NodeType(Ptr)) {
  146. case NPFS_NTC_VCB: NpDumpVcb(Ptr); break;
  147. case NPFS_NTC_ROOT_DCB: NpDumpRootDcb(Ptr); break;
  148. case NPFS_NTC_FCB: NpDumpFcb(Ptr); break;
  149. case NPFS_NTC_CCB: NpDumpCcb(Ptr); break;
  150. case NPFS_NTC_NONPAGED_CCB: NpDumpNonpagedCcb(Ptr); break;
  151. case NPFS_NTC_ROOT_DCB_CCB: NpDumpRootDcbCcb(Ptr); break;
  152. default :
  153. DbgPrint("NpDump - Unknown Node type code %8lx\n", *((PNODE_TYPE_CODE)(Ptr)));
  154. break;
  155. }
  156. return;
  157. }
  158. VOID NpDumpVcb (
  159. IN PVCB Ptr
  160. )
  161. /*++
  162. Routine Description:
  163. Dump an Vcb structure
  164. Arguments:
  165. Ptr - Supplies the Device record to be dumped
  166. Return Value:
  167. None
  168. --*/
  169. {
  170. TestForNull ("NpDumpVcb");
  171. DumpNewLine ();
  172. DbgPrint ("Vcb@ %lx", (Ptr));
  173. DumpNewLine ();
  174. DumpField (NodeTypeCode);
  175. DumpField (NodeByteSize);
  176. DumpField (RootDcb);
  177. DumpField (OpenCount);
  178. DumpNewLine ();
  179. NpDump (Ptr->RootDcb);
  180. return;
  181. }
  182. VOID NpDumpRootDcb (
  183. IN PROOT_DCB Ptr
  184. )
  185. /*++
  186. Routine Description:
  187. Dump a root dcb structure
  188. Arguments:
  189. Ptr - Supplies the Root Dcb record to be dumped
  190. Return Value:
  191. None
  192. --*/
  193. {
  194. PLIST_ENTRY Links;
  195. TestForNull ("NpDumpRootDcb");
  196. DumpNewLine ();
  197. DbgPrint ("RootDcb@ %lx", (Ptr));
  198. DumpNewLine ();
  199. DumpField (NodeTypeCode);
  200. DumpField (NodeByteSize);
  201. DumpListEntry (ParentDcbLinks);
  202. DumpField (ParentDcb);
  203. DumpField (OpenCount);
  204. DumpField (FullFileName.Length);
  205. DumpField (FullFileName.Buffer);
  206. DumpName (FullFileName.Buffer, 32);
  207. DumpField (LastFileName.Length);
  208. DumpField (LastFileName.Buffer);
  209. DumpListEntry (Specific.Dcb.NotifyFullQueue);
  210. DumpListEntry (Specific.Dcb.NotifyPartialQueue);
  211. DumpListEntry (Specific.Dcb.ParentDcbQueue);
  212. DumpNewLine ();
  213. for (Links = Ptr->Specific.Dcb.ParentDcbQueue.Flink;
  214. Links != &Ptr->Specific.Dcb.ParentDcbQueue;
  215. Links = Links->Flink) {
  216. NpDump(CONTAINING_RECORD(Links, FCB, ParentDcbLinks));
  217. }
  218. return;
  219. }
  220. VOID NpDumpFcb (
  221. IN PFCB Ptr
  222. )
  223. /*++
  224. Routine Description:
  225. Dump an Fcb structure
  226. Arguments:
  227. Ptr - Supplies the Fcb record to be dumped
  228. Return Value:
  229. None
  230. --*/
  231. {
  232. PLIST_ENTRY Links;
  233. TestForNull ("NpDumpFcb");
  234. DumpNewLine ();
  235. DbgPrint ("Fcb@ %lx", (Ptr));
  236. DumpNewLine ();
  237. DumpField (NodeTypeCode);
  238. DumpField (NodeByteSize);
  239. DumpListEntry (ParentDcbLinks);
  240. DumpField (ParentDcb);
  241. DumpField (OpenCount);
  242. DumpField (FullFileName.Length);
  243. DumpField (FullFileName.Buffer);
  244. DumpName (FullFileName.Buffer, 32);
  245. DumpField (LastFileName.Length);
  246. DumpField (LastFileName.Buffer);
  247. DumpField (Specific.Fcb.NamedPipeConfiguration);
  248. DumpField (Specific.Fcb.NamedPipeType);
  249. DumpField (Specific.Fcb.MaximumInstances);
  250. DumpField (Specific.Fcb.DefaultTimeOut.LowPart);
  251. DumpField (Specific.Fcb.DefaultTimeOut.HighPart);
  252. DumpListEntry (Specific.Fcb.CcbQueue);
  253. DumpNewLine ();
  254. for (Links = Ptr->Specific.Fcb.CcbQueue.Flink;
  255. Links != &Ptr->Specific.Fcb.CcbQueue;
  256. Links = Links->Flink) {
  257. NpDump(CONTAINING_RECORD(Links, CCB, CcbLinks));
  258. }
  259. return;
  260. }
  261. VOID NpDumpCcb (
  262. IN PCCB Ptr
  263. )
  264. /*++
  265. Routine Description:
  266. Dump a Ccb structure
  267. Arguments:
  268. Ptr - Supplies the Ccb record to be dumped
  269. Return Value:
  270. None
  271. --*/
  272. {
  273. TestForNull ("NpDumpCcb");
  274. DumpNewLine ();
  275. DbgPrint ("Ccb@ %lx", (Ptr));
  276. DumpNewLine ();
  277. DumpField (NodeTypeCode);
  278. DumpField (NodeByteSize);
  279. DumpField (Fcb);
  280. DumpField (FileObject[0]);
  281. DumpField (FileObject[1]);
  282. DumpField (NamedPipeState);
  283. DumpField (ReadMode[0]);
  284. DumpField (ReadMode[1]);
  285. DumpField (CompletionMode[0]);
  286. DumpField (CompletionMode[1]);
  287. DumpField (CreatorProcess);
  288. DumpField (SecurityClientContext);
  289. DumpNewLine ();
  290. NpDumpDataQueue(&Ptr->DataQueue[0]);
  291. NpDumpDataQueue(&Ptr->DataQueue[1]);
  292. NpDump (Ptr->NonpagedCcb);
  293. return;
  294. }
  295. VOID NpDumpNonpagedCcb (
  296. IN PNONPAGED_CCB Ptr
  297. )
  298. /*++
  299. Routine Description:
  300. Dump a Nonpaged Ccb structure
  301. Arguments:
  302. Ptr - Supplies the Nonpaged Ccb record to be dumped
  303. Return Value:
  304. None
  305. --*/
  306. {
  307. TestForNull ("NpDumpNonpagedCcb");
  308. DumpNewLine ();
  309. DbgPrint ("NonpagedCcb@ %lx", (Ptr));
  310. DumpNewLine ();
  311. DumpField (NodeTypeCode);
  312. DumpField (NodeByteSize);
  313. DumpField (EventTableEntry[0]);
  314. DumpField (EventTableEntry[1]);
  315. DumpListEntry (ListeningQueue);
  316. DumpNewLine ();
  317. return;
  318. }
  319. VOID NpDumpRootDcbCcb (
  320. IN PROOT_DCB_CCB Ptr
  321. )
  322. /*++
  323. Routine Description:
  324. Dump a Root Dcb Ccb structure
  325. Arguments:
  326. Ptr - Supplies the Root Dcb Ccb record to be dumped
  327. Return Value:
  328. None
  329. --*/
  330. {
  331. TestForNull ("NpDumpRootDcbCcb");
  332. DumpNewLine ();
  333. DbgPrint ("RootDcbCcb@ %lx", (Ptr));
  334. DumpNewLine ();
  335. DumpField (NodeTypeCode);
  336. DumpField (NodeByteSize);
  337. DumpField (IndexOfLastCcbReturned);
  338. DumpNewLine ();
  339. return;
  340. }
  341. #endif // NPDBG