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/VolumeDisc.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/VolumeDisc.cpp')
| -rw-r--r-- | Source/Core/DiscIO/VolumeDisc.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Source/Core/DiscIO/VolumeDisc.cpp b/Source/Core/DiscIO/VolumeDisc.cpp index fed82a8067..3ccea4b62f 100644 --- a/Source/Core/DiscIO/VolumeDisc.cpp +++ b/Source/Core/DiscIO/VolumeDisc.cpp @@ -4,11 +4,17 @@ #include "DiscIO/VolumeDisc.h" +#include <memory> #include <optional> #include <string> +#include <vector> + +#include <mbedtls/sha1.h> #include "Common/CommonTypes.h" +#include "DiscIO/DiscExtractor.h" #include "DiscIO/Enums.h" +#include "DiscIO/Filesystem.h" namespace DiscIO { @@ -90,4 +96,35 @@ bool VolumeDisc::IsNKit() const return ReadSwapped<u32>(0x200, PARTITION_NONE) == NKIT_MAGIC; } +void VolumeDisc::AddGamePartitionToSyncHash(mbedtls_sha1_context* context) const +{ + const Partition partition = GetGamePartition(); + + // All headers at the beginning of the partition, plus the apploader + ReadAndAddToSyncHash(context, 0, 0x2440 + GetApploaderSize(*this, partition).value_or(0), + partition); + + // Boot DOL (may be missing if this is a Datel disc) + const std::optional<u64> dol_offset = GetBootDOLOffset(*this, partition); + if (dol_offset) + { + ReadAndAddToSyncHash(context, *dol_offset, + GetBootDOLSize(*this, partition, *dol_offset).value_or(0), partition); + } + + // File system + const std::optional<u64> fst_offset = GetFSTOffset(*this, partition); + if (fst_offset) + ReadAndAddToSyncHash(context, *fst_offset, GetFSTSize(*this, partition).value_or(0), partition); + + // opening.bnr (name and banner) + const FileSystem* file_system = GetFileSystem(partition); + if (file_system) + { + std::unique_ptr<FileInfo> file_info = file_system->FindFileInfo("opening.bnr"); + if (file_info && !file_info->IsDirectory()) + ReadAndAddToSyncHash(context, file_info->GetOffset(), file_info->GetSize(), partition); + } +} + } // namespace DiscIO |
