From 789a6d6eb84391b4a23a6a75b3b1cca2850f5e99 Mon Sep 17 00:00:00 2001 From: Pablo Curiel Date: Fri, 12 Apr 2024 13:40:50 +0200 Subject: [PATCH] [skip ci] GameCardTab: reflect current gamecard dump options Other changes include: * gamecard: rename gamecardGetDecryptedCardInfoArea() -> gamecardGetPlaintextCardInfoArea(). * FocusableItem, FocusableTable: add positional arguments for the FocusableItem class constructor. --- code_templates/nxdt_rw_poc.c | 4 +-- include/about_tab.hpp | 2 +- include/core/gamecard.h | 2 +- include/focusable_item.hpp | 4 +-- libs/borealis | 2 +- romfs/i18n/en-US/gamecard_tab.json | 46 +++++++++++++++++++++++------- source/core/gamecard.c | 8 +++--- source/gamecard_tab.cpp | 41 ++++++++++++++++++++------ source/options_tab.cpp | 4 +-- 9 files changed, 81 insertions(+), 32 deletions(-) diff --git a/code_templates/nxdt_rw_poc.c b/code_templates/nxdt_rw_poc.c index f26cc46..f711f12 100644 --- a/code_templates/nxdt_rw_poc.c +++ b/code_templates/nxdt_rw_poc.c @@ -2641,7 +2641,7 @@ static bool saveGameCardCardInfo(void *userdata) u32 crc = 0; char *filename = NULL; - if (!gamecardGetDecryptedCardInfoArea(&gc_cardinfo)) + if (!gamecardGetPlaintextCardInfoArea(&gc_cardinfo)) { consolePrint("failed to get gamecard cardinfo\n"); goto end; @@ -3494,7 +3494,7 @@ static bool browseNintendoContentArchiveFsSection(void *userdata) pfs_ctx = (PartitionFileSystemContext*)fs_ctx; nca_fs_ctx = pfs_ctx->nca_fs_ctx; - snprintf(mount_name, MAX_ELEMENTS(mount_name), "%s", pfs_ctx->is_exefs ? "exefs" : "pfs"); + snprintf(mount_name, MAX_ELEMENTS(mount_name), "%s", pfs_ctx->is_exefs ? "ncaexefs" : "ncapfs"); if (!devoptabMountPartitionFileSystemDevice(pfs_ctx, mount_name)) { diff --git a/include/about_tab.hpp b/include/about_tab.hpp index 772d8f2..b2854b4 100644 --- a/include/about_tab.hpp +++ b/include/about_tab.hpp @@ -33,7 +33,7 @@ namespace nxdt::views class AboutTabLabel: public FocusableLabel { public: - AboutTabLabel(brls::LabelStyle labelStyle, std::string text, bool center = false) : FocusableLabel(labelStyle, text, true) + AboutTabLabel(brls::LabelStyle labelStyle, std::string text, bool center = false) : FocusableLabel(false, false, labelStyle, text, true) { if (center) this->setHorizontalAlign(NVG_ALIGN_CENTER); } diff --git a/include/core/gamecard.h b/include/core/gamecard.h index 8ea1323..6e11bc7 100644 --- a/include/core/gamecard.h +++ b/include/core/gamecard.h @@ -307,7 +307,7 @@ bool gamecardReadStorage(void *out, u64 read_size, u64 offset); bool gamecardGetHeader(GameCardHeader *out); /// Fills the provided GameCardInfo pointer. -bool gamecardGetDecryptedCardInfoArea(GameCardInfo *out); +bool gamecardGetPlaintextCardInfoArea(GameCardInfo *out); /// Fills the provided FsGameCardCertificate pointer. /// This area can also be read using gamecardReadStorage(), starting at GAMECARD_CERTIFICATE_OFFSET. diff --git a/include/focusable_item.hpp b/include/focusable_item.hpp index fa5b274..1ac171a 100644 --- a/include/focusable_item.hpp +++ b/include/focusable_item.hpp @@ -70,14 +70,14 @@ namespace nxdt::views { public: template - FocusableLabel(Types... args) : FocusableItem(false, false, args...) { } + FocusableLabel(bool highlight, bool highlight_bg, Types... args) : FocusableItem(highlight, highlight_bg, args...) { } }; class FocusableTable: public FocusableItem { public: template - FocusableTable(Types... args) : FocusableItem(true, false, args...) { } + FocusableTable(bool highlight, bool highlight_bg, Types... args) : FocusableItem(highlight, highlight_bg, args...) { } }; } diff --git a/libs/borealis b/libs/borealis index 2112222..7383102 160000 --- a/libs/borealis +++ b/libs/borealis @@ -1 +1 @@ -Subproject commit 21122223a496b313c2d45cb02cabfc0e4680e7e7 +Subproject commit 73831023b18d2c60df532bafbf61b1c18c2ab4f0 diff --git a/romfs/i18n/en-US/gamecard_tab.json b/romfs/i18n/en-US/gamecard_tab.json index 5cbf3c5..74af191 100644 --- a/romfs/i18n/en-US/gamecard_tab.json +++ b/romfs/i18n/en-US/gamecard_tab.json @@ -22,7 +22,6 @@ "trimmed_size": "Trimmed size", "update_version": "Bundled update version", "lafw_version": "Required LAFW version", - "lafw_version_value": "%lu or greater (%s)", "sdk_version": "SDK version", "compatibility_type": "Compatibility type", "package_id": "Package ID", @@ -36,29 +35,56 @@ "description": "Generates a raw gamecard image. This is the option most people will want to use." }, + "advanced_disclaimer": "The following options are considered advanced and are mostly aimed at developers, preservationists and experienced users.", + + "dump_initial_data": { + "label": "Dump InitialData area", + "description": "The InitialData area holds cryptographic information used by the Lotus ASIC to communicate with the gamecard.\nIt can't be dumped through normal means -- it's not part of the storage areas from gamecard images." + }, + "dump_certificate": { "label": "Dump gamecard certificate", - "description": "The gamecard certificate is used to unequivocally identify each individual gamecard." + "description": "The gamecard certificate serves to unequivocally identify each individual gamecard.\nIt's mostly used for online operations, and it's stored at sector {0} in all gamecard images." + }, + + "dump_card_id_set": { + "label": "Dump card ID set", + "description": "The card ID set is composed of three 32-bit integers that hold information such as the gamecard's memory type and manufacturer.\nIt can't be dumped through normal means -- it's not part of the storage areas from gamecard images." + }, + + "dump_card_uid": { + "label": "Dump card UID", + "description": "The card UID is a 64-byte long area that serves as a unique identifier for the gamecard. It's mostly used in security contexts.\nIt can't be dumped through normal means -- it's not part of the storage areas from gamecard images." }, "dump_header": { "label": "Dump gamecard header", - "description": "The gamecard header holds information such as the location of the root HFS partition and the gamecard capacity.\nOnly useful for developers, preservationists and advanced users." + "description": "The gamecard header holds information such as the location of the root HFS partition and the gamecard capacity.\nIt's stored at sector {0} in all gamecard images." }, - "dump_decrypted_cardinfo": { - "label": "Dump decrypted CardInfo area", - "description": "The CardInfo area holds information such as the bundled system update version and the Lotus ASIC firmware version required by the gamecard.\nThis area is part of the gamecard header, but it's always encrypted.\nOnly useful for developers, preservationists and advanced users." + "dump_plaintext_cardinfo": { + "label": "Dump plaintext CardInfo area", + "description": "The CardInfo area holds information such as the bundled system update version and the Lotus ASIC firmware version required by the gamecard.\nThis area is part of the gamecard header, but it's always encrypted." }, - "dump_initial_data": { - "label": "Dump InitialData area", - "description": "The InitialData area holds cryptographic information used by the Lotus ASIC to communicate with the gamecard.\nIt can't be dumped through normal means - it's not part of the storage areas from gamecard images.\nOnly useful for developers, preservationists and advanced users." + "dump_specific_data": { + "label": "Dump SpecificData area", + "description": "The SpecificData area is internally generated by the FS sysmodule, which means it can't be dumped through normal means.\nIt holds security data used at runtime by the Lotus ASIC." }, "dump_hfs_partitions": { "label": "Dump Hash File System (HFS) partitions", - "description": "Dumps data from the HFS partitions within the gamecard storage areas, in both raw and extracted forms." + "description": "Dumps data from the HFS partitions located within the gamecard storage areas, in both raw and extracted forms." + }, + + "browse_hfs_partitions": { + "label": "Browse Hash File System (HFS) partitions", + "description": "Displays a filesystem browser with file dumping capabilities using a specific gamecard HFS partition." + }, + + "dump_lafw": { + "label": "Dump Lotus ASIC firmware (LAFW) blob", + "description": "Dumps the encrypted LAFW blob stored within the FS sysmodule program memory." } } } diff --git a/source/core/gamecard.c b/source/core/gamecard.c index 3d79af0..7df9314 100644 --- a/source/core/gamecard.c +++ b/source/core/gamecard.c @@ -127,7 +127,7 @@ static void gamecardFreeInfo(bool clear_status); static bool gamecardReadHeader(void); -static bool _gamecardGetDecryptedCardInfoArea(void); +static bool _gamecardGetPlaintextCardInfoArea(void); static bool gamecardReadSecurityInformation(GameCardSecurityInformation *out); @@ -357,7 +357,7 @@ bool gamecardGetHeader(GameCardHeader *out) return ret; } -bool gamecardGetDecryptedCardInfoArea(GameCardInfo *out) +bool gamecardGetPlaintextCardInfoArea(GameCardInfo *out) { bool ret = false; @@ -737,7 +737,7 @@ static void gamecardLoadInfo(void) if (!gamecardReadHeader()) goto end; /* Get decrypted CardInfo area from header. */ - if (!_gamecardGetDecryptedCardInfoArea()) goto end; + if (!_gamecardGetPlaintextCardInfoArea()) goto end; /* Check if we meet the Lotus ASIC firmware (LAFW) version requirement. */ if (g_lafwVersion < g_gameCardInfoArea.fw_version) @@ -889,7 +889,7 @@ static bool gamecardReadHeader(void) return true; } -static bool _gamecardGetDecryptedCardInfoArea(void) +static bool _gamecardGetPlaintextCardInfoArea(void) { const u8 *card_info_key = NULL; u8 card_info_iv[AES_128_KEY_SIZE] = {0}; diff --git a/source/gamecard_tab.cpp b/source/gamecard_tab.cpp index d47dd12..e6ec89c 100644 --- a/source/gamecard_tab.cpp +++ b/source/gamecard_tab.cpp @@ -128,7 +128,7 @@ namespace nxdt::views /* Information about how to handle HOS launch errors. */ /* TODO: remove this if we ever find a way to fix this issue. */ - FocusableLabel *launch_error_info = new FocusableLabel(brls::LabelStyle::DESCRIPTION, "gamecard_tab/list/launch_error_info"_i18n, true); + FocusableLabel *launch_error_info = new FocusableLabel(true, false, brls::LabelStyle::DESCRIPTION, "gamecard_tab/list/launch_error_info"_i18n, true); launch_error_info->setHorizontalAlign(NVG_ALIGN_CENTER); this->list->addView(launch_error_info); @@ -160,7 +160,7 @@ namespace nxdt::views /* Populate gamecard properties table. */ this->list->addView(new brls::Header("gamecard_tab/list/properties_table/header"_i18n)); - FocusableTable *properties_table = new FocusableTable(); + FocusableTable *properties_table = new FocusableTable(true, false); brls::TableRow *capacity = properties_table->addRow(brls::TableRowType::BODY, "gamecard_tab/list/properties_table/capacity"_i18n); brls::TableRow *total_size = properties_table->addRow(brls::TableRowType::BODY, "gamecard_tab/list/properties_table/total_size"_i18n); brls::TableRow *trimmed_size = properties_table->addRow(brls::TableRowType::BODY, "gamecard_tab/list/properties_table/trimmed_size"_i18n); @@ -176,7 +176,7 @@ namespace nxdt::views trimmed_size->setValue(this->GetFormattedSizeString(&gamecardGetTrimmedSize)); gamecardGetHeader(&card_header); - gamecardGetDecryptedCardInfoArea(&card_info); + gamecardGetPlaintextCardInfoArea(&card_info); gamecardGetCardIdSet(&card_id_set); const SystemVersion upp_version = card_info.upp_version.system_version; @@ -257,21 +257,44 @@ namespace nxdt::views this->list->addView(dump_card_image); - brls::ListItem *dump_certificate = new brls::ListItem("gamecard_tab/list/dump_certificate/label"_i18n, "gamecard_tab/list/dump_certificate/description"_i18n); - this->list->addView(dump_certificate); + this->list->addView(new brls::ListItemGroupSpacing(true)); - brls::ListItem *dump_header = new brls::ListItem("gamecard_tab/list/dump_header/label"_i18n, "gamecard_tab/list/dump_header/description"_i18n); - this->list->addView(dump_header); + brls::Label *advanced_disclaimer = new brls::Label(brls::LabelStyle::DESCRIPTION, "gamecard_tab/list/advanced_disclaimer"_i18n, true); + advanced_disclaimer->setHorizontalAlign(NVG_ALIGN_CENTER); + this->list->addView(advanced_disclaimer); - brls::ListItem *dump_decrypted_cardinfo = new brls::ListItem("gamecard_tab/list/dump_decrypted_cardinfo/label"_i18n, "gamecard_tab/list/dump_decrypted_cardinfo/description"_i18n); - this->list->addView(dump_decrypted_cardinfo); + this->list->addView(new brls::ListItemGroupSpacing(true)); brls::ListItem *dump_initial_data = new brls::ListItem("gamecard_tab/list/dump_initial_data/label"_i18n, "gamecard_tab/list/dump_initial_data/description"_i18n); this->list->addView(dump_initial_data); + brls::ListItem *dump_certificate = new brls::ListItem("gamecard_tab/list/dump_certificate/label"_i18n, fmt::format("gamecard_tab/list/dump_certificate/description"_i18n, GAMECARD_CERTIFICATE_OFFSET / GAMECARD_PAGE_SIZE)); + this->list->addView(dump_certificate); + + brls::ListItem *dump_card_id_set = new brls::ListItem("gamecard_tab/list/dump_card_id_set/label"_i18n, "gamecard_tab/list/dump_card_id_set/description"_i18n); + this->list->addView(dump_card_id_set); + + brls::ListItem *dump_card_uid = new brls::ListItem("gamecard_tab/list/dump_card_uid/label"_i18n, "gamecard_tab/list/dump_card_uid/description"_i18n); + this->list->addView(dump_card_uid); + + brls::ListItem *dump_header = new brls::ListItem("gamecard_tab/list/dump_header/label"_i18n, fmt::format("gamecard_tab/list/dump_header/description"_i18n, 0)); + this->list->addView(dump_header); + + brls::ListItem *dump_plaintext_cardinfo = new brls::ListItem("gamecard_tab/list/dump_plaintext_cardinfo/label"_i18n, "gamecard_tab/list/dump_plaintext_cardinfo/description"_i18n); + this->list->addView(dump_plaintext_cardinfo); + + brls::ListItem *dump_specific_data = new brls::ListItem("gamecard_tab/list/dump_specific_data/label"_i18n, "gamecard_tab/list/dump_specific_data/description"_i18n); + this->list->addView(dump_specific_data); + brls::ListItem *dump_hfs_partitions = new brls::ListItem("gamecard_tab/list/dump_hfs_partitions/label"_i18n, "gamecard_tab/list/dump_hfs_partitions/description"_i18n); this->list->addView(dump_hfs_partitions); + brls::ListItem *browse_hfs_partitions = new brls::ListItem("gamecard_tab/list/browse_hfs_partitions/label"_i18n, "gamecard_tab/list/browse_hfs_partitions/description"_i18n); + this->list->addView(browse_hfs_partitions); + + brls::ListItem *dump_lafw = new brls::ListItem("gamecard_tab/list/dump_lafw/label"_i18n, "gamecard_tab/list/dump_lafw/description"_i18n); + this->list->addView(dump_lafw); + /* Update focus stack, if needed. */ if (focus_stack_index > -1) this->UpdateFocusStackViewAtIndex(focus_stack_index, this->GetListFirstFocusableChild()); diff --git a/source/options_tab.cpp b/source/options_tab.cpp index 2ac937c..5d48e24 100644 --- a/source/options_tab.cpp +++ b/source/options_tab.cpp @@ -293,7 +293,7 @@ namespace nxdt::views std::stringstream ss(std::string(this->json_data.changelog)); /* Display version string at the top. */ - FocusableLabel *version_lbl = new FocusableLabel(brls::LabelStyle::CRASH, std::string(this->json_data.version), true); + FocusableLabel *version_lbl = new FocusableLabel(true, false, brls::LabelStyle::CRASH, std::string(this->json_data.version), true); version_lbl->setHorizontalAlign(NVG_ALIGN_CENTER); this->changelog_list->addView(version_lbl); @@ -327,7 +327,7 @@ namespace nxdt::views /* Add line to the changelog view. */ if (!(line % 2)) { - this->changelog_list->addView(new FocusableLabel(brls::LabelStyle::SMALL, item, true)); + this->changelog_list->addView(new FocusableLabel(false, false, brls::LabelStyle::SMALL, item, true)); } else { this->changelog_list->addView(new brls::Label(brls::LabelStyle::SMALL, item, true)); }