1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-22 18:26:39 +00:00
Commit graph

595 commits

Author SHA1 Message Date
Pablo Curiel
bafe23b14e poc: implement PFS dumping (user titles only).
Other changes include:

* nca: add title_id and title_type fields to NcaContext; redefine title_version field in NcaContext; redefine ncaInitializeContext() function signature (now requiring NcmContentMetaKey and NcmContentInfo objects); modify ncaInitializeFsSectionContext() to make it skip extra boundary checks on FS sections with a bogus sparse storage.

* config: rename "nsp/write_section_image" flag to "nsp/write_raw_section".

* nxdt_utils: modify utilsGeneratePath() to make it also check if the first character from the filename is a slash.

* pfs: modify pfsGetEntryIndexByName() to only log an error if the entry name being looked up isn't "main.npdm".
2023-05-30 01:22:12 +02:00
Pablo Curiel
0e70eb0912 poc: add base/patch selector.
Other changes include:

* title: add titleGetAddOnContentBaseOrPatchList(); add titleIsValidInfoBlock(); rename titleDuplicateTitleInfo() -> titleDuplicateTitleInfoFull(); add non-linked-list aware titleDuplicateTitleInfo().
2023-05-27 20:10:35 +02:00
Pablo Curiel
c6a84f68de poc: add NCA FS section submenu.
Other changes include:

* nca: add section_size_str field to NcaFsSectionContext struct.
* config: add support for "nca_fs/write_section_image" flag.
2023-05-26 20:23:23 +02:00
Pablo Curiel
8e2b0a74b8 poc: add NCA FS section menu
Other changes include:

* nca: add content_size_str field to NcaContext struct.
* nxdt_utils: modify utilsGenerateFormattedSizeString() to avoid displaying decimal places if dealing with plain bytes.
2023-05-26 17:59:03 +02:00
Pablo Curiel
54e7c0e9be poc: add small sleep to all while() loops. 2023-05-26 14:41:49 +02:00
Pablo Curiel
55d744b5c2 nxdt_includes: properly handle old sysver fields.
Turns out old system versions just use 16-bit long relstep values in their lower half. The major/minor/micro combination in the upper half remains the same.

Thanks to @liamadvance for clarifying this.
2023-05-26 11:01:34 +02:00
Pablo Curiel
6bbe964f42 nca: fix layer hash calculation.
Long standing issue since 1bc1a05f96.

I feel extra stupid. It must be the date or something, I don't know. At least I'm getting to fix lots of silly issues within the codebase. Emphasis on "silly" -- I wouldn't have liked to rework the hierarchical patch generation algorithm.

Big thanks to @KookiesGH for notifying about the NSP installation issues with Goldleaf on the Discord server.
2023-05-25 04:15:58 +02:00
Pablo Curiel
3d6c65ba25 tik: fix memory leak. 2023-05-25 01:22:54 +02:00
Pablo Curiel
cf71f3e484 tik: look, I'm tired, I don't know what to say.
I don't even know what I'm thinking anymore. I'm frustrated.
2023-05-25 01:19:44 +02:00
Pablo Curiel
e63c7ff939 fml 2023-05-24 21:16:20 +02:00
Pablo Curiel
817de66f96 Update rewrite.yml 2023-05-24 21:12:01 +02: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
2b8dcec7f4 title: make ID generation easier to understand
Also updated the workflow file to only build new artifacts if pertinent files are updated.
2023-04-09 15:39:42 +02:00
Pablo Curiel
ed5a5565c0 Update smc.h 2023-04-08 13:45:05 +02:00
Pablo Curiel
9a4b8b573d Update copyright year 2023-04-08 13:42:22 +02:00
Pablo Curiel
f79680184d Runtime key derivation with hardcoded key sources
* aes: add aes128EcbCrypt() as a one-shot function to perform AES-128-ECB crypto. The rest of the codebase now calls this function whenever suitable.

* fs_ext: add const keyword to IPC input structs wherever suitable.

