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.

243 lines
3.8 KiB

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