Merge pull request #4759 from B3n30/load_cia_ticket

FileSys: Load the ticket when the CIAContainer is loaded
This commit is contained in:
Weiyi Wang 2019-05-03 00:44:08 -04:00 committed by GitHub
commit 59879366a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -30,6 +30,16 @@ Loader::ResultStatus CIAContainer::Load(const FileBackend& backend) {
if (result != Loader::ResultStatus::Success) if (result != Loader::ResultStatus::Success)
return result; return result;
// Load Ticket
std::vector<u8> ticket_data(cia_header.tik_size);
read_result = backend.Read(GetTicketOffset(), cia_header.tik_size, ticket_data.data());
if (read_result.Failed() || *read_result != cia_header.tik_size)
return Loader::ResultStatus::Error;
result = LoadTicket(ticket_data);
if (result != Loader::ResultStatus::Success)
return result;
// Load Title Metadata // Load Title Metadata
std::vector<u8> tmd_data(cia_header.tmd_size); std::vector<u8> tmd_data(cia_header.tmd_size);
read_result = backend.Read(GetTitleMetadataOffset(), cia_header.tmd_size, tmd_data.data()); read_result = backend.Read(GetTitleMetadataOffset(), cia_header.tmd_size, tmd_data.data());
@ -69,6 +79,16 @@ Loader::ResultStatus CIAContainer::Load(const std::string& filepath) {
if (result != Loader::ResultStatus::Success) if (result != Loader::ResultStatus::Success)
return result; return result;
// Load Ticket
std::vector<u8> ticket_data(cia_header.tik_size);
file.Seek(GetTicketOffset(), SEEK_SET);
if (file.ReadBytes(ticket_data.data(), cia_header.tik_size) != cia_header.tik_size)
return Loader::ResultStatus::Error;
result = LoadTicket(ticket_data);
if (result != Loader::ResultStatus::Success)
return result;
// Load Title Metadata // Load Title Metadata
std::vector<u8> tmd_data(cia_header.tmd_size); std::vector<u8> tmd_data(cia_header.tmd_size);
file.Seek(GetTitleMetadataOffset(), SEEK_SET); file.Seek(GetTitleMetadataOffset(), SEEK_SET);
@ -99,6 +119,11 @@ Loader::ResultStatus CIAContainer::Load(const std::vector<u8>& file_data) {
if (result != Loader::ResultStatus::Success) if (result != Loader::ResultStatus::Success)
return result; return result;
// Load Ticket
result = LoadTicket(file_data, GetTicketOffset());
if (result != Loader::ResultStatus::Success)
return result;
// Load Title Metadata // Load Title Metadata
result = LoadTitleMetadata(file_data, GetTitleMetadataOffset()); result = LoadTitleMetadata(file_data, GetTitleMetadataOffset());
if (result != Loader::ResultStatus::Success) if (result != Loader::ResultStatus::Success)