1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-23 02:36:41 +00:00
Commit graph

423 commits

Author SHA1 Message Date
Pablo Curiel
962cf00ba9 Display a CrashFrame warning at startup if the application is running under applet mode.
Other changes include:

* defines: added NON_MOVEABLE macro.
* AsyncTask: set class as non-moveable, too.
* RootView: provide an override for getDefaultFocus().
* StatusInfoTask: replace GetStatusInfoData with IsInternetConnectionAvailable().
2021-07-30 17:07:26 -04:00
Pablo Curiel
bc842d8905 OptionsTab: check if an Internet connection is available before starting an update. 2021-07-29 15:55:31 -04:00
Pablo Curiel
841fd73fbf utils: implement utilsSetLongRunningProcessState().
Other changes include:

* DownloadTask: use utilsSetLongRunningProcessState() to control HOME button block status, screen dimming and auto sleep.
* Add missing utilsCommitSdCardFileSystemChanges() calls throughout the codebase.
2021-07-29 12:48:32 -04:00
Pablo Curiel
dbbc5c7ebd Implemented OptionsTabUpdateFileDialog and OptionsTabUpdateFileDialogContent classes.
Other changes include:

* utils: utilsGenerateFormattedSizeString() now takes an input double instead of size_t.
* DownloadTask: calculated speed is now expressed in bytes per second, so now it's up to the caller to convert it to other units.
* DownloadTask: set download size and percentage if the download size isn't known and we're dealing with the final chunk.
* http: slightly improved CURL error info formatting.
* OptionsTab: fully implemented NSWDB XML update option.
2021-07-29 03:50:17 -04:00
Pablo Curiel
eb97ae3de5 Implement DownloadTask, DownloadFileTask and DownloadDataTask classes.
Other changes include:

* AsyncTask: use a recursive mutex instead of atomics. Fixes build issues related to non-trivially-copyable elements.
* http: remove CURLOPT_ACCEPT_ENCODING option in httpPerformGetRequest().
2021-07-27 11:00:09 -04:00
Pablo Curiel
63d9be7db1 Implemented CURL-based HTTP client.
Only supports GET requests, but that's more than enough for the time being.

Other changes include:

* OptionsTab: added an option to update the NSWDB XML (not implemented yet).
* config: add missing flag check in getters and setters.
* Move default socket initialization from utils.c to services.c.
2021-07-25 18:23:44 -04:00
Pablo Curiel
05dec93795 Implemented AsyncTask class.
Other changes include:

* Updated borealis.
* Updated Makefile.
* Began implementation of a (very) simple, CURL-based HTTP handler.
* OptionsTab: added a small disclaimer about dump options.
* OptionsTab:  added notifications for the update application item (running as NSO, app already updated).
* config: improved boundary handling while validating integer entries.
* utils: (de)initialize CURL (this will be moved to http.c eventually).
2021-07-25 01:37:13 -04:00
Pablo Curiel
6bb693b493 AboutTab: add json-c to dependencies list. 2021-07-23 03:42:26 -04:00
Pablo Curiel
3afe5caa7a Implement OptionsTab class.
Other changes:

* title: rename TitleFileNameConvention -> TitleNamingConvention.
* utils: display Lockpick_RCM's GitHub repository URL if keysLoadKeyset() fails.
2021-07-23 03:24:00 -04:00
Pablo Curiel
64ab1705bc Implement JSON configuration handler.
* Thread-safe.
* Provides getter/setter functions for the data types used by nxdumptool's configuration.
* Each setter function writes the modified JSON configuration back to the SD card.
* Configuration is validated on interface initialization. If validation fails, a default JSON template is loaded from the application's RomFS and written back to the SD card.

Other changes:

* Implement directory creation.
* Moved more preprocessor definitions to defines.h.
* Replaced strtok() calls throughout the code with strtok_r() to guarantee thread-safety.
2021-07-21 11:04:18 -04:00
Pablo Curiel
a2a401d36d More progress.
* Updated borealis fork (refer to https://github.com/DarkMatterCore/borealis/commits/nxdumptool-legacy).
* Updated NcaKeyGeneration enum.
* Commented out title task notification.
* Remove unnecessary instant view invalidations.
* NS application records are now retrieved using a loop.
* Fixed text alignment issues in RootView.
* Slightly improved gamecard notifications.
2021-07-19 17:09:58 -04:00
Pablo Curiel
4cd7a9c782 Smooth ticker for single line labels. 2021-06-30 13:48:30 -04:00
Pablo Curiel
b46740de8a Image class rewrite. 2021-06-27 16:53:58 -04:00
Pablo Curiel
a9d8edebcb RootView: display USB host speed. 2021-06-25 19:28:38 -04:00
Pablo Curiel
b23af8c131 usb: modified usbIsReady() to return the speed selected by the host device. 2021-06-25 17:01:15 -04:00
Pablo Curiel
e32782f322 Move notifications to tasks.cpp. 2021-06-25 16:26:20 -04:00
Pablo Curiel
c50840ec7c Move refocus logic to from TitlesTab to LayeredErrorFrame.
* Refocus logic now also takes care of updating Borealis' internal focus stack if a view has been pushed on top of the root view using a ListItem from LayeredErrorFrame.
* Further modifications to Borealis are used to store a pointer to the corresponding sidebar item in LayeredErrorFrame objects.
* The UI code now always uses C++-style casts.
* Git commit information is now displayed next to the nxdumptool release version.
* The applet mode warning is now displayed centered at the top.
* Title IDs in title lists are now displayed at the right of each entry.
2021-06-25 16:13:39 -04:00
Pablo Curiel
c683e77873 Implement TitlesTabPopup class. 2021-06-24 11:53:36 -04:00
Pablo Curiel
9635670007 Repurposed UserTitlesTab class into TitlesTab.
Also implemented system titles tab view in the process.
2021-06-23 21:37:57 -04:00
Pablo Curiel
7a15b4eab8 UserTitleTab: remove the need for a title ID map by extending the ListItem class.
Each ListItem element gets its own internal title ID.
2021-06-23 21:04:28 -04:00
Pablo Curiel
b5507b38a6 Fix building issues.
An unordered map is now being used to hold ListItem + TitleApplicationMetadata pairs.
2021-06-23 19:02:47 -04:00
Pablo Curiel
4d1b3660c3 Cherry-pick improvements from the rewrite-yoga branch. 2021-06-23 14:27:06 -04:00
Pablo Curiel
14374885f9 Add gamecard notification. 2021-06-21 00:06:44 -04:00
Pablo Curiel
75ebd97413 UserTitlesTab: display a notification after updating the user titles list. 2021-06-20 23:00:39 -04:00
Pablo Curiel
65a7816f2e Implemented UserTitlesTab class.
* LayeredErrorFrame: both the error frame and the list are now protected instead of private, letting any expanded classes take more control over the them. SetErrorFrameMessage(), AddListView() and the class destructor have been removed because of this change.

* LayeredErrorFrame: removed views vector and simplified the list element focus check carried out before switching to the error frame.
2021-06-20 22:43:40 -04:00
Pablo Curiel
1a2289c396 Simplified LayeredErrorFrame by letting extended classes handle task events. 2021-06-20 16:37:31 -04:00
Pablo Curiel
2ca9878c85 Rename ErrorLayerView -> LayeredErrorFrame. 2021-06-20 13:27:10 -04:00
Pablo Curiel
7af87f50f3 Added templated FocusableItem class. 2021-06-20 13:20:09 -04:00
Pablo Curiel
e621b0473f Added templated ErrorLayerView class. 2021-06-20 03:49:33 -04:00
Pablo Curiel
c70fd0c1c8 RootView: display status labels using StatusInfoTask data. 2021-06-18 14:10:19 -04:00
Pablo Curiel
063d8e9b3f Added StatusInfoTask. 2021-06-18 03:02:23 -04:00
Pablo Curiel
ee17ffca5d title: update hardcoded system title metadata. 2021-06-18 01:34:02 -04:00
Pablo Curiel
18a7fad3bb AboutTab: improve scrolling. 2021-06-18 00:47:41 -04:00
Pablo Curiel
601cae399f UI changes.
* GameCardTab: use fmt library to format strings.
* AboutTab: finish view.
2021-06-17 03:55:42 -04:00
Pablo Curiel
b7daac6807 title: handle extra allocated user application metadata entries in titleFindApplicationMetadataByTitleId(). 2021-06-15 01:44:10 -04:00
Pablo Curiel
7a964c8282 UI: add AboutTab class. 2021-06-14 16:54:33 -04:00
Pablo Curiel
296115f886 GameCardTab: use extended brls::Table class.
Allows focusing on our table without highlighting it.
2021-06-14 01:55:31 -04:00
Pablo Curiel
d7081bbc1c Fix borked LAFW version checks. 2021-06-14 00:55:22 -04:00
Pablo Curiel
df673f758d GameCardTab: show HOS version equivalent next to the required LAFW version. 2021-06-13 21:34:40 -04:00
Pablo Curiel
1e6b316cdc Update gamecard_tab.cpp 2021-06-13 20:48:40 -04:00
Pablo Curiel
3629f0029f GameCardTab: display table with gamecard properties. 2021-06-13 20:47:49 -04:00
Pablo Curiel
49d7ec8ab8 GameCardTab: add ListItem elements. 2021-06-13 15:32:37 -04:00
Pablo Curiel
c90251a52b GameCardTab: fix drawing issues while switching views through the LayerView class. 2021-06-13 13:47:00 -04:00
Pablo Curiel
ac647310ad UI: added ErrorFrame and GameCardTab classes. 2021-06-13 02:18:14 -04:00
Pablo Curiel
4ffbb1f903 views: create RootView class. 2021-06-11 00:41:58 -04:00
Pablo Curiel
04540643be tasks: minor cleanup + declare global task pointers in header file. 2021-06-10 21:13:26 -04:00
Pablo Curiel
06676a0639 tasks: cache application metadata and UMS device info using vectors.
* Tasks are now immediately started by their constructor function.

* Events are now part of the class of each task type, in order to avoid instantiating each one of them and passing them as a constructor argument.

* GetTaskEvent() has been added to each task class, which returns a pointer to the private event. This will be used to subscribe Borealis views to a particular event.

* Title and UMS tasks now both cache application metadata and UMS device info using private vectors. Pointers to these private vectors can now be retrieved using public functions GetApplicationMetadata() and GetUmsDevices(), respectively.
2021-06-10 20:33:11 -04:00
Pablo Curiel
672978150b tasks: use a macro for the task interval value. 2021-06-09 14:06:10 -04:00
Pablo Curiel
e48aa2e937 Implemented background tasks for Borealis.
* core: implemented SCOPED_TRY_LOCK macro. Specific functions are now using it instead of SCOPED_LOCK to avoid potentially locking the Borealis UI.

* UI: implemented background tasks for Borealis, which call functions that now use SCOPED_TRY_LOCK.
2021-06-09 00:48:17 -04:00
Pablo Curiel
a16f62fe6d title: trim display version string before duplicating it. 2021-06-08 12:10:41 -04:00
Pablo Curiel
78f780a981 Implemented C++ scope guards.
Thanks @SciresM

These will be used for handling resource deinitialization in Borealis-related code.
2021-06-07 23:13:45 -04:00
Pablo Curiel
986b19868f title: retrieve display version string from patches while generating output filenames. 2021-06-05 17:06:29 -04:00
Pablo Curiel
c0e82b3686 Tidy up GameCardFwVersion, NcaKeyGeneration and NcaMainSignatureKeyGeneration enums.
Thanks @0Liam
2021-06-03 10:46:21 -04:00
Pablo Curiel
96c7a35e20 Added prototype system titles. 2021-06-03 00:00:16 -04:00
Pablo Curiel
04abb342bb Small code refactor (part 3).
* Both gamecard header and decrypted CardInfo area are now retrieved upon gamecard insertion. LAFW version is checked against the CardInfo LAFW version right afterwards.

* Expanded GameCardStatus enum to add NoGameCardPatchEnabled and LotusAsicFirmwareUpdateRequired values.

* Updated utilsReplaceIllegalCharacters() to perform replacements on a per-codepoint basis, which means that invalid multibyte UTF-8 codepoints can now be replaced with a single ASCII underscore.

* Updated utilsGeneratePath() to truncate path elements that exceed 255 UTF-8 codepoints (safe limit for FAT and NTFS filesystems).

* Heavily simplified core logic in title functions by using newly defined TitleStorage elements (which hold the NCM database/storage handles, a TitleInfo array and a title counter) instead of the old, global index-based methods.

* Simplified background gamecard title thread logic by always returning duplicated TitleInfo data to the user.

* Update title API to account for the previously mentioned changes, including functions to free duplicated title data.

* Fallback gamecard filename string now also holds the gamecard package ID whenever possible.

* Implemented HDCP patching for Control NCAs.
2021-05-31 21:12:15 -04:00
Pablo Curiel
21d1b001ee LAFW shenanigans.
* Added custom key sources to derive CardInfo keys at runtime using SPL.

* Implemented CardInfo area decryption.

* Implemented LAFW blob lookup in FS .data segment to retrieve the current LAFW version.

P.S.: still need to move around code to perform the LAFW version check at the places we need. But the current code is good enough for a test.
2021-05-22 04:45:40 -04:00
Pablo Curiel
f526d4e6f4 Crypto changes.
* Implemented RSA-2048-PSS + SHA256 signature verification.

* Refactored RSA-2048-OAEP decryption steps to use mbedtls function calls.

* Implemented NCA header main signature verification.

* Replaced Björn Samuelsson's CRC32 algorithm with the hardware accelerated CRC32 checksum calculation from libnx (latest commit with support for calculation in blocks).
2021-05-21 09:34:43 -04:00
Pablo Curiel
f82d7a3db4 Small code refactor (part 2).
* Rewrote mutex handling throughout the code to use a small, macro-based scoped lock implementation.

* Removed extern variables from common.h - launch path management is now completely handled in utils.c.

* Updated NpdmSystemCallId_Count to reflect changes introduced in 12.0.0.

* Added NcaMainSignatureKeyGeneration enum.

* NCA main signature moduli are now retrieved from FS .rodata at runtime.

* Simplified lock management in usb.c by using a single global mutex with scoped locks instead of three different r/w locks.

* Updated FatFs to R0.14b.

* Enabled 64-bit LBA support in FatFs to potentially support custom eMMC replacements / resized USER partitions in the future.

* Updated LZ4 to v1.9.3.

* Fixed typos.

* USB gamecard dumper PoC now only dumps the Initial Data area.

* Updated to-do list.
2021-05-18 08:32:43 -04:00
Pablo Curiel
85f146f50c Add uppercase hex string generation to utilsGenerateHexStringFromData(). 2021-05-11 18:36:15 -04:00
Pablo Curiel
4c0c7d2c56 Small code refactor.
* Refactored keydata handling.

* Sealed NCA KAEKs are now generated at startup, and NCA key area entries are now decrypted by keysDecryptNcaKeyAreaEntry(), reducing the number of calls to spl functions.

* The eTicket RSA device key is now retrieved and decrypted at startup. RSA-OAEP wrapped titlekeys are now decrypted by keysDecryptRsaOaepWrappedTitleKey().

* Renamed titlekek -> ticket common key throughout the codebase.

* Added NcaKeyAreaEncryptionKeyIndex_Count and NcaKeyGeneration_Max enum values to nca.h.

* Proper usage of strcasecmp() in some functions.

* Moved syscall hint checks from keys.c to mem.c.

* Define illegal FS characters as an array rather than a char pointer.

* Services are now initialized before the CFW type checks.

* Fixed pcv/clkrst service initialization.

* Implemented additional thread safety and logfile output to service functions.

* Slightly tweaked running service checks.

* Added proper Markdown documentation for the USB ABI.
2021-05-11 02:00:33 -04:00
Pablo Curiel
455b86179b Verify NCA FS section header hash. 2021-04-26 01:51:01 -04:00
Pablo Curiel
17dd24bc92 Modified NCA key area handling + restored PoC building.
* Avoid performing any crypto operations on null NCA key area entries.

* Added commented out code to handle the aes_ctr_ex NCA key area entry, just in case we end up needing it at some point.
2021-04-25 19:10:34 -04:00
Pablo Curiel
6d08c7e94c Support HOS 12.0.x. 2021-04-20 18:43:37 -04:00
Pablo Curiel
460bee888b Match changes to the XCI page in Switchbrew. 2021-04-05 20:40:57 -04:00
Pablo Curiel
7c2d16714c Use legacy Borealis fork + add files from the legacy Borealis example.
These files will be modified to slowly add features from the nxdumptool rewrite codebase.

This commit effectively makes it impossible to build the previous PoC. The code from each PoC will be reused, though, so it hasn't been removed.
2021-03-30 15:30:10 -04:00
Pablo Curiel
194389b73f Some changes.
* Remove references to the secondary Nintendo Extended BFTTF because it's identical to the first one.

* Use format attribute in functions that need it (and fixed errors I made in the past).
2021-03-29 14:27:35 -04:00
Pablo Curiel
11da814fb2 Fix building issues with Borealis. 2021-03-26 00:35:14 -04:00
Pablo Curiel
c6c5667bf0 Change project layout + upgrade license to GPLv3. 2021-03-25 15:26:58 -04:00
Pablo Curiel
dd9cf1f41d Remove references to Freetype and LVGL. 2021-03-25 03:22:32 -04:00
Pablo Curiel
3cb6ef93aa Some changes.
* Placed C++ extern "C" blocks inside include guards.

* Added a "clean_all" rule to the Makefile to avoid recompiling libusbhsfs after each time "clean" is used.

* Added static asserts for all structs that may need it throughout the code.

* Preprocessor macros are now used to generate certificate and ticket structs.
2021-03-24 13:25:19 -04:00
MasaGratoR
e0949bba6b
Fix linkage for C++ projects (#79) 2021-03-23 10:06:52 -04:00
MasaGratoR
e9a9a5abcc
Change include of atomic to be compatible with C++ (#78) 2021-03-22 10:30:12 -04:00
Pablo Curiel
ae3b7266a0 Fix NACP bitflag checks. 2021-03-20 03:13:16 -04:00
Pablo Curiel
a7984de0c8 Send Git commit hash as part of the StartSession block. 2021-03-16 01:08:38 -04:00
Pablo Curiel
f8e10081d6 Update title.c 2021-03-12 12:47:40 -04:00
Pablo Curiel
0ec60092df Keep indexes and counters for all supported storage IDs.
Speeds up title lookups using a specific storage ID.

Also reworked a bit the way orphan titles are handled. Should be better now.
2021-03-10 09:10:43 -04:00
Pablo Curiel
34c15d92cc Update title.h
I was sleepy.
2021-03-09 21:15:40 -04:00
Pablo Curiel
a01b7846de title: use dynamic pointer arrays.
* Added functions to deal with title info and application metadata reallocations, greatly reducing the number of references to realloc() throughout the code.

* Tweaked gamecardGetHashFileSystemContext() to not return a pointer to a dynamic context.

* Added a type field to Hash FS contexts.
2021-03-09 21:12:01 -04:00
Pablo Curiel
8be5460229 Store last log message using a small stack buffer.
Will be used to print error messages down the road.
2021-03-08 10:44:11 -04:00
Pablo Curiel
43f744326f Minor fixes.
* The new logfile handler should now work properly.

* A UTF-8 BOM is now written at the start of every new logfile.
2021-03-08 07:11:28 -04:00
Pablo Curiel
3bc14696ec New logfile handler.
* Ported the logfile handler from libusbhsfs, with some slight modifications.

* Rewrote hash file system handling from scratch. I had been wanting to do this for some months now, it's a lot better now.

* Code cleanup.
2021-03-07 19:22:49 -04:00
Pablo Curiel
bcc688061e Account for orphan system titles as well.
Yeah, system titles we have no hardcoded metadata for, basically.
2021-03-02 01:22:10 -04:00
Pablo Curiel
56a4b2f747 Update utils.c 2021-02-27 05:55:25 -04:00
Pablo Curiel
5eb96cbece services: completely ditch smRegisterService() and just use the AtmosphereHasService SM API extension.
This extension was already being used - however, smRegisterService() was also being used as a fallback method.

More than a year and a half has already passed since this feature was introduced, and both SX OS and ReiNX apparently support it now, so it's a justified change.
2021-02-24 23:36:53 -04:00
Pablo Curiel
a90d8f2074 Title handler changes.
* Renamed titleRetrieveContentMetaKeysFromDatabase() to titleGenerateTitleInfoFromStorage().

* Moved linked lists generation from titleRetrieveContentMetaKeysFromDatabase() into its own function: titleUpdateTitleInfoLinkedLists().

* Adjusted orphan title checks. It is now explicitly verified if application metadata is available before treating a title as orphan, instead of checking if the parent user application is available.

* Code cleanup in titleRefreshGameCardTitleInfo().

* titleRefreshGameCardTitleInfo() now attempts to update the application metadata pointer in orphan title entries if new application metadata was retrieved after a gamecard was inserted *and* if the orphan title count is currently non-zero.

* Updated titleRemoveGameCardTitleInfoEntries() to make it use titleUpdateTitleInfoLinkedLists().
2021-02-22 17:30:47 -04:00
Pablo Curiel
6df7ff0cba Fix output filenames not being updated in usb_gc_dumper. 2021-02-20 14:52:07 -04:00
Pablo Curiel
85a045ba38 Add a Python-based companion script.
Serves the same purpose as the modded ns-usbloader builds. Supports the full USB ABI command set.

Also fixed a small issue related to ES IPC calls not writing the total number of available rights IDs.
2021-02-18 04:24:16 -04:00
Pablo Curiel
de076f4908 More USB changes.
* usb: copy command ID and block size before moving command data within the USB transfer buffer.

* nsp_dumper_usb: now spans a background thread for the dump process, progress is now displayed, process can now be cancelled by holding B, updated to properly make use of the new usbCancelFileTransfer() behavior.

* usb_gc_dumper: updated to properly make use of the new usbCancelFileTransfer() behavior.

* usb_romfs_dumper: updated to properly make use of the new usbCancelFileTransfer() behavior.

* Updated ns-usbloader patch. Must be used on commit `8771d551a4e6fa2d645e519d504a377e34cbd730`.
2021-02-16 08:22:14 -04:00
Pablo Curiel
b6759f764b Gracefully cancel ongoing USB file transfers.
Keeps alive the current USB session by informing the host device that the user cancelled an ongoing USB transfer, instead of stalling the endpoints.

Also updated the USB ABI specs once again.
2021-02-15 17:07:47 -04:00
Pablo Curiel
c3555431d4 Prevent ALIGN_DOWN() from overflowing. 2021-02-13 19:53:30 -04:00
Pablo Curiel
1d0cc9c45b USB changes (breaks ns-usbloader compatibility).
* Updated usbSendCommand() to make it send the command header first, and then the command block. Makes it easier for host applications to read and parse command data.

* Let usbSendCommand() take care of handling ZLT packets if required by any command block (only SendNspHeader at this moment), as well as logging status data via usbLogStatusDetail().

* Updated USB ABI specs doc.
2021-02-13 17:49:05 -04:00
Pablo Curiel
9bac8f3bdc Some more changes.
* nacp: updated u32 and u64 field functions to let the user choose if the provided value should be printed using decimal or hexadecimal base, fixed codestyle.

* utils: properly implement ALIGN_DOWN() macro.
2021-02-13 02:09:18 -04:00
Pablo Curiel
69d9c2d732 Update ffconf.h 2021-02-13 00:26:23 -04:00
Pablo Curiel
054c9be41b Define constants using C preprocessor. 2021-02-12 18:41:14 -04:00
Pablo Curiel
2795ed14eb Fix codestyle. 2021-02-12 18:01:33 -04:00
Pablo Curiel
e77c72b0db Some changes.
* gamecard: added more comments, modified gamecardGetBundledFirmwareUpdateVersion() to fill a VersionType1 pointer instead of a u32, fallback to manually reading the gamecard certificate if fsDeviceOperatorGetGameCardDeviceCertificate() fails, updated GameCardFwVersion enum.

* title: tweaked conditions for some functions.

* usb: explicitly defined values for previously omitted struct members while initializing USB comms, imported libusb structs to make it easier to work with the USB BOS, added a few more comments and changed around some code.

* utils: tweaked the illegal filesystem character array to remove some chars that are actually allowed.
2021-02-12 16:35:23 -04:00
Pablo Curiel
ed2061ae3e Update nca.h 2021-01-31 05:21:50 -04:00
Pablo Curiel
88793eceea Populate app_metadata pointer in TitleInfo elements that aren't system titles or user applications. 2021-01-31 05:16:05 -04:00
Pablo Curiel
232fe05587 Use LIBUSBHSFS_FS_TYPE_STR() macro from libusbhsfs instead of our own one. 2020-12-24 07:16:16 -04:00
Pablo Curiel
b4bf505d4f UMS changes.
* Temporarily changed tracked libusbhsfs branch from main to dev.

* Minor improvements in ums.c/h.

* Refactored nsp_dumper_sd into nsp_dumper_stor - now capable of dumping NSPs to a mounted partition from a UMS device.

* Fixed utilsWaitForButtonPress() when no button mask is provided.

* Refactored utilsGetFreeSpaceFromFileSystemByPath() into utilsGetFileSystemStatsByPath().
2020-12-24 04:49:38 -04:00
Pablo Curiel
6f43764e1b Improved UMS interface. 2020-12-23 14:43:12 -04:00
Pablo Curiel
736f2e155b Add DisableDeviceAddressSpaceMerge NPDM meta flag.
Also updated the Makefile to link the application against lwext4.
2020-12-23 14:02:02 -04:00
Pablo Curiel
fbd250a417 Update copyright years. 2020-12-23 13:48:57 -04:00
Pablo Curiel
ae12e48678 Added UMS interface based around libusbhsfs.
Also normalized Initialized -> Init in names from global variables.
2020-12-07 00:26:59 -04:00
Pablo Curiel
5a070f624c Use UsbState enum values from latest libnx. 2020-12-06 18:45:30 -04:00
Pablo Curiel
c29f994b35 Support for HOS 11.0.0.
* Updated hardcoded system title list to match HOS 11.0.0.
* Updated NcaKeyGeneration_Current.
* Updated button input handling to match the new pad API from libnx.
2020-12-04 02:38:44 -04:00
Pablo Curiel
9732bf9adf libusbhsfs-related changes.
* Free space is now retrieved via statvfs() for all filesystems, including the SD card.
* Updated Makefile to reflect latest libusbhsfs changes (dev branch).
2020-12-02 02:28:35 -04:00
Pablo Curiel
7899fc419c Update usbHsFsInitialize() call to reflect changes in libusbhsfs. 2020-11-28 02:56:54 -04:00
Pablo Curiel
457f468519 Fix comments. 2020-11-28 02:38:53 -04:00
Pablo Curiel
dff9b1defa Revert "Rename FatFs functions to avoid linking issues with libusbhsfs."
This reverts commit 6715242fed.
2020-11-28 02:38:01 -04:00
Pablo Curiel
477c321773 Remove unnecessary code.
libusbhsfs doesn't return FsFileSystem objects, that's why.
2020-11-21 06:29:29 -04:00
Pablo Curiel
6715242fed Rename FatFs functions to avoid linking issues with libusbhsfs. 2020-11-20 04:56:12 -04:00
Pablo Curiel
e8956c0e4b Various changes.
* Cancel USB file transfer if something goes wrong during a NSP transfer via USB.
* Added SD card RomFS dumper.
* Further optimizations to the *WriteNcaPatch() functions.
* Change struct naming in nso.c/h (thanks @0Liam !).
* Replace fsp-usb with libusbhsfs. ( ͡° ͜ʖ ͡°)
2020-11-08 15:08:30 -04:00
Pablo Curiel
5f0f281e2d Added USB ABI specs. 2020-11-01 11:04:38 -04:00
Pablo Curiel
bceff64da4 Fix parent layer chunk size calculation while generating HierarchicalSha256 / HierarchicalIntegrity patches. 2020-10-29 03:51:17 -04:00
Pablo Curiel
0229124173 NACP changes.
Fixed types for some NACP struct entries (thanks @0Liam !) + added functions to generate and write NACP patches.
2020-10-28 18:48:46 -04:00
Pablo Curiel
2b8e80c283 Remove unused code. 2020-10-28 01:03:48 -04:00
Pablo Curiel
57162b5634 CNMT: fixed support for patches. 2020-10-28 00:30:13 -04:00
Pablo Curiel
278afbabfa Title handler bugfixes.
* Fixed possible invalid memory accesses using TitleInfo pointers from gamecard titles if the gamecard they belong to is taken out.
* Fixed invalid for loop condition in _titleGetInfoFromStorageByTitleId() if no gamecard titles have been retrieved.
2020-10-27 17:23:19 -04:00
Pablo Curiel
5c5f388feb Add NSP transfer mode to USB code + implement SendNspHeader USB command.
Completely untested.
2020-10-26 02:39:33 -04:00
Pablo Curiel
da5290189b Optimize modified NCA header(s) write code. 2020-10-25 20:03:02 -04:00
Pablo Curiel
ae6defb0e6 Another typo. 2020-10-25 11:43:22 -04:00
Pablo Curiel
c44b9c998e Add endpoint max packet size field to the UsbStatus response block.
And fix typos. lol
2020-10-25 11:42:53 -04:00
Pablo Curiel
7e2aa976b4 Rename KEY_NONE definition. 2020-10-22 16:13:00 -04:00
Pablo Curiel
974790944f More changes.
* Added NSP dumper PoC (SD card only atm, single-threaded).
* Cert: replaced a wrong strcmp() with a proper strncmp().
* CNMT: added functions to update content info entries and generate/write Partition FS patches.
* NCA: encrypt key area right after removing titlekey crypto.
* NPDM/ProgramInfo: changed function names.
* NPDM: check if the NCA has been modified before attempting to patch ACID data + calculate RSA-PSS signature *after* generating the PFS patch, not before. lol
* PFS: restore name table size value before writing the header padding.
* Tik: reworked the ticket lookup algorithm. Now uses information from ticket_list.bin to properly calculate the offset to the requested ticket in ticket.bin.
* Title: changed title type strings used for filename generation.
* Updated to-do list.
2020-10-22 00:38:14 -04:00
Pablo Curiel
15431ec2c8 Many changes.
* AES: moved CTR initializing/updating functions here from nca.c.
* BKTR/RomFS/PFS: check if we're dealing with a NCA with titlekey crypto and the titlekey hasn't been retrieved.
* BFTTF: use void pointers for output font data.
* Mem: Only exclude Unmapped/Uo/ThreadLocal/Reserved memory pages if dealing with FS.
* NCA: use content type context pointers inside NCA contexts to manage ContentMeta, ProgramInfo, Nacp and LegalInfo contexts.
* NCA: added 'written' bool elements to patch structs to indicate patch write completion.
* NPDM: remove unnecessary inline functions, generate PFS patch right after changing ACID data, add a pfsWriteEntryPatchToMemoryBuffer wrapper.
* PFS: added PartitionFileSystemFileContext and related functions to deal with NSP headers.
* ProgramInfo: removed unnecessary inline functions.
* Save: added commented code to dump a full system savefile - will probably use it down the road.
* Tik: added support for volatile tickets (thanks to @shchmue and @Whovian9369!), added a rights ID string representation to the Ticket struct, clear Volatile and ELicenseRequired flags in conversions to common tickets.
* Title: added a function to calculate the number of titles (current + siblings) from a TItleInfo block.
* Utils: added a function to generate a dynamically allocated path string using a prefix, a filename and a extension.
* Removed explicit offset checks throughout all the code.
* Codestyle fixes.
* Updated to-do.
2020-10-21 00:27:48 -04:00
Pablo Curiel
bd98fd4c32 Replace unnecessary strlen() calls with pointer dereferences or calculations using info available at runtime (when possible).
This should probably improve performance a little bit in certain sections.
2020-10-14 20:06:53 -04:00
Pablo Curiel
6f4cb98033 Cleanup startup logfile messages. 2020-10-14 19:08:01 -04:00
Pablo Curiel
5b22fe07f2 More code cleanup. 2020-10-14 14:58:33 -04:00
Pablo Curiel
13efdb6074 Update bfttf.h 2020-10-14 09:24:56 -04:00
Pablo Curiel
e6bb15d608 Implemented BFTTF font loading and decoding.
Some people may call me a madman but I don't want to see any more nxdumptool screenshots with a Disney-like font. *war flashbacks*
2020-10-14 09:23:49 -04:00
Pablo Curiel
44965430b3 Even more code cleanup.
* Added a function to write re-encrypted NCA and/or FS section headers. Getting ready to re-implement NSP dumping.
* Added more CNMT XML fields (thanks 0Liam).
* Updated my to-do list because I'm dummy.
2020-10-13 20:15:21 -04:00
Pablo Curiel
ba4fdcd01c Code cleanup.
* Added 'encrypted_header' members to both NcaContext and NcaFsSectionContext. In-place re-encryption isn't desirable in this case.
* Fixed FsAccessControl-related type naming for ACI0 blocks.
2020-10-13 10:00:03 -04:00
Pablo Curiel
3ab65d8dca Fix support for CNMTs with no ContentInfo entries. 2020-10-12 22:46:59 -04:00
Pablo Curiel
ebd97d7c82 Add FsAccessControlData to ProgramInfo XML.
Also:

* Fixed support for NSOs with invalid module_name, api_info, dynstr and/or dynsym offsets/sizes.
* Updated the XML generator example to generate XML data for all available NCAs, regardless of their ID offset values.
2020-10-12 16:35:47 -04:00
Pablo Curiel
84f651eae8 Further improvements to the ProgramInfo XML generation code. 2020-10-12 12:02:44 -04:00
Pablo Curiel
7059bacfce Improved ProgramInfo XML generation.
Also added some additional fields. Thanks to 0Liam.
2020-10-12 00:59:50 -04:00
Pablo Curiel
40fc21b5a3 Fix ProgramInfo and NSO issues.
XML generation confirmed to be working. The new algorithm faithfully reproduces the same output from legacy nxdumptool with much less overhead and memory usage.
2020-10-11 20:40:54 -04:00
Pablo Curiel
3affe1f4d0 ProgramInfo AuthoringTool-like XML generation.
Untested. Completely reworked both Middleware and ELF symbol parsing from NSOs.
2020-10-11 15:55:01 -04:00
Pablo Curiel
495e331306 Fix support for NSOs without a valid .api_info section + ProgramInfo context.
ProgramInfo XML generation is still missing. Getting real close to reimplementing NSP dumping.
2020-10-11 14:13:09 -04:00
Pablo Curiel
f45d1a21b5 Verify decompressed .rodata segment hash. 2020-10-11 13:23:58 -04:00
Pablo Curiel
e3e6552c4e NSO context.
Also updated LZ4 to latest stable release to allow for in-place decompression.
2020-10-11 11:22:26 -04:00
Pablo Curiel
62945728c7 Fix wrong NCA ACID signature area size. 2020-10-10 17:12:35 -04:00
Pablo Curiel
9f010c4129 NPDM ACID public key replacement + NCA ACID signature recalculation. 2020-10-10 17:08:17 -04:00
Pablo Curiel
2066b11d5a NPDM context. 2020-10-10 15:29:14 -04:00
Pablo Curiel
dcbedbf13a Remove homebrew-only NSO extensions. 2020-10-10 11:38:06 -04:00
Pablo Curiel
1de967ed42 NSO structs (thanks 0Liam). 2020-10-10 11:35:14 -04:00
Pablo Curiel
3e59d15bc4 Minor template tweaks + LegalInfo fix. 2020-10-10 06:10:50 -04:00
Pablo Curiel
d1f0361725 Update NPDM structs (thanks to 0Liam) + LegalInformation XML retrieval.
From now on, I'll delete code from the legacy codebase directory as soon as specific features from it are rewritten... Because it's a mess to navigate.
2020-10-09 05:58:53 -04:00
Pablo Curiel
4425666395 NPDM support (part 1).
Only added header file with structs and enums. Actual functions come next but I'm tired atm.
2020-10-08 17:52:31 -04:00
Pablo Curiel
1c15a096b5 Codestyle fixes + prepare code for NPDM support. 2020-10-08 14:31:09 -04:00
Pablo Curiel
e943e84380 Unified XML generator + finished NACP parsing.
Big thanks to 0Liam.
2020-10-06 11:41:26 -04:00
Pablo Curiel
2859f26cb3 NACP: add NeighborDetectionClientConfiguration and RequiredAddOnContentsSetBinaryDescriptor to XML generation.
This is tentative. I need to look into how these fields are really parsed / appended to the XML.
2020-10-06 02:00:18 -04:00
Pablo Curiel
7573c53457 Fix silly bug in titleGetNcmContentMetaTypeName. 2020-10-04 06:40:56 -04:00
Pablo Curiel
afa99ba445 Added info about XCI header keys. 2020-10-04 05:25:42 -04:00
Pablo Curiel
1e41148c02 NACP parsing (part 2).
NeighborDetectionClientConfiguration and RequiredAddOnContentsSetBinaryDescriptor haven't been implemented (yet).
2020-10-04 03:05:05 -04:00
Pablo Curiel
d385d40862 NACP parsing (part 1).
God, I'm so tired. I'll go play some good old MGS3 and continue this stuff at a later time. It builds, though.
2020-10-03 13:09:29 -04:00
Pablo Curiel
fa1b9c70a5 NCA changes. 2020-10-02 22:37:05 -04:00
Pablo Curiel
d440d88bbe CNTM: type name consistence. 2020-10-02 06:28:41 -04:00
Pablo Curiel
98b7a309b3 CNMT AuthoringTool-like XML generation. 2020-10-02 05:53:58 -04:00
Pablo Curiel
6e32829cf1 CNMT parsing. 2020-10-01 02:17:59 -04:00
Pablo Curiel
97d9603e93 BKTR: add support for games with base Program NCAs without a RomFS section. 2020-09-26 06:49:18 -04:00
Pablo Curiel
1a6f2ee50c Rename some reserved fields. 2020-09-24 13:03:26 -04:00
Pablo Curiel
38f19351a9 Add build script. 2020-09-22 21:13:39 -04:00
Pablo Curiel
083874bd4e Fix unaligned reads from the gamecard secure storage area.
Big thanks to Whovian for finding the bug and testing the change.
2020-09-19 06:21:23 -04:00
Pablo Curiel
b806c2e7d0 Support multi-program titles in the RomFS dumper. 2020-09-19 02:59:31 -04:00
Pablo Curiel
01ff151946 Update fs_ext.h 2020-09-18 23:18:32 -04:00
Pablo Curiel
679aa170b5 Some small changes.
* tik: check for common certificate availability before attempting to convert a personalized ticket to a common one. The raw common certificate chain data for the ticket signature issuer is now returned.

* usb: skip waitMulti call in the USB background thread if an invalid endpoint max packet size was received from the USB host in the previous while loop iteration.
2020-08-27 15:18:31 -04:00
Pablo Curiel
d6cdfe5c06 Perform title sorting at startup and in the background gamecard title info thread, not while retrieving data using non-static functions.
Orphan titles are now sorted by title ID.
2020-08-20 20:18:05 -04:00
Pablo Curiel
a19d3f2338 Ditched C threads in favor of libnx threads.
Preemptive multithreading is still used, just like libnx's newlib implementation.

Also changed the version number because the rewrite deserves it.
2020-08-18 01:04:13 -04:00
Pablo Curiel
1e50cec315 Update usb.c 2020-08-17 17:31:24 -04:00
Pablo Curiel
dfa425790a Get endpoint max packet size from USB host to properly enable ZLT packets when needed.
Also updated the diff patch for ns-usbloader.
2020-08-17 17:30:47 -04:00
Pablo Curiel
f724eaa9a9 Update utils.c 2020-08-15 17:25:40 -04:00
Pablo Curiel
6b8b3184ac Fixes for development units + diff patch for ns-usbloader.
Big thanks to ZachyCatGames.
2020-08-15 17:22:49 -04:00
Pablo Curiel
ace4732fda Functions to generate gamecard/title filenames + fix CRC32 calculation.
Updated the threaded gamecard dumper to reflect these changes.
2020-08-13 22:31:02 -04:00
Pablo Curiel
7606f7b40a Clear previous and next pointers from user application entries while freeing gamecard title info entries. 2020-08-13 14:20:53 -04:00
Pablo Curiel
90c6d8a9f8 Use linked lists to deal with user applications available in multiple storages at the same time. 2020-08-13 14:12:33 -04:00
Pablo Curiel
ad401d559d New template: threaded gamecard dumper via USB.
Key area and certificate can be optionally appended and/or preserved, respectively. Trimming is supported.

Also added a bunch of ZLT packet related fixes to usb.c, as well as a function to properly cancel an ongoing file transfer.
2020-08-13 02:01:23 -04:00
Pablo Curiel
e26637125b Add slightly better scrolling + title counter. 2020-08-03 17:41:00 -04:00
Pablo Curiel
3105540c99 Block HOME button presses during dumping operations in code templates. 2020-08-03 14:13:24 -04:00
Pablo Curiel
032a4fc22c Perform gamecard initial data area lookup only on demand. 2020-08-01 01:17:08 -04:00
Pablo Curiel
ca333bd71d Missing fs commit changes. 2020-08-01 00:52:40 -04:00
Pablo Curiel
64f3a566f8 Commit filesystem changes when needed. 2020-08-01 00:43:55 -04:00
Pablo Curiel
b11df5e732 Remove unnecessary line breaks. 2020-07-30 18:42:53 -04:00
Pablo Curiel
5d1944b43c Move title info dump code to a template. 2020-07-30 18:40:02 -04:00
Pablo Curiel
3f837cef05 Simple functions to deal with orphan titles...
... No way to avoid them, I guess.
2020-07-30 18:37:45 -04:00
Pablo Curiel
bb8cba1eaa Threaded gamecard title info/metadata retrieval. 2020-07-30 17:43:50 -04:00
Pablo Curiel
cd8afd2cd8 Fixed gamecard key area template. 2020-07-30 16:01:26 -04:00
Pablo Curiel
7c4e7a4db0 New test app: system title NCA section dumper. 2020-07-29 17:02:21 -04:00
Pablo Curiel
5320260b4e Better names for TITLE_* defines. 2020-07-28 02:20:19 -04:00
Pablo Curiel
64766be416 Update title.c 2020-07-27 23:38:45 -04:00
Pablo Curiel
98f3f85a31 Bunch of title related changes.
* Improved patch and add-on content title ID verification against a base application title ID.
* Implemented linked lists in TitleInfo structs, which make it easier to deal with multiple patches / add-on contents belonging to the same application.
* TitleApplicationMetadata elements are retrieved with titleGetApplicationMetadataEntries() and used by the UI to display title entries. An 'is_system' filter argument is used to determine which kind of metadata should be retrieved. These are ordered by ID (system titles) or alphabetically (user applications) using qsort().
* Added TitleUserApplicationData struct, which is populated when an user application is selected.
* Tweaked titleRefreshGameCardTitleInfo() behaviour a little bit. Now returns true whenever there are title info changes, so the UI can reload the list.
* Temporarily commented out title info logging from titleInitialize().
* Fixed decrypted key retrieval from the NCA key area for patches with titlekey crypto removed.
* Implemented a very small menu to select a title to dump.
2020-07-27 23:32:08 -04:00
Pablo Curiel
62366327ee Reduce memory footprint + hardcode system title names.
Also increased the USB timeout again, since 1 second seems to be too low for gamecard transfers.

Big thanks to Whovian for helping me format that long system title list.
2020-07-26 04:00:54 -04:00
Pablo Curiel
158e424b96 List content infos as part of title list entries.
Finally got rid of location resolver stuff.
2020-07-26 00:57:12 -04:00
Pablo Curiel
2521ac3f15 List titles from the inserted gamecard. 2020-07-25 14:50:42 -04:00
Pablo Curiel
e4a6e0e77a Begin work on title listing stuff. 2020-07-25 01:56:35 -04:00
Pablo Curiel
8a54ea4823 Supress unnecessary log messages. 2020-07-23 17:57:43 -04:00
Pablo Curiel
ee5a08f5d9 Trivial changes. 2020-07-23 17:30:01 -04:00
Pablo Curiel
e7f2c927c2 FIx small overlook. 2020-07-22 21:34:13 -04:00
Pablo Curiel
c8c062e7fa Test unified NCA hash layer write function (works gucci). 2020-07-22 20:37:02 -04:00