* key_sources: add hardcoded master key vectors (prod, dev); master KEK sources (Erista, Mariko); master key source; ticket common key source; SMC key type sources; SMC seal key masks; AES key generation source; NCA header KEK source; NCA header key source and NCA KAEK sources. Also fixed the hardcoded gamecard CardInfo key source for dev units (it was previously generated using retail keydata, my bad).

* keys: remove keysGetNcaMainSignatureModulus(); remove keysDecryptNcaKeyAreaEntry(); repurpose keyset struct to only hold keys that can actually be used for the current hardware type; remove KeysGameCardKeyset; remove keysIsXXModulusYYMandatory() helpers; remove keysRetrieveKeysFromProgramMemory(); remove keysDeriveSealedNcaKeyAreaEncryptionKeys(); add keysDeriveMasterKeys() and keysDerivePerGenerationKeys(); rename keysDeriveGameCardKeys() -> keysDeriveGcCardInfoKey(); add small reimplementations of GenerateAesKek, LoadAesKey and GenerateAesKey; add keysLoadAesKeyFromAesKek() and keysGenerateAesKeyFromAesKek() wrappers. Furthermore, master key derivation is now carried out manually using hardcoded key sources and the last known master key, which is loaded from the Lockpick_RCM keys file -- if the last known master key is unavailable, the key derivation algorithm will then fallback to TSEC root key / Mariko KEK based key derivation, depending on the hardware type.

* nca: add hardcoded NCA man signature moduli (prod, dev); merge ncaDecryptKeyArea() and ncaEncryptKeyArea() into ncaKeyAreaCrypt().

* nxdt_utils: add utilsIsMarikoUnit(); remove _utilsAppletModeCheck(); rename utilsAppletModeCheck() -> utilsIsAppletMode().

* services: remove spl:mig dependency (yay).

* smc: add SmcKeyType enum; add SmcSealKey enum; add SmcGenerateAesKekOption struct; add smcPrepareGenerateAesKekOption().
2023-04-08 13:38:28 +02:00
Pablo Curiel
7ddf1bb1fb
Update README.md 2023-03-31 13:29:46 +02:00
Pablo Curiel
5edd6deb7c
workflow: rename UI artifacts 2023-03-29 23:45:07 +02:00
Pablo Curiel
74d6bcf7f9
Update README.md 2023-03-29 23:40:06 +02:00
Pablo Curiel
978ed292f2 Support for HOS 16.x changes.
* cnmt: add ContentMetaInstallState_Count to prepare for any future bitflags; add ContentMetaContentAccessibility enum; remove comment about unknown extended data size for DataPatch CNMTs.
* nacp: rename NacpSupportingLimitedLicenses -> NacpSupportingLimitedApplicationLicenses everywhere; don't allow empty strings for StartupUserAccountOption field in XML; remove ApplicationId field from XML.
* nca: update NcaKeyGeneration enum; update comments; properly handle NcaHashType_None in parsed NCA FS sections.
* npdm: update comments.
* keys: removed sealed key entries from structs; add keysGenerateAesKey() as a GenerateAesKek + GenerateAesKey wrapper; update Lockpick_RCM key block hashes.
* title: update hardcoded system title list.
2023-03-29 23:14:21 +02:00
Pablo Curiel
20ce881db6 I hate my life 2023-03-25 12:54:18 +01:00
Pablo Curiel
a9aa7540e5 Update rewrite.yml 2023-03-25 12:17:01 +01:00
Pablo Curiel
f8e78e655d Update libusbhsfs 2023-03-25 12:10:07 +01:00
Pablo Curiel
55f3856f47 workflow: build nxdumptool GUI binary 2023-03-25 00:39:34 +01:00
Pablo Curiel
79a6f5f741 Update rewrite.yml 2023-03-20 19:15:59 +01:00
Pablo Curiel
f4e3843950 More workflow changes 2023-03-20 17:48:21 +01:00
Pablo Curiel
1bfbed08b3 Update libusbhsfs + workflow 2023-03-20 16:58:00 +01:00
Pablo Curiel
7e399d91db Update dependencies.
* Update libusbhsfs to 8c2e517. Furthermore, the UMS handler has been rewritten to use the new callback-based system from libusbhsfs.

