From cec601f1fbe54026e27339b2e9b1540166835511 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 12 Sep 2018 12:54:36 +0200 Subject: [PATCH] Read Wii disc metadata from the unencrypted header The header of a Wii disc can be read from two places: The unencrypted area at the beginning of the disc, or the beginning of the game partition. The two copies are usually identical (except for 0x60 and 0x61), but there are exceptions. For most of Dolphin's history, we have been reading from the header inside the game partition when getting metadata. This was however not the case starting with 4.0-4901 and ending with 5.0-3762. This commit once again makes Dolphin read metadata from the unencrypted header, because of the following reasons that I recently was informed about: - The "pink fish" disc has the game ID 410E01 in the unencrypted header but the placeholder game ID RELSAB in the partition header. - The revisions of some games differ between the two headers, with the unencrypted one making more sense. (See https://bugs.dolphin-emu.org/issues/11387) For better or worse, this also means that sloppily hacked games where only the game ID in the unencrypted header has been changed now will use that modified game ID. And unlike with the partition header, there is no signing or hashing that can tell us whether the unencrypted header has been modified by someone other than Nintendo. --- Source/Core/DiscIO/Volume.h | 27 +++++++++++++------------- Source/Core/UICommon/GameFileCache.cpp | 2 +- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Source/Core/DiscIO/Volume.h b/Source/Core/DiscIO/Volume.h index 4db300c82b..60bfd137a0 100644 --- a/Source/Core/DiscIO/Volume.h +++ b/Source/Core/DiscIO/Volume.h @@ -62,8 +62,10 @@ public: virtual std::vector GetPartitions() const { return {}; } virtual Partition GetGamePartition() const { return PARTITION_NONE; } virtual std::optional GetPartitionType(const Partition& partition) const { return {}; } - std::optional GetTitleID() const { return GetTitleID(GetGamePartition()); } - virtual std::optional GetTitleID(const Partition& partition) const { return {}; } + virtual std::optional GetTitleID(const Partition& partition = PARTITION_NONE) const + { + return {}; + } virtual const IOS::ES::TicketReader& GetTicket(const Partition& partition) const { return INVALID_TICKET; @@ -75,14 +77,10 @@ public: { return offset; } - std::string GetGameID() const { return GetGameID(GetGamePartition()); } - virtual std::string GetGameID(const Partition& partition) const = 0; - std::string GetMakerID() const { return GetMakerID(GetGamePartition()); } - virtual std::string GetMakerID(const Partition& partition) const = 0; - std::optional GetRevision() const { return GetRevision(GetGamePartition()); } - virtual std::optional GetRevision(const Partition& partition) const = 0; - std::string GetInternalName() const { return GetInternalName(GetGamePartition()); } - virtual std::string GetInternalName(const Partition& partition) const = 0; + virtual std::string GetGameID(const Partition& partition = PARTITION_NONE) const = 0; + virtual std::string GetMakerID(const Partition& partition = PARTITION_NONE) const = 0; + virtual std::optional GetRevision(const Partition& partition = PARTITION_NONE) const = 0; + virtual std::string GetInternalName(const Partition& partition = PARTITION_NONE) const = 0; virtual std::map GetShortNames() const { return {}; } virtual std::map GetLongNames() const { return {}; } virtual std::map GetShortMakers() const { return {}; } @@ -92,15 +90,16 @@ public: std::string GetApploaderDate() const { return GetApploaderDate(GetGamePartition()); } virtual std::string GetApploaderDate(const Partition& partition) const = 0; // 0 is the first disc, 1 is the second disc - std::optional GetDiscNumber() const { return GetDiscNumber(GetGamePartition()); } - virtual std::optional GetDiscNumber(const Partition& partition) const { return 0; } + virtual std::optional GetDiscNumber(const Partition& partition = PARTITION_NONE) const + { + return 0; + } virtual Platform GetVolumeType() const = 0; virtual bool SupportsIntegrityCheck() const { return false; } virtual bool CheckIntegrity(const Partition& partition) const { return false; } // May be inaccurate for WADs virtual Region GetRegion() const = 0; - Country GetCountry() const { return GetCountry(GetGamePartition()); } - virtual Country GetCountry(const Partition& partition) const = 0; + virtual Country GetCountry(const Partition& partition = PARTITION_NONE) const = 0; virtual BlobType GetBlobType() const = 0; // Size of virtual disc (may be inaccurate depending on the blob type) virtual u64 GetSize() const = 0; diff --git a/Source/Core/UICommon/GameFileCache.cpp b/Source/Core/UICommon/GameFileCache.cpp index 82ade8e964..c1790f5b59 100644 --- a/Source/Core/UICommon/GameFileCache.cpp +++ b/Source/Core/UICommon/GameFileCache.cpp @@ -27,7 +27,7 @@ namespace UICommon { -static constexpr u32 CACHE_REVISION = 12; // Last changed in PR 7285 +static constexpr u32 CACHE_REVISION = 13; // Last changed in PR 7411 std::vector FindAllGamePaths(const std::vector& directories_to_scan, bool recursive_scan)