2020-10-02 10:53:58 +01:00
|
|
|
/*
|
|
|
|
* main.c
|
|
|
|
*
|
|
|
|
* Copyright (c) 2020, DarkMatterCore <pabloacurielz@gmail.com>.
|
|
|
|
*
|
|
|
|
* This file is part of nxdumptool (https://github.com/DarkMatterCore/nxdumptool).
|
|
|
|
*
|
2021-03-25 19:26:58 +00:00
|
|
|
* nxdumptool is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2020-10-02 10:53:58 +01:00
|
|
|
*
|
2021-03-25 19:26:58 +00:00
|
|
|
* nxdumptool is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2020-10-02 10:53:58 +01:00
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-03-25 19:26:58 +00:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-10-02 10:53:58 +01:00
|
|
|
*/
|
|
|
|
|
2021-03-26 04:35:14 +00:00
|
|
|
#include "nxdt_utils.h"
|
2020-10-02 10:53:58 +01:00
|
|
|
#include "gamecard.h"
|
|
|
|
#include "title.h"
|
|
|
|
#include "cnmt.h"
|
2020-10-11 19:13:09 +01:00
|
|
|
#include "program_info.h"
|
2020-10-06 16:41:26 +01:00
|
|
|
#include "nacp.h"
|
2020-10-09 10:58:53 +01:00
|
|
|
#include "legal_info.h"
|
2020-10-02 10:53:58 +01:00
|
|
|
|
2021-09-04 05:17:17 +01:00
|
|
|
bool g_borealisInitialized = false;
|
|
|
|
|
2021-04-26 00:10:34 +01:00
|
|
|
static PadState g_padState = {0};
|
|
|
|
|
|
|
|
static void utilsScanPads(void)
|
|
|
|
{
|
|
|
|
padUpdate(&g_padState);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 utilsGetButtonsDown(void)
|
|
|
|
{
|
|
|
|
return padGetButtonsDown(&g_padState);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u64 utilsGetButtonsHeld(void)
|
|
|
|
{
|
|
|
|
return padGetButtons(&g_padState);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void utilsWaitForButtonPress(u64 flag)
|
|
|
|
{
|
|
|
|
/* Don't consider stick movement as button inputs. */
|
|
|
|
if (!flag) flag = ~(HidNpadButton_StickLLeft | HidNpadButton_StickLRight | HidNpadButton_StickLUp | HidNpadButton_StickLDown | HidNpadButton_StickRLeft | HidNpadButton_StickRRight | \
|
|
|
|
HidNpadButton_StickRUp | HidNpadButton_StickRDown);
|
|
|
|
|
|
|
|
while(appletMainLoop())
|
|
|
|
{
|
|
|
|
utilsScanPads();
|
|
|
|
if (utilsGetButtonsDown() & flag) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
static void consolePrint(const char *text, ...)
|
|
|
|
{
|
|
|
|
va_list v;
|
|
|
|
va_start(v, text);
|
|
|
|
vfprintf(stdout, text, v);
|
|
|
|
va_end(v);
|
|
|
|
consoleUpdate(NULL);
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
static void writeFile(void *buf, size_t buf_size, const char *path)
|
|
|
|
{
|
|
|
|
FILE *fd = fopen(path, "wb");
|
|
|
|
if (fd)
|
|
|
|
{
|
|
|
|
fwrite(buf, 1, buf_size, fd);
|
|
|
|
fclose(fd);
|
|
|
|
utilsCommitSdCardFileSystemChanges();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
|
2021-05-18 13:32:43 +01:00
|
|
|
if (!utilsInitializeResources(argc, (const char**)argv))
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
|
|
|
ret = -1;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2021-04-26 00:10:34 +01:00
|
|
|
/* Configure input. */
|
|
|
|
/* Up to 8 different, full controller inputs. */
|
|
|
|
/* Individual Joy-Cons not supported. */
|
|
|
|
padConfigureInput(8, HidNpadStyleSet_NpadFullCtrl);
|
|
|
|
padInitializeWithMask(&g_padState, 0x1000000FFUL);
|
|
|
|
|
2021-03-08 14:44:11 +00:00
|
|
|
consoleInit(NULL);
|
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
u32 app_count = 0;
|
|
|
|
TitleApplicationMetadata **app_metadata = NULL;
|
|
|
|
TitleUserApplicationData user_app_data = {0};
|
|
|
|
|
|
|
|
u32 selected_idx = 0, page_size = 30, scroll = 0;
|
2022-02-19 05:03:06 +00:00
|
|
|
bool applet_status = true, exit_prompt = true;
|
2020-10-02 10:53:58 +01:00
|
|
|
|
|
|
|
NcaContext *nca_ctx = NULL;
|
|
|
|
Ticket tik = {0};
|
2020-10-06 16:41:26 +01:00
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
u32 meta_idx = 0;
|
2020-10-02 10:53:58 +01:00
|
|
|
ContentMetaContext cnmt_ctx = {0};
|
2020-10-06 16:41:26 +01:00
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
u32 program_count = 0, program_idx = 0;
|
|
|
|
ProgramInfoContext *program_info_ctx = NULL;
|
|
|
|
|
|
|
|
u32 control_count = 0, control_idx = 0;
|
|
|
|
NacpContext *nacp_ctx = NULL;
|
|
|
|
|
|
|
|
u32 legal_info_count = 0, legal_info_idx = 0;
|
|
|
|
LegalInfoContext *legal_info_ctx = NULL;
|
|
|
|
|
2020-10-06 16:41:26 +01:00
|
|
|
char path[FS_MAX_PATH] = {0};
|
2020-10-02 10:53:58 +01:00
|
|
|
|
|
|
|
app_metadata = titleGetApplicationMetadataEntries(false, &app_count);
|
|
|
|
if (!app_metadata || !app_count)
|
|
|
|
{
|
|
|
|
consolePrint("app metadata failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
consolePrint("app metadata succeeded\n");
|
|
|
|
|
|
|
|
utilsSleep(1);
|
|
|
|
|
2022-02-19 05:03:06 +00:00
|
|
|
while((applet_status = appletMainLoop()))
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
|
|
|
consoleClear();
|
2020-10-14 01:15:21 +01:00
|
|
|
printf("select a user application to generate xmls for.\npress b to exit.\n\n");
|
2020-10-10 11:10:50 +01:00
|
|
|
printf("title: %u / %u\n", selected_idx + 1, app_count);
|
|
|
|
printf("selected title: %016lX - %s\n\n", app_metadata[selected_idx]->title_id, app_metadata[selected_idx]->lang_entry.name);
|
2020-10-02 10:53:58 +01:00
|
|
|
|
|
|
|
for(u32 i = scroll; i < app_count; i++)
|
|
|
|
{
|
|
|
|
if (i >= (scroll + page_size)) break;
|
|
|
|
printf("%s%016lX - %s\n", i == selected_idx ? " -> " : " ", app_metadata[i]->title_id, app_metadata[i]->lang_entry.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
consoleUpdate(NULL);
|
|
|
|
|
|
|
|
u64 btn_down = 0, btn_held = 0;
|
2022-02-19 05:03:06 +00:00
|
|
|
while((applet_status = appletMainLoop()))
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
2020-12-04 06:38:44 +00:00
|
|
|
utilsScanPads();
|
|
|
|
btn_down = utilsGetButtonsDown();
|
|
|
|
btn_held = utilsGetButtonsHeld();
|
2020-10-02 10:53:58 +01:00
|
|
|
if (btn_down || btn_held) break;
|
|
|
|
|
|
|
|
if (titleIsGameCardInfoUpdated())
|
|
|
|
{
|
|
|
|
free(app_metadata);
|
|
|
|
|
|
|
|
app_metadata = titleGetApplicationMetadataEntries(false, &app_count);
|
|
|
|
if (!app_metadata)
|
|
|
|
{
|
|
|
|
consolePrint("\napp metadata failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
selected_idx = scroll = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-19 05:03:06 +00:00
|
|
|
if (!applet_status) break;
|
|
|
|
|
2020-12-04 06:38:44 +00:00
|
|
|
if (btn_down & HidNpadButton_A)
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
|
|
|
if (!titleGetUserApplicationData(app_metadata[selected_idx]->title_id, &user_app_data) || !user_app_data.app_info)
|
|
|
|
{
|
|
|
|
consolePrint("\nthe selected title doesn't have available base content.\n");
|
|
|
|
utilsSleep(3);
|
2021-06-01 02:12:15 +01:00
|
|
|
titleFreeUserApplicationData(&user_app_data);
|
2020-10-02 10:53:58 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
} else
|
2020-12-04 06:38:44 +00:00
|
|
|
if ((btn_down & HidNpadButton_Down) || (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown)))
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
|
|
|
selected_idx++;
|
|
|
|
|
|
|
|
if (selected_idx >= app_count)
|
|
|
|
{
|
2020-12-04 06:38:44 +00:00
|
|
|
if (btn_down & HidNpadButton_Down)
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
|
|
|
selected_idx = scroll = 0;
|
|
|
|
} else {
|
|
|
|
selected_idx = (app_count - 1);
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (selected_idx >= (scroll + (page_size / 2)) && app_count > (scroll + page_size))
|
|
|
|
{
|
|
|
|
scroll++;
|
|
|
|
}
|
|
|
|
} else
|
2020-12-04 06:38:44 +00:00
|
|
|
if ((btn_down & HidNpadButton_Up) || (btn_held & (HidNpadButton_StickLUp | HidNpadButton_StickRUp)))
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
|
|
|
selected_idx--;
|
|
|
|
|
|
|
|
if (selected_idx == UINT32_MAX)
|
|
|
|
{
|
2020-12-04 06:38:44 +00:00
|
|
|
if (btn_down & HidNpadButton_Up)
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
|
|
|
selected_idx = (app_count - 1);
|
|
|
|
scroll = (app_count >= page_size ? (app_count - page_size) : 0);
|
|
|
|
} else {
|
|
|
|
selected_idx = 0;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
if (selected_idx < (scroll + (page_size / 2)) && scroll > 0)
|
|
|
|
{
|
|
|
|
scroll--;
|
|
|
|
}
|
|
|
|
} else
|
2020-12-04 06:38:44 +00:00
|
|
|
if (btn_down & HidNpadButton_B)
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
|
|
|
exit_prompt = false;
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
2020-12-04 06:38:44 +00:00
|
|
|
if (btn_held & (HidNpadButton_StickLDown | HidNpadButton_StickRDown | HidNpadButton_StickLUp | HidNpadButton_StickRUp)) svcSleepThread(50000000); // 50 ms
|
2020-10-02 10:53:58 +01:00
|
|
|
}
|
|
|
|
|
2022-02-19 05:03:06 +00:00
|
|
|
if (!applet_status)
|
|
|
|
{
|
|
|
|
exit_prompt = false;
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
consoleClear();
|
|
|
|
consolePrint("selected title:\n%s (%016lX)\n\n", app_metadata[selected_idx]->lang_entry.name, app_metadata[selected_idx]->title_id);
|
|
|
|
|
|
|
|
nca_ctx = calloc(user_app_data.app_info->content_count, sizeof(NcaContext));
|
|
|
|
if (!nca_ctx)
|
|
|
|
{
|
|
|
|
consolePrint("nca ctx calloc failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
consolePrint("nca ctx calloc succeeded\n");
|
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
meta_idx = (user_app_data.app_info->content_count - 1);
|
|
|
|
|
|
|
|
program_count = titleGetContentCountByType(user_app_data.app_info, NcmContentType_Program);
|
|
|
|
if (program_count && !(program_info_ctx = calloc(program_count, sizeof(ProgramInfoContext))))
|
|
|
|
{
|
|
|
|
consolePrint("program info ctx calloc failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
control_count = titleGetContentCountByType(user_app_data.app_info, NcmContentType_Control);
|
|
|
|
if (control_count && !(nacp_ctx = calloc(control_count, sizeof(NacpContext))))
|
|
|
|
{
|
|
|
|
consolePrint("nacp ctx calloc failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
legal_info_count = titleGetContentCountByType(user_app_data.app_info, NcmContentType_LegalInformation);
|
|
|
|
if (legal_info_count && !(legal_info_ctx = calloc(legal_info_count, sizeof(LegalInfoContext))))
|
|
|
|
{
|
|
|
|
consolePrint("legal info ctx calloc failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
2020-10-06 16:41:26 +01:00
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
for(u32 i = 0, j = 0; i < user_app_data.app_info->content_count; i++)
|
|
|
|
{
|
2020-10-12 21:35:47 +01:00
|
|
|
// set meta nca as the last nca
|
|
|
|
NcmContentInfo *content_info = &(user_app_data.app_info->content_infos[i]);
|
|
|
|
if (content_info->content_type == NcmContentType_Meta) continue;
|
2020-10-02 10:53:58 +01:00
|
|
|
|
|
|
|
if (!ncaInitializeContext(&(nca_ctx[j]), user_app_data.app_info->storage_id, (user_app_data.app_info->storage_id == NcmStorageId_GameCard ? GameCardHashFileSystemPartitionType_Secure : 0), \
|
2020-10-12 21:35:47 +01:00
|
|
|
content_info, &tik))
|
2020-10-02 10:53:58 +01:00
|
|
|
{
|
2020-10-12 21:35:47 +01:00
|
|
|
consolePrint("%s #%u initialize nca ctx failed\n", titleGetNcmContentTypeName(content_info->content_type), content_info->id_offset);
|
2020-10-02 10:53:58 +01:00
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
consolePrint("%s #%u initialize nca ctx succeeded\n", titleGetNcmContentTypeName(content_info->content_type), content_info->id_offset);
|
2020-10-11 19:13:09 +01:00
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
switch(content_info->content_type)
|
|
|
|
{
|
|
|
|
case NcmContentType_Program:
|
|
|
|
if (!programInfoInitializeContext(&(program_info_ctx[program_idx]), &(nca_ctx[j])))
|
|
|
|
{
|
|
|
|
consolePrint("initialize program info ctx failed (%s)\n", nca_ctx[j].content_id_str);
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
nca_ctx[j].content_type_ctx = &(program_info_ctx[program_idx++]);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NcmContentType_Control:
|
|
|
|
if (!nacpInitializeContext(&(nacp_ctx[control_idx]), &(nca_ctx[j])))
|
|
|
|
{
|
|
|
|
consolePrint("initialize nacp ctx failed (%s)\n", nca_ctx[j].content_id_str);
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
nca_ctx[j].content_type_ctx = &(nacp_ctx[control_idx++]);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case NcmContentType_LegalInformation:
|
|
|
|
if (!legalInfoInitializeContext(&(legal_info_ctx[legal_info_idx]), &(nca_ctx[j])))
|
|
|
|
{
|
|
|
|
consolePrint("initialize legal info ctx failed (%s)\n", nca_ctx[j].content_id_str);
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
nca_ctx[j].content_type_ctx = &(legal_info_ctx[legal_info_idx++]);
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2020-10-09 10:58:53 +01:00
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
j++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!ncaInitializeContext(&(nca_ctx[meta_idx]), user_app_data.app_info->storage_id, (user_app_data.app_info->storage_id == NcmStorageId_GameCard ? GameCardHashFileSystemPartitionType_Secure : 0), \
|
|
|
|
titleGetContentInfoByTypeAndIdOffset(user_app_data.app_info, NcmContentType_Meta, 0), &tik))
|
|
|
|
{
|
|
|
|
consolePrint("Meta nca initialize ctx failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
consolePrint("Meta nca initialize ctx succeeded\n");
|
|
|
|
|
|
|
|
if (!cnmtInitializeContext(&cnmt_ctx, &(nca_ctx[meta_idx])))
|
|
|
|
{
|
|
|
|
consolePrint("cnmt initialize ctx failed\n");
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
consolePrint("cnmt initialize ctx succeeded\n");
|
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
sprintf(path, "sdmc:/at_xml/%016lX", app_metadata[selected_idx]->title_id);
|
|
|
|
utilsCreateDirectoryTree(path, true);
|
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
if (cnmtGenerateAuthoringToolXml(&cnmt_ctx, nca_ctx, user_app_data.app_info->content_count))
|
|
|
|
{
|
|
|
|
consolePrint("cnmt xml succeeded\n");
|
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
//sprintf(path, "sdmc:/at_xml/%016lX/%s.cnmt", app_metadata[selected_idx]->title_id, cnmt_ctx.nca_ctx->content_id_str);
|
|
|
|
//writeFile(cnmt_ctx.raw_data, cnmt_ctx.raw_data_size, path);
|
2020-10-06 16:41:26 +01:00
|
|
|
|
2020-10-11 19:13:09 +01:00
|
|
|
sprintf(path, "sdmc:/at_xml/%016lX/%s.cnmt.xml", app_metadata[selected_idx]->title_id, cnmt_ctx.nca_ctx->content_id_str);
|
2020-10-12 21:35:47 +01:00
|
|
|
writeFile(cnmt_ctx.authoring_tool_xml, cnmt_ctx.authoring_tool_xml_size, path);
|
2020-10-02 10:53:58 +01:00
|
|
|
} else {
|
2020-10-04 08:05:05 +01:00
|
|
|
consolePrint("cnmt xml failed\n");
|
2020-10-02 10:53:58 +01:00
|
|
|
}
|
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
for(u32 i = 0; i < user_app_data.app_info->content_count; i++)
|
2020-10-11 19:13:09 +01:00
|
|
|
{
|
2020-10-12 21:35:47 +01:00
|
|
|
NcaContext *cur_nca_ctx = &(nca_ctx[i]);
|
2020-10-12 01:40:54 +01:00
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
if (!cur_nca_ctx->content_type_ctx || cur_nca_ctx->content_type == NcmContentType_Meta) continue;
|
2020-10-11 20:55:01 +01:00
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
switch(cur_nca_ctx->content_type)
|
2020-10-11 20:55:01 +01:00
|
|
|
{
|
2020-10-12 21:35:47 +01:00
|
|
|
case NcmContentType_Program:
|
2020-10-06 16:41:26 +01:00
|
|
|
{
|
2020-10-12 21:35:47 +01:00
|
|
|
ProgramInfoContext *cur_program_info_ctx = (ProgramInfoContext*)cur_nca_ctx->content_type_ctx;
|
|
|
|
if (!programInfoGenerateAuthoringToolXml(cur_program_info_ctx))
|
|
|
|
{
|
|
|
|
consolePrint("program info xml failed (%s | id offset #%u)\n", cur_nca_ctx->content_id_str, cur_nca_ctx->id_offset);
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
consolePrint("program info xml succeeded (%s | id offset #%u)\n", cur_nca_ctx->content_id_str, cur_nca_ctx->id_offset);
|
|
|
|
|
|
|
|
sprintf(path, "sdmc:/at_xml/%016lX/%s.programinfo.xml", app_metadata[selected_idx]->title_id, cur_nca_ctx->content_id_str);
|
|
|
|
writeFile(cur_program_info_ctx->authoring_tool_xml, cur_program_info_ctx->authoring_tool_xml_size, path);
|
|
|
|
|
|
|
|
break;
|
2020-10-06 16:41:26 +01:00
|
|
|
}
|
2020-10-12 21:35:47 +01:00
|
|
|
case NcmContentType_Control:
|
|
|
|
{
|
|
|
|
NacpContext *cur_nacp_ctx = (NacpContext*)cur_nca_ctx->content_type_ctx;
|
|
|
|
if (!nacpGenerateAuthoringToolXml(cur_nacp_ctx, user_app_data.app_info->version.value, cnmtGetRequiredTitleVersion(&cnmt_ctx)))
|
|
|
|
{
|
|
|
|
consolePrint("nacp xml failed (%s | id offset #%u)\n", cur_nca_ctx->content_id_str, cur_nca_ctx->id_offset);
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
|
|
|
consolePrint("nacp xml succeeded (%s | id offset #%u)\n", cur_nca_ctx->content_id_str, cur_nca_ctx->id_offset);
|
|
|
|
|
|
|
|
//sprintf(path, "sdmc:/at_xml/%016lX/%s.nacp", app_metadata[selected_idx]->title_id, cur_nca_ctx->content_id_str);
|
|
|
|
//writeFile(cur_nacp_ctx->data, sizeof(_NacpStruct), path);
|
|
|
|
|
|
|
|
sprintf(path, "sdmc:/at_xml/%016lX/%s.nacp.xml", app_metadata[selected_idx]->title_id, cur_nca_ctx->content_id_str);
|
|
|
|
writeFile(cur_nacp_ctx->authoring_tool_xml, cur_nacp_ctx->authoring_tool_xml_size, path);
|
|
|
|
|
|
|
|
for(u8 j = 0; j < cur_nacp_ctx->icon_count; j++)
|
|
|
|
{
|
|
|
|
NacpIconContext *icon_ctx = &(cur_nacp_ctx->icon_ctx[j]);
|
|
|
|
sprintf(path, "sdmc:/at_xml/%016lX/%s.nx.%s.jpg", app_metadata[selected_idx]->title_id, cur_nca_ctx->content_id_str, nacpGetLanguageString(icon_ctx->language));
|
|
|
|
writeFile(icon_ctx->icon_data, icon_ctx->icon_size, path);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NcmContentType_LegalInformation:
|
|
|
|
{
|
|
|
|
LegalInfoContext *cur_legal_info_ctx = (LegalInfoContext*)cur_nca_ctx->content_type_ctx;
|
|
|
|
|
|
|
|
sprintf(path, "sdmc:/at_xml/%016lX/%s.legalinfo.xml", app_metadata[selected_idx]->title_id, cur_nca_ctx->content_id_str);
|
|
|
|
writeFile(cur_legal_info_ctx->authoring_tool_xml, cur_legal_info_ctx->authoring_tool_xml_size, path);
|
|
|
|
|
|
|
|
consolePrint("legal info xml succeeded (%s | id offset #%u)\n", cur_nca_ctx->content_id_str, cur_nca_ctx->id_offset);
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2020-10-06 16:41:26 +01:00
|
|
|
}
|
2020-10-09 10:58:53 +01:00
|
|
|
}
|
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
out2:
|
|
|
|
if (exit_prompt)
|
|
|
|
{
|
|
|
|
consolePrint("press any button to exit\n");
|
2020-12-04 06:38:44 +00:00
|
|
|
utilsWaitForButtonPress(0);
|
2020-10-02 10:53:58 +01:00
|
|
|
}
|
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
if (legal_info_ctx)
|
|
|
|
{
|
|
|
|
for(u32 i = 0; i < legal_info_count; i++) legalInfoFreeContext(&(legal_info_ctx[i]));
|
|
|
|
free(legal_info_ctx);
|
|
|
|
}
|
2020-10-09 10:58:53 +01:00
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
if (nacp_ctx)
|
|
|
|
{
|
|
|
|
for(u32 i = 0; i < control_count; i++) nacpFreeContext(&(nacp_ctx[i]));
|
|
|
|
free(nacp_ctx);
|
|
|
|
}
|
2020-10-08 19:31:09 +01:00
|
|
|
|
2020-10-12 21:35:47 +01:00
|
|
|
if (program_info_ctx)
|
|
|
|
{
|
|
|
|
for(u32 i = 0; i < program_count; i++) programInfoFreeContext(&(program_info_ctx[i]));
|
|
|
|
free(program_info_ctx);
|
|
|
|
}
|
2020-10-11 19:13:09 +01:00
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
cnmtFreeContext(&cnmt_ctx);
|
|
|
|
|
|
|
|
if (nca_ctx) free(nca_ctx);
|
|
|
|
|
2021-06-01 02:12:15 +01:00
|
|
|
titleFreeUserApplicationData(&user_app_data);
|
|
|
|
|
2020-10-02 10:53:58 +01:00
|
|
|
if (app_metadata) free(app_metadata);
|
|
|
|
|
|
|
|
out:
|
|
|
|
utilsCloseResources();
|
|
|
|
|
|
|
|
consoleExit(NULL);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|