|
Compound File Binary Format (CFBF) is a format originally developed by Microsoft for on-disk storage of data using the IStorage COM object and the OLE32 StgCreateStorageEx, StgOpenStorageEx, etc API calls. Microsoft has opened the format for use by others and it is now used in a variety of programs from Microsoft's Access to Business Objects[1]. It also forms the basis of the Advanced Authoring Format.[1]
OverviewAt its simplest the Compound File Binary Format is a container, with little restriction on what can be stored within it. Internally a CFBF file loosely resembles a FAT filesytem. The file is partitioned into Sectors which are chained together with a File Allocation Table (FAT, aka Sector Allocation Table for disambiguation) which contains chains of sectors related to each file, a Directory holds information for contained files with a Sector ID (SID) for the starting sector of a FAT chain and so on. CompetitionA number of alternatives to CFBF exist, including CoreFSIF. StructureThe CFBF file consists of a 512-Byte header record followed by a number of sectors whose size is defined in the header. The literature defines Sectors to be either 512 or 4096 bytes in length, although the format is potentially capable of supporting sectors ranging in size from 128-Bytes upwards in powers of 2 (128, 256, 512, 1024, etc). The lower limit of 128 is the minimum required to fit a single directory entry in a Directory Sector. There are several types of sector that may be present in a CFBF:
More detail is given below for the header and each sector type. CFBF Header FormatThe CFBF Header occupies the first 512 bytes of the file and information required to interpret the rest of the file. The C-Style structure declaration below (extracted from the AAFA's Low-Level Container Specification) shows the members of the CFBF header and their purpose:
typedef unsigned long ULONG; // 4 Bytes
typedef unsigned short USHORT; // 2 Bytes
typedef short OFFSET; // 2 Bytes
typedef ULONG SECT; // 4 Bytes
typedef ULONG FSINDEX; // 4 Bytes
typedef USHORT FSOFFSET; // 2 Bytes
typedef USHORT WCHAR; // 2 Bytes
typedef ULONG DFSIGNATURE; // 4 Bytes
typedef unsigned char BYTE; // 1 Byte
typedef unsigned short WORD; // 2 Bytes
typedef unsigned long DWORD; // 4 Bytes
typedef ULONG SID; // 4 Bytes
typedef GUID CLSID; // 16 Bytes
struct StructuredStorageHeader { // [offset from start (bytes), length (bytes)]
BYTE _abSig[8]; // [00H,08] {0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1,
// 0x1a, 0xe1} for current version
CLSID _clsid; // [08H,16] reserved must be zero (WriteClassStg/
// GetClassFile uses root directory class id)
USHORT _uMinorVersion; // [18H,02] minor version of the format: 33 is
// written by reference implementation
USHORT _uDllVersion; // [1AH,02] major version of the dll/format: 3 for
// 512-byte sectors, 4 for 4 KB sectors
USHORT _uByteOrder; // [1CH,02] 0xFFFE: indicates Intel byte-ordering
USHORT _uSectorShift; // [1EH,02] size of sectors in power-of-two;
// typically 9 indicating 512-byte sectors
USHORT _uMiniSectorShift; // [20H,02] size of mini-sectors in power-of-two;
// typically 6 indicating 64-byte mini-sectors
USHORT _usReserved; // [22H,02] reserved, must be zero
ULONG _ulReserved1; // [24H,04] reserved, must be zero
FSINDEX _csectDir; // [28H,04] must be zero for 512-byte sectors,
// number of SECTs in directory chain for 4 KB
// sectors
FSINDEX _csectFat; // [2CH,04] number of SECTs in the FAT chain
SECT _sectDirStart; // [30H,04] first SECT in the directory chain
DFSIGNATURE _signature; // [34H,04] signature used for transactions; must
// be zero. The reference implementation
// does not support transactions
ULONG _ulMiniSectorCutoff; // [38H,04] maximum size for a mini stream;
// typically 4096 bytes
SECT _sectMiniFatStart; // [3CH,04] first SECT in the MiniFAT chain
FSINDEX _csectMiniFat; // [40H,04] number of SECTs in the MiniFAT chain
SECT _sectDifStart; // [44H,04] first SECT in the DIFAT chain
FSINDEX _csectDif; // [48H,04] number of SECTs in the DIFAT chain
SECT _sectFat[109]; // [4CH,436] the SECTs of first 109 FAT sectors
};
File Allocation Table (FAT) SectorsWhen taken together as a single stream the collection of FAT sectors define the status and linkage of every sector in the file. Each entry in the FAT is 4 bytes in length and contains the sector number of the next sector in a FAT chain or one of the following special values:
MiniFAT Sectors(This section is not yet written. Refer to documentation linked below.) Double-Indirect FAT (DIFAT) Sectors(This section is not yet written. Refer to documentation linked below.) Directory Sectors(This section is not yet written. Refer to documentation linked below.) Stream Sectors(This section is not yet written. Refer to documentation linked below.) Range Lock Sector(This section is not yet complete. Refer to documentation linked below.) The Range Lock Sector must exist in files greater than 2GB in size, and must not exist in files smaller than 2GB. The Range Lock Sector must contain the byte range 0x7FFFFF00 to 0x7FFFFFFF in the file. This area is reserved by Microsoft's COM implementation for storing byte-range locking information for concurrent access. Glossary(This section is not yet complete. Refer to documentation linked below.)
See alsoReferencesThe following references relate to the Compound File Binary Format format:
NotesExternal links
|
This article is from Wikipedia. All text is available under the terms of the GNU Free Documentation License.
Mercedes Car
This site monitored by SitePinger.net