From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "struct" |
|---|
| subject | "Format:Mach-O" |
|---|
| claim | "The CodeDirectory is a big-endian struct of 0x2C fixed bytes followed by version-gated fields: scatterOffset (0x20100), teamOffset (0x20200), spare3 and codeLimit64 (0x20300), execSegBase/Limit/Flags (0x20400), runtime and preEncryptOffset (0x20500), linkage fields (0x20600)." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Mach-O code signatures, CodeDirectory versions up to 0x20600" |
|---|
| observed_in | |
|---|
|
|---|
| data | | name | "CS_CodeDirectory" |
|---|
| size_min | "0x2C" |
|---|
| endianness | "big" |
|---|
| fields | | offset | "0x0" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "magic" |
|---|
| notes | "0xFADE0C02" |
|---|
|
| offset | "0x4" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "length" |
|---|
|
| offset | "0x8" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "version" |
|---|
|
| offset | "0xC" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "flags" |
|---|
|
| offset | "0x10" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "hashOffset" |
|---|
| notes | "offset of hash slot element zero" |
|---|
|
| offset | "0x14" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "identOffset" |
|---|
|
| offset | "0x18" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "nSpecialSlots" |
|---|
|
| offset | "0x1C" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "nCodeSlots" |
|---|
|
| offset | "0x20" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "codeLimit" |
|---|
|
| offset | "0x24" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "hashSize" |
|---|
|
| offset | "0x25" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "hashType" |
|---|
|
| offset | "0x26" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "platform" |
|---|
|
| offset | "0x27" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "pageSize" |
|---|
| notes | "log2, 0 = infinite" |
|---|
|
| offset | "0x28" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "spare2" |
|---|
|
| offset | "0x2C" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "scatterOffset" |
|---|
| condition | "version >= 0x20100" |
|---|
|
| offset | "0x30" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "teamOffset" |
|---|
| condition | "version >= 0x20200" |
|---|
|
| offset | "0x34" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "spare3" |
|---|
| condition | "version >= 0x20300" |
|---|
|
| offset | "0x38" |
|---|
| size | 8 |
|---|
| type | "uint64_t" |
|---|
| name | "codeLimit64" |
|---|
| condition | "version >= 0x20300" |
|---|
|
| offset | "0x40" |
|---|
| size | 8 |
|---|
| type | "uint64_t" |
|---|
| name | "execSegBase" |
|---|
| condition | "version >= 0x20400" |
|---|
|
| offset | "0x48" |
|---|
| size | 8 |
|---|
| type | "uint64_t" |
|---|
| name | "execSegLimit" |
|---|
| condition | "version >= 0x20400" |
|---|
|
| offset | "0x50" |
|---|
| size | 8 |
|---|
| type | "uint64_t" |
|---|
| name | "execSegFlags" |
|---|
| condition | "version >= 0x20400" |
|---|
|
| offset | "0x58" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "runtime" |
|---|
| condition | "version >= 0x20500" |
|---|
|
| offset | "0x5C" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "preEncryptOffset" |
|---|
| condition | "version >= 0x20500" |
|---|
|
| offset | "0x60" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "linkageHashType" |
|---|
| condition | "version >= 0x20600" |
|---|
|
| offset | "0x61" |
|---|
| size | 1 |
|---|
| type | "uint8_t" |
|---|
| name | "linkageApplicationType" |
|---|
| condition | "version >= 0x20600" |
|---|
|
| offset | "0x62" |
|---|
| size | 2 |
|---|
| type | "uint16_t" |
|---|
| name | "linkageApplicationSubType" |
|---|
| condition | "version >= 0x20600" |
|---|
|
| offset | "0x64" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "linkageOffset" |
|---|
| condition | "version >= 0x20600" |
|---|
|
| offset | "0x68" |
|---|
| size | 4 |
|---|
| type | "uint32_t" |
|---|
| name | "linkageSize" |
|---|
| condition | "version >= 0x20600" |
|---|
|
|
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "struct __CodeDirectory with the version comments; offsets computed by adding field sizes (no padding: the struct is declared aligned(1))" |
|---|
| repo | "https://github.com/apple-oss-distributions/xnu" |
|---|
| commit | "f6217f891ac0bb64f3d375211650a4c1ff8ca1ea" |
|---|
| path | "osfmk/kern/cs_blobs.h" |
|---|
| lines | "212-263" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "CS_CodeDirectory" |
|---|
| topic | "Format:Mach-O/Code signature" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T01:09:08.514Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T06:20:04.332Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read osfmk/kern/cs_blobs.h at f6217f891ac0 lines 212-263 and summed field sizes: fixed part ends at 0x2C (spare2 at 0x28); scatterOffset 0x2C, teamOffset 0x30, spare3 0x34, codeLimit64 0x38, execSeg* 0x40/0x48/0x50, runtime 0x58, preEncryptOffset 0x5C, linkage 0x60-0x6B (total 0x6C with all versions). Version gates 0x20100-0x20600 match the CS_SUPPORTS* constants. Related SC_Scatter (24 bytes: count, base, targetOffset, spare) exists but is not in the fact." |
|---|
|
|
|---|