Repository navigation
Read NSO flags from 0xC so retail NSOs load - #18
Open
MeownsterHunter wants to merge 2 commits into
Open
MeownsterHunter wants to merge 2 commits into
MeownsterHunter wants to merge 2 commits into
Conversation
The NSO header is magic, version, a reserved word, then flags. The parser read flags from the reserved word at 0x8. Real NSO files have zero there, so every segment looked uncompressed and intake failed with a segment size mismatch. The test fixtures wrote flags at 0x8 as well, which is why the tests passed. They now use 0xC.
An NSO header stores the SHA-256 of each decompressed segment, and flag bits 3..5 say whether to check it. The reader now checks them, so a segment that was decompressed wrongly, or read with the wrong layout, is an error instead of silently wrong code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Retail NSO files fail intake with a segment size mismatch. The parser reads the flags word from the wrong place in the header, so it thinks every segment is uncompressed. This PR reads the flags from the right offset and checks the segment hashes, so a wrong layout fails loudly instead of producing bad code.
What was wrong
The NSO header starts with the magic
NSO0at 0x0, the version at 0x4, a reserved word at 0x8, and the flags at 0xC (NSO format on switchbrew).crates/recomp-pipeline/src/homebrew/nso.rsread the flags from 0x8. Real files have zero there, so no segment looked compressed, and intake failed when the raw segment size did not match the decompressed size.The test fixtures also wrote the flags at 0x8. The tests passed for that reason.
What this changes
crates/recomp-pipeline/tests/homebrew_intake.rs,crates/recomp-pipeline/tests/xci_intake.rs, andsamples/homebrew-intake/generate.pynow write the flags there too.Testing
cargo test --workspacepasses: 80 tests.