From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:RomFS (Switch)" |
|---|
| claim | "The RomFS name hash starts at parent_offset XOR 123456789, then for each name byte rotates the 32-bit value right by 5 and XORs the byte; the bucket is the hash modulo (hash table size / 4)." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:RomFS (Switch)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | trigger | "lookup of a file or directory name in its parent" |
|---|
| effect | "hash = parent ^ 123456789; for each byte: hash = ror32(hash, 5) ^ byte; bucket = hash % (tableSize / 4); chain through nextHash until 0xFFFFFFFF" |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "calcHash(parent, name, namelen, total) and searchForDir, which uses dirHashTableSize/4 as total and follows dirHashTable[hash] then nextHash while the offset is not romFS_none." |
|---|
| repo | "switchbrew/libnx" |
|---|
| commit | "20cbcfd90567f7bf84df7725f27e345e2164fa6b" |
|---|
| path | "nx/source/runtime/devices/romfs_dev.c" |
|---|
| lines | "468-477, 480-498" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Name hash" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T01:19:17.332Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T04:50:02.452Z" |
|---|
| result | "confirmed" |
|---|
| method | "Read calcHash, searchForDir and the file variant in libnx romfs_dev.c at the cited commit: parent ^ 123456789, ror 5 then xor each unsigned byte, modulo hashTableSize/4, chain via nextHash until romFS_none. Only libnx's reader read, not the writer." |
|---|
|
|
|---|