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

612 commits

Author SHA1 Message Date
Pablo Curiel
4882f8430a workflow: only build nxdt_rw_poc binary 2023-07-22 00:53:56 +02:00
Pablo Curiel
34615f19c3 poc: remove redundant checks in certain functions 2023-07-22 00:25:58 +02:00
Pablo Curiel
e3dc98643c poc: handle LFS for SystemProgram and SystemData 2023-07-22 00:04:51 +02:00
Pablo Curiel
a8a348afc8 poc: add system title dumping capabilities
system_title_dumper PoC build is no more.

Other changes include:

* smc: add missing assert for SmcGenerateAesKekOption struct.
* title: update titleGenerateFileName() to add support for system titles.
2023-07-21 23:56:50 +02:00
Pablo Curiel
cd73c6360f nxdt_utils: use an arbitrary filename length limit for SD card paths 2023-07-17 23:44:45 +02:00
Pablo Curiel
3b4477262b nxdt_utils: revert NT_MAX_FILENAME_LENGTH change
Treats NT_MAX_FILENAME_LENGTH as codepoints instead of bytes, again.
2023-07-17 23:19:17 +02:00
Pablo Curiel
ae420b3c7b PoC: change NCA FS output path + allow LFS for DLC 2023-07-17 20:20:49 +02:00
Pablo Curiel
75bf75b62a nxdt_rw_poc: use ID offsets in LFS dumps. 2023-07-17 01:17:45 +02:00
Pablo Curiel
8f75b6b923 *FormattedStringToBuffer: relax input validation
Affects both utilsAppendFormattedStringToBuffer() and logWriteFormattedStringToBuffer(). Fixes logging issues within both the exception handler and memory debugging code.

Other changes include:

* bfttf: rename BfttfFontType_Total -> BfttfFontType_Count.
* config: rename "append_authoringtool_data" -> "generate_authoringtool_data".
* fs_ext: update FsGameCardCertificate struct
* gamecard: fix gamecardReadLotusAsicFirmwareBlob() not returning false if FS .data segment memory couldn't be retrieved; update GameCardInfo struct to reflect a recently discovered area that's not zeroed out.
* mem: expand MemoryProgramSegmentType enum; define extra macros for PID buffer size and memory page type checks; force empty memory page attribute and R/X permission checks while looking for the last FS .text segment; make memory page filtering code more readable.
* npdm: rename KernelCapability enums; rename entry_value -> bitmask in all KernelCapability descriptor structs.
* tik: force byte-for-byte memory lookup while dumping volatile tickets.
* libs: update libusbhsfs to latest commit.
* codebase: add missing comments to some enums; add missing "None" and "Count" elements to some enums. "Count" entries from enums with bitmasks will only reflect the number of available bitmask values. Enums with hex values remain unchanged.
* PoC builds: use EXIT_SUCCESS and EXIT_FAILURE as return values.
* nxdt_rw_poc: move "end" jump label within main() to avoid a crash if utilsInitializeResources() fails; reflect changes in config.c.
2023-07-17 01:03:05 +02:00
Pablo Curiel
51b17f35fe Use BITL macro from libnx. 2023-07-10 18:06:34 +02:00
Pablo Curiel
eb4bdbf27a nxdt_log: use __FILE__ macro
Takes advantage of the -fmacro-prefix-map option from GCC8+.

Also updated libusbhsfs again.
2023-06-29 19:08:48 +02:00
Pablo Curiel
3071cee3bd ums: implement umsUnmountDevice
Other changes include:

* libs: update libusbhsfs to latest commit
* nxdt_rw_poc: fix UMS device unmounting, change output XCI naming scheme.
2023-06-29 00:12:51 +02:00
Pablo Curiel
af0db8b0ee host: fix exception message dup under CLI mode. 2023-06-04 20:58:46 +02:00
Pablo Curiel
0e17edace1 host: improve Windows EXE build generation
A virtual environment is now created and used to generate the EXE build, which helps to keep its size down to ~10 MiB.
2023-06-04 20:45:17 +02:00
Pablo Curiel
158d7c1e92 host: add verbose output toggle
Provided as a checkbox in the GUI and a command line argument in the CLI.

Exception information is now also printed to the GUI textbox if the verbose output checkbox is enabled.
2023-06-03 17:27:24 +02:00
Pablo Curiel
961459fe01 bktr: refactor bktrRead*Storage() functions.
Now using loops instead of recursion. Fixes a nasty stack exhaustion issue while dumping Them's Fightin' Herds raw RomFS section (Compressed+Sparse base with Compressed patch).
2023-05-31 15:36:21 +02:00
Pablo Curiel
ecdce35e8d poc: implement RomFS dumping (user titles only). 2023-05-30 23:34:34 +02:00
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