udf.h
上传用户:xjjlds
上传日期:2015-12-05
资源大小:22823k
文件大小:8k
源码类别:

多媒体编程

开发平台:

Visual C++

  1. #pragma once
  2. /*************************************************************************
  3.   vStrip by [maven] (maven@maven.de)
  4. *************************************************************************/
  5. typedef unsigned __int64 QWORD;
  6. #define fio_SECTOR_SIZE 2048
  7. typedef char dstring; // last BYTE of string indicates encoding/length
  8. #define udf_LengthMask 0x3fffffff
  9. #define udf_TAG_PrimaryVolumeDescriptor 0x0001
  10. #define udf_TAG_AnchorVolumeDescriptor 0x0002
  11. #define udf_TAG_PartitionDescriptor 0x0005
  12. #define udf_TAG_LogicalVolumeDescriptor 0x0006
  13. #define udf_TAG_TerminatingDescriptor 0x0008
  14. #define udf_TAG_FileSetDescriptor 0x0100
  15. #define udf_TAG_FileIdentifierDescriptor 0x0101
  16. #define udf_TAG_IndirectEntry 0x0103
  17. #define udf_TAG_TerminalEntry 0x0104
  18. #define udf_TAG_FileEntry 0x0105
  19. #define udf_FT_IndirectEntry 0x03
  20. #define udf_FT_Directory 0x04
  21. #define udf_FT_File 0x05
  22. #define udf_FT_TerminalEntry 0x0b
  23. #define udf_icbf_Mask 0x0007
  24. #define udf_icbf_ShortAd 0x0000
  25. #define udf_icbf_LongAd 0x0001
  26. #define udf_icbf_ExtAd 0x0002
  27. #define udf_icbf_Direct 0x0003
  28. #define udf_icbf_Contiguous 0x0100
  29. #define udf_FID_Directory 0x02
  30. #define udf_FID_Parent 0x08
  31. #pragma pack(push, 1)
  32. typedef struct
  33. {
  34. DWORD Length; // 00, high 2 bits: 0 ^= recorded & used, 1 ^= not recorded & used, 2 ^= not recorded & not used, 3 ^= linked list
  35. DWORD Location; // 04
  36. } t_udf_short_ad, *tp_udf_short_ad; // 08
  37. typedef struct
  38. {
  39. DWORD Length; // 00
  40. DWORD Location; // 04
  41. } t_udf_extent_ad, *tp_udf_extent_ad; // 08
  42. typedef struct
  43. {
  44. DWORD Location; // 00, relative to volume
  45. WORD PartitionNumber; // 04
  46. } t_udf_lb_addr; // 06
  47. typedef struct
  48. {
  49. DWORD Length; // 00, high 2 bits: 0 ^= recorded & used, 1 ^= not recorded & used, 2 ^= not recorded & not used, 3 ^= linked list
  50. t_udf_lb_addr Location; // 04
  51. BYTE ImplementationUse[6]; // 10
  52. } t_udf_long_ad, *tp_udf_long_ad; // 16
  53. typedef struct
  54. {
  55. DWORD Length; // 00, high 2 bits: 0 ^= recorded & used, 1 ^= not recorded & used, 2 ^= not recorded & not used, 3 ^= linked list
  56. DWORD RecordedLength; // 04
  57. DWORD InformationLength; // 08
  58. t_udf_lb_addr Location; // 12
  59. BYTE ImplementationUse[2]; // 18
  60. } t_udf_ext_ad, *tp_udf_ext_ad; // 20
  61. typedef struct
  62. {
  63. BYTE CharacterSetType; // 00
  64. BYTE CharacterSetInfo[63]; // 01
  65. } t_udf_charspec; // 64
  66. typedef struct
  67. { /* ECMA 167 1/7.3 */
  68. WORD TypeAndTimezone; // 00
  69. WORD Year; // 02
  70. BYTE Month; // 04
  71. BYTE Day; // 05
  72. BYTE Hour; // 06
  73. BYTE Minute; // 07
  74. BYTE Second; // 08
  75. BYTE Centiseconds; // 09
  76. BYTE HundredsofMicroseconds; // 10
  77. BYTE Microseconds; // 11
  78. } t_udf_timestamp; // 12
  79. typedef struct
  80. { /* ISO 13346 3/7.2 */
  81. WORD TagIdentifier; // 00
  82. WORD DescriptorVersion; // 02
  83. BYTE TagChecksum; // 04
  84. BYTE Reserved; // 05
  85. WORD TagSerialNumber; // 06
  86. WORD DescriptorCRC; // 08
  87. WORD DescriptorCRCLength; // 10
  88. DWORD TagLocation; // 12
  89. } t_udf_tag, *tp_udf_tag; // 16
  90. typedef struct
  91. { /* ISO 13346 1/7.4 */
  92. BYTE Flags; // 00
  93. char Identifier[23]; // 01
  94. char IdentifierSuffix[8]; // 24
  95. } t_udf_EntityID; // 32
  96. typedef struct
  97. { /* ISO 13346 3/10.2 */
  98. t_udf_tag DescriptorTag; // 00
  99. t_udf_extent_ad MainVolumeDescriptorSequenceExtent; // 16
  100. t_udf_extent_ad ReserveVolumeDescriptorSequenceExtent; // 24
  101. BYTE Reserved[480]; // 32
  102. } t_udf_AnchorVolumeDescriptorPointer, *tp_udf_AnchorVolumeDescriptorPointer; // 512
  103. typedef struct
  104. { /* ISO 13346 3/10.6 */
  105. t_udf_tag DescriptorTag; // 00
  106. DWORD VolumeDescriptorSequenceNumber; // 16
  107. t_udf_charspec DescriptorCharacterSet; // 20
  108. dstring LogicalVolumeIdentifier[128]; // 84
  109. DWORD LogicalBlockSize; // 212
  110. t_udf_EntityID DomainIdentifier; // 244
  111. // BYTE LogicalVolumeContentsUse[16]; // 276
  112. t_udf_long_ad FileSetDescriptorSequence; // 276
  113. DWORD MapTableLength; // 292
  114. DWORD NumberofPartitionMaps; // 296
  115. t_udf_EntityID ImplementationIdentifier; // 300
  116. BYTE ImplementationUse[128]; // 332
  117. t_udf_extent_ad IntegritySequenceExtent; // 460
  118. BYTE PartitionMaps[1]; // 468
  119. } t_udf_LogicalVolumeDescriptor, *tp_udf_LogicalVolumeDescriptor;
  120. typedef struct
  121. t_udf_short_ad UnallocatedSpaceTable; // 00
  122. t_udf_short_ad UnallocatedSpaceBitmap; // 08
  123. t_udf_short_ad PartitionIntegrityTable; // 16
  124. t_udf_short_ad FreedSpaceTable; // 24
  125. t_udf_short_ad FreedSpaceBitmap; // 32
  126. BYTE Reserved[88]; // 40
  127. } t_udf_PartitionHeaderDescriptor; // 128
  128. typedef struct
  129. { /* ECMA 167 3/10.5  */
  130. t_udf_tag DescriptorTag; // 00
  131. DWORD VolumeDescriptorSequenceNumber; // 16
  132. WORD PartitionFlags; // 20
  133. WORD PartitionNumber; // 22
  134. t_udf_EntityID PartitionContents; // 24
  135. t_udf_PartitionHeaderDescriptor PartitionHeaderDescriptor; // 56
  136. DWORD AccessType; // 184, 0 unspecified, 1 read only, 2 write once, 3 rewriteable, 4 overwriteable
  137. DWORD PartitionStartingLocation; // 188
  138. DWORD PartitionLength; // 192
  139. t_udf_EntityID ImplementationIdentifier; // 196
  140. BYTE ImplementationUse[128]; // 228
  141. BYTE Reserved[156]; // 356
  142. } t_udf_PartitionDescriptor, *tp_udf_PartitionDescriptor; // 512
  143. typedef struct
  144. { /* ECMA 167 4/14.1 */
  145. t_udf_tag DescriptorTag; // 00
  146. t_udf_timestamp RecordingDateandTime; // 16
  147. WORD InterchangeLevel; // 28
  148. WORD MaximumInterchangeLevel; // 30
  149. DWORD CharacterSetList; // 32
  150. DWORD MaximumCharacterSetList; // 36
  151. DWORD FileSetNumber; // 40
  152. DWORD FileSetDescriptorNumber; // 44
  153. t_udf_charspec LogicalVolumeIdentifierCharacterSet; // 48
  154. dstring LogicalVolumeIdentifier[128]; // 112
  155. t_udf_charspec FileSetCharacterSet; // 240
  156. dstring FileSetIdentifer[32]; // 304
  157. dstring CopyrightFileIdentifier[32]; // 336
  158. dstring AbstractFileIdentifier[32]; // 368
  159. t_udf_long_ad RootDirectoryICB; // 400
  160. t_udf_EntityID DomainIdentifier; // 416
  161. t_udf_long_ad NextExtent; // 448
  162. t_udf_long_ad StreamDirectoryICB; // 464
  163. BYTE Reserved[32]; // 480
  164. } t_udf_FileSetDescriptor, *tp_udf_FileSetDescriptor; // 512
  165. typedef struct
  166. { /* ECMA 167 4/14.6 */
  167. DWORD PriorRecordedNumberofDirectEntries; // 00
  168. WORD StrategyType; // 04
  169. BYTE StrategyParameter[2]; // 06
  170. WORD NumberofEntries; // 08
  171. BYTE Reserved; // 10
  172. BYTE FileType; // 11
  173. t_udf_lb_addr ParentICBLocation; // 12
  174. WORD Flags; // 18
  175. } t_udf_icbtag; // 20
  176. typedef struct
  177. { /* ECMA 167 4/14.9 */
  178. t_udf_tag DescriptorTag; // 00
  179. t_udf_icbtag ICBTag; // 16
  180. DWORD Uid; // 36
  181. DWORD Gid; // 40
  182. DWORD Permissions; // 44
  183. WORD FileLinkCount; // 48
  184. BYTE RecordFormat; // 50
  185. BYTE RecordDisplayAttributes; // 51
  186. DWORD RecordLength; // 52
  187. QWORD InformationLength; // 56
  188. QWORD LogicalBlocksRecorded; // 64
  189. t_udf_timestamp AccessTime; // 72
  190. t_udf_timestamp ModificationTime; // 84
  191. t_udf_timestamp AttributeTime; // 96
  192. DWORD Checkpoint; // 108
  193. t_udf_long_ad ExtendedAttributeICB; // 112
  194. t_udf_EntityID ImplementationIdentifier; // 128
  195. QWORD UniqueID; // 160
  196. DWORD LengthofExtendedAttributes; // 168
  197. DWORD LengthofAllocationDescriptors; // 172
  198. BYTE ExtendedAttributes[]; // 176
  199. // BYTE AllocationDescriptors[]; // 176
  200. } t_udf_FileEntry, *tp_udf_FileEntry; // >= 176
  201. typedef struct
  202. { /* ECMA 167 4/14.4 */
  203. t_udf_tag DescriptorTag; // 00
  204. WORD FileVersionNumber; // 16
  205. BYTE FileCharacteristics; // 18
  206. BYTE LengthofFileIdentifier; // 19
  207. t_udf_long_ad ICB; // 20
  208. WORD LengthofImplementationUse; // 36
  209. BYTE ImplementationUse[]; // 38
  210. // char FileIdentifier[]; // 38
  211. // BYTE Padding[]; // 38
  212. } t_udf_FileIdentifierDescriptor, *tp_udf_FileIdentifierDescriptor; // >= 38
  213. #define udf_MAX_NAMELEN 256
  214. #define udf_MAX_PATHLEN 2048
  215. typedef struct
  216. {
  217. // public
  218. char name[udf_MAX_NAMELEN];
  219. bool is_dir, is_parent;
  220. // internal
  221. BYTE *sector;
  222. tp_udf_FileIdentifierDescriptor fid;
  223. DWORD partition_lba;
  224. DWORD dir_lba, dir_end_lba;
  225. DWORD sec_size;
  226. int dir_left;
  227. } t_udf_file, *tp_udf_file;
  228. #pragma pack(pop)
  229. tp_udf_file udf_find_file(const HANDLE hDrive, const WORD partition, const char *name);
  230. tp_udf_file udf_get_root(const HANDLE hDrive, const WORD partition_number);
  231. tp_udf_file udf_get_next(const HANDLE hDrive, tp_udf_file f); // advances f
  232. tp_udf_file udf_get_sub(const HANDLE hDrive, tp_udf_file f); // creates new f
  233. bool udf_get_lba(const HANDLE hDrive, const tp_udf_file f, DWORD *start_lba, DWORD *end_lba);
  234. void udf_free(tp_udf_file f);