From 14ed70297189d368ab8666e2c1d785ee8f371d0c Mon Sep 17 00:00:00 2001 From: B3n30 Date: Sun, 28 Apr 2019 21:21:28 +0200 Subject: [PATCH] FileSys: Load the ticket when the CIAContainer is loaded --- src/core/file_sys/cia_container.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/core/file_sys/cia_container.cpp b/src/core/file_sys/cia_container.cpp index a53e04d4b3..09d815c303 100644 --- a/src/core/file_sys/cia_container.cpp +++ b/src/core/file_sys/cia_container.cpp @@ -30,6 +30,16 @@ Loader::ResultStatus CIAContainer::Load(const FileBackend& backend) { if (result != Loader::ResultStatus::Success) return result; + // Load Ticket + std::vector 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 std::vector tmd_data(cia_header.tmd_size); 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) return result; + // Load Ticket + std::vector 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 std::vector tmd_data(cia_header.tmd_size); file.Seek(GetTitleMetadataOffset(), SEEK_SET); @@ -99,6 +119,11 @@ Loader::ResultStatus CIAContainer::Load(const std::vector& file_data) { if (result != Loader::ResultStatus::Success) return result; + // Load Ticket + result = LoadTicket(file_data, GetTicketOffset()); + if (result != Loader::ResultStatus::Success) + return result; + // Load Title Metadata result = LoadTitleMetadata(file_data, GetTitleMetadataOffset()); if (result != Loader::ResultStatus::Success)