DirectoryBlob: Fix partition size mixup for encrypted Wii discs. #10970
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.
I found this while trying to debug https://bugs.dolphin-emu.org/issues/12965, though this does not actually fix that issue.
What's happening here is that the
ContentPartitionchunks inside DirectoryBlob are designed to look from the outside as if they are encrypted/hashed, but present their filesize without the headers such a partition would actually have. This confuses non-ReadWiiDecrypted()reads near the end of the partition, because the offset with headers gets compared against the size without headers so the read is considered out of bounds and returns a failure.I also round the size up to a full group because otherwise this read inVolumeWii::EncryptGroup()fails on the last not-full-group-sized chunk of the partition:dolphin/Source/Core/DiscIO/VolumeWii.cpp
Lines 595 to 599 in dcdba11
I'm not sure if on a real Wii disc a partition is always full group sized; this could be solved in other ways too if needed.Just rounding to block size seems to work fine actually.This shouldn't affect much in practice (I assume RawDump would produce incorrect results without this PR), but probably doesn't hurt to fix anyway. I've tested this by forcing
DirectoryBlobReader::SupportsReadWiiDecrypted()to always return false and then checking if Properties -> Filesystem -> Extract Entire Disc on a DirectoryBlob survives a roundtrip; without this PR, files near the end of the disc end up corrupt, while with this PR it works fine (minusboot.binandfst.binwhich are affected by the difference in how we build the file system compared to whatever tool was used for official discs).@JosJuice Please review.