From 74d84c5af2c82f5395ce2d67d4f901a4e1825185 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 21 Apr 2015 11:33:51 +0200 Subject: [PATCH] VolumeWiiCrypted: Turn m_dataOffset into a constant --- Source/Core/DiscIO/VolumeWiiCrypted.cpp | 10 ++++++---- Source/Core/DiscIO/VolumeWiiCrypted.h | 1 - 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Core/DiscIO/VolumeWiiCrypted.cpp b/Source/Core/DiscIO/VolumeWiiCrypted.cpp index d37df8d9c7..a78b3017d5 100644 --- a/Source/Core/DiscIO/VolumeWiiCrypted.cpp +++ b/Source/Core/DiscIO/VolumeWiiCrypted.cpp @@ -29,10 +29,12 @@ namespace DiscIO { +constexpr u64 PARTITION_DATA_OFFSET = 0x20000; + CVolumeWiiCrypted::CVolumeWiiCrypted(std::unique_ptr reader, u64 _VolumeOffset, const unsigned char* _pVolumeKey) : m_pReader(std::move(reader)), m_AES_ctx(std::make_unique()), - m_VolumeOffset(_VolumeOffset), m_dataOffset(0x20000), m_last_decrypted_block(-1) + m_VolumeOffset(_VolumeOffset), m_last_decrypted_block(-1) { _assert_(m_pReader); @@ -63,7 +65,7 @@ bool CVolumeWiiCrypted::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, bool de { // Calculate offsets u64 block_offset_on_disc = - m_VolumeOffset + m_dataOffset + _ReadOffset / BLOCK_DATA_SIZE * BLOCK_TOTAL_SIZE; + _ReadOffset / BLOCK_DATA_SIZE * BLOCK_TOTAL_SIZE + m_VolumeOffset + PARTITION_DATA_OFFSET; u64 data_offset_in_block = _ReadOffset % BLOCK_DATA_SIZE; if (m_last_decrypted_block != block_offset_on_disc) @@ -143,7 +145,7 @@ IOS::ES::TMDReader CVolumeWiiCrypted::GetTMD() const u64 CVolumeWiiCrypted::PartitionOffsetToRawOffset(u64 offset) const { - return m_VolumeOffset + m_dataOffset + (offset / BLOCK_DATA_SIZE * BLOCK_TOTAL_SIZE) + + return m_VolumeOffset + PARTITION_DATA_OFFSET + (offset / BLOCK_DATA_SIZE * BLOCK_TOTAL_SIZE) + (offset % BLOCK_DATA_SIZE); } @@ -286,7 +288,7 @@ bool CVolumeWiiCrypted::CheckIntegrity() const u32 nClusters = (u32)(partDataSize / 0x8000); for (u32 clusterID = 0; clusterID < nClusters; ++clusterID) { - u64 clusterOff = m_VolumeOffset + m_dataOffset + (u64)clusterID * 0x8000; + u64 clusterOff = m_VolumeOffset + PARTITION_DATA_OFFSET + (u64)clusterID * 0x8000; // Read and decrypt the cluster metadata u8 clusterMDCrypted[0x400]; diff --git a/Source/Core/DiscIO/VolumeWiiCrypted.h b/Source/Core/DiscIO/VolumeWiiCrypted.h index 3a62b59efd..88ffdc61de 100644 --- a/Source/Core/DiscIO/VolumeWiiCrypted.h +++ b/Source/Core/DiscIO/VolumeWiiCrypted.h @@ -66,7 +66,6 @@ private: std::unique_ptr m_AES_ctx; u64 m_VolumeOffset; - u64 m_dataOffset; mutable u64 m_last_decrypted_block; mutable u8 m_last_decrypted_block_data[BLOCK_DATA_SIZE];