diff options
| author | JMC47 <JMC4789@gmail.com> | 2020-09-06 17:14:08 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-06 17:14:08 -0400 |
| commit | e7e51756068a450b6e920c7783c81d7df4d2d133 (patch) | |
| tree | 94f0bfe833986f8d35f0d2a40842807601f53b9f /Source/Core/DiscIO/DiscExtractor.cpp | |
| parent | 344fdabf23c048b81b8e87008a7a16837d180f55 (diff) | |
| parent | fc6c1931fa09513388f35507b724bc378a0758e1 (diff) | |
Merge pull request #8861 from JosJuice/netplay-hash
Make netplay's "same game" check more robust
Diffstat (limited to 'Source/Core/DiscIO/DiscExtractor.cpp')
| -rw-r--r-- | Source/Core/DiscIO/DiscExtractor.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/Source/Core/DiscIO/DiscExtractor.cpp b/Source/Core/DiscIO/DiscExtractor.cpp index 3c2a67568d..b12b56b5c2 100644 --- a/Source/Core/DiscIO/DiscExtractor.cpp +++ b/Source/Core/DiscIO/DiscExtractor.cpp @@ -245,19 +245,26 @@ bool ExportBI2Data(const Volume& volume, const Partition& partition, return ExportData(volume, partition, 0x440, 0x2000, export_filename); } +std::optional<u64> GetApploaderSize(const Volume& volume, const Partition& partition) +{ + constexpr u64 header_size = 0x20; + const std::optional<u32> apploader_size = volume.ReadSwapped<u32>(0x2440 + 0x14, partition); + const std::optional<u32> trailer_size = volume.ReadSwapped<u32>(0x2440 + 0x18, partition); + if (!apploader_size || !trailer_size) + return std::nullopt; + + return header_size + *apploader_size + *trailer_size; +} + bool ExportApploader(const Volume& volume, const Partition& partition, const std::string& export_filename) { if (!IsDisc(volume.GetVolumeType())) return false; - std::optional<u32> apploader_size = volume.ReadSwapped<u32>(0x2440 + 0x14, partition); - const std::optional<u32> trailer_size = volume.ReadSwapped<u32>(0x2440 + 0x18, partition); - constexpr u32 header_size = 0x20; - if (!apploader_size || !trailer_size) + const std::optional<u64> apploader_size = GetApploaderSize(volume, partition); + if (!apploader_size) return false; - *apploader_size += *trailer_size + header_size; - DEBUG_LOG(DISCIO, "Apploader size -> %x", *apploader_size); return ExportData(volume, partition, 0x2440, *apploader_size, export_filename); } |
