1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-09 12:11:44 +00:00
Commit graph

48 commits

Author SHA1 Message Date
Pablo Curiel
7a0268eeb0 Update todo.txt 2023-12-22 12:41:34 +01:00
Pablo Curiel
d402776032 Custom devoptab wrappers (part 1).
This commit implements a devoptab wrapper for Partition FS sections within NCAs, using code from pfs.c/h.

Other changes include:

* codebase: use NX_IGNORE_ARG macro where needed.

* hfs: slight tweaks to some of the static functions.

* pfs: slight tweaks to some of the static functions.
* pfs: use pfsIsValidContext() where needed.

* utils: update utilsInitializeResources() to use __system_argc and __system_argv variables from libnx.

* todo: update text file.
2023-12-20 20:32:48 +01:00
Pablo Curiel
fb58d20fe3 I'm a terrible person and an even worse developer.
And I don't need anyone to tell me so, thank you very much.

* PoC: remove gc_dumper and nsp_dumper PoC; create nxdt_rw_poc with all gc_dumper and nsp_dumper capabilities + standalone ticket dumping + raw NCA dumping; use ftruncate() to set output file sizes whenever possible. PoC code is a mess, as always. Expect the features from the rest of the PoCs to be implemented into nxdt_rw_poc soon.

* workflow: temporarily disable borealis build generation; comment out manual installation of up-to-date packages from Leseratte's mirrors because the latest devkitA64 Docker image has them all.

* borealis: update to fix building issues with latest devkitA64.

* bfttf: error out on invalid NCA signatures.

* config: save configuration to the current working directory; parse and validate new "gamecard/write_raw_hfs_partition" flag.

* defines: remove CONFIG_PATH macro; rename CONFIG_FILE_NAME.

* gamecard: rename fs_ctx -> hfs_ctx everywhere; use HFS function calls to retrieve partition names.

* hfs: move GameCardHashFileSystemPartitionType enum from gamecard.h and rename it to HashFileSystemPartitionType; add hfsIsValidContext(); add hfsGetPartitionNameString().

* nca/npdm: update comments to reflect latest HOS version.

* nxdt_bfsar: always generate absolute SD card paths with the device name; error out on an invalid NCA signature.

* nxdt_includes: include dirent.h; refactor Version struct to make it a union of all known *Version structs.

* nxdt_log: don't write session separator if the logfile is empty.

* nxdt_utils: log appletIsGamePlayRecordingSupported() errors; add utilsDeleteDirectoryRecursively().

* rsa: provide clearer function descriptions in header file.

* services: handle usb:ds initialization.

* tik: update tikConvertPersonalizedTicketToCommonTicket() to allow NULL input pointers as raw certificate chain arguments (much needed for standalone ticket dumping).

* title: add titleGetApplicationIdByMetaKey().

* usb: refactor interface (de)initialization code; slightly improve ABI usage (console-side only); redefine ABI version field in StartSession command blocks; upgrade ABI to v1.1.

* FatFs: rename DIR -> FDIR to avoid conflicts with definitions from stdlib's dirent.h.

* gamecard_tab: display package ID from the inserted gamecard; fix displayed version numbers from bundled system updates below 3.0.0.

* todo: add notes about creating devoptab devices for HFS/PFS/RomFS file tree dumping.
2023-05-24 21:05:34 +02:00
Pablo Curiel
a9b5f7211c Some changes. Read full commit message.
* title: implemented titleGetNcmStorageIdName().

* nxdt_log: implemented log verbosity levels (debug, info, warning, error, none) and helper macros for each level. The rest of the codebase still needs to be updated to take advantange of this change.

* nxdt_log: implemented auxiliary logging via nxlink, if available.

* nxdt_utils: system CPU/MEM overclocking is now only applied through utilsSetLongRunningProcessState(), as it should have been from the beginning.

* nxdt_utils: nxlink initialization is now carried out without redirecting stdout and/or stderr, entirely removing the need for utilsRestoreConsoleOutput(). utilsGetNxLinkFileDescriptor() is used to send data to the nxlink host via dprintf() in log functions.
2022-07-12 02:27:03 +02:00
Pablo Curiel
243080f1a6 NSP dumper: re-enable AT option by default. 2022-07-10 19:45:18 +02:00
Pablo Curiel
942a407247 Codebase cleanup.
Remove legacy code and trailing whitespace from all files.
2022-07-05 03:04:28 +02:00
Pablo Curiel
91dc20b7f3 Fix some issues + update PoCs.
ncaStorageSetPatchOriginalSubStorage: allow Patch title version to be equal to the Base title version (e.g. sparse titles).

ncaStorageGetHashTargetExtents: actually set proper storage extents.

bktrGetTreeNodeEntryIndex: fix index lookup algorithm.

