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 diff --git a/Source/Core/DiscIO/VolumeWad.h b/Source/Core/DiscIO/VolumeWad.h index fce0a10d30..02276f7797 100644 --- a/Source/Core/DiscIO/VolumeWad.h +++ b/Source/Core/DiscIO/VolumeWad.h @@ -33,6 +33,8 @@ public: const Partition& partition = PARTITION_NONE) const override; const FileSystem* GetFileSystem(const Partition& partition = PARTITION_NONE) const override; std::optional GetTitleID(const Partition& partition = PARTITION_NONE) const override; + const IOS::ES::TicketReader& + GetTicket(const Partition& partition = PARTITION_NONE) const override; const IOS::ES::TMDReader& GetTMD(const Partition& partition = PARTITION_NONE) const override; std::string GetGameID(const Partition& partition = PARTITION_NONE) const override; std::string GetGameTDBID(const Partition& partition = PARTITION_NONE) const override; @@ -59,13 +61,14 @@ public: private: std::unique_ptr m_reader; + IOS::ES::TicketReader m_ticket; IOS::ES::TMDReader m_tmd; - u32 m_offset = 0; + u32 m_ticket_offset = 0; u32 m_tmd_offset = 0; u32 m_opening_bnr_offset = 0; u32 m_hdr_size = 0; u32 m_cert_size = 0; - u32 m_tick_size = 0; + u32 m_ticket_size = 0; u32 m_tmd_size = 0; u32 m_data_size = 0; };