From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:STFS (Xbox 360 package)" |
|---|
| claim | "Xenia maps an STFS data block number to a file offset by adding hash blocks (170, 28900 and 4913000 blocks per level, one or two backing blocks per hash table) in front of it, starting at the header size rounded up to 0x1000." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:STFS (Xbox 360 package)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | function | "StfsContainerDevice::BlockToOffsetSTFS, BlockToHashBlockNumberSTFS" |
|---|
| effect | "offset = round_up(header_size, 0x1000) + (block << 12), where block = data block index plus, for each of up to 3 levels with base 170, 170*170, 170^3 (kBlocksPerHashLevel {170, 28900, 4913000}): ((index + base) / base) * blocks_per_hash_table, stopping after the first level where index < base. blocks_per_hash_table is 1 when the volume descriptor flag read_only_format is set, else 2. Hash table positions (in blocks from the data start): level 0 table of the group containing index: 0 if index < 170, else (index/170)*block_step0 + ((index/28900)+1)*bpht, plus one more bpht when index >= 28900; level 1 table: block_step0 if index < 28900, else (index/28900)*block_step1 + bpht; level 2 table: block_step1, where block_step0 = 170 + bpht and block_step1 = 28900 + 171*bpht." |
|---|
| condition | "volume_type 0 (STFS). The header size used is XContentHeader.header_size (offset 0x340) from the file; block_step values are only computed when volume_type is STFS. Not read: behavior when header_size is 0 in BlockToOffset (data_size() special-cases it, the offset functions do not)." |
|---|
| notes | "Verified only by reading; the formulas were not run on a package." |
|---|
|
|---|
| evidence | | type | "source" |
|---|
| detail | "BlockToOffsetSTFS loop, BlockToHashBlockNumberSTFS levels 0/1/2, BlockToHashBlockOffsetSTFS, block_step setup in ReadHeaderAndVerify" |
|---|
| repo | "https://github.com/xenia-project/xenia" |
|---|
| commit | "95a5c3ee250f80c3b9d139658649d9ffb6db3eec" |
|---|
| path | "src/xenia/vfs/devices/stfs_container_device.cc" |
|---|
| lines | "183-193, 641-697" |
|---|
|
| type | "source" |
|---|
| detail | "kBlocksPerHashLevel, kEndOfChain, kBlockSize 0x1000" |
|---|
| repo | "https://github.com/xenia-project/xenia" |
|---|
| commit | "95a5c3ee250f80c3b9d139658649d9ffb6db3eec" |
|---|
| path | "src/xenia/vfs/devices/stfs_container_device.h" |
|---|
| lines | "33, 85-88" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "Block to file offset" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-19T13:26:30.202Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T16:36:08.775Z" |
|---|
| result | "confirmed" |
|---|
| method | "Downloaded stfs_container_device.cc at xenia 95a5c3ee and read lines 38-195 (ReadHeaderAndVerify block_step setup) and 641-697 (BlockToOffsetSTFS loop breaking after first level with index < base, BlockToHashBlockNumberSTFS levels 0/1/2, offset = round_up(header_size,0x1000)+(block<<12)); every formula in the fact matches. Source read only, not run." |
|---|
|
|
|---|