Allow building "pirate legit" CIAs (TMD & encryption intact)

This commit is contained in:
d0k3 2020-05-11 18:02:26 +02:00
parent 73dc54a754
commit a7ce125d7f

View File

@ -1360,21 +1360,32 @@ u32 BuildCiaFromTmdFileBuffered(const char* path_tmd, const char* path_cia, bool
bool src_emunand = ((*path_tmd == 'B') || (*path_tmd == '4')); bool src_emunand = ((*path_tmd == 'B') || (*path_tmd == '4'));
if (force_legit) { if (force_legit) {
Ticket* ticket_tmp = NULL; Ticket* ticket_tmp = NULL;
bool copy = true;
if ((cdn && (LoadCdnTicketFile(&ticket_tmp, path_tmd) != 0)) || if ((cdn && (LoadCdnTicketFile(&ticket_tmp, path_tmd) != 0)) ||
(!cdn && (FindTicket(&ticket_tmp, title_id, true, src_emunand) != 0))) { (!cdn && (FindTicket(&ticket_tmp, title_id, true, src_emunand) != 0))) {
ShowPrompt(false, "ID %016llX\nLegit ticket not found.", getbe64(title_id)); static bool use_generic = false;
if (!use_generic) {
use_generic = ShowPrompt(true, "ID %016llX\nLegit ticket not found.\n \nFallback to generic as default?", getbe64(title_id));
if (!use_generic) {
free(ticket_tmp); free(ticket_tmp);
return 1; return 1;
} }
ShowProgress(0, 0, path_tmd);
}
if (use_generic) {
FindTitleKey(ticket, title_id);
copy = false;
}
}
// either, it's a ticket without ways to check ownership data, smaller sized // either, it's a ticket without ways to check ownership data, smaller sized
// or, it's title ticket with > 1024 contents, of which can't make it work with current CiaStub // or, it's title ticket with > 1024 contents, of which can't make it work with current CiaStub
if (GetTicketSize(ticket_tmp) != TICKET_COMMON_SIZE) { if (copy && GetTicketSize(ticket_tmp) != TICKET_COMMON_SIZE) {
ShowPrompt(false, "ID %016llX\nLegit ticket of unsupported size.", getbe64(title_id)); ShowPrompt(false, "ID %016llX\nLegit ticket of unsupported size.", getbe64(title_id));
free(ticket_tmp); free(ticket_tmp);
return 1; return 1;
} }
bool copy = true; // check the tickets' console id, warn if it isn't zero
if (getbe32(ticket_tmp->console_id)) { if (copy && getbe32(ticket_tmp->console_id)) {
static u32 default_action = 0; static u32 default_action = 0;
const char* optionstr[2] = const char* optionstr[2] =
{"Use personalized ticket (legit)", "Use generic ticket (not legit)"}; {"Use personalized ticket (legit)", "Use generic ticket (not legit)"};