The base block, also called the file header, is the first 4096 bytes of a primary file. All numbers in a hive are little-endian and all sizes and offsets are in bytes. This page follows Maxim Suhanov’s Windows registry file format specification.
Fields (Windows XP layout)
| Offset | Length | Field | Value and meaning |
|---|---|---|---|
| 0 | 4 | Signature | regf (ASCII) |
| 4 | 4 | Primary sequence number | Raised by 1 at the start of a write to the primary file |
| 8 | 4 | Secondary sequence number | Raised by 1 at the end of a write; equal to the primary number after a successful write |
| 12 | 8 | Last written timestamp | FILETIME (UTC): 100-nanosecond ticks since 1 January 1601 |
| 20 | 4 | Major version | 1: the major version of the hive writer |
| 24 | 4 | Minor version | 3, 4, 5 or 6 (1 and 2 in old NT hives, see old versions) |
| 28 | 4 | File type | 0: primary file; 1, 2 or 6 in a transaction log (Transaction logs) |
| 32 | 4 | File format | 1: direct memory load |
| 36 | 4 | Root cell offset | Offset of the root key’s cell, from the start of the hive bins data |
| 40 | 4 | Hive bins data size | Total size of the hive bins, a multiple of 4096 |
| 44 | 4 | Clustering factor | Logical sector size of the disk divided by 512 (always 1 as of Windows 8) |
| 48 | 64 | File name | UTF-16LE: a partial path or the name of the primary file, for debugging |
| 112 | 396 | Reserved | |
| 508 | 4 | Checksum | XOR-32 of the previous 508 bytes |
| 512 | 3576 | Reserved | |
| 4088 | 4 | Boot type | No meaning on a disk |
| 4092 | 4 | Boot recover | No meaning on a disk |
The file offset of anything the hive addresses is 4096 + offset. An offset of
0xFFFFFFFF points nowhere. The Boot type and Boot recover fields are used in
memory by the boot loader and the kernel; they are not normally written to disk and mean nothing there.
Fields added in later versions of Windows
In Windows 10 these fields are found in the areas that were reserved:
| Offset | Length | Field | Meaning |
|---|---|---|---|
| 112 | 16 | RmId | GUID of the Resource Manager (see ZwCreateResourceManager()) |
| 128 | 16 | LogId | GUID used for the name of the physical log file (ClfsCreateLogFile()); usually equals RmId |
| 144 | 4 | Flags | Bit mask, below |
| 148 | 16 | TmId | GUID used for the name of the Transaction Manager’s log file stream (ZwCreateTransactionManager()) |
| 164 | 4 | GUID signature | rmtm, unless the hive is frozen |
| 168 | 8 | Last reorganized timestamp | FILETIME (UTC); Windows 8 and Server 2012 onwards |
| 4040 | 16 | ThawTmId | No meaning on a disk: restores TmId when a frozen hive is thawed |
| 4056 | 16 | ThawRmId | No meaning on a disk |
| 4072 | 16 | ThawLogId | No meaning on a disk |
The GUID fields came with the Common Log File System in Windows Vista. When RmId is null, LogId and TmId may contain garbage. The Flags field records the state of the Kernel Transaction Manager (KTM) and the hive:
| Mask | Meaning |
|---|---|
0x00000001 | KTM locked the hive (transactions are pending or expected) |
0x00000002 | The hive was defragmented, so all its pages are dirty, and is being written (Windows 8 and Server 2012 only, to speed up recovery from a log); the hive supports layered keys (from Windows 10 “Redstone 1” Insider builds) |
The last reorganized timestamp records the latest reorganisation, which happens about once a week when the hive is not locked: it either defragments the hive on disk or clears the access history of its key nodes. Its two lowest bits carry meaning: bit 0 set means the last reorganisation defragmented the hive, bit 1 set means it cleared the access history; a value of exactly 1 or 2 forces that operation next time. The last written timestamp is not updated as of Windows 8.1 and Server 2012 R2, though it can be set when a hive is created.
Fields written by the Offline Registry Library
The Offline Registry Library (offreg.dll) writes extra fields when it saves a hive. Current
versions (6.2, 6.3, 10.0) use:
| Offset | Length | Field | Value |
|---|---|---|---|
| 176 | 4 | Signature | OfRg |
| 180 | 4 | Flags | 1, the only value used |
| 512 | 8 | Serialization timestamp | FILETIME (UTC) |
Legacy versions of the library (6.1) put the signature at 168 and the flags at 172, and the serialization timestamp at 512 as before.
The checksum
The checksum is an XOR of the first 508 bytes read as 127 little-endian 32-bit numbers:
- Start with a 32-bit value C of zero.
- For each of the 127 groups G of four bytes, C = C xor G.
- If C is
0xFFFFFFFF(−1), use0xFFFFFFFE(−2) instead. - If C is 0, use 1 instead.
A base block with a wrong checksum marks the hive as dirty, see dirty state.
Sequence numbers and the timestamp
A writer raises the primary sequence number before it writes to the primary file and the secondary one when it has finished, so a difference between the two means a write did not finish. The first hive bin’s header carries a copy of the last written timestamp (hive bin header), used in place of the base block’s when the base block’s checksum is wrong.