Content deleted Content added
→CFBF Header Format: 1 Byte is only 1 Byte long and NOT 2 bytes |
No edit summary |
||
(64 intermediate revisions by 43 users not shown) | |||
Line 1:
{{Short description|Compound document file format}}
{{Use dmy dates|date=December 2019}}
'''Compound File Binary Format''' (CFBF), also called '''Compound File''', '''Compound Document format''',<ref>{{cite web|url=http://poi.apache.org/poifs/index.html|title=Apache POI – POIFS|publisher=POI Project|accessdate=10 May 2011|archive-url=https://web.archive.org/web/20110426150340/http://poi.apache.org/poifs/index.html|archive-date=26 April 2011|url-status=dead}}</ref> or '''Composite Document File V2'''<ref>{{cite web
|url=https://linuxconfig.org/how-to-convert-documents-between-libreoffice-and-microsoft-office-file-formats-on-linux
|title=How to convert documents between LibreOffice and Microsoft Office file formats on Linux
|accessdate=25 November 2016
|archive-url=https://web.archive.org/web/20190921163547/https://linuxconfig.org/how-to-convert-documents-between-libreoffice-and-microsoft-office-file-formats-on-linux
|archive-date=21 September 2019
|url-status=dead
}}</ref> (CDF), is a [[compound document|compound]] [[document file format]] for storing numerous files and streams within a single file on a disk. CFBF is developed by [[Microsoft]] and is an implementation of Microsoft [[COM Structured Storage]].<ref>{{cite web
|url=http://msdn.microsoft.com/en-us/library/aa378938%28VS.85%29.aspx
|title=Compound Files (Windows)
|work=Microsoft Developers Network (MSDN) library – COM SDK|publisher=Microsoft Corporation|accessdate=23 September 2009|date=20 November 2008}}</ref><ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/ydd3k45e.aspx|title=Containers: Compound Files|work=Microsoft Developers Network (MSDN) library – Visual Studio 2008 documentation|publisher=Microsoft Corporation|accessdate=23 September 2009}}</ref><ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/cc542545%28VS.85%29.aspx|title=Understand Compound Files|work=Microsoft Developers Network (MSDN) library – ActiveDirectory Rights Management|accessdate=23 September 2009|date=25 June 2009}}</ref> The file format is used for storing storage objects and stream objects in a hierarchical structure within a single file.<ref>{{Cite web |date=2020-01-28 |title=Microsoft Compound File Binary File Format, Version 4 |url=https://www.loc.gov/preservation/digital/formats/fdd/fdd000392.shtml |access-date=2024-06-13 |website=www.loc.gov}}</ref>
==Overview==
At its simplest, the Compound File Binary Format is a container, with little restriction on what can be stored within it.
==Structure==
The CFBF file consists of a 512-
There are several types of sector that may be present in a CFBF file:
* File Allocation Table (FAT) Sector
* MiniFAT Sectors
* Double-Indirect FAT (DIFAT) Sector
* Directory Sector
* Stream Sector
* Range Lock Sector
More detail is given below for the header and each sector type.
===CFBF
The CFBF
<syntaxhighlight lang="c">
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,
// GetClassFile uses root directory class id)
USHORT _uMinorVersion; // [18H,02] minor version of the format: 33 is
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;
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
FSINDEX
FSINDEX
SECT _sectDirStart; // [30H,04] first SECT in the directory chain
DFSIGNATURE
ULONG
SECT
FSINDEX _csectMiniFat; // [40H,04] number of SECTs in the MiniFAT chain
SECT
FSINDEX
SECT
};
</syntaxhighlight>
===File Allocation Table (FAT)
When 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:
* {{Mono|FREESECT}} ({{Mono|0xFFFFFFFF}})
* {{Mono|ENDOFCHAIN}} ({{Mono|0xFFFFFFFE}})
* {{Mono|FATSECT}} ({{Mono|0xFFFFFFFD}})
* {{Mono|DIFSECT}} ({{Mono|0xFFFFFFFC}})
===Range Lock Sector===
{{Expand section|date=November 2009}}
The '''Range Lock Sector'''
===Glossary===
* ''FAT'' – File Allocation Table; also known as ''SAT'' – Sector Allocation Table
* ''DIFAT'' – Double-Indirect File Allocation Table
* ''FAT Chain'' – a group of FAT entries which indicate the Sectors allocated to a Stream in the file
* ''Stream'' – a virtual file which occupies a number of Sectors within the CFBF
* ''Sector'' – the unit of allocation within the CFBF, usually 512 or 4096 Bytes in length
==See also==
* [[COM Structured Storage]]
* [[Advanced Authoring Format]] (AAF)
* [[Cabinet (file format)]]
==References==
{{Reflist}}
==External links==
* {{cite web
| accessdate =
| url = https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-cfb/53989ce4-7b05-4f8d-829b-d08d6148375b
| title = [MS-CFB]: Compound File Binary File Format
| publisher = Microsoft
}}
* {{cite web
| accessdate = 22 May 2006
| url = http://sc.openoffice.org/compdocfileformat.pdf
| title = Microsoft Compound Document File Format
Line 127 ⟶ 128:
}}
* {{cite web
| accessdate =
| url = http://www.amwa.tv/downloads/specifications/aafcontainerspec-v1.0.1.pdf
| title = Advanced Authoring Format Low-Level Container Specification
| work = Microsoft Structured Storage version 3 specification (PDF)
| archive-url = https://web.archive.org/web/20110809045600/http://www.amwa.tv/downloads/specifications/aafcontainerspec-v1.0.1.pdf
| archive-date = 9 August 2011
| url-status = dead
}}
* {{cite web
| accessdate = 6 July 2019
| url = https://www.loc.gov/preservation/digital/formats/fdd/fdd000380.shtml
| title = Microsoft Compound File Binary File Format, Version 3
| publisher = Library of Congress, Digital Formats web site
}}
[[Category:Computer file formats]]
[[Category:Digital container formats]]
|