After the base block, the file is a run of hive bins. This page follows Maxim Suhanov’s Windows registry file format specification.
Hive bin
A hive bin is a multiple of 4096 bytes in size. Its header is 32 bytes:
| Offset | Length | Field | Meaning |
|---|---|---|---|
| 0 | 4 | Signature | hbin |
| 4 | 4 | Offset | Offset of this bin from the start of the hive bins data |
| 8 | 4 | Size | Size of this bin in bytes |
| 12 | 8 | Reserved | |
| 20 | 8 | Timestamp | FILETIME (UTC); defined for the first bin only, where it backs up the base block’s last written timestamp |
| 28 | 4 | Spare (or MemAlloc) | No meaning on a disk. Used when bins and cells are shifted in memory; called MemAlloc in Windows 2000, where it tracks memory allocations |
Cell
Cells fill the rest of a bin without gaps. A cell starts with a signed 32-bit size that includes the size field itself and is aligned to 8 bytes. The size is negative when the cell is allocated and positive when it is unallocated (free); use the absolute value for calculations. The cell data follows, and padding may follow the data.
The data of an allocated cell is one of these records, identified by its two-character signature, or raw data:
| Record | Signature | Holds | Page |
|---|---|---|---|
| Index leaf | li | A list of subkeys | Keys |
| Fast leaf | lf | A list of subkeys with name hints | Keys |
| Hash leaf | lh | A list of subkeys with name hashes | Keys |
| Index root | ri | A list of subkey lists, to subdivide a long list | Keys |
| Key node | nk | A registry key | Keys |
| Key value | vk | A registry value | Values |
| Key security | sk | A security descriptor | Security |
| Big data | db | A list of data segments for a value over 16,344 bytes | Values |
| (no signature) | A key values list, a list of big data segments, value data, a class name |
A record that holds an offset points at the cell that holds the target record. The offset counts from the
start of the hive bins data, and 0xFFFFFFFF points nowhere.
Unallocated cells
When a cell is freed next to another free cell, the two are coalesced, so one free cell can hold the remains of several records. The data of a freed cell is not erased: the signatures and fields of the records that lived there usually survive and can be recognised and read, which is how deleted keys and values can be recovered. A reader must treat such records as remnants, because the space can be reused at any time.
In Windows 2000 the first four bytes of the data of a free cell hold Next: the offset of the next free
cell in a free list (many lists exist for one hive in memory), or 0xFFFFFFFF. As of Windows XP
this record is not used.
Old versions of the format
The layout above applies to hives whose version in the base block is 1.3, 1.4, 1.5 or 1.6. Hives of Windows NT 3.1, 3.5 and 3.51 have version 1.1 or 1.2:
- With minor version 2, fast leaf (
lf) records are not supported. - With minor version 1, fast leaves are not supported either; the key name of a key node and the name of a value are always UTF-16LE; a key value has no flags and spare fields but a 4-byte title index at offset 16; a key node has no access bits field but a title index at offset 12; and every cell has a different header, with the size aligned to 16 bytes and a Last field:
| Offset | Length | Field | Meaning |
|---|---|---|---|
| 0 | 4 | Size | Signed, as above, aligned to 16 bytes |
| 4 | 4 | Last | Offset of the previous cell from the start of this hive bin, or 0xFFFFFFFF for the first cell of a bin |
| 8 | … | Cell data |
The title index would give a localised alias for a name; it was never supported and became deprecated in Windows NT 3.5. In Windows NT 3.1 a free cell’s data starts with two offsets, Next and Previous, in a free list. Hives with minor version 0 come from pre-release Windows NT 3.1 and are outside the specification.