📄 cdstruc.h
字号:
//
// The only special case is where we span a cache view. In that case
// we will allocate a buffer and read both pieces into it.
//
// This strategy takes advantage of the CC enhancement which allows
// overlapping ranges.
//
typedef struct _PATH_ENUM_CONTEXT {
//
// Pointer to the current sector and the offset of this sector to
// the beginning of the path table. The Data pointer may be
// a pool block in the case where we cross a cache view
// boundary. Also the length of the data for this block.
//
PVOID Data;
ULONG BaseOffset;
ULONG DataLength;
//
// Bcb for the sector. (We may actually have pinned two sectors)
// This will be NULL for the case where we needed to allocate a
// buffer in the case where we span a cache view.
//
PBCB Bcb;
//
// Offset to current entry within the current data block.
//
ULONG DataOffset;
//
// Did we allocate the buffer for the entry.
//
BOOLEAN AllocatedData;
//
// End of Path Table. This tells us whether the current data
// block includes the end of the path table. This is the
// only block where we need to do a careful check about whether
// the path table entry fits into the buffer.
//
// Also once we have reached the end of the path table we don't
// need to remap the data as we move into the final sector.
// We always look at the last two sectors together.
//
BOOLEAN LastDataBlock;
} PATH_ENUM_CONTEXT;
typedef PATH_ENUM_CONTEXT *PPATH_ENUM_CONTEXT;
#define VACB_MAPPING_MASK (VACB_MAPPING_GRANULARITY - 1)
#define LAST_VACB_SECTOR_OFFSET (VACB_MAPPING_GRANULARITY - SECTOR_SIZE)
//
// Path Entry. This is our representation of the on disk data.
//
typedef struct _PATH_ENTRY {
//
// Directory number and offset. This is the ordinal and the offset from
// the beginning of the path table stream for this entry.
//
//
ULONG Ordinal;
ULONG PathTableOffset;
//
// Logical block Offset on the disk for this entry. We already bias
// this by any Xar blocks.
//
ULONG DiskOffset;
//
// Length of on-disk path table entry.
//
ULONG PathEntryLength;
//
// Parent number.
//
ULONG ParentOrdinal;
//
// DirName length and Id. Typically the pointer here points to the raw on-disk
// bytes. We will point to a fixed self entry if this is the root directory.
//
ULONG DirNameLen;
PCHAR DirName;
//
// Following are the flags used to cleanup this structure.
//
ULONG Flags;
//
// The following is the filename string and version number strings. We embed a buffer
// large enough to hold two 8.3 names. One for exact case and one for case insensitive.
//
CD_NAME CdDirName;
CD_NAME CdCaseDirName;
WCHAR NameBuffer[BYTE_COUNT_EMBEDDED_NAME / sizeof( WCHAR ) * 2];
} PATH_ENTRY;
typedef PATH_ENTRY *PPATH_ENTRY;
#define PATH_ENTRY_FLAG_ALLOC_BUFFER (0x00000001)
//
// Compound path entry. This structure combines the on-disk entries
// with the in-memory structures.
//
typedef struct _COMPOUND_PATH_ENTRY {
PATH_ENUM_CONTEXT PathContext;
PATH_ENTRY PathEntry;
} COMPOUND_PATH_ENTRY;
typedef COMPOUND_PATH_ENTRY *PCOMPOUND_PATH_ENTRY;
//
// The following is used for enumerating through a directory via the
// dirents.
//
typedef struct _DIRENT_ENUM_CONTEXT {
//
// Pointer the current sector and the offset of this sector within
// the directory file. Also the data length of this pinned block.
//
PVOID Sector;
ULONG BaseOffset;
ULONG DataLength;
//
// Bcb for the sector.
//
PBCB Bcb;
//
// Offset to the current dirent within this sector.
//
ULONG SectorOffset;
//
// Length to next dirent. A zero indicates to move to the next sector.
//
ULONG NextDirentOffset;
} DIRENT_ENUM_CONTEXT;
typedef DIRENT_ENUM_CONTEXT *PDIRENT_ENUM_CONTEXT;
//
// Following structure is used to smooth out the differences in the HSG, ISO
// and Joliett directory entries.
//
typedef struct _DIRENT {
//
// Offset in the Directory of this entry. Note this includes
// any bytes added to the beginning of the directory to pad
// down to a sector boundary.
//
ULONG DirentOffset;
ULONG DirentLength;
//
// Starting offset on the disk including any Xar blocks.
//
ULONG StartingOffset;
//
// DataLength of the data. If not the last block then this should
// be an integral number of logical blocks.
//
ULONG DataLength;
//
// The following field is the time stamp out of the directory entry.
// Use a pointer into the dirent for this.
//
PCHAR CdTime;
//
// The following field is the dirent file flags field.
//
UCHAR DirentFlags;
//
// Following field is a Cdfs flag field used to clean up this structure.
//
UCHAR Flags;
//
// The following fields indicate the file unit size and interleave gap
// for interleaved files. Each of these are in logical blocks.
//
ULONG FileUnitSize;
ULONG InterleaveGapSize;
//
// System use offset. Zero value indicates no system use area.
//
ULONG SystemUseOffset;
//
// CDXA attributes and file number for this file.
//
USHORT XAAttributes;
UCHAR XAFileNumber;
//
// Filename length and ID. We copy the length (in bytes) and keep
// a pointer to the start of the name.
//
ULONG FileNameLen;
PCHAR FileName;
//
// The following are the filenames stored by name and version numbers.
// The fixed buffer here can hold two Unicode 8.3 names. This allows
// us to upcase the name into a fixed buffer.
//
CD_NAME CdFileName;
CD_NAME CdCaseFileName;
//
// Data stream type. Indicates if this is audio, XA mode2 form2 or cooked sectors.
//
XA_EXTENT_TYPE ExtentType;
WCHAR NameBuffer[BYTE_COUNT_EMBEDDED_NAME / sizeof( WCHAR ) * 2];
} DIRENT;
typedef DIRENT *PDIRENT;
#define DIRENT_FLAG_ALLOC_BUFFER (0x01)
#define DIRENT_FLAG_CONSTANT_ENTRY (0x02)
#define DIRENT_FLAG_NOT_PERSISTENT (0)
//
// Following structure combines the on-disk information with the normalized
// structure.
//
typedef struct _COMPOUND_DIRENT {
DIRENT_ENUM_CONTEXT DirContext;
DIRENT Dirent;
} COMPOUND_DIRENT;
typedef COMPOUND_DIRENT *PCOMPOUND_DIRENT;
//
// The following structure is used to enumerate the files in a directory.
// It contains three DirContext/Dirent pairs and then self pointers to
// know which of these is begin used how.
//
typedef struct _FILE_ENUM_CONTEXT {
//
// Pointers to the current compound dirents below.
//
// PriorDirent - Initial dirent for the last file encountered.
// InitialDirent - Initial dirent for the current file.
// CurrentDirent - Second or later dirent for the current file.
//
PCOMPOUND_DIRENT PriorDirent;
PCOMPOUND_DIRENT InitialDirent;
PCOMPOUND_DIRENT CurrentDirent;
//
// Flags indicating the state of the search.
//
ULONG Flags;
//
// This is an accumulation of the file sizes of the different extents
// of a single file.
//
LONGLONG FileSize;
//
// Short name for this file.
//
CD_NAME ShortName;
WCHAR ShortNameBuffer[ BYTE_COUNT_8_DOT_3 / sizeof( WCHAR ) ];
//
// Array of compound dirents.
//
COMPOUND_DIRENT Dirents[3];
} FILE_ENUM_CONTEXT;
typedef FILE_ENUM_CONTEXT *PFILE_ENUM_CONTEXT;
#define FILE_CONTEXT_MULTIPLE_DIRENTS (0x00000001)
//
// RIFF header. Prepended to the data of a file containing XA sectors.
// This is a hard-coded structure except that we bias the 'ChunkSize' and
// 'RawSectors' fields with the file size. We also copy the attributes flag
// from the system use area in the dirent. We always initialize this
// structure by copying the XAFileHeader.
//
typedef struct _RIFF_HEADER {
ULONG ChunkId;
LONG ChunkSize;
ULONG SignatureCDXA;
ULONG SignatureFMT;
ULONG XAChunkSize;
ULONG OwnerId;
USHORT Attributes;
USHORT SignatureXA;
UCHAR FileNumber;
UCHAR Reserved[7];
ULONG SignatureData;
ULONG RawSectors;
} RIFF_HEADER;
typedef RIFF_HEADER *PRIFF_HEADER;
//
// Audio play header for CDDA tracks.
//
typedef struct _AUDIO_PLAY_HEADER {
ULONG Chunk;
ULONG ChunkSize;
ULONG SignatureCDDA;
ULONG SignatureFMT;
ULONG FMTChunkSize;
USHORT FormatTag;
USHORT TrackNumber;
ULONG DiskID;
ULONG StartingSector;
ULONG SectorCount;
UCHAR TrackAddress[4];
UCHAR TrackLength[4];
} AUDIO_PLAY_HEADER;
typedef AUDIO_PLAY_HEADER *PAUDIO_PLAY_HEADER;
//
// Some macros for supporting the use of a Generic Table
// containing all the FCB/DCBs and indexed by their FileId.
//
// For directories:
//
// The HighPart contains the path table offset of this directory in the
// path table.
//
// The LowPart contains zero except for the upper bit which is
// set to indicate that this is a directory.
//
// For files:
//
// The HighPart contains the path table offset of the parent directory
// in the path table.
//
// The LowPart contains the byte offset of the dirent in the parent
// directory file.
//
// A directory is always entered into the Fcb Table as if it's
// dirent offset was zero. This enables any child to look in the FcbTable
// for it's parent by searching with the same HighPart but with zero
// as the value for LowPart.
//
// The Id field is a LARGE_INTEGER where the High and Low parts can be
// accessed separately.
//
// The following macros are used to access the Fid fields.
//
// CdQueryFidDirentOffset - Accesses the Dirent offset field
// CdQueryFidPathTableNumber - Accesses the PathTable offset field
// CdSetFidDirentOffset - Sets the Dirent offset field
// CdSetFidPathTableNumber - Sets the PathTable ordinal field
// CdFidIsDirectory - Queries if directory bit is set
// CdFidSetDirectory - Sets directory bit
//
#define FID_DIR_MASK 0x80000000 // high order bit means directory.
#define CdQueryFidDirentOffset(I) ((I).LowPart & ~FID_DIR_MASK)
#define CdQueryFidPathTableOffset(I) ((I).HighPart)
#define CdSetFidDirentOffset(I,D) ((I).LowPart = D)
#define CdSetFidPathTableOffset(I,P) ((I).HighPart = P)
#define CdFidIsDirectory(I) FlagOn( (I).LowPart, FID_DIR_MASK )
#define CdFidSetDirectory(I) SetFlag( (I).LowPart, FID_DIR_MASK )
#define CdSetFidFromParentAndDirent(I,F,D) { \
CdSetFidPathTableOffset( (I), CdQueryFidPathTableOffset( (F)->FileId )); \
CdSetFidDirentOffset( (I), (D)->DirentOffset ); \
if (FlagOn( (D)->DirentFlags, CD_ATTRIBUTE_DIRECTORY )) { \
CdFidSetDirectory((I)); \
} \
}
#endif // _CDSTRUC_
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -