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

422 commits

Author SHA1 Message Date
Pablo Curiel
27465434d4 [ci skip] GamecardTab: fix transition to DumpOptionsFrame view 2024-04-15 13:47:50 +02:00
Pablo Curiel
9525f37e51 [ci skip] Add DataTransfer* classes.
Adds the DataTransferTask and DataTransferProgressDisplay classes, which use repurposed logic from the DownloadTask and EtaProgressDisplay classes, respectively. The EtaProgressDisplay class and EtaProgressInfo struct have been removed.

Other changes include:

* DownloadTask: heavily simplified logic by using DataTransferTask as the base class.

* DumpOptionsFrame: implement some additional/experimental changes.

* OptionsTab: update logic to use the new DataTransferProgressDisplay class.
2024-04-15 01:53:43 +02:00
Pablo Curiel
8f8fc6af37 [ci skip] Add EtaProgressDisplay class.
Also adds a nxdt::views::EtaProgressInfo struct that's used by EtaProgressDisplay's setProgress() method. It may also be used by child classes of AsyncTask.

Other changes include:

* DownloadTask: remove DownloadTaskProgress struct, update logic to use the new nxdt::views::EtaProgressInfo struct.

* DumpOptionsFrame, GameCardTab: minor formatting fixes.

* OptionsTab: remove OptionsTabUpdateProgress class, update logic to use the new nxdt::views::EtaProgressInfo struct.
2024-04-12 23:08:54 +02:00
Pablo Curiel
789a6d6eb8 [skip ci] GameCardTab: reflect current gamecard dump options
Other changes include:

* gamecard: rename gamecardGetDecryptedCardInfoArea() -> gamecardGetPlaintextCardInfoArea().

* FocusableItem, FocusableTable: add positional arguments for the FocusableItem class constructor.
2024-04-12 13:40:50 +02:00
Pablo Curiel
fc5226bfce [skip ci] Update copyright year. 2024-04-12 11:49:03 +02:00
Pablo Curiel
5e333bb92e keys: make latest mkey non-mandatory for older FWs 2024-04-09 02:05:44 +02:00
Pablo Curiel
a5e72a45e0 bktr: minor code cleanup
Removes all references to Compressed storages being used as substorages for Indirect storages.

I should have taken care of this in 0f1055c84e, but I guess I just forgot.
2024-04-06 04:41:47 +02:00
Pablo Curiel
54c5677cd0 QoL changes
* codebase: remove all references to Lockpick / Lockpick_RCM.

* keys: retrieve Atmosphère's key generation in keysLoadKeyset().
* keys: replace all "key_gen_val" references with "mkey_index".
* keys: move latest master key checks in keysReadKeysFromFile() to keysDeriveMasterKeys().
* keys: update latest master key checks to determine if nxdumptool's hardcoded master key vectors are outdated, using the key generation value from Atmosphère. If the master key vectors are outdated, and the newer master key(s) are not available, an error will be displayed.

* nxdt_utils: update logic in utilsReplaceIllegalCharacters() to replace consecutive illegal characters with a single underscore.
* nxdt_utils: move servicesGetExosphereApiVersion() to nxdt_utils as utilsGetExosphereApiVersion().
* nxdt_utils: define internal UtilsExosphereApiVersion struct, which is used to parse the output from utilsGetExosphereApiVersion().
* nxdt_utils: add utilsGetAtmosphereVersion(), utilsGetAtmosphereKeyGeneration() and utilsGetAtmosphereTargetFirmware() functions.

* services: remove servicesGetExosphereApiVersion().
* services: Atmosphère version is now retrieved via utilsGetAtmosphereVersion().
2024-04-05 23:25:32 +02:00
Pablo Curiel
e3cd2a15eb title: updated hardcoded titles list 2024-03-31 15:04:14 +02:00
Pablo Curiel
9e75a019a9 keys/nca: add new keydata for HOS 18.0.0. 2024-03-31 12:16:37 +02:00
Pablo Curiel
c5d6081f08 Fix building with latest libnx commit. 2024-02-16 23:57:08 +01:00
Pablo Curiel
7b707509c7 bktr: perform binary search in bktrGetTreeNodeEntryIndex()
Other changes include:

