mirror of
https://github.com/DarkMatterCore/nxdumptool.git
synced 2024-12-23 00:52:10 +00:00
romfs_dumper: get latest patch from linked list.
This commit is contained in:
parent
2fa61dc228
commit
9604b5923d
2 changed files with 46 additions and 4 deletions
|
@ -357,6 +357,25 @@ u8 get_program_id_offset(TitleInfo *info, u32 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 ret = 0;
|
||||
|
@ -569,8 +588,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
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), \
|
||||
titleGetContentInfoByTypeAndIdOffset(user_app_data.patch_info, NcmContentType_Program, program_id_offset), NULL))
|
||||
TitleInfo *latest_patch = get_latest_patch_info(user_app_data.patch_info);
|
||||
|
||||
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");
|
||||
goto out2;
|
||||
|
|
|
@ -336,6 +336,25 @@ u8 get_program_id_offset(TitleInfo *info, u32 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 ret = 0;
|
||||
|
@ -542,8 +561,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
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), \
|
||||
titleGetContentInfoByTypeAndIdOffset(user_app_data.patch_info, NcmContentType_Program, program_id_offset), NULL))
|
||||
TitleInfo *latest_patch = get_latest_patch_info(user_app_data.patch_info);
|
||||
|
||||
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");
|
||||
goto out2;
|
||||
|
|
Loading…
Reference in a new issue