bktrStorageNodeFind: fix binary search.

bktrVisitorMoveNext / bktrVisitorMovePrevious: fix integer overflows.
2022-07-05 01:25:28 +02:00
Pablo Curiel
d722683a77 Create merged nsp_dumper PoC. 2022-06-27 04:58:03 +02:00
Pablo Curiel
ce4034852c Remove support for NPDM patching. 2022-06-26 03:34:31 +02:00
Pablo Curiel
7189943680 More changes.
* gc_dumper: fixed Card ID Set dumping.

* nacp: updated structs and enums to match latest changes (big thanks to @0Liam !), added helper macros.

* cnmt: added helper macros.

* program_info: added helper macros.

* exception_handler: added helper macros.

* nxdt_utils: only create output directories if the app isn't a PoC build.

* todo: changed task priority order. Sparse/compressed section support is mandatory and must be implemented ASAP.
2022-03-18 17:48:16 +01:00
Pablo Curiel
3e3469b471 Update todo.txt 2021-08-08 03:59:02 -04:00
Pablo Curiel
ba0c5d9e35 utils: implement utilsIsApplicationUpdatable().
Also removed legacy code that has already been reimplemented.
2021-08-07 05:44:36 -04:00
Pablo Curiel
28cd0ce10f OptionsTab: fully implement application update feature.
Other changes include:

* Codebase: move JSON parsing logic from config.c/h to nxdt_json.c/h.
* Codebase: replace all calls to localtime() with localtime_r() to guarantee thread-safety.
* Codebase: updated todo.txt.
* utils: implement utilsParseGitHubReleaseJsonData(), utilsFreeGitHubReleaseJsonData(), utilsGetApplicationUpdatedState() and utilsGetApplicationUpdatedState().
* utils: add extra logic to move the application's NRO to its proper path if the launch path isn't the right one (commented out at this moment).
* utils: add extra logic to replace the application's NRO at exit (commented out at this moment).
* defines: add DEVOPTAB_SDMC_DEVICE and tweak GitHub URL macros.
* DownloadTask: set percentage to 0 if the download size is unknown.
* DownloadTask: fix ETA string formatting.
* OptionsTab: repurpose OptionsTabUpdateFileDialogContent into OptionsTabUpdateProgress.
* OptionsTab: implement OptionsTabUpdateApplicationFrame.
* RootView: move date formatting into the static GetFormattedDateString() method.
* Makefile: use _GNU_SOURCE as part of CFLAGS to use strptime().
2021-08-07 04:42:03 -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
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
39040b3e03 Update todo.txt 2021-06-09 01:03:12 -04:00
Pablo Curiel
9c009753e3 Update todo.txt 2021-06-05 19:05:31 -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
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
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
57162b5634 CNMT: fixed support for patches. 2020-10-28 00:30:13 -04:00
Pablo Curiel
7c4c969fc6 Update todo.txt 2020-10-27 17:25:49 -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
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
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
9f010c4129 NPDM ACID public key replacement + NCA ACID signature recalculation. 2020-10-10 17:08:17 -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
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
3eb5239d38 Update todo.txt 2020-08-01 01:18:38 -04:00
Pablo Curiel
5d1944b43c Move title info dump code to a template. 2020-07-30 18:40:02 -04:00
Pablo Curiel
bb8cba1eaa Threaded gamecard title info/metadata retrieval. 2020-07-30 17:43:50 -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
e4a6e0e77a Begin work on title listing stuff. 2020-07-25 01:56:35 -04:00
Pablo Curiel
ee5a08f5d9 Trivial changes. 2020-07-23 17:30:01 -04:00
Pablo Curiel
62cc25805d Update todo.txt 2020-07-22 16:50:10 -04:00
Pablo Curiel
b4d0e595f9 Update todo.txt 2020-07-22 16:37:31 -04:00
Pablo Curiel
b8d80bf260 Functions and wrappers to write generated NCA hash layer patches. 2020-07-22 16:35:23 -04:00
Pablo Curiel
90e0f057bc Bunch of changes.
* Updated NCA structs (including NcaSparseInfo).
* Changed the way NCA header + NCA FS header decryption is handled.
* Changed the way the NCA encrypted key area is handled.
* Unified hierarchical patch generation functions.
* Updated PFS, RomFS and BKTR functions accordingly to reflect NCA handling changes.
* Logfile path is now relative.
* Gamecard initial data lookup code now uses the initial data hash from the gamecard header (a tad bit slower, but way more failproof).
2020-07-22 04:03:28 -04:00
Pablo Curiel
eba26a59a5 Changes to the gamecard key area handling. 2020-07-15 18:50:34 -04:00
Pablo Curiel
24cec26980 Move to-do list out of the readme. 2020-07-07 09:01:17 -04:00