* Update FatFs to R0.15 w/patch2.
2023-02-24 21:32:58 +01:00
Pablo Curiel
3c0312961b gc_dumper: fix storage device path generation 2023-01-14 00:51:54 +01:00
Pablo Curiel
665a5baf7e Update libusbhsfs.
Also fixed a small bug in the gc_dumper PoC.
2023-01-05 01:30:12 +01:00
Pablo Curiel
3aae84a025 QoL changes.
* gc_dumper: add UMS device support.
* nsp_dumper: add DLC Update support.
* cnmt: add a reminder about the extended data size in NcmContentMetaType_DataPatch CNMTs.
* nca: update NcaKeyGeneration enum comment.
* title: update system titles array, severely overhaul the way linked lists work in Title* structs to properly support DLC updates.
2022-12-04 11:29:47 +01:00
Pablo Curiel
0f1055c84e Preliminar 15.x support.
This commit uses my yet unmerged libnx PR to update ncm_types.h.

PoC code hasn't been updated yet, so proper support for DLC updates will arrive at a later time.

Note to self: implement a way to provide access to loaded DataPatch TitleInfo entries (linked list hell).

* bktr: renamed bktrBucketInitializeSubStorageReadParams to bktrInitializeSubStorageReadParams to avoid redundancy, added debug code to dump BucketInfo and BucketTree tables if BucketTree storage initialization fails.

* cnmt: updated ContentMetaAddOnContentMetaExtendedHeader struct to its 15.x equivalent, added ContentMetaLegacyAddOnContentMetaExtendedHeader struct, added ContentMetaDataPatchMetaExtendedHeader struct, updated the cnmtGetRequiredTitleId and cnmtGetRequiredTitleVersion functions to support DataPatch titles, updated cnmtInitializeContext to support both the new AddOnContent extended header and DataPatch titles, added debug code to dump the whole CNMT if context initialization fails, updated cnmtGenerateAuthoringToolXml to support DataPatch titles.

* keys: updated block hashes to match 15.x keyset, use case-insensitive comparison while looking for entry names in keysReadKeysFromFile, make sure the eticket_rsa_kek is non-zero before proceeding in keysGetDecryptedEticketRsaDeviceKey.

* nca: updated NcaKeyGeneration enum, added reminder about updating NcaSignatureKeyGeneration if necessary, replaced ncaFsSectionCheckHashRegionAccess with ncaFsSectionCheckPlaintextHashRegionAccess, removed all extents checks on Patch RomFS and sparse sections, updated ncaGetFsSectionTypeName to reflect if a FS section holds a sparse layer or not.

* nca_storage: updated ncaStorageInitializeContext to avoid initializing a compressed storage if a sparse layer is also used (fixes issues with Them's Fightin' Herds), updated ncaStorageSetPatchOriginalSubStorage to enforce the presence of a compressed storage in a patch if the base FS holds a compressed storage.

* npdm: added reminder about updating NpdmSignatureKeyGeneration if necessary, updated NpdmFsAccessControlFlags enum, updated NpdmAccessibility enum, updated NpdmSystemCallId enum, fixed typos.

