mirror of
https://github.com/Dark98/threeSD.git
synced 2026-07-04 08:39:05 +00:00
A bunch of fixes to CIA building
1. Clean stale state 2. DLC CIAs 3. Build content index for ticket better
This commit is contained in:
@@ -47,6 +47,9 @@ bool CIABuilder::Init(const std::string& destination, TitleMetadata tmd_,
|
||||
const std::string& certs_db_path, std::size_t total_size_,
|
||||
const ProgressCallback& callback_) {
|
||||
|
||||
header = {};
|
||||
meta = {};
|
||||
|
||||
file = std::make_shared<HashedFile>(destination, "wb");
|
||||
if (!*file) {
|
||||
LOG_ERROR(Core, "Could not open file {}", destination);
|
||||
@@ -165,13 +168,14 @@ bool CIABuilder::AddContent(u16 content_id, NCCHContainer& ncch) {
|
||||
written = Common::AlignUp(file->Tell(), CIA_ALIGNMENT);
|
||||
|
||||
header.content_size = written - content_offset;
|
||||
header.SetContentPresent(content_id);
|
||||
|
||||
auto& tmd_chunk = tmd.GetContentChunkByID(content_id);
|
||||
header.SetContentPresent(tmd_chunk.index);
|
||||
file->GetHash(tmd_chunk.hash.data());
|
||||
file->SetHashEnabled(false);
|
||||
|
||||
if (tmd_chunk.index != TMDContentIndex::Main) {
|
||||
// DLCs do not have a meta
|
||||
if (tmd_chunk.index != TMDContentIndex::Main || (tmd.GetTitleID() & 0x0004008c'00000000)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -97,7 +97,6 @@ private:
|
||||
std::size_t ticket_offset{};
|
||||
std::size_t tmd_offset{};
|
||||
std::size_t content_offset{};
|
||||
std::size_t metadata_offset{};
|
||||
|
||||
std::shared_ptr<HashedFile> file;
|
||||
std::size_t written{}; // size written (with alignment)
|
||||
|
||||
@@ -31,8 +31,9 @@ Ticket BuildFakeTicket(u64 title_id) {
|
||||
ticket.title_id = title_id;
|
||||
ticket.common_key_index = 0x00;
|
||||
ticket.audit = 0x01;
|
||||
std::memset(ticket.content_index.data(), 0xFF, ticket.content_index.size());
|
||||
std::memcpy(ticket.content_index.data(), TicketContentIndex.data(), TicketContentIndex.size());
|
||||
// GodMode9 by default sets all remaining 0x80 bytes to 0xFF, but legit tickets only set 0x20
|
||||
std::memset(ticket.content_index.data() + TicketContentIndex.size(), 0xFF, 0x20);
|
||||
return ticket;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user