From 3014dadfa8c2065f81009895ecf81396de5120bc Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 21 Mar 2019 22:20:23 +0100 Subject: DiscIO: Add way of checking whether blob data size is accurate --- Source/Core/DiscIO/VolumeWad.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index a49488506b..a7316ffde9 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -175,6 +175,11 @@ u64 VolumeWAD::GetSize() const return m_reader->GetDataSize(); } +bool VolumeWAD::IsSizeAccurate() const +{ + return m_reader->IsDataSizeAccurate(); +} + u64 VolumeWAD::GetRawSize() const { return m_reader->GetRawSize(); -- cgit v1.2.3 From abb3c5bccd0a678fb5c70417064854b006ed110c Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 23 Mar 2019 13:05:42 +0100 Subject: VolumeWad: Implement GetTicket --- Source/Core/DiscIO/VolumeWad.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index a7316ffde9..48a315331b 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -33,16 +33,20 @@ VolumeWAD::VolumeWAD(std::unique_ptr reader) : m_reader(std::move(re // Source: http://wiibrew.org/wiki/WAD_files m_hdr_size = m_reader->ReadSwapped(0x00).value_or(0); m_cert_size = m_reader->ReadSwapped(0x08).value_or(0); - m_tick_size = m_reader->ReadSwapped(0x10).value_or(0); + m_ticket_size = m_reader->ReadSwapped(0x10).value_or(0); m_tmd_size = m_reader->ReadSwapped(0x14).value_or(0); m_data_size = m_reader->ReadSwapped(0x18).value_or(0); - m_offset = Common::AlignUp(m_hdr_size, 0x40) + Common::AlignUp(m_cert_size, 0x40); + m_ticket_offset = Common::AlignUp(m_hdr_size, 0x40) + Common::AlignUp(m_cert_size, 0x40); m_tmd_offset = Common::AlignUp(m_hdr_size, 0x40) + Common::AlignUp(m_cert_size, 0x40) + - Common::AlignUp(m_tick_size, 0x40); + Common::AlignUp(m_ticket_size, 0x40); m_opening_bnr_offset = m_tmd_offset + Common::AlignUp(m_tmd_size, 0x40) + Common::AlignUp(m_data_size, 0x40); + std::vector ticket_buffer(m_ticket_size); + Read(m_ticket_offset, m_ticket_size, ticket_buffer.data()); + m_ticket.SetBytes(std::move(ticket_buffer)); + if (!IOS::ES::IsValidTMDSize(m_tmd_size)) { ERROR_LOG(DISCIO, "TMD is too large: %u bytes", m_tmd_size); @@ -95,6 +99,11 @@ Country VolumeWAD::GetCountry(const Partition& partition) const return CountryCodeToCountry(country_byte, Platform::WiiWAD, region); } +const IOS::ES::TicketReader& VolumeWAD::GetTicket(const Partition& partition) const +{ + return m_ticket; +} + const IOS::ES::TMDReader& VolumeWAD::GetTMD(const Partition& partition) const { return m_tmd; @@ -126,7 +135,7 @@ std::string VolumeWAD::GetMakerID(const Partition& partition) const std::optional VolumeWAD::GetTitleID(const Partition& partition) const { - return ReadSwapped(m_offset + 0x01DC, partition); + return ReadSwapped(m_ticket_offset + 0x01DC, partition); } std::optional VolumeWAD::GetRevision(const Partition& partition) const -- cgit v1.2.3 From c028a84531ce08bb1f24f88ebdcc8885561a89e1 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Thu, 21 Mar 2019 23:04:44 +0100 Subject: Volume: Add a GetCertificateChain function --- Source/Core/DiscIO/VolumeWad.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 48a315331b..94191c05c7 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -32,14 +32,14 @@ VolumeWAD::VolumeWAD(std::unique_ptr reader) : m_reader(std::move(re // Source: http://wiibrew.org/wiki/WAD_files m_hdr_size = m_reader->ReadSwapped(0x00).value_or(0); - m_cert_size = m_reader->ReadSwapped(0x08).value_or(0); + m_cert_chain_size = m_reader->ReadSwapped(0x08).value_or(0); m_ticket_size = m_reader->ReadSwapped(0x10).value_or(0); m_tmd_size = m_reader->ReadSwapped(0x14).value_or(0); m_data_size = m_reader->ReadSwapped(0x18).value_or(0); - m_ticket_offset = Common::AlignUp(m_hdr_size, 0x40) + Common::AlignUp(m_cert_size, 0x40); - m_tmd_offset = Common::AlignUp(m_hdr_size, 0x40) + Common::AlignUp(m_cert_size, 0x40) + - Common::AlignUp(m_ticket_size, 0x40); + m_cert_chain_offset = Common::AlignUp(m_hdr_size, 0x40); + m_ticket_offset = m_cert_chain_offset + Common::AlignUp(m_cert_chain_size, 0x40); + m_tmd_offset = m_ticket_offset + Common::AlignUp(m_ticket_size, 0x40); m_opening_bnr_offset = m_tmd_offset + Common::AlignUp(m_tmd_size, 0x40) + Common::AlignUp(m_data_size, 0x40); @@ -56,6 +56,9 @@ VolumeWAD::VolumeWAD(std::unique_ptr reader) : m_reader(std::move(re std::vector tmd_buffer(m_tmd_size); Read(m_tmd_offset, m_tmd_size, tmd_buffer.data()); m_tmd.SetBytes(std::move(tmd_buffer)); + + m_cert_chain.resize(m_cert_chain_size); + Read(m_cert_chain_offset, m_cert_chain_size, m_cert_chain.data()); } VolumeWAD::~VolumeWAD() @@ -109,6 +112,11 @@ const IOS::ES::TMDReader& VolumeWAD::GetTMD(const Partition& partition) const return m_tmd; } +const std::vector& VolumeWAD::GetCertificateChain(const Partition& partition) const +{ + return m_cert_chain; +} + std::string VolumeWAD::GetGameID(const Partition& partition) const { return m_tmd.GetGameID(); -- cgit v1.2.3 From c885fed9da6f6b0c5862b99904bbb5edbba144fe Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 22 Mar 2019 20:47:05 +0100 Subject: DiscIO: Make Korean GC checks in Enums.cpp less fragile --- Source/Core/DiscIO/VolumeWad.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 94191c05c7..19f907e6f7 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -96,10 +96,11 @@ Country VolumeWAD::GetCountry(const Partition& partition) const return TypicalCountryForRegion(GetSysMenuRegion(m_tmd.GetTitleVersion())); const Region region = GetRegion(); - if (CountryCodeToRegion(country_byte, Platform::WiiWAD, region) != region) + const std::optional revision = GetRevision(); + if (CountryCodeToRegion(country_byte, Platform::WiiWAD, region, revision) != region) return TypicalCountryForRegion(region); - return CountryCodeToCountry(country_byte, Platform::WiiWAD, region); + return CountryCodeToCountry(country_byte, Platform::WiiWAD, region, revision); } const IOS::ES::TicketReader& VolumeWAD::GetTicket(const Partition& partition) const -- cgit v1.2.3 From 8709b21ac30f5da5c32ef056b6562a37345b5f82 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 30 Mar 2019 17:42:31 +0100 Subject: VolumeVerifier: Verify WAD contents --- Source/Core/DiscIO/VolumeWad.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Source/Core/DiscIO/VolumeWad.cpp') diff --git a/Source/Core/DiscIO/VolumeWad.cpp b/Source/Core/DiscIO/VolumeWad.cpp index 19f907e6f7..40516df6b6 100644 --- a/Source/Core/DiscIO/VolumeWad.cpp +++ b/Source/Core/DiscIO/VolumeWad.cpp @@ -40,8 +40,8 @@ VolumeWAD::VolumeWAD(std::unique_ptr reader) : m_reader(std::move(re m_cert_chain_offset = Common::AlignUp(m_hdr_size, 0x40); m_ticket_offset = m_cert_chain_offset + Common::AlignUp(m_cert_chain_size, 0x40); m_tmd_offset = m_ticket_offset + Common::AlignUp(m_ticket_size, 0x40); - m_opening_bnr_offset = - m_tmd_offset + Common::AlignUp(m_tmd_size, 0x40) + Common::AlignUp(m_data_size, 0x40); + m_data_offset = m_tmd_offset + Common::AlignUp(m_tmd_size, 0x40); + m_opening_bnr_offset = m_data_offset + Common::AlignUp(m_data_size, 0x40); std::vector ticket_buffer(m_ticket_size); Read(m_ticket_offset, m_ticket_size, ticket_buffer.data()); @@ -118,6 +118,21 @@ const std::vector& VolumeWAD::GetCertificateChain(const Partition& partition return m_cert_chain; } +std::vector VolumeWAD::GetContentOffsets() const +{ + const std::vector contents = m_tmd.GetContents(); + std::vector content_offsets; + content_offsets.reserve(contents.size()); + u64 offset = m_data_offset; + for (const IOS::ES::Content& content : contents) + { + content_offsets.emplace_back(offset); + offset += Common::AlignUp(content.size, 0x40); + } + + return content_offsets; +} + std::string VolumeWAD::GetGameID(const Partition& partition) const { return m_tmd.GetGameID(); -- cgit v1.2.3