From 5f8935932d38cb17f104e0363a4bb1e988e83548 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Wed, 7 Jun 2017 14:30:55 +0200 Subject: [PATCH] Blob: Add interface for reading decrypted Wii data directly This is useful for blob types that store Wii data unencrypted (such as WIA and discs extracted to directories) so that we don't have to waste CPU time encrypting in the blob code just to decrypt right afterwards in the volume code. --- Source/Core/DiscIO/Blob.h | 6 ++++++ Source/Core/DiscIO/VolumeWii.cpp | 3 +++ 2 files changed, 9 insertions(+) diff --git a/Source/Core/DiscIO/Blob.h b/Source/Core/DiscIO/Blob.h index 686605ed80..20107bef0f 100644 --- a/Source/Core/DiscIO/Blob.h +++ b/Source/Core/DiscIO/Blob.h @@ -56,6 +56,12 @@ public: return Common::FromBigEndian(temp); } + virtual bool SupportsReadWiiDecrypted() const { return false; } + virtual bool ReadWiiDecrypted(u64 offset, u64 size, u8* out_ptr, u64 partition_offset) + { + return false; + } + protected: BlobReader() {} }; diff --git a/Source/Core/DiscIO/VolumeWii.cpp b/Source/Core/DiscIO/VolumeWii.cpp index 7f7670d6d7..4e8bba6b91 100644 --- a/Source/Core/DiscIO/VolumeWii.cpp +++ b/Source/Core/DiscIO/VolumeWii.cpp @@ -128,6 +128,9 @@ bool VolumeWii::Read(u64 _ReadOffset, u64 _Length, u8* _pBuffer, const Partition if (partition == PARTITION_NONE) return m_pReader->Read(_ReadOffset, _Length, _pBuffer); + if (m_pReader->SupportsReadWiiDecrypted()) + return m_pReader->ReadWiiDecrypted(_ReadOffset, _Length, _pBuffer, partition.offset); + // Get the decryption key for the partition auto it = m_partitions.find(partition); if (it == m_partitions.end())