* poc: fix switching to a different title entry via L/R/ZL/ZR if the content counts don't match. Fixes issues with MGS Master Collection games.
2024-02-16 23:31:24 +01:00
Pablo Curiel
5ffe06508e log: make logGetLastMessage() return a heap buffer 2024-01-20 23:12:55 +01:00
Pablo Curiel
38ff475d9e title: handle NACPs with empty language entries.
Leftover ns application records for factory software yield NACP structs with no identifying strings.

I wasn't expecting this to be a thing.
2024-01-13 21:25:02 +01:00
Pablo Curiel
62c15ca7cf poc: add browser for gamecard HFS partitions
Just in time for New Year's Eve.

Other changes include:

* title: use snprintf() in filename generation functions + reduce array sizes.
2023-12-31 18:16:49 +01:00
Pablo Curiel
c585e8f9d3 poc: add file browser for NCA FS sections.
Takes advantage of the recently implemented devoptab interfaces. Supports individual file dumping and multiple file/dir dumping via highlighting. May possibly need some additional testing. The code could potentially be improved, but I'll look into it at a later time -- I just want to release this now.

Other changes include:

* devoptab: comment out log messages.

* utils: add utilsGetDirectorySize() function.
2023-12-26 01:25:29 +01:00
Pablo Curiel
364b3f39dc romfs: use hash buckets for FS entry lookups.
* romfs: add hash bucket fields to RomFileSystemContext struct.
* romfs: remove current offset fields from RomFileSystemContext struct and all functions that relied on them.
* romfs: add romfsCalculateEntryHash().
* romfs: update romfsInitializeContext() to also load file/directory hash buckets.
* romfs: update romfsGetTotalDataSize() to make up for the removed functions.
* romfs: update romfsGetChild*EntryByName() functions to use hash bucket lookups.

Other changes include:

* devoptab: add missing exit macros to some FS operations across all interfaces.

* poc: update extractedRomFsReadThreadFunc() to make up for the removed RomFS functions.
2023-12-22 12:20:27 +01:00
Pablo Curiel
ef03aa4cbe Custom devoptab wrappers (part 5).
This commit implements a devoptab wrapper for RomFS sections within NCAs, using code from romfs.c/h.

Other changes include:

* devoptab: add additional safety checks and some minor tweaks to both hfs_dev and pfs_dev calls.
2023-12-21 16:51:26 +01:00
Pablo Curiel
091747d197 Custom devoptab wrappers (part 4).
Improve dirnext() calls in both PFS and HFS devoptab wrappers to make them also return bogus "." and ".." directory entries.

The "st_ino" field is now also being filled for all file entries.

Other changes include:

* libs: update libusbhsfs.
2023-12-21 13:29:53 +01:00
Pablo Curiel
e6caff3b17 Custom devoptab wrappers (part 3).
Add some minor tweaks to the devoptab macros.
2023-12-21 02:20:37 +01:00
Pablo Curiel
c392a9f126 Custom devoptab wrappers (part 2).
This commit implements a devoptab wrapper for Hash FS sections within gamecard images, using code from hfs.c/h.

Other changes include:

