[Cleanup] Move FindSignedTicket to IOS/ES
For consistency and because NANDContentManager is going to be removed.
This commit is contained in:
parent
0476c0e60e
commit
689ed2a0ce
|
@ -684,7 +684,7 @@ ReturnCode ES::SetUpStreamKey(const u32 uid, const u8* ticket_view, const IOS::E
|
|||
// Find a signed ticket from the view.
|
||||
const u64 ticket_id = Common::swap64(&ticket_view[offsetof(IOS::ES::TicketView, ticket_id)]);
|
||||
const u64 title_id = Common::swap64(&ticket_view[offsetof(IOS::ES::TicketView, title_id)]);
|
||||
const IOS::ES::TicketReader installed_ticket = DiscIO::FindSignedTicket(title_id);
|
||||
const IOS::ES::TicketReader installed_ticket = FindSignedTicket(title_id);
|
||||
// Unlike the other "get ticket from view" function, this returns a FS error, not ES_NO_TICKET.
|
||||
if (!installed_ticket.IsValid())
|
||||
return FS_ENOENT;
|
||||
|
|
|
@ -85,6 +85,7 @@ public:
|
|||
|
||||
IOS::ES::TMDReader FindImportTMD(u64 title_id) const;
|
||||
IOS::ES::TMDReader FindInstalledTMD(u64 title_id) const;
|
||||
IOS::ES::TicketReader FindSignedTicket(u64 title_id) const;
|
||||
|
||||
// Get installed titles (in /title) without checking for TMDs at all.
|
||||
std::vector<u64> GetInstalledTitles() const;
|
||||
|
|
|
@ -50,6 +50,20 @@ IOS::ES::TMDReader ES::FindInstalledTMD(u64 title_id) const
|
|||
return FindTMD(title_id, Common::GetTMDFileName(title_id, Common::FROM_SESSION_ROOT));
|
||||
}
|
||||
|
||||
IOS::ES::TicketReader ES::FindSignedTicket(u64 title_id) const
|
||||
{
|
||||
const std::string path = Common::GetTicketFileName(title_id, Common::FROM_SESSION_ROOT);
|
||||
File::IOFile ticket_file(path, "rb");
|
||||
if (!ticket_file)
|
||||
return {};
|
||||
|
||||
std::vector<u8> signed_ticket(ticket_file.GetSize());
|
||||
if (!ticket_file.ReadBytes(signed_ticket.data(), signed_ticket.size()))
|
||||
return {};
|
||||
|
||||
return IOS::ES::TicketReader{std::move(signed_ticket)};
|
||||
}
|
||||
|
||||
static bool IsValidPartOfTitleID(const std::string& string)
|
||||
{
|
||||
if (string.length() != 8)
|
||||
|
|
|
@ -220,7 +220,7 @@ ReturnCode ES::ImportTitleInit(Context& context, const std::vector<u8>& tmd_byte
|
|||
if (ret != IPC_SUCCESS)
|
||||
return ret;
|
||||
|
||||
const auto ticket = DiscIO::FindSignedTicket(context.title_import_export.tmd.GetTitleId());
|
||||
const auto ticket = FindSignedTicket(context.title_import_export.tmd.GetTitleId());
|
||||
if (!ticket.IsValid())
|
||||
return ES_NO_TICKET;
|
||||
|
||||
|
@ -528,7 +528,7 @@ ReturnCode ES::DeleteTicket(const u8* ticket_view)
|
|||
if (!CanDeleteTitle(title_id))
|
||||
return ES_EINVAL;
|
||||
|
||||
auto ticket = DiscIO::FindSignedTicket(title_id);
|
||||
auto ticket = FindSignedTicket(title_id);
|
||||
if (!ticket.IsValid())
|
||||
return FS_ENOENT;
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ IPCCommandResult ES::GetTicketViewCount(const IOCtlVRequest& request)
|
|||
|
||||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
|
||||
const IOS::ES::TicketReader ticket = DiscIO::FindSignedTicket(TitleID);
|
||||
const IOS::ES::TicketReader ticket = FindSignedTicket(TitleID);
|
||||
u32 view_count = ticket.IsValid() ? static_cast<u32>(ticket.GetNumberOfTickets()) : 0;
|
||||
|
||||
if (ShouldReturnFakeViewsForIOSes(TitleID, m_title_context))
|
||||
|
@ -73,7 +73,7 @@ IPCCommandResult ES::GetTicketViews(const IOCtlVRequest& request)
|
|||
u64 TitleID = Memory::Read_U64(request.in_vectors[0].address);
|
||||
u32 maxViews = Memory::Read_U32(request.in_vectors[1].address);
|
||||
|
||||
const IOS::ES::TicketReader ticket = DiscIO::FindSignedTicket(TitleID);
|
||||
const IOS::ES::TicketReader ticket = FindSignedTicket(TitleID);
|
||||
|
||||
if (ticket.IsValid())
|
||||
{
|
||||
|
@ -102,7 +102,7 @@ ReturnCode ES::GetV0TicketFromView(const u8* ticket_view, u8* ticket) const
|
|||
const u64 title_id = Common::swap64(&ticket_view[offsetof(IOS::ES::TicketView, title_id)]);
|
||||
const u64 ticket_id = Common::swap64(&ticket_view[offsetof(IOS::ES::TicketView, ticket_id)]);
|
||||
|
||||
const auto installed_ticket = DiscIO::FindSignedTicket(title_id);
|
||||
const auto installed_ticket = FindSignedTicket(title_id);
|
||||
// TODO: when we get std::optional, check for presence instead of validity.
|
||||
// This is close enough, though.
|
||||
if (!installed_ticket.IsValid())
|
||||
|
|
|
@ -157,7 +157,7 @@ IPCCommandResult WFSI::IOCtl(const IOCtlRequest& request)
|
|||
Memory::CopyFromEmu(tmd_bytes.data(), tmd_addr, tmd_size);
|
||||
m_tmd.SetBytes(std::move(tmd_bytes));
|
||||
|
||||
IOS::ES::TicketReader ticket = DiscIO::FindSignedTicket(m_tmd.GetTitleId());
|
||||
IOS::ES::TicketReader ticket = m_ios.GetES()->FindSignedTicket(m_tmd.GetTitleId());
|
||||
if (!ticket.IsValid())
|
||||
{
|
||||
return_error_code = -11028;
|
||||
|
|
|
@ -670,7 +670,7 @@ UpdateResult DiscSystemUpdater::ProcessEntry(u32 type, std::bitset<32> attrs,
|
|||
return UpdateResult::AlreadyUpToDate;
|
||||
|
||||
const IOS::ES::TMDReader tmd = m_ios.GetES()->FindInstalledTMD(title.id);
|
||||
const IOS::ES::TicketReader ticket = DiscIO::FindSignedTicket(title.id);
|
||||
const IOS::ES::TicketReader ticket = m_ios.GetES()->FindSignedTicket(title.id);
|
||||
|
||||
// Optional titles can be skipped if the ticket is present, even when the title isn't installed.
|
||||
if (attrs.test(16) && ticket.IsValid())
|
||||
|
@ -735,7 +735,7 @@ NANDCheckResult CheckNAND(IOS::HLE::Kernel& ios)
|
|||
}
|
||||
|
||||
// Check for incomplete title installs (missing ticket, TMD or contents).
|
||||
const auto ticket = DiscIO::FindSignedTicket(title_id);
|
||||
const auto ticket = es->FindSignedTicket(title_id);
|
||||
if (!IOS::ES::IsDiscTitle(title_id) && !ticket.IsValid())
|
||||
{
|
||||
ERROR_LOG(CORE, "CheckNAND: Missing ticket for title %016" PRIx64, title_id);
|
||||
|
@ -801,7 +801,7 @@ bool RepairNAND(IOS::HLE::Kernel& ios)
|
|||
const auto content_files = File::ScanDirectoryTree(content_dir, false).children;
|
||||
const bool has_no_tmd_but_contents =
|
||||
!es->FindInstalledTMD(title_id).IsValid() && !content_files.empty();
|
||||
if (has_no_tmd_but_contents || !DiscIO::FindSignedTicket(title_id).IsValid())
|
||||
if (has_no_tmd_but_contents || !es->FindSignedTicket(title_id).IsValid())
|
||||
{
|
||||
const std::string title_dir = Common::GetTitlePath(title_id, Common::FROM_CONFIGURED_ROOT);
|
||||
File::DeleteDirRecursively(title_dir);
|
||||
|
|
Loading…
Reference in New Issue