Reimplement support for unencrypted Wii discs #5548
Merged
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.
You may want to read the PR #2047 comments before reading this.
Dolphin attempts to support an unencrypted type of Wii discs that apparently is identified by a 4-byte integer at 0x60 being non-zero. I don't know what discs (if any) would be using that format, so I haven't been able to test Dolphin's support for it, but it has probably been broken for a while.
The old implementation is very short but also strange. In CreateVolumeFromFilename, we read a 4-byte integer from 0x60, and if it's non-zero, we create a CVolumeGC object instead of a CVolumeWiiCrypted object. This might seem like it makes no sense, but it presumably worked in the past because IsVolumeWiiDisc used to check the volume type by reading the magic word for Wii straight from the disc,
meaning that CVolumeGC objects representing unencrypted Wii discs would be treated as Wii discs by pretty much all of Dolphin's code except for the volume implementation code. (It wasn't possible to simply use CVolumeWiiCrypted, because that class only handled encrypted discs, like the name says.)
However, that stopped working as intended because of ace0607. And furthermore, bb93336 made it even more broken by making parts of Dolphin expect that data read from Wii discs needed to be decrypted (rather than the volume implementation implicitly deciding whether to decrypt when Read was called). Disclaimer: Like I said before, I haven't been able to test any of this because I don't have any discs that use this unencrypted Wii disc format, so this is all theoretical.
Later, PR #2047 tried to remove Dolphin's support for the unencrypted Wii disc format because seemingly no discs used it, but the PR got closed without being merged. At the end of that PR, I said that I would make a new PR with a better implementation for the format after PR #2353 was merged. Now that PR #2353 is merged (two years later...) and PR #5521 is merged, the new implementation was easy to make, and here it is!
Untested.