* poc: disable buffering on FILE objects via setvbuf().
* gamecard: fix crash in gamecardInitializeHashFileSystemContext() while calculating the size for the root Hash FS partition.
2023-12-21 00:39:56 +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
bfdd9e056e poc: enable update option on ExeFS sections. 2023-12-17 19:03:08 +01:00
Johnson
af275a558e
Standardize complete gamecard image (#150)
Makes it possible to retrieve the raw gamecard UID in one go, without having to manually parse the gamecard specific data block.
2023-12-05 19:21:45 +01:00
Pablo Curiel
8c4e432035 Fix building with latest libnx commit. 2023-11-26 23:13:58 +01:00
Pablo Curiel
e2c0cbc898 config: add configResetSettings().
Other changes include:

* poc: add a "reset settings" option to the root menu.
* poc: add a message about using the controller sticks to scroll faster.
* poc: update missing ticket message to be more detailed.
* poc: add "retrieved" flag to MenuElementOption struct, which is reset while going back to a parent menu via menuResetAttributes().
* poc: fix index/count values in title selection screens.
2023-11-26 22:54:25 +01:00
Pablo Curiel
be00971965 title: log orphan title info at initialization.
Other changes include:

* title: rename titleGetApplicationIdByMetaKey() -> titleGetApplicationIdByContentMetaKey().
2023-11-26 22:17:52 +01:00
Pablo Curiel
1f7d73e8ac tik: recreate forged tickets from scratch if detected 2023-11-26 22:16:39 +01:00
Pablo Curiel
b723eb1758 gamecard: add commented out ns call.
`nsEnsureGameCardAccess()` has supposedly helped another user to fix the gamecard launch error after exiting their application, but it's not working under nxdumptool. I have yet to find out why.
2023-11-26 22:13:49 +01:00
Pablo Curiel
ea8bc05146 utils: show Discord server link on keyset errors 2023-11-26 22:12:23 +01:00
Pablo Curiel
315a052ddf usb: bump ABI version. 2023-11-11 21:50:02 +01:00
Pablo Curiel
dcd1f66790 usb: add extra cmds for extracted FS handling
Implements both `StartExtractedFsDump` and `EndExtractedFsDump` commands into both nxdumptool and the Python host script.

Other changes include:

* poc: wake the write thread up if a preprocessing error occurs in all extracted FS dump functions. Fixes previously unhandled hangups.
* poc: verify current NCA hash before sending its last data chunk while dumping a NSP.

* host: update command handler to support CancelFileTransfer commands issued in-between SendFileProperties commands.
* host: update Markdown document.

* usb: use UsbCommandType_Count for the safety check in usbPrepareCommandHeader().
* usb: log both USB command header and command block whenever an error is reported by the host side.
2023-11-11 21:39:41 +01:00
Pablo Curiel
98ed7d1c29 poc: cancel USB xfer on NSP dump error. 2023-11-11 12:16:29 +01:00
Pablo Curiel
1445faf17f I should really stop coding as soon as I arrive back home from work. 2023-11-04 12:38:09 +01:00
Pablo Curiel
e1df86fb27 Fix building with latest libnx + QoL changes.
libnx now implements fsDeviceOperatorGetGameCardIdSet(), so I got rid of my own implementation.

Other changes include:

* cnmt: add cnmtVerifyContentHash().

* defines: add SHA256_HASH_STR_SIZE.

* fs_ext: add FsCardId1MakerCode, FsCardId1MemoryType and FsCardId2CardType enums.
* fs_ext: update FsCardId* structs.

* gamecard: change all package_id definitions from u64 -> u8[0x8].
* gamecard: fix misleading struct member names in GameCardHeader.
* gamecard: rename gamecardGetIdSet() -> gamecardGetCardIdSet().

* gamecard_tab: fix Package ID printing.
* gamecard_tab: add Card ID Set printing.

* host: add executable flag to Python scripts.

* keys: detect if we're dealing with a wiped eTicket RSA device key (e.g. via set:cal blanking). If so, the application will still launch, but all operations related to personalized titlekey crypto are disabled.

* pfs: rename PartitionFileSystemFileContext -> PartitionFileSystemImageContext and propagate the change throughout the codebase.
* pfs: rename PFS_FULL_HEADER_ALIGNMENT -> PFS_HEADER_PADDING_ALIGNMENT and update pfsWriteImageContextHeaderToMemoryBuffer() accordingly.

* poc: print certain button prompts with reversed colors, in the hopes of getting the user's attention.
* poc: NSP, Ticket and NCA submenus for updates and DLC updates now display the highest available title by default.
* poc: simplified output path generation for extracted NCA FS section dumps.
* poc: handle edge cases where a specific NCA from an update has no matching equivalent by type/ID offset in its base title (e.g. Fall Guys' HtmlDocument NCA).
* poc: implement NCA checksum validation while generating NSP dumps.

* romfs: update romfsInitializeContext() to allow its base_nca_fs_ctx argument to be NULL.

* usb: use USB_BOS_SIZE only once.

* workflow: update commit hash referenced by "rewrite-prerelease" tag on update.
2023-11-03 02:22:47 +01:00
Pablo Curiel
32bb5fd46e nxdt_utils: add more helpers.
Implement utilsParseHexString() and utilsAppletLoopDelay().

Other changes include:

* defines: add THIRTY_FPS_DELAY define.
* defines: remove unused CERT_PATH define.

* gamecard: restore original reserved_2 field in GameCardInfo struct. The last 16 bytes weren't being properly due to an issue within libnx's AES-CBC implementation.
* gamecard: rename GAMECARD_ACCESS_WAIT_TIME -> GAMECARD_ACCESS_DELAY.

* host: improve ABI documentation (thanks @v1993).

* keys: remove keysConvertHexDigitToBinary().
* keys: change keysParseHexKey() function signature + update it to use utilsParseHexString() instead.

* nso: change "NRO" to "NSO" in some misleading log error messages (thanks @liamadvance).

* nxdt_rw_poc: replace svcSleepThread() calls with utilsAppletLoopDelay().

* nxdt_utils: rename utilsGenerateHexStringFromData() -> utilsGenerateHexString().
* nxdt_utils: add static utilsConvertHexDigitToBinary() function, used by utilsParseHexString().
* nxdt_utils: update utilsAppendFormattedStringToBuffer() to avoid logging an error string if resources haven't been initialized.
* nxdt_utils: use a single call to sprintf() with a variable precision argument in utilsGenerateFormattedSizeString().
* nxdt_utils: call utilsAppletLoopDelay() in the while loop from utilsPrintConsoleError().
* nxdt_utils: remove unused utilsCloseFileDescriptor() function.

* tik: log input rights ID at the start of tikRetrieveTicketByRightsId().
2023-10-23 00:44:40 +02:00
Pablo Curiel
c1b76fb2d9 Rework signature/cert/tik interfaces.
* signature: add comments to SignatureType enum entries about the exact signing algorithms and padding schemes used.
* signature: rename signatureGetSigType() -> signatureGetTypeFromSignedBlob().
* signature: rename signatureIsValidSigType() -> signatureIsValidType().
* signature: rename signatureGetSigSize() -> signatureGetSigSizeByType().
* signature: rename signatureGetBlockSize() -> signatureGetBlockSizeByType().
* signature: rename signatureGetSig() -> signatureGetSigFromSignedBlob().
* signature: rename signatureGetPayload() -> signatureGetPayloadFromSignedBlob().
* signature: add signatureGetBlockSizeFromSignedBlob().

* cert: add more comments to the code.
* cert: update code to match signature interface changes.
* cert: add CERT_RSA_PUB_EXP_SIZE macro.
* cert: change public_exponent field in CertPublicKeyBlockRsa* structs from u32 to u8 array.
* cert: add size field to CertificateChain struct.
* cert: rename certGetCommonBlock() -> certGetCommonBlockFromSignedCertBlob.
* cert: rename certGetPublicKeySize() -> certGetPublicKeySizeByType().
* cert: rename certGetPublicKeyBlockSize() -> certGetPublicKeyBlockSizeByType().
* cert: rename certIsValidCertificate() -> certIsValidSignedCertBlob().
* cert: rename certGetSignedCertificateSize() -> certGetSignedCertBlobSize().
* cert: rename certGetSignedCertificateHashAreaSize() -> certGetSignedCertBlobHashAreaSize().
* cert: remove certGetPublicKey(), certGetPublicExponent() and certCalculateRawCertificateChainSize().
* cert: add certGetPublicKeyTypeFromCommonBlock(), certGetPublicKeyTypeFromSignedCertBlob(), certGetPublicKeySizeFromSignedCertBlob(), certGetPublicKeyBlockSizeFromSignedCertBlob(), certGetPublicKeyFromSignedCertBlob(), certGetPublicExponentFromSignedCertBlob(), certIsValidCertificate() (w/diff func sig), certGetCommonBlockFromCertificate(), certGetPublicKeyTypeFromCertificate(), certGetPublicKeySizeFromCertificate(), certGetPublicKeyBlockSizeFromCertificate(), certGetPublicKeyFromCertificate(), certGetPublicExponentFromCertificate() and certGetHashAreaSizeFromCertificate() functions.
* cert: avoid byteswapping the public key type value in multiple places -- it is now only being done in certGetPublicKeyTypeFromCommonBlock().
* cert: call certFreeCertificateChain() in _certRetrieveCertificateChainBySignatureIssuer() before attempting to retrieve the certificate chain.
* cert: other minor changes and corrections.

* tik: update code to match signature interface changes.
* tik: add missing comments to TikPropertyMask enum entries.
* tik: add key_generation, enc_titlekey_str and dec_titlekey_str fields to Ticket struct.
* tik: update tikRetrieveTicketByRightsId() to also take in a key_generation argument, instead of getting it from the rights ID (which could fail if it's using a key generation lower than HOS 3.0.1) or the key_generation field from the common ticket block (which could fail if the ticket has been tampered by certain tools).
* tik: rename tikGetCommonBlock() -> tikGetCommonBlockFromSignedTicketBlob().
* tik: change function signature for tikGetTicketSectionRecordsBlockSize().
* tik: rename tikIsValidTicket() -> tikIsValidSignedTicketBlob().
* tik: rename tikGetSignedTicketSize() -> tikGetSignedTicketBlobSize().
* tik: rename tikGetSignedTicketHashAreaSize() -> tikGetSignedTicketBlobHashAreaSize().
* tik: rename tikGetEncryptedTitleKeyFromTicket() -> tikGetEncryptedTitleKey().
* tik: add tikIsValidTicket() (w/diff func sig), tikGetCommonBlockFromTicket(), tikGetHashAreaSizeFromTicket(), tikFixTamperedCommonTicket(), tikVerifyRsa2048Sha256Signature() and tikDecryptVolatileTicket() functions. Ticket signature verification is only carried out for common tickets in tikFixTamperedCommonTicket().
* tik: change argument order in tikGetTicketEntryOffsetFromTicketList() and tikRetrieveTicketEntryFromTicketBin().
* tik: add TIK_COMMON_CERT_NAME and TIK_DEV_CERT_ISSUER macros.
* tik: use a scoped lock when calling tikRetrieveTicketFromEsSaveDataByRightsId().
* tik: simplify certificate chain retrieval steps in tikConvertPersonalizedTicketToCommonTicket() by always using the XS00000020 certificate.
* tik: wipe license_type and property_mask fields in tikConvertPersonalizedTicketToCommonTicket().
* tik: other minor changes and corrections.

Other changes include:

* keys: fix key generation checks in keysGetNcaKeyAreaKeyEncryptionKey() and keysGetTicketCommonKey().

* rsa: move core logic from rsa2048VerifySha256BasedPssSignature() into a new function: rsa2048VerifySha256BasedSignature().
* rsa: add rsa2048VerifySha256BasedPkcs1v15Signature() function.
2023-10-15 17:53:46 +02:00
Pablo Curiel
ecaeddf356 Fix Patch RomFS ctx init w/missing base NCA FS.
This bug was introduced in c474435ea8.

Other changes include:

* nxdt_rw_poc, bktr: minor cosmetic code changes.
* cnmt: add ContentMetaPlatform enum.
2023-10-12 11:24:03 +02:00
Pablo Curiel
bb4608118d Update hardcoded key sources to match HOS 17.0.0 2023-10-11 07:41:58 +02:00
Pablo Curiel
c474435ea8 nca_storage: set original substorage while initializing a patch NCA storage.
ncaStorageInitializeContext() now takes an extra input argument. ncaStorageSetPatchOriginalSubStorage() is now a static function that's only used internally.

Fixes issues with "AKIBA'S TRIP: Undead & Undressed Director's Cut" compressed storage initialization while using an update. Big thanks to @Arch9SK7 for reporting the issue.
2023-09-24 18:41:39 +02:00
Pablo Curiel
d2d192c9ea title: updated hardcoded systitle list. 2023-09-03 10:57:20 +02:00
Pablo Curiel
4103d91111 nxdt_utils: treat max filename length as bytes.
Fixes issues while using USB dumping with a Linux host. We're still preserving the arbitrary max filename length for SD card files.
2023-09-03 02:29:16 +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
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
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
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
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