Format:PE (Portable Executable)/Rich header
The undocumented block that Microsoft link.exe writes between the DOS stub and the PE header: "DanS", a list of (product id, build, count) entries for every compiler, assembler, linker and import-library build that contributed objects, then "Rich" and a 32-bit key that XOR-encodes the block and checksums the DOS header, stub and entries.
Layout
Microsoft link.exe (richprint lists ids back to the VS97 5.10 linker; not lld-link, GNU ld, Go or .NET compilers) writes an undocumented block between the DOS stub and the PE signature. Every dword except the "Rich" marker and the key itself is XORed with a 32-bit key:
| Offset (from start of block) | Size | Content (after XOR with key) |
|---|---|---|
| 0 | 4 | "DanS" (0x536E6144)
|
| 4 | 12 | three zero dwords (stored as the key itself) |
| 16 | 8 x n | n entries {uint32 comp_id; uint32 count}; comp_id = product id << 16 | build number
|
| 16 + 8n | 4 | "Rich" (0x68636952), not XORed
|
| 20 + 8n | 4 | the key, not XORed |
then zero padding up to e_lfanew. With Microsoft's standard 64-byte DOS stub the block starts at file offset 0x80 (all 3964 Rich headers seen on a Windows 11 installation and its programs started there). To find it in any file, search backwards from e_lfanew for "Rich", read the key after it, and search backwards for "DanS" XOR key (bytes 44 61 6E 53 XOR the key bytes).
Each entry counts the object files (or import-library members) in the link that were produced by one tool build: the Windows 11 x64 kernel32.dll lists prodid 0x0104 build 33145 (C compiler, 11 objects), 0x0108 (C compiled with /GL, 208), 0x0103 (MASM, 5), 0x0101 (import library, 4), 0x0100 (export record, 1), 0x00FF (resource converter, 1) and 0x0102 (the linker itself, count 1, as in every one of 1855 files checked). prodid 0x0001 build 0 is listed by richprint as "Unmarked objects"; its count is large in import-heavy DLLs (1351 in a Windows 11 x64 kernel32.dll that imports 1274 functions plus 18 delay-loaded ones; Unverified: it counts import-library members without a comp.id); old entries such as 0x0093 build 30729 (VS2008 SP1 Implib900) come from import libraries in the Windows SDK, not from the compiler used for the program.
Key (checksum)
The key is a checksum of the DOS header and stub and of the entries:
key = start # file offset of "DanS", normally 0x80
for i in 0 .. start-1:
if 0x3C <= i <= 0x3F: continue # e_lfanew is not covered
key += rol32(byte[i], i % 32)
for (comp_id, count) in entries:
key += rol32(comp_id, count % 32)
key &= 0xFFFFFFFF
The key recomputed this way matched the stored one in 3964 of 3964 Rich headers of a first scan (Windows 11 System32 DLLs and executables and third-party MSVC programs, linker 8.0 to 14.51) and in 2433 of 2433 x86 DLLs of SysWOW64. A mismatch means the DOS header, stub or entries were edited after linking (a tool stripped or forged entries, or the stub was replaced); the key does not cover the PE headers, so changes there go unnoticed. pefile parses the block but does not recompute the key.
Product ids
Product ids changed with every Visual Studio release up to VS2013; since VS2015 (toolset 14.x) they are fixed and only the build number tells releases apart:
| prodid | Tool (VS2015 and later) |
|---|---|
| 0x00FD | AliasObj1400 |
| 0x00FE | Cvtpgd1900 |
| 0x00FF | Cvtres1400 (resource object) |
| 0x0100 | Export1400 (export record) |
| 0x0101 | Implib1400 (import library) |
| 0x0102 | Linker1400 |
| 0x0103 | Masm1400 |
| 0x0104 / 0x0105 | Utc1900_C / Utc1900_CPP (C / C++ compiler) |
| 0x0106 / 0x0107 | Utc1900_CVTCIL_C / _CPP |
| 0x0108 / 0x0109 / 0x010A | Utc1900_LTCG_C / _CPP / _MSIL (/GL objects) |
| 0x010B / 0x010C | Utc1900_POGO_I_C / _CPP (PGO instrumented) |
| 0x010D / 0x010E | Utc1900_POGO_O_C / _CPP (PGO optimized) |
Older ranges: VS2003 0x005A-0x006C (Linker710 0x005A), VS2005 0x006D-0x0082 (Linker800 0x0078), VS2008 0x0083-0x0096 (Linker900 0x0091, Implib900 0x0093), VS2010 0x0098-0x00B4 (Linker1000 0x009D), VS2012 0x00C7-0x00D8 (Linker1100 0x00CC), VS2013 0x00D9-0x00EA (Linker1200 0x00DE). Build numbers of the 14.x linker (prodid 0x0102), from richprint's comp_id.txt: 23026 VS2015 RTM, 24215 VS2015 Update 3.1, 25017 VS2017 15.0, 27508 VS2019 16.0, 30133 VS2019 16.11.1, 33130 VS2022 17.8.0, 35207 VS2022 17.14 preview 7, 35717-35730 VS2026 18.0-18.5, 36243-36260 VS2026 18.6-18.10. Windows' own binaries use internal toolset builds (33145 on Windows 11 in 2026) that no public Visual Studio shipped.
Uses
- Toolchain identification: the linker entry gives the exact Visual Studio update that linked the file; compiler entries show C vs C++, LTCG (
/GL) and PGO. - Clustering: the MD5 of the decoded block from
DanSto the last entry (pefileget_rich_header_hash) groups files built from the same project and toolchain, independent of code changes that keep the object list. - Tampering: a key mismatch, a Rich header in a file whose linker version is not Microsoft's, or Rich entries whose linker build disagrees with MajorLinkerVersion/MinorLinkerVersion indicate edited headers.
Code & repositories
- https://github.com/dishather/richprint @
b0a4f598cc076a8c2ff4b1b90850004bc17da31c· license: BSD-2-Clause
richprint: prints the Rich header of PE and COFF files; its comp_id.txt maps comp.id values (product id + build) to tool names and Visual Studio releases from VS97 to VS2026 18.12 Insiders (about 4800 lines). The reference to turn a Rich entry into a Visual Studio update.
Tested on: comp_id.txt read at this commit; its product-id names and linker build numbers agree with the Rich headers and linker versions of Windows 11 system files and installed MSVC programs (e.g. 14.38 with builds 33130-33145, 14.51 with 36248). The C++ tool itself was not built (no compiler on the test machine). · checked 2026-10-17; last activity 2026-10-14
Evidence & references
- pefile
parse_rich_header(pefile.py lines 3349-3462 at commit 58186a9): location, XOR decoding and the three key copies after DanS;get_rich_header_hashlines 5755-5768. - richprint (dishather/richprint, BSD-2-Clause) comp_id.txt at commit b0a4f59: product id names (lines 4852-5121) and build-number-to-release mapping.
- Key algorithm: recomputed by Code:PE (Portable Executable)/peinfo (Python) on 3964 + 2433 files, all matching; test vector on the fact page.