Jump to content
Setting up an AI agent? ReverseEngineering.wiki skill (works from the command line, no configuration): https://reverseengineering.wiki/skill/rewiki/SKILL.md · setup for every client, including MCP: https://reverseengineering.wiki/llms.txt · REWiki:Connect

Format:Windows Registry hive (REGF)

From ReverseEngineering.wiki
Format
On this wiki Facts · Code · Notes · Topics

The Windows NT registry hive file: a 4096-byte 'regf' base block followed by 'hbin' hive bins of cells (nk, vk, sk, lf/lh/li/ri, db); the on-disk form of SYSTEM, SOFTWARE, NTUSER.DAT and similar.

A registry hive is one file (SYSTEM, SOFTWARE, SAM, SECURITY, NTUSER.DAT, UsrClass.dat, Amcache.hve and others) holding a tree of keys with typed values. Layout from libregf (libyal, LGPL), documentation/Windows NT Registry File (REGF) format.asciidoc. Little endian; timestamps are FILETIME (UTC).

Identification

  • Magic regf (72 65 67 66) at offset 0; each hive bin starts with hbin.
  • Transaction logs (.LOG1, .LOG2) share the header with a different file type value.

Base block

The header is 512 bytes inside a 4096-byte block (transaction logs may use 1024).

Offset Size Field
0 4 signature regf
4 4 primary sequence number
8 4 secondary sequence number (differs from primary: the hive was not synchronized, apply the .LOG files)
12 8 last modification FILETIME
20 4 major version (1)
24 4 minor version: 3 = NT 4.0+ (typical NTUSER.DAT), 5 = XP SP2+ (typical SOFTWARE, SYSTEM), 6 = seen only in Windows Docker delta hives
28 4 file type: 0 hive, 1 and 6 transaction log variants, 2 older log
36 4 root key offset, relative to the start of the hive bin area (file offset 0x1000)
40 4 hive bins data size
508 4 checksum, XOR-32 of the previous 508 bytes

File offset of a cell = 0x1000 + cell offset.

Hive bins and cells

  • Hive bin header (32 bytes): hbin, offset of the bin, size of the bin (multiple of 4096).
  • Cell: 4-byte signed size including itself. Negative = allocated, positive = free (deleted keys and values often survive in free cells and slack, which is why forensic tools carve them). Cells are 8-byte aligned.
  • Cell data starts with a 2-byte signature: nk named key, vk value key, sk security descriptor, lf lh li ri sub key lists, db big data block.

Key node (nk)

Signature, flags (0x0004 root, 0x0020 name is ASCII, 0x0010 symbolic link, 0x0001 volatile, 0x0002 mount point, 0x0008 no delete), last written FILETIME at +4, parent offset at +16, sub key count at +20, sub key list offset at +28, value count at +36, value list offset at +40, security key offset at +44, class name offset at +48, key name size at +72, name at +76. Offset -1 (0xFFFFFFFF) means none.

Value key (vk)

Signature, name size (0 = the default value), data size at +4, data offset at +8, type at +12, flags at +16 (0x0001 name is ASCII), name at +20. If the top bit 0x80000000 of the data size is set, the data (up to 4 bytes) is stored inline in the data offset field. Types: 0 REG_NONE, 1 REG_SZ, 2 REG_EXPAND_SZ, 3 REG_BINARY, 4 REG_DWORD, 5 REG_DWORD_BIG_ENDIAN, 6 REG_LINK, 7 REG_MULTI_SZ, 8-10 resource lists, 11 REG_QWORD.

Lists and big data

  • lf and lh: count, then 8-byte elements (key offset, hash); li: 4-byte key offsets; ri: 4-byte offsets of further sub key lists.
  • db: 12 bytes (signature, segment count, offset of a list of segment offsets) used for value data larger than one cell; the segments are concatenated.
  • sk: previous and next security key offsets, reference count, descriptor size, then an NT security descriptor shared by many keys.

Transaction logs and format versions

Format versions (major.minor, libregf documentation @ eb1364c992): 1.0 unknown, 1.1 NT 3.1 and 3.5 (different layout), 1.2 NT 3.51, 1.3 NT 4.0 and later (typical NTUSER.DAT; REG_STANDARD_FORMAT of RegSaveKeyEx), 1.4 mentioned but never observed, 1.5 XP SP2 and later (typical SOFTWARE, SYSTEM; REG_LATEST_FORMAT), 1.6 only Windows Docker delta hives. Sub key lists, value keys and value data have a different layout in 1.1 (an extra 4 unknown bytes before the signature in the list).

Transaction logs (.LOG, .LOG1, .LOG2) use the regf header with file type 1, 2 or 6 and, in variant 1 and 2, a 'DIRT' dirty vector at offset 512 (one bit per 512-byte page); see Fact:Windows Registry hive (REGF)/behavior/Transaction log files and sequence numbers. Differing sequence numbers mean the hive needs its log applied.

Value data over 16344 bytes (format 1.5) is stored through a db cell: see Fact:Windows Registry hive (REGF)/behavior/Large value data and db segments. The lh hash is in Fact:Windows Registry hive (REGF)/behavior/lh sub key hash; hive bin header details in Fact:Windows Registry hive (REGF)/struct/hbin header and base block remainder.

Code & repositories

  • https://github.com/libyal/libregf @ eb1364c9926ab12cee76139fe91a38ab29ea1896 · license: LGPL-3.0
    libyal C library and tools (regfinfo, regfexport, regfmount) with the REGF format specification in documentation/.
    Tested on: source read, not run: source read, not run · checked 2026-10-18; last activity 2026-10-10

Open questions

Checked: libyal/libregf documentation (Windows NT Registry File (REGF) format.asciidoc @ eb1364c992, "Hash algorithms" section read) describes the lh hash: hash = 0; for each character of the key name, hash = hash * 37 + uppercase(character), modulo 2^32, over UTF-16 code units for a UTF-16 name (the document says it is unknown how 4-byte UTF-16 characters are handled). For lf lists the same document only says a different hash function is used and marks the lf and lh descriptions with question marks, so the lf hash stays Unverified here (commonly described elsewhere as the first four characters of the name; not checked).

See also

Format:Windows Shell Link (LNK), Format:Windows XML Event Log (EVTX), Format:Windows Prefetch, Format:Windows Jump Lists.