From 1b3b7518e6f93d943745d23efd8958608a1cbb71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Tue, 25 Apr 2017 20:32:01 +0200 Subject: [PATCH] ESFormats: Fix the first field of ticket views Looking more carefully at the IOS ticket view generation code reveals that the first field in the TicketView struct is copied over from the ticket version, extended to 4 bytes. --- Source/Core/Core/IOS/ES/Formats.cpp | 12 ++++++------ Source/Core/Core/IOS/ES/Formats.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Source/Core/Core/IOS/ES/Formats.cpp b/Source/Core/Core/IOS/ES/Formats.cpp index d57bffb460..2c91dc923f 100644 --- a/Source/Core/Core/IOS/ES/Formats.cpp +++ b/Source/Core/Core/IOS/ES/Formats.cpp @@ -285,17 +285,17 @@ const std::vector& TicketReader::GetRawTicket() const std::vector TicketReader::GetRawTicketView(u32 ticket_num) const { - // A ticket view is composed of a view ID + part of a ticket starting from the ticket_id field. + // A ticket view is composed of a version + part of a ticket starting from the ticket_id field. const auto ticket_start = m_bytes.cbegin() + GetOffset() + sizeof(Ticket) * ticket_num; const auto view_start = ticket_start + offsetof(Ticket, ticket_id); - // Copy the view ID to the buffer. - std::vector view(sizeof(TicketView::view)); - const u32 view_id = Common::swap32(ticket_num); - std::memcpy(view.data(), &view_id, sizeof(view_id)); + // Copy the ticket version to the buffer (a single byte extended to 4). + std::vector view(sizeof(TicketView::version)); + const u32 version = Common::swap32(m_bytes.at(offsetof(Ticket, version))); + std::memcpy(view.data(), &version, sizeof(version)); // Copy the rest of the ticket view structure from the ticket. - view.insert(view.end(), view_start, view_start + (sizeof(TicketView) - sizeof(view_id))); + view.insert(view.end(), view_start, view_start + (sizeof(TicketView) - sizeof(version))); _assert_(view.size() == sizeof(TicketView)); return view; diff --git a/Source/Core/Core/IOS/ES/Formats.h b/Source/Core/Core/IOS/ES/Formats.h index 691babdc9b..5f370c2cbd 100644 --- a/Source/Core/Core/IOS/ES/Formats.h +++ b/Source/Core/Core/IOS/ES/Formats.h @@ -82,7 +82,7 @@ struct TimeLimit struct TicketView { - u32 view; + u32 version; u64 ticket_id; u32 device_id; u64 title_id;