Source code of Windows XP (NT5)
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.

174 lines
3.0 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. cluster.hxx
  5. Abstract:
  6. This class models a chain of clusters in a FAT file system. It gives
  7. the ability to refer to a scattered chain of clusters as one contiguous
  8. region of memory. This memory will be acquired from a MEM object at
  9. initialization.
  10. --*/
  11. #if !defined(CLUSTER_CHAIN_DEFN)
  12. #define CLUSTER_CHAIN_DEFN
  13. #include "secrun.hxx"
  14. #include "hmem.hxx"
  15. #if defined ( _AUTOCHECK_ ) || defined( _EFICHECK_ )
  16. #define UFAT_EXPORT
  17. #elif defined ( _UFAT_MEMBER_ )
  18. #define UFAT_EXPORT __declspec(dllexport)
  19. #else
  20. #define UFAT_EXPORT __declspec(dllimport)
  21. #endif
  22. //
  23. // Forward references
  24. //
  25. DECLARE_CLASS( CLUSTER_CHAIN );
  26. DECLARE_CLASS( FAT );
  27. DECLARE_CLASS( FAT_SA );
  28. DECLARE_CLASS( LOG_IO_DP_DRIVE );
  29. DECLARE_CLASS( MEM );
  30. class CLUSTER_CHAIN : public OBJECT {
  31. public:
  32. UFAT_EXPORT
  33. DECLARE_CONSTRUCTOR( CLUSTER_CHAIN );
  34. VIRTUAL
  35. UFAT_EXPORT
  36. ~CLUSTER_CHAIN(
  37. );
  38. NONVIRTUAL
  39. UFAT_EXPORT
  40. BOOLEAN
  41. Initialize(
  42. IN OUT PMEM Mem,
  43. IN OUT PLOG_IO_DP_DRIVE Drive,
  44. IN PFAT_SA FatSuperArea,
  45. IN PCFAT Fat,
  46. IN ULONG ClusterNumber,
  47. IN ULONG LengthOfChain DEFAULT 0
  48. );
  49. VIRTUAL
  50. UFAT_EXPORT
  51. BOOLEAN
  52. Read(
  53. );
  54. VIRTUAL
  55. UFAT_EXPORT
  56. BOOLEAN
  57. Write(
  58. );
  59. NONVIRTUAL
  60. PVOID
  61. GetBuf(
  62. );
  63. NONVIRTUAL
  64. ULONG
  65. QueryLength(
  66. ) CONST;
  67. private:
  68. NONVIRTUAL
  69. VOID
  70. Construct (
  71. );
  72. NONVIRTUAL
  73. VOID
  74. Destroy(
  75. );
  76. PSECRUN* _secruns;
  77. USHORT _num_secruns;
  78. ULONG _length_of_chain;
  79. //
  80. // Stuff needed for compressed volumes.
  81. //
  82. BOOLEAN _is_compressed;
  83. PSECRUN _secrun;
  84. PUCHAR _buf;
  85. HMEM _hmem;
  86. PFAT_SA _fat_sa;
  87. PCFAT _fat;
  88. PLOG_IO_DP_DRIVE
  89. _drive;
  90. ULONG _starting_cluster;
  91. };
  92. INLINE
  93. PVOID
  94. CLUSTER_CHAIN::GetBuf(
  95. )
  96. /*++
  97. Routine Description:
  98. This routine returns a pointer to the beginning of the memory map for
  99. the cluster chain.
  100. Arguments:
  101. None.
  102. Return Value:
  103. A pointer to the beginning of the memory map for the cluster chain.
  104. --*/
  105. {
  106. if (_is_compressed) {
  107. return _buf;
  108. }
  109. return (_secruns && _secruns[0]) ? _secruns[0]->GetBuf() : NULL;
  110. }
  111. INLINE
  112. ULONG
  113. CLUSTER_CHAIN::QueryLength(
  114. ) CONST
  115. /*++
  116. Routine Description:
  117. Computes the number of clusters in the cluster chain.
  118. Arguments:
  119. None.
  120. Return Value:
  121. The number of clusters in the cluster chain.
  122. --*/
  123. {
  124. return _length_of_chain;
  125. }
  126. #endif // CLUSTER_CHAIN_DEFN