* title: updated all relevant functions that deal with NcmContentMetaType values to also handle DataPatch titles, added functions to handle DataPatchId values, removed titleConvertNcmContentSizeToU64 and titleConvertU64ToNcmContentSize functions in favor of ncmContentInfoSizeToU64 and ncmU64ToContentInfoSize from my unmerged libnx PR, updated internal arrays to match 15.x changes, renamed titleOrphanTitleInfoSortFunction to titleInfoEntrySortFunction and updated it to also sort entries by version and storage ID, updated titleGenerateTitleInfoEntriesForTitleStorage to sort TitleInfo entries, simplified titleDuplicateTitleInfo a bit by using macros.
2022-10-23 16:44:47 +02:00
Pablo Curiel
00dd3df4fc Update usb.c 2022-09-13 02:53:11 +02:00
Pablo Curiel
5be5a7b16d keys: implement NCA KAEK and titlekek validation.
Keyslots beyond the hardcoded "current" one won't be validated.
2022-09-13 02:22:15 +02:00
Pablo Curiel
7bb708e394 Many small changes (sorry, I need to push these).
* Use forward declarations for type definitions wherever suitable (e.g. NcaContext, BucketTreeContext).
* Replace references to "DumpDestination" with "OutputStorage".
* Replace references to "append key area" with "prepend key area".
* Update LZ4 to v1.9.4.
* Update Material Icons font to 2022-08-01.
* RootView: change USB-related icons, reflect how many UMS devices are currently connected to the console, provide a way for child views to retrieve the populated UMS devices vector.
* Tasks: implement GetUmsDevices().
* Update borealis.
* Update libusbhsfs.
* Begin implementation of a DumpOptionsFrame class to display configurable options before starting a new dump process.
* bktr: rename bktrIsValidSubstorage() to bktrIsValidSubStorage(), use bktrIsValidSubStorage() in bktrInitializeCompressedStorageContext(), fixed a bug in bktrReadCompressedStorage() where Sparse substorages wouldn't be allowed.
* GamecardTab: push a DumpOptionsFrame object onto the view stack if the XCI option is clicked.
2022-09-12 20:19:10 +02:00
Pablo Curiel
3cbdb5dc65 OptionsTab: let AppletFrame take care of registering the B button action. 2022-07-31 04:21:19 +02:00
Pablo Curiel
3b892e2179 OptionsTab: only make even lines focusable in changelog. 2022-07-31 01:47:40 +02:00
Pablo Curiel
cc13552b08 OptionsTab: let borealis take care of hint mgmt. 2022-07-30 16:25:41 +02:00
Pablo Curiel
4d9cb8f19d Even (more) changes.
* TitlesTabItem: override playClickAnimation() to only play the animation when we really need it.

* Fix typos in the localization files.
2022-07-28 04:13:48 +02:00
Pablo Curiel
eee1b2a771 More changes.
* Update libusbhsfs.

* Update borealis.

* nsp_dumper: force free size retrieval after dumping an NSP.

* title: add titleGetGameCardApplicationMetadataEntries().

* Makefile: remove -gdwarf-4 flag.

* nxdt_utils: treat NT_MAX_FILENAME_LENGTH as bytes instead of codepoints, add "TiB" to the array of supported size suffixes.

* GameCardTab: add ProcessGameCardStatus() and PopulateList(), manage list updates in the same fashion as TitlesTab, display message about how to mitigate launch errors after exiting the application, display available applications in the inserted gamecard, display message about how to perform individual operations on the gamecard titles.

* main: add a try/catch block to intercept any possible exceptions thrown while the application is running + use brls::Application::crash() to gracefully exit afterwards. Temporarily disable Applet Mode support.

* exception_handler: use LOG_LEVEL_ERROR.

* LayeredErrorFrame: add GetListFirstFocusableChild().
2022-07-28 00:53:52 +02:00
Pablo Curiel
2f85394117 Update libusbhsfs 2022-07-21 03:43:08 +02:00
Pablo Curiel
b70da7e7bf nca: fix ctx init for NCAs with bogus Patch RomFS. 2022-07-14 14:10:03 +02:00
Pablo Curiel
f5d418e0d3 Update libusbhsfs. 2022-07-14 12:28:40 +02:00
Pablo Curiel
d6d277920b Adjust levels for some log messages. 2022-07-12 19:11:23 +02:00
Pablo Curiel
5cc83491c1 Use verbosity-level-based log macros everywhere.
Also, Result codes are now just printed using %X.
2022-07-12 18:34:49 +02:00
Pablo Curiel
9cb2a0440e Absolute bare minimum to get this to build.
Codebase still needs to be updated to properly use log levels, but at least it's building on all of them.
2022-07-12 05:27:30 +02:00
Pablo Curiel
5f59d0f444 Use nxdumptool's logger in borealis code.
Also updated submodules.
2022-07-12 03:31:39 +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
1cd88b1cd4 bktr: handle compression in patches (part 3).
Updated bktrIsBlockWithinIndirectStorageRange().

Got confirmation that everything is now working as it should. Big thanks to BigKahuna.
2022-07-10 06:41:18 +02:00