Skip to content

Commit

Permalink
QoL changes
Browse files Browse the repository at this point in the history
* codebase: remove all references to Lockpick / Lockpick_RCM.

* keys: retrieve Atmosphère's key generation in keysLoadKeyset().
* keys: replace all "key_gen_val" references with "mkey_index".
* keys: move latest master key checks in keysReadKeysFromFile() to keysDeriveMasterKeys().
* keys: update latest master key checks to determine if nxdumptool's hardcoded master key vectors are outdated, using the key generation value from Atmosphère. If the master key vectors are outdated, and the newer master key(s) are not available, an error will be displayed.

* nxdt_utils: update logic in utilsReplaceIllegalCharacters() to replace consecutive illegal characters with a single underscore.
* nxdt_utils: move servicesGetExosphereApiVersion() to nxdt_utils as utilsGetExosphereApiVersion().
* nxdt_utils: define internal UtilsExosphereApiVersion struct, which is used to parse the output from utilsGetExosphereApiVersion().
* nxdt_utils: add utilsGetAtmosphereVersion(), utilsGetAtmosphereKeyGeneration() and utilsGetAtmosphereTargetFirmware() functions.

* services: remove servicesGetExosphereApiVersion().
* services: Atmosphère version is now retrieved via utilsGetAtmosphereVersion().
  • Loading branch information
