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