Export (0) Print
Expand All

2.6.1 Compound File Directory Entry

The directory entry array is an array of directory entries grouped into a directory sector. Each storage object or stream object within a compound file is represented by a single directory entry. The space for the directory sectors holding the array is allocated from the FAT.

The valid values for a stream ID—used in Child ID, Right Sibling ID, and Left Sibling ID—are 0 through MAXREGSID (0xFFFFFFFA). The special value NOSTREAM (0xFFFFFFFF) is used as a terminator.

Stream ID name

Integer value

Description

REGSID

0x00000000 through 0xFFFFFFF9

Regular stream ID to identify directory entry

MAXREGSID

0xFFFFFFFA

Maximum regular stream ID

NOSTREAM

0xFFFFFFFF

Terminator or empty pointer

The directory entry size is fixed at 128 bytes. The name in the directory entry is limited to 32 UnicodeUTF-16 code points, including the required Unicode terminating null character.

Directory entries are grouped into blocks to form directory sectors. There are four directory entries in a 512-byte directory sector (version 3 compound file), and there are 32 directory entries in a 4096-byte directory sector (version 4 compound file). The number of directory entries can exceed the number of storage objects and stream objects due to unallocated directory entries.

The detailed Directory Entry structure is specified below.


0

1

2

3

4

5

6

7

8

9
1
0

1

2

3

4

5

6

7

8

9
2
0

1

2

3

4

5

6

7

8

9
3
0

1

Directory Entry Name

...

...

...

...

...

...

...

(Directory Entry Name cont'd for 8 rows)

Directory Entry Name Length

Object Type

Color Flag

Left Sibling ID

Right Sibling ID

Child ID

CLSID

...

...

...

State Bits

Creation Time

...

Modified Time

...

Starting Sector Location

Stream Size

...

Directory Entry Name (64 bytes): This field MUST contain a Unicode string for the storage or stream name encoded in UTF-16. The name MUST be terminated with a UTF-16 terminating null character. Thus storage and stream names are limited to 32 UTF-16 code points, including the terminating null character. When locating an object in the compound file except for the root storage, the directory entry name is compared using a special case-insensitive upper-case mapping, described in Red-Black Tree. The following characters are illegal and MUST NOT be part of the name: '/', '\', ':', '!'.

Directory Entry Name Length (2 bytes): This field MUST match the length of the Directory Entry Name Unicode string in bytes. The length MUST be a multiple of 2, and include the terminating null character in the count. This length MUST NOT exceed 64, the maximum size of the Directory Entry Name field.

Object Type (1 byte): This field MUST be 0x00, 0x01, 0x02, or 0x05, depending on the actual type of object. All other values are not valid.

Name Value

Unknown or unallocated

0x00

Storage Object

0x01

Stream Object

0x02

Root Storage Object

0x05

Color Flag (1 byte): This field MUST be 0x00 (red) or 0x01 (black). All other values are not valid.

Name Value

red

0x00

black

0x01

Left Sibling ID (4 bytes): This field contains the Stream ID of the left sibling. If there is no left sibling, the field MUST be set to NOSTREAM (0xFFFFFFFF).

Value Meaning

REGSID
0x00000000 — 0xFFFFFFF9

Regular stream ID to identify directory entry.

MAXREGSID
0xFFFFFFFA

Maximum regular stream ID.

NOSTREAM
0xFFFFFFFF

If there is no left sibling.

Right Sibling ID (4 bytes): This field contains the Stream ID of the right sibling. If there is no right sibling, the field MUST be set to NOSTREAM (0xFFFFFFFF).

Value Meaning

REGSID
0x00000000 — 0xFFFFFFF9

Regular stream ID to identify directory entry.

MAXREGSID
0xFFFFFFFA

Maximum regular stream ID.

NOSTREAM
0xFFFFFFFF

If there is no right sibling.

Child ID (4 bytes): This field contains the Stream ID of a child object. If there is no child object, then the field MUST be set to NOSTREAM (0xFFFFFFFF).

Value Meaning

REGSID
0x00000000 — 0xFFFFFFF9

Regular stream ID to identify the directory entry.

MAXREGSID
0xFFFFFFFA

Maximum regular stream ID.

NOSTREAM
0xFFFFFFFF

If there is no child object.

CLSID (16 bytes): This field contains an object classGUID, if this entry is a storage or root storage. If there is no object class GUID set on this object, then the field MUST be set to all zeroes. In a stream object, this field MUST be set to all zeroes. If not NULL, the object class GUID can be used as a parameter to launch applications.

Value Meaning

0x00000000000000000000000000000000

If there is no object class GUID set on this object.

State Bits (4 bytes): This field contains the user-defined flags if this entry is a storage object or root storage object. If there are no state bits set on the object, then this field MUST be set to all zeroes.

Value Meaning

0x00000000

If there are no state bits set on the object.

Creation Time (8 bytes): This field contains the creation time for a storage object. The Windows FILETIME structure is used to represent this field in UTC. If there is no creation time set on the object, this field MUST be all zeroes. For a root storage object, this field MUST be all zeroes, and the creation time is retrieved or set on the compound file itself.

Value Meaning

0x0000000000000000

If there is no creation time set on the object or for a root storage object.

Modified Time (8 bytes): This field contains the modification time for a storage object. The Windows FILETIME structure is used to represent this field in UTC. If there is no modified time set on the object, this field MUST be all zeroes. For a root storage object, this field MUST be all zeroes, and the modified time is retrieved or set on the compound file itself.

Value Meaning

0x0000000000000000

If there is no modified time set on the object or the object is a root storage object.

Starting Sector Location (4 bytes): This field contains the first sector location if this is a stream object. For a root storage object, this field MUST contain the first sector of the mini stream, if the mini stream exists.

Stream Size (8 bytes): This 64-bit integer field contains the size of the user-defined data, if this is a stream object. For a root storage object, this field contains the size of the mini stream.

  • For a version 3 compound file 512-byte sector size, this value of this field MUST be less than or equal to 0x80000000 (equivalently, this requirement could be stated: the size of a stream or of the mini stream in a version 3 compound file MUST be less than or equal to 2GB). Note that as a consequence of this requirement, the most significant 32 bits of this field MUST be zero in a version 3 compound file. However, implementers should be aware that some older implementations did not initialize the most significant 32 bits of this field, and these bits might therefore be nonzero in files that are otherwise valid version 3 compound files. Although this document does not normatively specify parser behavior, it is recommended that parsers ignore the most significant 32 bits of this field in version 3 compound files, treating it as if its value were zero, unless there is a specific reason to do otherwise (for example, a parser whose purpose is to verify the correctness of a compound file).

 
Show:
© 2014 Microsoft