* 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.
* 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.
* 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.
* 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).
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
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.
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.
* 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.
* 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.
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.
* 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).