DarkMatterCore committed Apr 5, 2024
1 parent e3cd2a1 commit 54c5677
Show file tree
Hide file tree
Showing 9 changed files with 203 additions and 125 deletions.
2 changes: 1 addition & 1 deletion include/core/keys.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
extern "C" {
#endif

/// Loads (and derives) keydata from sysmodule program memory, the Lockpick_RCM keys file and hardcoded/obfuscated information.
/// Loads (and derives) keydata from sysmodule program memory, a keys file and hardcoded/obfuscated information.
/// Must be called (and succeed) before calling any of the functions below.
bool keysLoadKeyset(void);

Expand Down
18 changes: 15 additions & 3 deletions include/core/nxdt_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,17 @@ FsFileSystem *utilsGetSdCardFileSystemObject(void);
/// Must be used after closing a file handle from the SD card.
bool utilsCommitSdCardFileSystemChanges(void);

/// Returns an integer that represents the full Atmosphère release version.
/// Use the HOSVER_* macros to retrieve specific version numbers from it.
u32 utilsGetAtmosphereVersion(void);

/// Returns an integer that represents the global key generation used by Atmosphère.
/// The returned value represents an index, so it doesn't match 1:1 the NcaKeyGeneration enum.
u8 utilsGetAtmosphereKeyGeneration(void);

/// Fills the provided SdkAddOnVersion element with the target firmware set by Atmosphère.
void utilsGetAtmosphereTargetFirmware(SdkAddOnVersion *out);

/// Returns a UtilsCustomFirmwareType value.
u8 utilsGetCustomFirmwareType(void);

Expand Down Expand Up @@ -113,9 +124,10 @@ void utilsJoinThread(Thread *thread);
/// If the buffer isn't big enough to hold both its current contents and the new formatted string, it will be resized.
__attribute__((format(printf, 3, 4))) bool utilsAppendFormattedStringToBuffer(char **dst, size_t *dst_size, const char *fmt, ...);

/// Replaces illegal FAT characters in the provided UTF-8 string with underscores.
/// If 'ascii_only' is set to true, all codepoints outside the [0x20,0x7F) range will also be replaced with underscores.
/// Replacements are performed on a per-codepoint basis, which means the string length can be reduced by this function.
/// Replaces illegal filesystem characters in the provided NULL-terminated UTF-8 string with underscores ('_').
/// If 'ascii_only' is set to true, all codepoints outside of the [0x20,0x7F) range will also be replaced with underscores.
/// Replacements are performed on a per-codepoint basis, which means the string size in bytes can be reduced by this function.
/// Furthermore, if multiple, consecutive illegal characters are found, they will all get replaced by a single underscore.
void utilsReplaceIllegalCharacters(char *str, bool ascii_only);

/// Trims whitespace characters from the provided string.
Expand Down
6 changes: 3 additions & 3 deletions include/core/services.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,11 @@ bool servicesInitialize();
/// Closes services previously initialized by servicesInitialize().
void servicesClose();

/// Check if a service has been initialized using its name.
/// Check if a service has been initialized by this interface using its name.
bool servicesCheckInitializedServiceByName(const char *name);

/// Checks if a service is running using its name.
/// Wrapper for the "AtmosphereHasService" SM API extension from Atmosphère and Atmosphère-based CFWs.
/// Checks if a service is running using its name, even if it wasn't initialized by this interface.
/// This servers as a wrapper for the "AtmosphereHasService" SM API extension from Atmosphère and Atmosphère-based CFWs.
/// Perfectly safe to use under development units. Not available in older Atmosphère releases.
bool servicesCheckRunningServiceByName(const char *name);

Expand Down
7 changes: 5 additions & 2 deletions include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
#define NRO_PATH DEVOPTAB_SDMC_DEVICE APP_BASE_PATH NRO_NAME
#define NRO_TMP_PATH NRO_PATH ".tmp"

#define PROD_KEYS_FILE_PATH DEVOPTAB_SDMC_DEVICE HBMENU_BASE_PATH "prod.keys" /* Location used by Lockpick_RCM for retail unit keys. */
#define DEV_KEYS_FILE_PATH DEVOPTAB_SDMC_DEVICE HBMENU_BASE_PATH "dev.keys" /* Location used by Lockpick_RCM for development unit keys. */
#define PROD_KEYS_FILE_PATH DEVOPTAB_SDMC_DEVICE HBMENU_BASE_PATH "prod.keys" /* Retail unit keys. */
#define DEV_KEYS_FILE_PATH DEVOPTAB_SDMC_DEVICE HBMENU_BASE_PATH "dev.keys" /* Development unit keys. */

#define LOG_FILE_NAME APP_TITLE ".log"
#define LOG_BUF_SIZE 0x400000 /* 4 MiB. */
Expand Down Expand Up @@ -133,4 +133,7 @@

#define DISCORD_SERVER_URL "https://discord.gg/SCbbcQx"

// TODO: remove this after the PoC builds are no longer needed.
#define PRERELEASE_URL GITHUB_URL "/" APP_AUTHOR "/nxdumptool/releases/tag/rewrite-prerelease"

#endif /* __DEFINES_H__ */
21 changes: 11 additions & 10 deletions romfs/i18n/en-US/about_tab.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"description": "Nintendo Switch Dump Tool",

"copyright": "Licensed under GPLv3+\n\u00A9 2020 - 2022 {0}\n{1}",
"copyright": "Licensed under GPLv3+\n\u00A9 2020 - 2024 {0}\n{1}",

"dependencies": {
"header": "Dependencies",
Expand All @@ -16,15 +16,16 @@
"header": "Acknowledgments",
"line_00": "\uE016 Switchbrew and libnx contributors.",
"line_01": "\uE016 SciresM, for hactool, hac2l and Atmosphère-NX.",
"line_02": "\uE016 shchmue, for Lockpick and its runtime key-collection algorithm, as well as helping with reverse engineering tasks.",
"line_03": "\uE016 Adubbz, for Tinfoil and its ES service bindings.",
"line_04": "\uE016 RattletraPM, for the awesome icon.",
"line_05": "\uE016 Whovian9369, for being a key piece throughout the whole development by providing lots of testing and cool ideas.",
"line_06": "\uE016 liamadvance, Shadów and SimonTime, for their tremendous help in understanding Nintendo Switch file and data formats.",
"line_07": "\uE016 The folks from NSWDB.COM and No-Intro.org, for being kind enough to put up public APIs to perform online checksum lookups.",
"line_08": "\uE016 The folks at the nxdumptool Discord server.",
"line_09": "\uE016 The Comfy Boyes, for always being awesome and supportive. You know who you are.",
"line_10": "\uE016 And, at last but not least, you! Thank you for using my work!"
"line_02": "\uE016 Moosehunter, for LibHac and hactoolnet.",
"line_03": "\uE016 shchmue, for the runtime key derivation algorithm, as well as helping with reverse engineering tasks.",
"line_04": "\uE016 Adubbz, for Tinfoil and its ES service bindings.",
"line_05": "\uE016 RattletraPM, for the awesome icon.",
"line_06": "\uE016 Whovian9369, for being a key piece throughout the whole development by providing lots of testing and cool ideas.",
"line_07": "\uE016 liamadvance, Shadów and SimonTime, for their tremendous help in understanding Nintendo Switch file and data formats.",
"line_08": "\uE016 The folks from NSWDB.COM and No-Intro.org, for being kind enough to put up public APIs to perform online checksum lookups.",
"line_09": "\uE016 The folks at the nxdumptool Discord server.",
"line_10": "\uE016 The Comfy Boyes, for always being awesome and supportive. You know who you are.",
"line_11": "\uE016 And, at last but not least, you! Thank you for using my work!"
},

"links": {
Expand Down
2 changes: 1 addition & 1 deletion source/about_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace nxdt::views
/* Acknowledgments. */
this->addView(new brls::Header("about_tab/acknowledgments/header"_i18n));
for(int i = 0; i < 7; i++) this->addView(new AboutTabLabel(brls::LabelStyle::SMALL, i18n::getStr(fmt::format("about_tab/acknowledgments/line_{:02d}", i))));
for(int i = 7; i < 11; i++) this->addView(new brls::Label(brls::LabelStyle::SMALL, i18n::getStr(fmt::format("about_tab/acknowledgments/line_{:02d}", i)), true));
for(int i = 7; i < 12; i++) this->addView(new brls::Label(brls::LabelStyle::SMALL, i18n::getStr(fmt::format("about_tab/acknowledgments/line_{:02d}", i)), true));

/* Additional links and resources. */
this->addView(new brls::Header("about_tab/links/header"_i18n));
Expand Down
Loading

0 comments on commit 54c5677

Please sign in to comment.