hac2l: parse patches and apps separately in appfs

This commit is contained in:
Michael Scire 2022-06-10 14:53:46 -07:00
parent 9dc4aa70bd
commit bec2e55748
5 changed files with 33 additions and 4 deletions

View File

@ -264,6 +264,9 @@ namespace ams::hactool {
/* Get the version. */
const auto version = meta_header->version;
/* We'll want to insert into the appropriate tracking holder. */
auto &target = meta_header->type == ncm::ContentMetaType::Patch ? ctx->patches : ctx->apps;
/* Add all the content metas. */
for (size_t i = 0; i < meta_reader.GetContentCount(); ++i) {
const auto &info = *meta_reader.GetContentInfo(i);
@ -274,7 +277,7 @@ namespace ams::hactool {
}
/* Check that we don't already have an info for the content. */
if (auto existing = ctx->apps.Find(*app_id, version, info.GetIdOffset(), info.GetType()); existing != ctx->apps.end()) {
if (auto existing = target.Find(*app_id, version, info.GetIdOffset(), info.GetType()); existing != target.end()) {
fprintf(stderr, "[Warning]: Ignoring duplicate entry { %016" PRIX64 ", %" PRIu32 ", %d, %d }\n", app_id->value, version, static_cast<int>(info.GetIdOffset()), static_cast<int>(info.GetType()));
continue;
}
@ -301,7 +304,7 @@ namespace ams::hactool {
}
/* Add the new version for the content. */
auto *entry = ctx->apps.Insert(*app_id, version, info.GetIdOffset(), info.GetType());
auto *entry = target.Insert(*app_id, version, info.GetIdOffset(), info.GetType());
entry->GetData().storage = std::move(storage);
}
@ -348,6 +351,18 @@ namespace ams::hactool {
this->PrintFormat(field_name, "{ Idx=%d, ProgramId=%016" PRIX64 ", Version=0x%08" PRIX32 ", IdOffset=%02" PRIX32 " }", app_idx, entry.GetId().value, entry.GetVersion(), entry.GetIdOffset());
field_name = "";
}
if (ctx.patches.begin() != ctx.patches.end()) {
field_name = "Patches";
for (const auto &entry : ctx.patches) {
if (entry.GetType() != ncm::ContentType::Program) {
continue;
}
this->PrintFormat(field_name, "{ ProgramId=%016" PRIX64 ", Version=0x%08" PRIX32 ", IdOffset=%02" PRIX32 " }", entry.GetId().value, entry.GetVersion(), entry.GetIdOffset());
field_name = "";
}
}
}
/* TODO */

View File

@ -83,6 +83,7 @@ namespace ams::hactool {
};
ApplicationContentsHolder<ApplicationEntryData> apps;
ApplicationContentsHolder<ApplicationEntryData> patches;
};
struct ProcessAsXciContext {

View File

@ -106,7 +106,7 @@ namespace ams::hactool {
/* Set output reader. */
*out = std::move(nca_reader);
return ResultSuccess();
R_SUCCEED();
}
}
@ -191,7 +191,7 @@ namespace ams::hactool {
break;
}
} else {
fprintf(stderr, "[Warning]: Failed to open NCA section %d: 2%03d-%04d, NCA may be corrupt.\n", i, res.GetModule(), res.GetDescription());
fprintf(stderr, "[Warning]: Failed to open NCA section %d: 2%03d-%04d, NCA may be corrupt.\n", i, real_res.GetModule(), real_res.GetDescription());
}
} else if (fs::ResultPartitionNotFound::Includes(res)) {
ctx->has_sections[i] = false;

View File

@ -603,6 +603,7 @@ namespace ams::hactool {
this->PrintMagic(ctx.acid->magic);
this->PrintHex("Version", ctx.acid->version);
this->PrintHex("Unknown 209", ctx.acid->unknown_209);
this->PrintHex("Sign Key Generation", ctx.npdm->signature_key_generation);

View File

@ -375,6 +375,18 @@ namespace ams::hactool {
this->PrintFormat(field_name, "{ Idx=%d, ProgramId=%016" PRIX64 ", Version=0x%08" PRIX32 ", IdOffset=%02" PRIX32 " }", app_idx, entry.GetId().value, entry.GetVersion(), entry.GetIdOffset());
field_name = "";
}
if (ctx.app_ctx.patches.begin() != ctx.app_ctx.patches.end()) {
field_name = "Patches";
for (const auto &entry : ctx.app_ctx.patches) {
if (entry.GetType() != ncm::ContentType::Program) {
continue;
}
this->PrintFormat(field_name, "{ ProgramId=%016" PRIX64 ", Version=0x%08" PRIX32 ", IdOffset=%02" PRIX32 " }", entry.GetId().value, entry.GetVersion(), entry.GetIdOffset());
field_name = "";
}
}
}
AMS_UNUSED(ctx);