Share via


2.1 Compound File Sector Numbers and Types

Each sector, except for the header, is identified by a nonnegative, 32-bit sector number. The following sector numbers above 0xFFFFFFFA are reserved and MUST NOT be used to identify the location of a sector in a compound file.

Sector name

Integer value

Description

REGSECT

0x00000000 - 0xFFFFFFF9

Regular sector number.

MAXREGSECT

0xFFFFFFFA

Maximum regular sector number.

Not applicable

0xFFFFFFFB

Reserved for future use.

DIFSECT

0xFFFFFFFC

Specifies a DIFAT sector in the FAT.

FATSECT

0xFFFFFFFD

Specifies a FAT sector in the FAT.

ENDOFCHAIN

0xFFFFFFFE

End of a linked chain of sectors.

FREESECT

0xFFFFFFFF

Specifies an unallocated sector in the FAT, Mini FAT, or DIFAT.

The following list contains the types of sectors that are allowed in a compound file. Their structures are described in sections 2.2 through 2.8.

Sector type

Array entry length

Purpose

Header

Not applicable

A single sector with fields that are needed to read the other structures of the compound file. This sector must be at file offset 0.

FAT

4 bytes

Main allocator of space within the compound file.

DIFAT

4 bytes

Used to locate FAT sectors in the compound file.

Mini FAT

4 bytes

Allocator for mini stream  user-defined data.

Directory

128 bytes

Contains storage object and stream object metadata.

User-defined Data

Not applicable

User-defined data for stream objects.

Range Lock

Not applicable

A single sector that is used to manage concurrent access to the compound file. This sector must cover file offset 0x7FFFFFFF.

Unallocated Free

Not applicable

Empty space in the compound file.

Compound file sectors can contain unallocated free space, user-defined data for stream objects, directory sectors containing directory entries, FAT sectors containing the FAT entries, DIFAT sectors containing the DIFAT entries, and mini FAT sectors containing the mini FAT entries. Compound file sectors can be located at any sector-sized offset in the file, with the exception of the header and range lock sector.

Example of the hierarchy of compound file sectors

Figure 10: Example of the hierarchy of compound file sectors

All the sector types are eventually linked back to the header sector, except for the range lock sector and unallocated free sectors. Unallocated free sectors are marked in the FAT as FREESECT (0xFFFFFFFF). Unallocated free sectors can be in the middle of the file, and they can be created by extending the file size and allocating additional FAT sectors to cover the increased length. The range lock sector is identified by a fixed file offset (0x7FFFFFFF) in the compound file.

In a compound file, all sector chains MUST contain valid sector numbers, less than or equal to MAXREGSECT (0xFFFFFFFA). In a sector chain, the last sector's next pointer MUST be ENDOFCHAIN (0xFFFFFFFE). All sectors in a sector chain MUST NOT be part of any other sector chain in the same file. A sector chain MUST NOT link to a sector appearing earlier in the same chain, which would result in a cycle. Finally, the actual sector count MUST match the size that is specified for a sector chain.