1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-22 18:26:39 +00:00

romfs_dumper: get latest patch from linked list.

This commit is contained in:
Pablo Curiel 2022-03-17 20:29:44 +01:00
parent 2fa61dc228
commit 9604b5923d
2 changed files with 46 additions and 4 deletions

View file

@ -357,6 +357,25 @@ u8 get_program_id_offset(TitleInfo *info, u32 program_count)
return (applet_status ? id_offset : (u8)program_count); return (applet_status ? id_offset : (u8)program_count);
} }
static TitleInfo *get_latest_patch_info(TitleInfo *patch_info)
{
if (!patch_info || patch_info->meta_key.type != NcmContentMetaType_Patch) return NULL;
TitleInfo *output = patch_info, *tmp = patch_info;
u32 highest_version = patch_info->version.value;
while((tmp = tmp->next) != NULL)
{
if (tmp->version.value > highest_version)
{
output = tmp;
highest_version = output->version.value;
}
}
return output;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret = 0; int ret = 0;
@ -569,8 +588,10 @@ int main(int argc, char *argv[])
if (user_app_data.patch_info) if (user_app_data.patch_info)
{ {
if (!ncaInitializeContext(update_nca_ctx, user_app_data.patch_info->storage_id, (user_app_data.patch_info->storage_id == NcmStorageId_GameCard ? GameCardHashFileSystemPartitionType_Secure : 0), \ TitleInfo *latest_patch = get_latest_patch_info(user_app_data.patch_info);
titleGetContentInfoByTypeAndIdOffset(user_app_data.patch_info, NcmContentType_Program, program_id_offset), NULL))
if (!ncaInitializeContext(update_nca_ctx, latest_patch->storage_id, (latest_patch->storage_id == NcmStorageId_GameCard ? GameCardHashFileSystemPartitionType_Secure : 0), \
titleGetContentInfoByTypeAndIdOffset(latest_patch, NcmContentType_Program, program_id_offset), NULL))
{ {
consolePrint("nca initialize update ctx failed\n"); consolePrint("nca initialize update ctx failed\n");
goto out2; goto out2;

View file

@ -336,6 +336,25 @@ u8 get_program_id_offset(TitleInfo *info, u32 program_count)
return (applet_status ? id_offset : (u8)program_count); return (applet_status ? id_offset : (u8)program_count);
} }
static TitleInfo *get_latest_patch_info(TitleInfo *patch_info)
{
if (!patch_info || patch_info->meta_key.type != NcmContentMetaType_Patch) return NULL;
TitleInfo *output = patch_info, *tmp = patch_info;
u32 highest_version = patch_info->version.value;
while((tmp = tmp->next) != NULL)
{
if (tmp->version.value > highest_version)
{
output = tmp;
highest_version = output->version.value;
}
}
return output;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int ret = 0; int ret = 0;
@ -542,8 +561,10 @@ int main(int argc, char *argv[])
if (user_app_data.patch_info) if (user_app_data.patch_info)
{ {
if (!ncaInitializeContext(update_nca_ctx, user_app_data.patch_info->storage_id, (user_app_data.patch_info->storage_id == NcmStorageId_GameCard ? GameCardHashFileSystemPartitionType_Secure : 0), \ TitleInfo *latest_patch = get_latest_patch_info(user_app_data.patch_info);
titleGetContentInfoByTypeAndIdOffset(user_app_data.patch_info, NcmContentType_Program, program_id_offset), NULL))
if (!ncaInitializeContext(update_nca_ctx, latest_patch->storage_id, (latest_patch->storage_id == NcmStorageId_GameCard ? GameCardHashFileSystemPartitionType_Secure : 0), \
titleGetContentInfoByTypeAndIdOffset(latest_patch, NcmContentType_Program, program_id_offset), NULL))
{ {
consolePrint("nca initialize update ctx failed\n"); consolePrint("nca initialize update ctx failed\n");
goto out2; goto out2;