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.

388 lines
7.9 KiB

  1. /*++
  2. Copyright (c) 1999-2001 Microsoft Corporation
  3. Module Name:
  4. mftinfo.hxx
  5. Abstract:
  6. This module contains the declarations for the NTFS_MFT_INFO
  7. class, which stores extracted information from the NTFS MFT.
  8. Author:
  9. Daniel Chan (danielch) Oct 18, 1999
  10. Environment:
  11. ULIB, User Mode
  12. --*/
  13. #if !defined( _NTFS_MFT_INFO_DEFN_ )
  14. #define _NTFS_MFT_INFO_DEFN_
  15. #include "membmgr2.hxx"
  16. DECLARE_CLASS( NTFS_UPCASE_TABLE );
  17. typedef UCHAR FILE_NAME_SIGNATURE[4];
  18. typedef UCHAR DUP_INFO_SIGNATURE[4];
  19. DEFINE_POINTER_AND_REFERENCE_TYPES( FILE_NAME_SIGNATURE );
  20. DEFINE_POINTER_AND_REFERENCE_TYPES( DUP_INFO_SIGNATURE );
  21. struct _NTFS_FILE_NAME_INFO {
  22. FILE_NAME_SIGNATURE Signature;
  23. UCHAR Flags;
  24. UCHAR Reserved[3];
  25. };
  26. struct _NTFS_FRS_INFO {
  27. MFT_SEGMENT_REFERENCE SegmentReference;
  28. DUP_INFO_SIGNATURE DupInfoSignature;
  29. USHORT NumberOfFileNames;
  30. USHORT Reserved;
  31. struct _NTFS_FILE_NAME_INFO FileNameInfo[1];
  32. };
  33. DEFINE_TYPE( _NTFS_FRS_INFO, NTFS_FRS_INFO );
  34. class NTFS_MFT_INFO : public OBJECT {
  35. public:
  36. UNTFS_EXPORT
  37. DECLARE_CONSTRUCTOR( NTFS_MFT_INFO );
  38. VIRTUAL
  39. UNTFS_EXPORT
  40. ~NTFS_MFT_INFO(
  41. );
  42. NONVIRTUAL
  43. UNTFS_EXPORT
  44. BOOLEAN
  45. Initialize(
  46. IN BIG_INT NumOfFrs,
  47. IN PNTFS_UPCASE_TABLE UpcaseTable,
  48. IN UCHAR Major,
  49. IN UCHAR Minor,
  50. IN ULONG64 MaxMemUse
  51. );
  52. NONVIRTUAL
  53. UNTFS_EXPORT
  54. BOOLEAN
  55. Initialize(
  56. );
  57. NONVIRTUAL
  58. BOOLEAN
  59. IsInRange(
  60. IN VCN FileNumber
  61. );
  62. NONVIRTUAL
  63. VOID
  64. UpdateRange(
  65. IN VCN FileNumber
  66. );
  67. NONVIRTUAL
  68. VCN
  69. QueryMinFileNumber(
  70. );
  71. NONVIRTUAL
  72. VCN
  73. QueryMaxFileNumber(
  74. );
  75. NONVIRTUAL
  76. PVOID
  77. QueryIndexEntryInfo(
  78. IN VCN FileNumber
  79. );
  80. STATIC
  81. NONVIRTUAL
  82. UNTFS_EXPORT
  83. MFT_SEGMENT_REFERENCE
  84. QuerySegmentReference(
  85. IN PVOID FrsInfo
  86. );
  87. STATIC
  88. NONVIRTUAL
  89. UNTFS_EXPORT
  90. BOOLEAN
  91. CompareFileName(
  92. IN PVOID FrsInfo,
  93. IN ULONG ValueLength,
  94. IN PFILE_NAME FileName,
  95. OUT PUSHORT FileNameIndex
  96. );
  97. STATIC
  98. NONVIRTUAL
  99. UNTFS_EXPORT
  100. BOOLEAN
  101. CompareDupInfo(
  102. IN PVOID FrsInfo,
  103. IN PFILE_NAME FileName
  104. );
  105. STATIC
  106. NONVIRTUAL
  107. UNTFS_EXPORT
  108. UCHAR
  109. QueryFlags(
  110. IN PVOID FrsInfo,
  111. IN USHORT FileNameIndex
  112. );
  113. NONVIRTUAL
  114. BOOLEAN
  115. ExtractIndexEntryInfo(
  116. IN PNTFS_FILE_RECORD_SEGMENT Frs,
  117. IN PMESSAGE Message,
  118. IN BOOLEAN IgnoreFileName,
  119. OUT PBOOLEAN OutOfMemory
  120. );
  121. private:
  122. NONVIRTUAL
  123. VOID
  124. Construct(
  125. );
  126. NONVIRTUAL
  127. VOID
  128. Destroy(
  129. );
  130. STATIC
  131. NONVIRTUAL
  132. UNTFS_EXPORT
  133. VOID
  134. ComputeFileNameSignature(
  135. IN ULONG ValueLength,
  136. IN PFILE_NAME FileName,
  137. OUT FILE_NAME_SIGNATURE Signature
  138. );
  139. STATIC
  140. NONVIRTUAL
  141. UNTFS_EXPORT
  142. VOID
  143. ComputeDupInfoSignature(
  144. IN PDUPLICATED_INFORMATION DupInfo,
  145. OUT DUP_INFO_SIGNATURE Signature
  146. );
  147. VCN _min_file_number;
  148. VCN _max_file_number;
  149. PVOID *_mft_info;
  150. STATIC PNTFS_UPCASE_TABLE _upcase_table;
  151. STATIC UCHAR _major;
  152. STATIC UCHAR _minor;
  153. MEM_ALLOCATOR _mem_mgr;
  154. ULONG64 _max_mem_use;
  155. ULONG _num_of_files;
  156. };
  157. INLINE
  158. VCN
  159. NTFS_MFT_INFO::QueryMinFileNumber(
  160. )
  161. /*++
  162. Routine Description:
  163. This routine returns the minimum file number captured so far.
  164. Arguments:
  165. N/A
  166. Return Value:
  167. Minimum File Number
  168. --*/
  169. {
  170. return _min_file_number;
  171. }
  172. INLINE
  173. VCN
  174. NTFS_MFT_INFO::QueryMaxFileNumber(
  175. )
  176. /*++
  177. Routine Description:
  178. This routine returns the maximum file number captured so far.
  179. Arguments:
  180. N/A
  181. Return Value:
  182. Maximum File Number
  183. --*/
  184. {
  185. return _max_file_number;
  186. }
  187. INLINE
  188. BOOLEAN
  189. NTFS_MFT_INFO::IsInRange(
  190. IN VCN FileNumber
  191. )
  192. /*++
  193. Routine Description:
  194. This routine checks the file number to see if it is within range of
  195. an NTFS_MFT_INFO object.
  196. Arguments:
  197. FileNumber - file number to check
  198. Return Value:
  199. TRUE if FileNumber falls within the range of the NTFS_MFT_INFO object;
  200. otherwise, FALSE.
  201. --*/
  202. {
  203. return (_min_file_number <= FileNumber && FileNumber <= _max_file_number);
  204. }
  205. INLINE
  206. PVOID
  207. NTFS_MFT_INFO::QueryIndexEntryInfo(
  208. IN VCN FileNumber
  209. )
  210. /*++
  211. Routine Description:
  212. This method returns a pointer to a frs information.
  213. Arguments:
  214. FileNumber - file number to check
  215. Return Value:
  216. Pointer to base frs information.
  217. --*/
  218. {
  219. ASSERT(IsInRange(FileNumber));
  220. return _mft_info[FileNumber.GetLowPart()];
  221. }
  222. INLINE
  223. MFT_SEGMENT_REFERENCE
  224. NTFS_MFT_INFO::QuerySegmentReference(
  225. IN PVOID FrsInfo
  226. )
  227. /*++
  228. Routine Description:
  229. This method retrieves the Segment Reference of the frs
  230. from the FrsInfo pointer.
  231. Arguments:
  232. FrsInfo -- Pointer to the FRS information block.
  233. Returns:
  234. Segment Reference of the FRS.
  235. --*/
  236. {
  237. ASSERT(FrsInfo);
  238. return ((PNTFS_FRS_INFO)FrsInfo)->SegmentReference;
  239. }
  240. INLINE
  241. BOOLEAN
  242. NTFS_MFT_INFO::CompareDupInfo(
  243. IN PVOID FrsInfo,
  244. IN PFILE_NAME FileName
  245. )
  246. /*++
  247. Routine Description:
  248. This method compares the given FileName signature to that in FrsInfo.
  249. Arguments:
  250. FrsInfo -- Pointer to the FRS information block.
  251. FileName -- Pointer to the file name.
  252. Returns:
  253. TRUE -- if equals
  254. FALSE -- if not equal
  255. --*/
  256. {
  257. DUP_INFO_SIGNATURE dupinfo;
  258. ASSERT(FrsInfo);
  259. NTFS_MFT_INFO::ComputeDupInfoSignature(&(FileName->Info), dupinfo);
  260. return memcmp(dupinfo,
  261. ((PNTFS_FRS_INFO)FrsInfo)->DupInfoSignature,
  262. sizeof(DUP_INFO_SIGNATURE)) == 0;
  263. }
  264. INLINE
  265. UCHAR
  266. NTFS_MFT_INFO::QueryFlags(
  267. IN PVOID FrsInfo,
  268. IN USHORT FileNameIndex
  269. )
  270. /*++
  271. Routine Description:
  272. This method compares the given FileName signature to that in FrsInfo.
  273. Arguments:
  274. FrsInfo -- Pointer to the FRS information block.
  275. FileNameIndex -- Supplies the index of the file name
  276. Returns:
  277. TRUE -- if equals
  278. FALSE -- if not equal
  279. --*/
  280. {
  281. ASSERT(FrsInfo);
  282. ASSERT(((PNTFS_FRS_INFO)FrsInfo)->NumberOfFileNames > FileNameIndex);
  283. return ((PNTFS_FRS_INFO)FrsInfo)->FileNameInfo[FileNameIndex].Flags;
  284. }
  285. #endif