复合二进制文档(CFBF),簡称复合文档,英文全名 Composite Document File V2 Document,是微软开发、用於实现COM结构化存储的文件格式(10)

复合二进制文档

复合二进制文档(CFBF),簡称复合文档,英文全名 Composite Document File V2 Document,是微软开发、用於实现COM结构化存储的文件格式,用于把多个对象内容存放在同一个硬盘文件。

Microsoft已经开放了这个文件格式。广泛用于Microsoft WordMicrosoft Access。也是Advanced Authoring Format的基础。

文件结构

CFBF文件头部是512字节,随后跟着是保存数据的扇区。扇区的长度在文件头部指定,通常是512字节或4096字节。

CFBF的扇区类型:

  • FAT扇区
  • MiniFAT扇区:用于Mini-Stream
  • Double-Indirect FAT (DIFAT)扇区 - 包含FAT扇区索引的链表数据
  • Directory扇区
  • Stream扇区 - 包含数据内容
  • Range Lock扇区 - 包含大文件的上锁的字节范围

CFBF文件头

CFBF头是该文件的最前的512字节。对应于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,
                                 // 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
 };

FAT扇区

每个FAT条目长度4字节,包含下个FAT链表条目的扇区号,或下述特定值:

  • FREESECT (0xFFFFFFFF) - 未用扇区
  • ENDOFCHAIN (0xFFFFFFFE) - FAT链表最后一个扇区
  • FATSECT (0xFFFFFFFD) - 用于FAT数据存储
  • DIFSECT (0xFFFFFFFC) - 用于DIFAT数据存储

词汇表

  • FAT - 文件分配表,也称 SAT - 扇区分配表
  • DIFAT - Double-Indirect File Allocation Table
  • FAT Chain - 一群FAT条目指出分配给一个流的那些扇区
  • Stream - 一个数据对象的内容
  • Sector - 扇区,占据512或4096个字节

参见

参考文献

  1.  . POI Project. [10 May 2011]. (原始内容存档于2011-04-26).
  2.  . [25 Nov 2016]. (原始内容存档于2019-09-21).
  3.  . Microsoft Developers Network (MSDN) library – COM SDK. Microsoft Corporation. 20 November 2008 [23 September 2009]. (原始内容存档于2016-03-07).
  4.  . Microsoft Developers Network (MSDN) library – Visual Studio 2008 documentation. Microsoft Corporation. [23 September 2009]. (原始内容存档于2012-10-18).
  5.  . Microsoft Developers Network (MSDN) library – ActiveDirectory Rights Management. 25 June 2009 [23 September 2009]. (原始内容存档于2016-03-09).
  6.  AMW Association (formerly AAF Association) 的存檔,存档日期15 August 2000.

外部链接

  • (PDF). OpenOffice.org CFBF description. [2006-05-22]. (原始内容存档 (PDF)于2011-10-12).
  • (PDF). Microsoft Structured Storage version 3 specification (PDF). [2006-05-22]. (原始内容 (PDF)存档于2011-08-09).

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

weixin_40191861_zj

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值