DiscIO: Use partition data offset for ReadWiiDecrypted parameter

Instead of the partition offset (which is usually 0x20000 less).
This commit is contained in:
JosJuice 2019-12-27 22:04:51 +01:00
parent 7e94d6ed37
commit a4c7100bcc
4 changed files with 13 additions and 8 deletions

View File

@ -58,7 +58,7 @@ public:
}
virtual bool SupportsReadWiiDecrypted() const { return false; }
virtual bool ReadWiiDecrypted(u64 offset, u64 size, u8* out_ptr, u64 partition_offset)
virtual bool ReadWiiDecrypted(u64 offset, u64 size, u8* out_ptr, u64 partition_data_offset)
{
return false;
}

View File

@ -387,12 +387,13 @@ bool DirectoryBlobReader::SupportsReadWiiDecrypted() const
return m_is_wii;
}
bool DirectoryBlobReader::ReadWiiDecrypted(u64 offset, u64 size, u8* buffer, u64 partition_offset)
bool DirectoryBlobReader::ReadWiiDecrypted(u64 offset, u64 size, u8* buffer,
u64 partition_data_offset)
{
if (!m_is_wii)
return false;
auto it = m_partitions.find(partition_offset);
auto it = m_partitions.find(partition_data_offset);
if (it == m_partitions.end())
return false;
@ -514,7 +515,8 @@ void DirectoryBlobReader::SetPartitions(std::vector<PartitionWithType>&& partiti
SetPartitionHeader(partitions[i].partition, partition_address);
const u64 partition_data_size = partitions[i].partition.GetDataSize();
m_partitions.emplace(partition_address, std::move(partitions[i].partition));
m_partitions.emplace(partition_address + PARTITION_DATA_OFFSET,
std::move(partitions[i].partition));
const u64 unaligned_next_partition_address = VolumeWii::EncryptedPartitionOffsetToRawOffset(
partition_data_size, Partition(partition_address), PARTITION_DATA_OFFSET);
partition_address = Common::AlignUp(unaligned_next_partition_address, 0x10000ull);

View File

@ -141,7 +141,7 @@ public:
bool Read(u64 offset, u64 length, u8* buffer) override;
bool SupportsReadWiiDecrypted() const override;
bool ReadWiiDecrypted(u64 offset, u64 size, u8* buffer, u64 partition_offset) override;
bool ReadWiiDecrypted(u64 offset, u64 size, u8* buffer, u64 partition_data_offset) override;
BlobType GetBlobType() const override;
u64 GetRawSize() const override;

View File

@ -162,14 +162,17 @@ bool VolumeWii::Read(u64 offset, u64 length, u8* buffer, const Partition& partit
if (partition == PARTITION_NONE)
return m_reader->Read(offset, length, buffer);
if (m_reader->SupportsReadWiiDecrypted())
return m_reader->ReadWiiDecrypted(offset, length, buffer, partition.offset);
auto it = m_partitions.find(partition);
if (it == m_partitions.end())
return false;
const PartitionDetails& partition_details = it->second;
if (m_reader->SupportsReadWiiDecrypted())
{
return m_reader->ReadWiiDecrypted(offset, length, buffer,
partition.offset + *partition_details.data_offset);
}
if (!m_encrypted)
{
return m_reader->Read(partition.offset + *partition_details.data_offset + offset, length,