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.

239 lines
3.7 KiB

  1. /*++
  2. Copyright (c) 1990 Microsoft Corporation
  3. Module Name:
  4. easet.hxx
  5. Abstract:
  6. This class models an EA set.
  7. Notes:
  8. There are minor alignment problems here.
  9. --*/
  10. #if !defined(EA_SET_DEFN)
  11. #define EA_SET_DEFN
  12. #include "cluster.hxx"
  13. #if defined ( _AUTOCHECK_ ) || defined( _EFICHECK_ )
  14. #define UFAT_EXPORT
  15. #elif defined ( _UFAT_MEMBER_ )
  16. #define UFAT_EXPORT __declspec(dllexport)
  17. #else
  18. #define UFAT_EXPORT __declspec(dllimport)
  19. #endif
  20. //
  21. // Forward references
  22. //
  23. DECLARE_CLASS( EA_SET );
  24. DECLARE_CLASS( FAT );
  25. DECLARE_CLASS( FAT_SA );
  26. DECLARE_CLASS( LOG_IO_DP_DRIVE );
  27. DECLARE_CLASS( MEM );
  28. struct _EA_HDR {
  29. USHORT Signature;
  30. USHORT OwnHandle;
  31. ULONG NeedCount;
  32. UCHAR OwnerFileName[14];
  33. ULONG Reserved;
  34. LONG TotalSize;
  35. };
  36. DEFINE_TYPE( struct _EA_HDR, EA_HDR );
  37. struct _PACKED_EA_HDR {
  38. USHORT Signature;
  39. USHORT OwnHandle;
  40. ULONG NeedCount;
  41. UCHAR OwnerFileName[14];
  42. UCHAR Reserved[4];
  43. UCHAR TotalSize[4];
  44. };
  45. DEFINE_TYPE( struct _PACKED_EA_HDR, PACKED_EA_HDR );
  46. const SizeOfEaHdr = 30; // sizeof returns 32.
  47. struct _EA {
  48. UCHAR Flag;
  49. UCHAR NameSize;
  50. UCHAR ValueSize[2]; // Was USHORT.
  51. CHAR Name[1];
  52. };
  53. DEFINE_TYPE( struct _EA, EA );
  54. CONST USHORT EaSetSignature = 0x4145;
  55. CONST UCHAR NeedFlag = 0x80;
  56. class EA_SET : public CLUSTER_CHAIN {
  57. public:
  58. UFAT_EXPORT
  59. DECLARE_CONSTRUCTOR( EA_SET );
  60. VIRTUAL
  61. UFAT_EXPORT
  62. ~EA_SET(
  63. );
  64. NONVIRTUAL
  65. UFAT_EXPORT
  66. BOOLEAN
  67. Initialize(
  68. IN OUT PMEM Mem,
  69. IN OUT PLOG_IO_DP_DRIVE Drive,
  70. IN PFAT_SA FatSuperArea,
  71. IN PCFAT Fat,
  72. IN ULONG ClusterNumber,
  73. IN ULONG LengthOfChain DEFAULT 0
  74. );
  75. NONVIRTUAL
  76. UFAT_EXPORT
  77. BOOLEAN
  78. Read(
  79. );
  80. NONVIRTUAL
  81. BOOLEAN
  82. Write(
  83. );
  84. NONVIRTUAL
  85. PEA_HDR
  86. GetEaSetHeader(
  87. );
  88. NONVIRTUAL
  89. UFAT_EXPORT
  90. PEA
  91. GetEa(
  92. IN ULONG Index,
  93. OUT PLONG EaSize DEFAULT NULL,
  94. OUT PBOOLEAN PossiblyMore DEFAULT NULL
  95. );
  96. NONVIRTUAL
  97. BOOLEAN
  98. VerifySignature(
  99. ) CONST;
  100. private:
  101. NONVIRTUAL
  102. VOID
  103. Construct(
  104. );
  105. NONVIRTUAL
  106. VOID
  107. Destroy(
  108. );
  109. NONVIRTUAL
  110. BOOLEAN
  111. PackEaHeader(
  112. );
  113. NONVIRTUAL
  114. BOOLEAN
  115. UnPackEaHeader(
  116. );
  117. EA_HDR _eahdr;
  118. LONG _size;
  119. BOOLEAN _size_imposed;
  120. PEA _current_ea;
  121. ULONG _current_index;
  122. };
  123. INLINE
  124. BOOLEAN
  125. EA_SET::Write(
  126. )
  127. /*++
  128. Routine Description:
  129. This routine packs the ea header and then writes the cluster chain to disk.
  130. Arguments:
  131. None.
  132. Return Value:
  133. FALSE - Failure.
  134. TRUE - Success.
  135. --*/
  136. {
  137. return PackEaHeader() && CLUSTER_CHAIN::Write();
  138. }
  139. INLINE
  140. PEA_HDR
  141. EA_SET::GetEaSetHeader(
  142. )
  143. /*++
  144. Routine Description:
  145. This routine returns a pointer to the unpacked ea set header.
  146. Arguments:
  147. None.
  148. Return Value:
  149. A pointer to the unpacked ea set header.
  150. --*/
  151. {
  152. return &_eahdr;
  153. }
  154. INLINE
  155. BOOLEAN
  156. EA_SET::VerifySignature(
  157. ) CONST
  158. /*++
  159. Routine Description:
  160. This routine verifies the signature on the EA set.
  161. Arguments:
  162. None.
  163. Return Value:
  164. FALSE - The signature is invalid.
  165. TRUE - The signature is valid.
  166. --*/
  167. {
  168. return _eahdr.Signature == EaSetSignature;
  169. }
  170. #endif // EA_SET_DEFN