diff options
| author | Leo Lam <leolino.lam@gmail.com> | 2017-07-04 19:31:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-07-04 19:31:21 +0200 |
| commit | 60ee0b2913d6da077ce84d3c729aa17d50d4555d (patch) | |
| tree | 3055130b4cb0d183b8642d85d0cc649fcec7f0dd /Source/Core | |
| parent | cf79ff236691b22073545a266ac4d9bc382c6b14 (diff) | |
| parent | 333b6d99d2370fe1c9ef769771d8ae04178ff105 (diff) | |
Merge pull request #5745 from JosJuice/partition-map
VolumeWii: Change the format of partition maps
Diffstat (limited to 'Source/Core')
| -rw-r--r-- | Source/Core/DiscIO/VolumeWii.cpp | 32 | ||||
| -rw-r--r-- | Source/Core/DiscIO/VolumeWii.h | 13 |
2 files changed, 24 insertions, 21 deletions
diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index 93c7133036..cf570e39ea 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -107,10 +107,8 @@ VolumeWii::VolumeWii(std::unique_ptr<BlobReader> reader) // We've read everything. Time to store it! (The reason we don't store anything // earlier is because we want to be able to skip adding the partition if an error occurs.) const Partition partition(partition_offset); - m_partition_types[partition] = *partition_type; - m_partition_keys[partition] = std::move(aes_context); - m_partition_tickets[partition] = std::move(ticket); - m_partition_tmds[partition] = std::move(tmd); + m_partitions.emplace(partition, PartitionDetails{std::move(aes_context), std::move(ticket), + std::move(tmd), *partition_type}); if (m_game_partition == PARTITION_NONE && *partition_type == 0) m_game_partition = partition; } @@ -127,10 +125,10 @@ bool VolumeWii::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, const Partition return m_pReader->Read(_ReadOffset, _Length, _pBuffer); // Get the decryption key for the partition - auto it = m_partition_keys.find(partition); - if (it == m_partition_keys.end()) + auto it = m_partitions.find(partition); + if (it == m_partitions.end()) return false; - mbedtls_aes_context* aes_context = it->second.get(); + mbedtls_aes_context* aes_context = it->second.key.get(); std::vector<u8> read_buffer(BLOCK_TOTAL_SIZE); while (_Length > 0) @@ -177,7 +175,7 @@ bool VolumeWii::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, const Partition std::vector<Partition> VolumeWii::GetPartitions() const { std::vector<Partition> partitions; - for (const auto& pair : m_partition_keys) + for (const auto& pair : m_partitions) partitions.push_back(pair.first); return partitions; } @@ -189,8 +187,8 @@ Partition VolumeWii::GetGamePartition() const std::optional<u32> VolumeWii::GetPartitionType(const Partition& partition) const { - auto it = m_partition_types.find(partition); - return it != m_partition_types.end() ? it->second : std::optional<u32>(); + auto it = m_partitions.find(partition); + return it != m_partitions.end() ? it->second.type : std::optional<u32>(); } std::optional<u64> VolumeWii::GetTitleID(const Partition& partition) const @@ -203,14 +201,14 @@ std::optional<u64> VolumeWii::GetTitleID(const Partition& partition) const const IOS::ES::TicketReader& VolumeWii::GetTicket(const Partition& partition) const { - auto it = m_partition_tickets.find(partition); - return it != m_partition_tickets.end() ? it->second : INVALID_TICKET; + auto it = m_partitions.find(partition); + return it != m_partitions.end() ? it->second.ticket : INVALID_TICKET; } const IOS::ES::TMDReader& VolumeWii::GetTMD(const Partition& partition) const { - auto it = m_partition_tmds.find(partition); - return it != m_partition_tmds.end() ? it->second : INVALID_TMD; + auto it = m_partitions.find(partition); + return it != m_partitions.end() ? it->second.tmd : INVALID_TMD; } u64 VolumeWii::PartitionOffsetToRawOffset(u64 offset, const Partition& partition) @@ -338,10 +336,10 @@ u64 VolumeWii::GetRawSize() const bool VolumeWii::CheckIntegrity(const Partition& partition) const { // Get the decryption key for the partition - auto it = m_partition_keys.find(partition); - if (it == m_partition_keys.end()) + auto it = m_partitions.find(partition); + if (it == m_partitions.end()) return false; - mbedtls_aes_context* aes_context = it->second.get(); + mbedtls_aes_context* aes_context = it->second.key.get(); // Get partition data size u32 partSizeDiv4; diff --git a/Source/Core/DiscIO/VolumeWii.h b/Source/Core/DiscIO/VolumeWii.h index 780bdb6dd4..d8cdfe8cb8 100644 --- a/Source/Core/DiscIO/VolumeWii.h +++ b/Source/Core/DiscIO/VolumeWii.h @@ -64,11 +64,16 @@ public: static constexpr unsigned int BLOCK_TOTAL_SIZE = BLOCK_HEADER_SIZE + BLOCK_DATA_SIZE; private: + struct PartitionDetails + { + std::unique_ptr<mbedtls_aes_context> key; + IOS::ES::TicketReader ticket; + IOS::ES::TMDReader tmd; + u32 type; + }; + std::unique_ptr<BlobReader> m_pReader; - std::map<Partition, u32> m_partition_types; - std::map<Partition, std::unique_ptr<mbedtls_aes_context>> m_partition_keys; - std::map<Partition, IOS::ES::TicketReader> m_partition_tickets; - std::map<Partition, IOS::ES::TMDReader> m_partition_tmds; + std::map<Partition, PartitionDetails> m_partitions; Partition m_game_partition; mutable u64 m_last_decrypted_block; |
