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.

329 lines
12 KiB

  1. #include "pch.h"
  2. #include "fatkd.h"
  3. #include "..\nodetype.h"
  4. #include "..\fat.h"
  5. #include "..\fatstruc.h"
  6. #include "..\fatdata.h"
  7. STATE FatFcbState[] = {
  8. { FCB_STATE_DELETE_ON_CLOSE, FCB_STATE_DELETE_ON_CLOSE, "DeleteOnClose" },
  9. { FCB_STATE_TRUNCATE_ON_CLOSE, FCB_STATE_TRUNCATE_ON_CLOSE, "TruncateOnClose" },
  10. { FCB_STATE_PAGING_FILE, FCB_STATE_PAGING_FILE, "PagingFile" },
  11. { FCB_STATE_FORCE_MISS_IN_PROGRESS, FCB_STATE_FORCE_MISS_IN_PROGRESS, "ForceMissInProgress" },
  12. { FCB_STATE_FLUSH_FAT, FCB_STATE_FLUSH_FAT, "FlushFat" },
  13. { FCB_STATE_TEMPORARY, FCB_STATE_TEMPORARY, "Temporary" },
  14. { FCB_STATE_SYSTEM_FILE, FCB_STATE_SYSTEM_FILE, "SystemFile" },
  15. { FCB_STATE_NAMES_IN_SPLAY_TREE, FCB_STATE_NAMES_IN_SPLAY_TREE, "NamesInSplayTree" },
  16. { FCB_STATE_HAS_OEM_LONG_NAME, FCB_STATE_HAS_OEM_LONG_NAME, "OEMLongName" },
  17. { FCB_STATE_HAS_UNICODE_LONG_NAME, FCB_STATE_HAS_UNICODE_LONG_NAME, "UnicodeLongName" },
  18. { FCB_STATE_DELAY_CLOSE, FCB_STATE_DELAY_CLOSE, "DelayClose" },
  19. { FCB_STATE_8_LOWER_CASE, FCB_STATE_8_LOWER_CASE, "8LowerCase" },
  20. { FCB_STATE_3_LOWER_CASE, FCB_STATE_3_LOWER_CASE, "3LowerCase" },
  21. { 0 }
  22. };
  23. STATE FatIrpContextFlags[] = {
  24. { IRP_CONTEXT_FLAG_DISABLE_DIRTY, IRP_CONTEXT_FLAG_DISABLE_DIRTY, "DisableDirty" },
  25. { IRP_CONTEXT_FLAG_WAIT, IRP_CONTEXT_FLAG_WAIT, "Wait"},
  26. { IRP_CONTEXT_FLAG_WRITE_THROUGH, IRP_CONTEXT_FLAG_WRITE_THROUGH, "WriteThrough"},
  27. { IRP_CONTEXT_FLAG_DISABLE_WRITE_THROUGH, IRP_CONTEXT_FLAG_DISABLE_WRITE_THROUGH, "DisableWriteThrough"},
  28. { IRP_CONTEXT_FLAG_RECURSIVE_CALL, IRP_CONTEXT_FLAG_RECURSIVE_CALL, "RecursiveCall"},
  29. { IRP_CONTEXT_FLAG_DISABLE_POPUPS, IRP_CONTEXT_FLAG_DISABLE_POPUPS, "DisablePopups"},
  30. { IRP_CONTEXT_FLAG_DEFERRED_WRITE, IRP_CONTEXT_FLAG_DEFERRED_WRITE, "DeferredWrite"},
  31. { IRP_CONTEXT_FLAG_VERIFY_READ, IRP_CONTEXT_FLAG_VERIFY_READ, "VerifyRead"},
  32. { IRP_CONTEXT_STACK_IO_CONTEXT, IRP_CONTEXT_STACK_IO_CONTEXT, "StackIoContext"},
  33. { IRP_CONTEXT_FLAG_IN_FSP, IRP_CONTEXT_FLAG_IN_FSP, "InFsp"},
  34. { IRP_CONTEXT_FLAG_USER_IO, IRP_CONTEXT_FLAG_USER_IO, "UserIo"},
  35. { IRP_CONTEXT_FLAG_DISABLE_RAISE, IRP_CONTEXT_FLAG_DISABLE_RAISE, "DisableRaise"},
  36. { IRP_CONTEXT_FLAG_PARENT_BY_CHILD, IRP_CONTEXT_FLAG_PARENT_BY_CHILD, "ParentByChild"},
  37. { 0 }
  38. };
  39. STATE FatVcbStateFlags[] = {
  40. { VCB_STATE_FLAG_LOCKED, VCB_STATE_FLAG_LOCKED, "Locked"},
  41. { VCB_STATE_FLAG_REMOVABLE_MEDIA, VCB_STATE_FLAG_REMOVABLE_MEDIA, "Removable"},
  42. { VCB_STATE_FLAG_VOLUME_DIRTY, VCB_STATE_FLAG_VOLUME_DIRTY, "VolumeDirty"},
  43. { VCB_STATE_FLAG_MOUNTED_DIRTY, VCB_STATE_FLAG_MOUNTED_DIRTY, "MountedDirty"},
  44. { VCB_STATE_FLAG_SHUTDOWN, VCB_STATE_FLAG_SHUTDOWN, "Shutdown"},
  45. { VCB_STATE_FLAG_CLOSE_IN_PROGRESS, VCB_STATE_FLAG_CLOSE_IN_PROGRESS, "CloseInProgress"},
  46. { VCB_STATE_FLAG_DELETED_FCB, VCB_STATE_FLAG_DELETED_FCB, "DeletedFcb"},
  47. { VCB_STATE_FLAG_CREATE_IN_PROGRESS, VCB_STATE_FLAG_CREATE_IN_PROGRESS, "CreateInProgress"},
  48. { VCB_STATE_FLAG_BOOT_OR_PAGING_FILE, VCB_STATE_FLAG_BOOT_OR_PAGING_FILE, "BootOrPagingFile"},
  49. { VCB_STATE_FLAG_DEFERRED_FLUSH, VCB_STATE_FLAG_DEFERRED_FLUSH, "DeferredFlush"},
  50. { VCB_STATE_FLAG_ASYNC_CLOSE_ACTIVE, VCB_STATE_FLAG_ASYNC_CLOSE_ACTIVE, "AsyncCloseActive"},
  51. { VCB_STATE_FLAG_WRITE_PROTECTED, VCB_STATE_FLAG_WRITE_PROTECTED, "WriteProtect"},
  52. { VCB_STATE_FLAG_REMOVAL_PREVENTED, VCB_STATE_FLAG_REMOVAL_PREVENTED, "RemovalPrevented"},
  53. { VCB_STATE_FLAG_VOLUME_DISMOUNTED, VCB_STATE_FLAG_VOLUME_DISMOUNTED, "Dismounted"},
  54. { 0 }
  55. };
  56. STATE FatCcbFlags[] = {
  57. { CCB_FLAG_MATCH_ALL, CCB_FLAG_MATCH_ALL, "MatchAll"},
  58. { CCB_FLAG_SKIP_SHORT_NAME_COMPARE, CCB_FLAG_SKIP_SHORT_NAME_COMPARE, "ShortNameCompare"},
  59. { CCB_FLAG_FREE_OEM_BEST_FIT, CCB_FLAG_FREE_OEM_BEST_FIT, "OemBestFit"},
  60. { CCB_FLAG_FREE_UNICODE, CCB_FLAG_FREE_UNICODE, "FreeUnicode"},
  61. { CCB_FLAG_USER_SET_LAST_WRITE, CCB_FLAG_USER_SET_LAST_WRITE, "UserSetLastWrite"},
  62. { CCB_FLAG_USER_SET_LAST_ACCESS, CCB_FLAG_USER_SET_LAST_ACCESS, "UserSetLastAccess"},
  63. { CCB_FLAG_USER_SET_CREATION, CCB_FLAG_USER_SET_CREATION, "UserSetCreation"},
  64. { CCB_FLAG_READ_ONLY, CCB_FLAG_READ_ONLY, "ReadOnly"},
  65. { CCB_FLAG_DASD_FLUSH_DONE, CCB_FLAG_DASD_FLUSH_DONE, "DasdFlushDone"},
  66. { CCB_FLAG_DASD_PURGE_DONE, CCB_FLAG_DASD_PURGE_DONE, "DasdPurgeDone"},
  67. { CCB_FLAG_DELETE_ON_CLOSE, CCB_FLAG_DELETE_ON_CLOSE, "DeleteOnClose"},
  68. { CCB_FLAG_OPENED_BY_SHORTNAME, CCB_FLAG_OPENED_BY_SHORTNAME, "OpenedByShortname"},
  69. { CCB_FLAG_QUERY_TEMPLATE_MIXED, CCB_FLAG_QUERY_TEMPLATE_MIXED, "QueryTemplateMixed"},
  70. { CCB_FLAG_ALLOW_EXTENDED_DASD_IO, CCB_FLAG_ALLOW_EXTENDED_DASD_IO, "AllowExtendedDasdIo"},
  71. { CCB_FLAG_CLOSE_CONTEXT, CCB_FLAG_CLOSE_CONTEXT, "CloseContext"},
  72. { CCB_FLAG_COMPLETE_DISMOUNT, CCB_FLAG_COMPLETE_DISMOUNT, "CompleteDismount"},
  73. { 0 }
  74. };
  75. VOID
  76. FatSummaryFcbDumpRoutine(
  77. IN ULONG64 RemoteAddress,
  78. IN LONG Options
  79. )
  80. {
  81. ULONG Offset;
  82. if (Options >= 2) {
  83. DumpFatFcb( RemoteAddress, 0, 0);
  84. }
  85. else {
  86. USHORT Type;
  87. ReadM( &Type, RemoteAddress, sizeof( Type));
  88. if ((Type != FAT_NTC_FCB) && (FAT_NTC_DCB != Type) &&
  89. (Type != FAT_NTC_ROOT_DCB)
  90. ) {
  91. dprintf( "FCB/DCB signature does not match @%I64x", RemoteAddress);
  92. return;
  93. }
  94. ROE( GetFieldValue( RemoteAddress, "fastfat!FCB", "LfnOffsetWithinDirectory", Offset));
  95. dprintf( "\n%s @ %I64x LFNDirOfst: %08x ", NodeTypeName( TypeCodeInfoIndex( Type)), RemoteAddress, Offset);
  96. ROE( GetFieldOffset( "fastfat!FCB", "FullFileName", &Offset));
  97. DumpStr( Offset, RemoteAddress + Offset, "ShortName", FALSE, TRUE);
  98. }
  99. }
  100. DUMP_ROUTINE( DumpFatFcb )
  101. {
  102. ULONG Result;
  103. USHORT Type;
  104. ULONG FcbState, Flags, Offset, Offsetb;
  105. UINT64 NonP;
  106. FIELD_INFO Expand[] = { //{ ".", NULL, 0, 0, 0, NULL},
  107. { "Header.", NULL, 0, DBG_DUMP_FIELD_RECUR_ON_THIS,0, NULL}
  108. };
  109. FIELD_INFO ExpandFcb[] = { //{ ".", NULL, 0, 0, 0, NULL},
  110. { "Specific.Fcb.", NULL, 0, DBG_DUMP_FIELD_RECUR_ON_THIS,0, NULL}
  111. };
  112. FIELD_INFO ExpandDcb[] = { //{ ".", NULL, 0, 0, 0, NULL},
  113. { "Specific.Dcb.", NULL, 0, DBG_DUMP_FIELD_RECUR_ON_THIS,0, NULL}
  114. };
  115. ReadM( &Type, Address, sizeof( Type));
  116. dprintf("[ Option flags: 1 = list children, 2 = Dump MCB ]\n\n");
  117. //
  118. // Having established that this looks like an fcb, let's dump the
  119. // interesting parts.
  120. //
  121. ROE( GetFieldValue( Address, InfoNode->TypeName, "FcbState", FcbState));
  122. dprintf("FcbState : ");
  123. PrintState( FatFcbState, FcbState );
  124. ROE( GetFieldValue( Address, InfoNode->TypeName, "Header.Flags", Flags));
  125. dprintf("Header.Flags : ");
  126. PrintState( HeaderFlags, Flags );
  127. ROE( GetFieldValue( Address, InfoNode->TypeName, "Header.Flags2", Flags));
  128. dprintf("Header.Flags2: ");
  129. PrintState( HeaderFlags2, Flags );
  130. dprintf("\n");
  131. //
  132. // Dump names etc.
  133. //
  134. ROE( GetFieldOffset( InfoNode->TypeName, "ShortName.Name.Unicode", &Offset));
  135. DumpStr( Offset, Address + Offset, "ShortName: ", FALSE, FALSE);
  136. if ( FcbState & FCB_STATE_HAS_UNICODE_LONG_NAME) {
  137. ROE( GetFieldOffset( InfoNode->TypeName, "LongName.Unicode.Name.Unicode", &Offset));
  138. DumpStr( Offset, Address + Offset, "LongName :", FALSE, TRUE);
  139. }
  140. dprintf("\n");
  141. Dt( InfoNode->TypeName, Address, 0, 1, Expand);
  142. Dt( InfoNode->TypeName, Address, 0, 0, NULL);
  143. dprintf("\n");
  144. //
  145. // Expand F/Dcb specific portion
  146. //
  147. if (Type == FAT_NTC_FCB) {
  148. Dt( InfoNode->TypeName, Address, 0, 1, ExpandFcb);
  149. }
  150. else {
  151. Dt( InfoNode->TypeName, Address, 0, 1, ExpandDcb);
  152. }
  153. //
  154. // Nonpaged portion
  155. //
  156. ROE( GetFieldValue( Address, InfoNode->TypeName, "NonPaged", NonP));
  157. if (NonP != 0) {
  158. dprintf("\nNonpaged part @ %I64x\n\n", NonP);
  159. Dt( "fastfat!NON_PAGED_FCB", NonP, 0, 0, NULL);
  160. }
  161. //
  162. // Dump all children / siblings?
  163. //
  164. if (( Options & 1) && ((FAT_NTC_DCB == Type) ||
  165. (FAT_NTC_ROOT_DCB == Type))) {
  166. dprintf("\nChild Fcb list\n");
  167. ROE( GetFieldOffset( InfoNode->TypeName, "Specific.Dcb.ParentDcbQueue", &Offset));
  168. ROE( GetFieldOffset( InfoNode->TypeName, "ParentDcbLinks", &Offsetb));
  169. DumpList( Address + Offset,
  170. FatSummaryFcbDumpRoutine,
  171. Offsetb,
  172. FALSE,
  173. 0 );
  174. }
  175. if (Options & 2) {
  176. ROE( GetFieldOffset( InfoNode->TypeName, "Mcb", &Offset));
  177. DumpLargeMcb( Address+Offset, 0, NULL);
  178. }
  179. dprintf( "\n" );
  180. }
  181. DUMP_ROUTINE( DumpFatCcb)
  182. {
  183. ULONG Flags;
  184. ROE( GetFieldValue( Address, InfoNode->TypeName, "Flags", Flags));
  185. dprintf( "Ccb.Flags: ");
  186. PrintState( FatCcbFlags, Flags);
  187. dprintf( "\n");
  188. Dt( InfoNode->TypeName, Address, Options, 0, NULL);
  189. }
  190. DUMP_ROUTINE( DumpFatIrpContext)
  191. {
  192. ULONG Flags;
  193. ROE( GetFieldValue( Address, InfoNode->TypeName, "Flags", Flags));
  194. dprintf( "IrpContext.Flags: ");
  195. PrintState( FatIrpContextFlags, Flags);
  196. dprintf( "\n");
  197. Dt( InfoNode->TypeName, Address, Options, 0, NULL);
  198. }
  199. DUMP_ROUTINE( DumpFatVcb)
  200. {
  201. ULONG Flags;
  202. FIELD_INFO Alloc[] = { //{ ".", NULL, 0, 0, 0, NULL},
  203. { "AllocationSupport.", NULL, 0, DBG_DUMP_FIELD_RECUR_ON_THIS,0, NULL}
  204. };
  205. ROE( GetFieldValue( Address, InfoNode->TypeName, "VcbState", Flags));
  206. dprintf( "Vcb.VcbState: ");
  207. PrintState( FatVcbStateFlags, Flags);
  208. dprintf( "\n");
  209. Dt( InfoNode->TypeName, Address, Options, 0, NULL);
  210. dprintf( "\n");
  211. Dt( InfoNode->TypeName, Address, 1, 1, Alloc);
  212. dprintf( "\n" );
  213. }
  214. DUMP_ROUTINE( DumpFatVdo)
  215. {
  216. USHORT Ntc;
  217. PUSHORT pNtc;
  218. ULONG Offset;
  219. ReadM( &Ntc, Address, sizeof( Ntc));
  220. if (FAT_NTC_VCB == Ntc) {
  221. //
  222. // Looks like we've been given a VCB pointer. Work back to the containing vdo.
  223. //
  224. dprintf("Backtracking to containing VDO from VCB...");
  225. ROE( GetFieldOffset( "fastfat!VOLUME_DEVICE_OBJECT", "Vcb", &Offset));
  226. Address -= Offset;
  227. }
  228. dprintf( "\nFAT Volume device object @ %08lx\n", Address );
  229. Dt( "fastfat!VOLUME_DEVICE_OBJECT", Address, Options, 0, NULL);
  230. }
  231. DECLARE_API( fatvdo )
  232. {
  233. UNREFERENCED_PARAMETER( dwCurrentPc );
  234. UNREFERENCED_PARAMETER( hCurrentProcess );
  235. ParseAndDump( (PCHAR) args, (STRUCT_DUMP_ROUTINE) DumpFatVdo, dwProcessor, hCurrentThread );
  236. }
  237. DECLARE_API( fatmcb )
  238. {
  239. UNREFERENCED_PARAMETER( dwCurrentPc );
  240. UNREFERENCED_PARAMETER( hCurrentProcess );
  241. ParseAndDump( (PCHAR) args, (STRUCT_DUMP_ROUTINE) DumpLargeMcb, dwProcessor, hCurrentThread );
  242. }