VolumeWad: Implement GetTicket

This commit is contained in:
JosJuice 2019-03-23 13:05:42 +01:00
parent cf9ab6ddcc
commit abb3c5bccd
2 changed files with 18 additions and 6 deletions

View File

@ -33,16 +33,20 @@ VolumeWAD::VolumeWAD(std::unique_ptr<BlobReader> reader) : m_reader(std::move(re
// Source: http://wiibrew.org/wiki/WAD_files
m_hdr_size = m_reader->ReadSwapped<u32>(0x00).value_or(0);
m_cert_size = m_reader->ReadSwapped<u32>(0x08).value_or(0);
m_tick_size = m_reader->ReadSwapped<u32>(0x10).value_or(0);
m_ticket_size = m_reader->ReadSwapped<u32>(0x10).value_or(0);
m_tmd_size = m_reader->ReadSwapped<u32>(0x14).value_or(0);
m_data_size = m_reader->ReadSwapped<u32>(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<u8> 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<u64> VolumeWAD::GetTitleID(const Partition& partition) const
{
return ReadSwapped<u64>(m_offset + 0x01DC, partition);
return ReadSwapped<u64>(m_ticket_offset + 0x01DC, partition);
}
std::optional<u16> VolumeWAD::GetRevision(const Partition& partition) const

View File

@ -33,6 +33,8 @@ public:
const Partition& partition = PARTITION_NONE) const override;
const FileSystem* GetFileSystem(const Partition& partition = PARTITION_NONE) const override;
std::optional<u64> 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<BlobReader> 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;
};