00001 #pragma once
00002
00003
00004
00005
00006
00007 typedef unsigned __int64 QWORD;
00008 #define fio_SECTOR_SIZE 2048
00009
00010 typedef char dstring;
00011
00012 #define udf_LengthMask 0x3fffffff
00013
00014 #define udf_TAG_PrimaryVolumeDescriptor 0x0001
00015 #define udf_TAG_AnchorVolumeDescriptor 0x0002
00016 #define udf_TAG_PartitionDescriptor 0x0005
00017 #define udf_TAG_LogicalVolumeDescriptor 0x0006
00018 #define udf_TAG_TerminatingDescriptor 0x0008
00019 #define udf_TAG_FileSetDescriptor 0x0100
00020 #define udf_TAG_FileIdentifierDescriptor 0x0101
00021 #define udf_TAG_IndirectEntry 0x0103
00022 #define udf_TAG_TerminalEntry 0x0104
00023 #define udf_TAG_FileEntry 0x0105
00024
00025 #define udf_FT_IndirectEntry 0x03
00026 #define udf_FT_Directory 0x04
00027 #define udf_FT_File 0x05
00028 #define udf_FT_TerminalEntry 0x0b
00029
00030 #define udf_icbf_Mask 0x0007
00031 #define udf_icbf_ShortAd 0x0000
00032 #define udf_icbf_LongAd 0x0001
00033 #define udf_icbf_ExtAd 0x0002
00034 #define udf_icbf_Direct 0x0003
00035 #define udf_icbf_Contiguous 0x0100
00036
00037 #define udf_FID_Directory 0x02
00038 #define udf_FID_Parent 0x08
00039
00040 #pragma pack(push, 1)
00041
00042 typedef struct
00043 {
00044 DWORD Length;
00045 DWORD Location;
00046 } t_udf_short_ad, *tp_udf_short_ad;
00047
00048 typedef struct
00049 {
00050 DWORD Length;
00051 DWORD Location;
00052 } t_udf_extent_ad, *tp_udf_extent_ad;
00053
00054 typedef struct
00055 {
00056 DWORD Location;
00057 WORD PartitionNumber;
00058 } t_udf_lb_addr;
00059
00060 typedef struct
00061 {
00062 DWORD Length;
00063 t_udf_lb_addr Location;
00064 BYTE ImplementationUse[6];
00065 } t_udf_long_ad, *tp_udf_long_ad;
00066
00067 typedef struct
00068 {
00069 DWORD Length;
00070 DWORD RecordedLength;
00071 DWORD InformationLength;
00072 t_udf_lb_addr Location;
00073 BYTE ImplementationUse[2];
00074 } t_udf_ext_ad, *tp_udf_ext_ad;
00075
00076 typedef struct
00077 {
00078 BYTE CharacterSetType;
00079 BYTE CharacterSetInfo[63];
00080 } t_udf_charspec;
00081
00082 typedef struct
00083 {
00084 WORD TypeAndTimezone;
00085 WORD Year;
00086 BYTE Month;
00087 BYTE Day;
00088 BYTE Hour;
00089 BYTE Minute;
00090 BYTE Second;
00091 BYTE Centiseconds;
00092 BYTE HundredsofMicroseconds;
00093 BYTE Microseconds;
00094 } t_udf_timestamp;
00095
00096 typedef struct
00097 {
00098 WORD TagIdentifier;
00099 WORD DescriptorVersion;
00100 BYTE TagChecksum;
00101 BYTE Reserved;
00102 WORD TagSerialNumber;
00103 WORD DescriptorCRC;
00104 WORD DescriptorCRCLength;
00105 DWORD TagLocation;
00106 } t_udf_tag, *tp_udf_tag;
00107
00108 typedef struct
00109 {
00110 BYTE Flags;
00111 char Identifier[23];
00112 char IdentifierSuffix[8];
00113 } t_udf_EntityID;
00114
00115 typedef struct
00116 {
00117 t_udf_tag DescriptorTag;
00118 t_udf_extent_ad MainVolumeDescriptorSequenceExtent;
00119 t_udf_extent_ad ReserveVolumeDescriptorSequenceExtent;
00120 BYTE Reserved[480];
00121 } t_udf_AnchorVolumeDescriptorPointer, *tp_udf_AnchorVolumeDescriptorPointer;
00122
00123 typedef struct
00124 {
00125 t_udf_tag DescriptorTag;
00126 DWORD VolumeDescriptorSequenceNumber;
00127 t_udf_charspec DescriptorCharacterSet;
00128 dstring LogicalVolumeIdentifier[128];
00129 DWORD LogicalBlockSize;
00130 t_udf_EntityID DomainIdentifier;
00131
00132 t_udf_long_ad FileSetDescriptorSequence;
00133 DWORD MapTableLength;
00134 DWORD NumberofPartitionMaps;
00135 t_udf_EntityID ImplementationIdentifier;
00136 BYTE ImplementationUse[128];
00137 t_udf_extent_ad IntegritySequenceExtent;
00138 BYTE PartitionMaps[1];
00139 } t_udf_LogicalVolumeDescriptor, *tp_udf_LogicalVolumeDescriptor;
00140
00141 typedef struct
00142 {
00143 t_udf_short_ad UnallocatedSpaceTable;
00144 t_udf_short_ad UnallocatedSpaceBitmap;
00145 t_udf_short_ad PartitionIntegrityTable;
00146 t_udf_short_ad FreedSpaceTable;
00147 t_udf_short_ad FreedSpaceBitmap;
00148 BYTE Reserved[88];
00149 } t_udf_PartitionHeaderDescriptor;
00150
00151 typedef struct
00152 {
00153 t_udf_tag DescriptorTag;
00154 DWORD VolumeDescriptorSequenceNumber;
00155 WORD PartitionFlags;
00156 WORD PartitionNumber;
00157 t_udf_EntityID PartitionContents;
00158 t_udf_PartitionHeaderDescriptor PartitionHeaderDescriptor;
00159 DWORD AccessType;
00160 DWORD PartitionStartingLocation;
00161 DWORD PartitionLength;
00162 t_udf_EntityID ImplementationIdentifier;
00163 BYTE ImplementationUse[128];
00164 BYTE Reserved[156];
00165 } t_udf_PartitionDescriptor, *tp_udf_PartitionDescriptor;
00166
00167 typedef struct
00168 {
00169 t_udf_tag DescriptorTag;
00170 t_udf_timestamp RecordingDateandTime;
00171 WORD InterchangeLevel;
00172 WORD MaximumInterchangeLevel;
00173 DWORD CharacterSetList;
00174 DWORD MaximumCharacterSetList;
00175 DWORD FileSetNumber;
00176 DWORD FileSetDescriptorNumber;
00177 t_udf_charspec LogicalVolumeIdentifierCharacterSet;
00178 dstring LogicalVolumeIdentifier[128];
00179 t_udf_charspec FileSetCharacterSet;
00180 dstring FileSetIdentifer[32];
00181 dstring CopyrightFileIdentifier[32];
00182 dstring AbstractFileIdentifier[32];
00183 t_udf_long_ad RootDirectoryICB;
00184 t_udf_EntityID DomainIdentifier;
00185 t_udf_long_ad NextExtent;
00186 t_udf_long_ad StreamDirectoryICB;
00187 BYTE Reserved[32];
00188 } t_udf_FileSetDescriptor, *tp_udf_FileSetDescriptor;
00189
00190 typedef struct
00191 {
00192 DWORD PriorRecordedNumberofDirectEntries;
00193 WORD StrategyType;
00194 BYTE StrategyParameter[2];
00195 WORD NumberofEntries;
00196 BYTE Reserved;
00197 BYTE FileType;
00198 t_udf_lb_addr ParentICBLocation;
00199 WORD Flags;
00200 } t_udf_icbtag;
00201
00202 typedef struct
00203 {
00204 t_udf_tag DescriptorTag;
00205 t_udf_icbtag ICBTag;
00206 DWORD Uid;
00207 DWORD Gid;
00208 DWORD Permissions;
00209 WORD FileLinkCount;
00210 BYTE RecordFormat;
00211 BYTE RecordDisplayAttributes;
00212 DWORD RecordLength;
00213 QWORD InformationLength;
00214 QWORD LogicalBlocksRecorded;
00215 t_udf_timestamp AccessTime;
00216 t_udf_timestamp ModificationTime;
00217 t_udf_timestamp AttributeTime;
00218 DWORD Checkpoint;
00219 t_udf_long_ad ExtendedAttributeICB;
00220 t_udf_EntityID ImplementationIdentifier;
00221 QWORD UniqueID;
00222 DWORD LengthofExtendedAttributes;
00223 DWORD LengthofAllocationDescriptors;
00224 BYTE ExtendedAttributes[];
00225
00226 } t_udf_FileEntry, *tp_udf_FileEntry;
00227
00228 typedef struct
00229 {
00230 t_udf_tag DescriptorTag;
00231 WORD FileVersionNumber;
00232 BYTE FileCharacteristics;
00233 BYTE LengthofFileIdentifier;
00234 t_udf_long_ad ICB;
00235 WORD LengthofImplementationUse;
00236 BYTE ImplementationUse[];
00237
00238
00239 } t_udf_FileIdentifierDescriptor, *tp_udf_FileIdentifierDescriptor;
00240
00241 #define udf_MAX_NAMELEN 256
00242 #define udf_MAX_PATHLEN 2048
00243
00244 typedef struct
00245 {
00246
00247 char name[udf_MAX_NAMELEN];
00248 bool is_dir, is_parent;
00249
00250 BYTE *sector;
00251 tp_udf_FileIdentifierDescriptor fid;
00252 DWORD partition_lba;
00253 DWORD dir_lba, dir_end_lba;
00254 DWORD sec_size;
00255 int dir_left;
00256 } t_udf_file, *tp_udf_file;
00257
00258 #pragma pack(pop)
00259
00260 tp_udf_file udf_find_file(const HANDLE hDrive, const WORD partition, const char *name);
00261 tp_udf_file udf_get_root(const HANDLE hDrive, const WORD partition_number);
00262 tp_udf_file udf_get_next(const HANDLE hDrive, tp_udf_file f);
00263 tp_udf_file udf_get_sub(const HANDLE hDrive, tp_udf_file f);
00264 bool udf_get_lba(const HANDLE hDrive, const tp_udf_file f, DWORD *start_lba, DWORD *end_lba);
00265 void udf_free(tp_udf_file f);