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

628 commits

Author SHA1 Message Date
Pablo Curiel
94f0312566 bis_storage: add QoL improvements
The BIS storage interface is now initialized by utilsInitializeResources() via bisStorageInitialize(). It takes care of mounting all eMMC FAT partitions in read-only mode, making it possible for the rest of the code to interact with them at any time without having to manually mount them beforehand.

Other changes include:

* bis_storage: add bisStorageExit().
* bis_storage: add bisStorageGetGptPartitionNameByBisPartitionId(), bisStorageGetSystemInitializerPartitionNameByBisPartitionId() and bisStorageGetMountNameByBisPartitionId() helpers.
* bis_storage: change bisStorageMountPartition(), bisStorageUnmountPartition() and bisStorageUnmountAllPartitions() to static functions.
* bis_storage: mount FAT partitions with FatFs by using drive numbers instead of arbitrary strings.

* cert: update code to reflect BIS storage interface changes.

* defines: add BIS_FAT_PARTITION_COUNT macro.

* fatfs/ffconf: use BIS_FAT_PARTITION_COUNT macro as the value for the FF_VOLUMES macro.
* fatfs/ffconf: disable arbitrary string support for volume IDs.

* nxdt_devoptab: increase concurrent mounted device count to 8.

* nxdt_utils: add missing underscores to anonymous variables in SCOPED_LOCK and SCOPED_TRY_LOCK macros.
* nxdt_utils: take care of BIS storage interface (de)initialization.

* poc: update code to reflect BIS storage interface changes.

* tik: update code to reflect BIS storage interface changes.
2024-11-01 13:54:37 +01:00
Pablo Curiel
4589614183 bis_storage: add menu option.
Makes it possible to browse eMMC partitions and dump data from them.

Since we're manually parsing FAT partitions, reading files protected by the FS sysmodule at runtime is possible.
2024-10-28 15:44:31 +01:00
Pablo Curiel
596928a3c6 Create BIS storage interface.
Takes care of retrieving a FsStorage object for any FAT eMMC BIS partition, mounting it via FatFs and creating a virtual devoptab device that can be used to carry out FS operations. All write operations have been stubbed, disabled or ifdef'd out of the code.

Other changes include:

* cert: update code to use the new BIS storage interface.

* defines: remove BIS_SYSTEM_PARTITION_MOUNT_NAME macro.

* devoptab: slightly improve macros.
* devoptab: add operation table for FatFs devices.
* devoptab: add rodev_fstat().
* devoptab: add devoptabMountFatFsDevice().

* fatfs: update diskio code to use the new BIS storage interface.
* fatfs: update configuration.

* save: update code to use regular C I/O calls instead of FatFs calls.

* tik: update code to use the new BIS storage interface.

* utils: remove eMMC BIS System partition (un)mount code.
2024-10-28 14:31:58 +01:00
Pablo Curiel
160236c4de system_update: add menu option.
Makes it possible to dump a system update. The SystemVersion file is retrieved to get additional information about the system update.
2024-10-27 12:23:46 +01:00
Pablo Curiel
d2baf7ee7f Create and initialize system update interface.
It will be used to dump system updates by parsing content meta info records from the SystemUpdate CNMT while also validating all content hashes and signatures.
2024-10-24 23:26:00 +02:00
Pablo Curiel
323b38cb15 nso: update NsoModHeader struct to HOS 19.0.0. 2024-10-12 22:12:18 +02:00
Pablo Curiel
f376eb6db4 keys: relax mkey requirements on older firmwares.
A hardcoded table with HOS version numbers and master key indexes is now used to determine the HOS key generation at runtime, whenever possible. This allows the application to more accurately determine the key generation that's actually required by the console it's running on.

Most parts of the code that relied on the Atmosphère key generation value have been updated to use the HOS key generation value instead. If the HOS version is too high/unknown, the code will fallback to the Atmosphère key generation value.

Furthermore, if the HOS key generation value is lower than our last known key generation, the code will now try to look for the highest available master key it can use to derive all lower master keys, beginning with the last known master key and ending with the master key that matches the HOS key generation value. Previous behavior only checked the availability of the master key that matched the Atmosphère key generation, which isn't completely reliable nor accurate.

If this process fails, current master key derivation will be carried out as a last resort, which wasn't being done either under this specific scenario.

Other changes include:

* keys: add keysGetHorizonOsKeyGeneration().
* keys: move current master key derivation logic into its own function, keysDeriveCurrentMasterKey(), which is now used if both Atmosphère and HOS and up-to-date, or if a lower master key is required (as a last resort method).
2024-10-12 20:38:33 +02:00
Pablo Curiel
94c396af19 codebase: support HOS 19.0.0.
Still missing NACP changes.
2024-10-10 13:14:01 +02:00
Pablo Curiel
b7718cb6e9 title: update internal system title list
Other changes include:

* title: update titleGetContentInfosByGameCardContentMetaContext() to make it write the forged NcmContentInfo entry for the Meta NCA at the start of the returned buffer (matches ncm output).
2024-10-08 01:15:16 +02:00
Pablo Curiel
521191e0d3 utils: add emuMMC detection 2024-10-08 01:09:46 +02:00
Pablo Curiel
7b36fddf33 Upgrade C standard to C23. 2024-10-08 00:58:45 +02:00
Pablo Curiel
f7d6eaf73f host: fix speed calculation issues 2024-10-08 00:57:01 +02:00
Pablo Curiel
14acd00559
Update nxdt_host_exe.yml
Upload Python script to pre-release tag, too.
2024-08-28 14:16:36 +02:00
Whovian9369
669e39a943
Add GitHub Actions Workflow to build Host EXE (#170) 2024-08-28 12:03:19 +02:00
Pablo Curiel
76de7b10fd [ci skip] nxdt_host: update to v0.5
Changes include:

* Fix progress bar window not being automatically closed if a cancel request is received from the console in-between two different NSP file entry transfers.
* Handle unit and divisor retrieval directly inside the ProgressBarWindow class.
* Carry out a separate speed calculation whenever necessary to always display transfer rates in MiB/s.
* Fix CLI mode.
* Minor grammar corrections in the code.
2024-08-26 11:25:33 +02:00
Pablo Curiel
392887c12f title: clean up CSV generation
Makes titleGenerateTitleRecordsCsv() more readable.
2024-08-26 10:08:58 +02:00
Pablo Curiel
4b57609860 pfs: change name table padding handling
Updates pfsAddEntryInformationToImageContext() to handle name table padding and alignment on its own. As a result, the logic from pfsWriteImageContextHeaderToMemoryBuffer() has been heavily simplified.
2024-08-26 10:06:17 +02:00
Pablo Curiel
9d792279d3 poc: small fixes
* Fix reset settings option.
* Try to display sizes using a human-readable format after starting a dump process.
2024-08-26 09:45:52 +02:00
Pablo Curiel
7ed5de9201 Uses a dynamically allocated buffer to hold the CSV data, which can then be written to an output file.
Changes include:

* nxdt_utils: add utilsEscapeCharacters().

* title: add titleGenerateTitleRecordsCsv().
* title: move core logic from titleGetUserApplicationData() into _titleGetUserApplicationData(). titleGetUserApplicationData() now only takes care of duplicating the retrieved data.
* title: update titleGetContentInfosByGameCardContentMetaContext() to make it write the forged NcmContentInfo entry for the Meta NCA at the end of the returned buffer.
* title: fix a bug in titleRefreshGameCardTitleInfo() that prevented a title info's metadata pointer to be updated after retrieving application metadata via ns.
* title: update titleGenerateGameCardApplicationMetadataArray() to add a logfile warning if an application entry doesn't have a valid application metadata pointer.
* title: make _titleGenerateGameCardFileName() a bit easier to read.
2024-08-24 20:10:16 +02:00
Pablo Curiel
9c7a57e028 title: init gc title storage by HFS as fallback
Makes it possible to generate TitleInfo and TitleApplicationMetadata elements for gamecards that can't be used with ncm (e.g. Kiosk / Quest gamecards under retail, non-Quest units). This is achieved by:

1. Retrieving a Hash FS context for the gamecard's secure partition.
2. Initializing NCA and CNMT contexts for all of the Meta NCAs within the secure partition.
3. Manually generating NcmContentMetaKey and NcmContentInfo elements per each CNMT context.
4. Creating TitleInfo elements using the generated NcmContentMetaKey and NcmContentInfo elements.
5. Initializing NCA and NACP contexts for the base (or update) Control NCAs within the secure partition.
6. Manually generating a NsApplicationControlData element per each NACP context.
7. Creating TitleApplicationMetadata elements using the generated NsApplicationControlData elements.

Afterwards, gamecard title/content enumeration and all other features that rely on it (e.g. NSP, NCA, NCA FS) work as expected. Please note that this process is only carried out if regular title storage initialization fails.

Other changes include:

* title: reorder code.
* title: add TitleGameCardContentMetaContext struct.
* title: rename titleGetInfoFromStorageByTitleId() -> titleGetTitleInfoEntryFromStorageByTitleId().
* title: add titleInitializeGameCardTitleStorageByHashFileSystem().
* title: rename titleGenerateDummySystemMetadataEntry() -> titleGetSystemMetadataEntry().
* title: rename titleRetrieveUserApplicationMetadataByTitleId() -> titleGenerateUserMetadataEntryFromNs().
* title: move ns logic from titleRetrieveUserApplicationMetadataByTitleId() into a new function: titleGetApplicationControlDataFromNs().
* title: add titleGenerateUserMetadataEntryFromControlNca().
* title: add titleGetApplicationControlDataFromControlNca().
* title: add titleInitializeUserMetadataEntryFromControlData().
* title: add titleGenerateTitleInfoEntriesByHashFileSystemForGameCardTitleStorage().
* title: move TitleInfo generation logic from titleGenerateTitleInfoEntriesForTitleStorage() into a new function: titleGenerateTitleInfoEntry().
* title: add titleInitializeTitleInfoApplicationMetadataFromControlNca().
* title: add titleGetGameCardContentMetaContexts().
* title: add titleFreeGameCardContentMetaContexts().
* title: add titleGetContentInfosByGameCardContentMetaContext().
* title: rename _titleGetInfoFromStorageByTitleId() -> _titleGetTitleInfoEntryFromStorageByTitleId().
* title: rename titleSystemTitleMetadataEntrySortFunction() -> titleSystemMetadataSortFunction().
* title: rename titleUserApplicationMetadataEntrySortFunction() -> titleUserMetadataSortFunction().
* title: rename titleInfoEntrySortFunction() -> titleInfoSortFunction().
* title: add titleGameCardContentMetaContextSortFunction().

* codebase: update to reflect the rest of the changes.
2024-08-18 15:29:57 +02:00
Pablo Curiel
89b211c146 nca: fix impl issues in ncaInitializeContextCommon()
Other changes include:

* cnmt, nca: handle NcmContentId elements in a more uniform way.

* gamecard: add some comments to the GameCardFlags enum.

* nxdt_log: make sure log messages are horizontally aligned.
2024-08-12 12:10:34 +02:00
Pablo Curiel
a06a511ce7 nca: add ncaInitializeContextByHashFileSystemEntry
Other changes include:

* nca: move common logic from ncaInitializeContext() into ncaInitializeContextCommon().
2024-08-11 20:15:45 +02:00
Pablo Curiel
5a40167a13 title: pre-generate gamecard filenames
Changes include:

* title: define a global string array for the pre-generated gamecard filenames.
* title: move gamecard filename generation logic into a new function, _titleGenerateGameCardFileName().
* title: update background gamecard thread logic to make it generate gamecard filenames on any status changes.
* title: update titleGenerateFileName() to make it return a duplicate of the gamecard filename requested by the caller.
2024-08-11 12:59:22 +02:00
Pablo Curiel
00497b5181 nso: update read logic
Changes include:

* mem: change all references to `Rodata` to `RoData`.

* nso: change all references to `Rodata` to `RoData`.
* nso: update `NsoModStart` struct.
* nso: rename `NsoModuleInfo` struct to `NsoModulePath`.
* nso: add `NsoRoDataStart` struct.
* nso: update logic in both nsoIsNnSdkVersionWithinSegment() and nsoGetNnSdkVersion() functions to work entirely with memory-based offsets.
* nso: rename nsoGetModuleInfoName() to nsoGetModulePath().
* nso: update logic in nsoInitializeContext() to always validate and use the NsoNnSdkVersion block offset from the NsoModStart block.
2024-08-08 12:27:54 +02:00
Pablo Curiel
414780ada8 Some updates
* fs_ext: rename `sel_t1_key` field in `FsCardId2` struct to `card_security_number`.
* fs_ext: add `FsCardId2CardSecurityNumber` enum.

* gamecard: add `GameCardUid` struct.
* gamecard: add `GameCardUidMakerCode` enum.
* gamecard: add `GameCardUidCardType` enum.
* gamecard: update `GameCardSpecificData` struct to reflect the other changes.

* lz4: update to v1.10.0.

* npdm: update `NpdmMetaFlags` struct.

* nso: rename `entry_point` field in `NsoModStart` struct to `version`.
* nso: add `NsoNnSdkVersion` struct.
* nso: update code to make it retrieve nnSdk version info from input NSOs whenever possible.

* GameCardImageDumpTask: fix gamecard image dumping with prepended key areas.
2024-08-06 22:57:54 +02:00
Pablo Curiel
d64c4de092 utils: report IsT flag at startup 2024-05-26 13:31:43 +02:00
Pablo Curiel
503ce4c1a7 gamecard: add proper validation of root HFS partition headers in Terra gamecards 2024-05-20 23:06:36 +02:00
Pablo Curiel
7d5b904835 gamecard: disable hash checks on Terra gamecards 2024-05-19 20:55:36 +02:00
Pablo Curiel
b97fb24005 poc: fix crash if no user titles are available
Thanks to @piplup55 for testing the changes.
2024-05-11 00:09:49 +02:00
Pablo Curiel
b0ce6fc618 LayeredErrorFrame: use focus stack references
Other changes include:

* Codebase: remove `_i18n` operators from strings used in brls::i18n::getStr() calls.

* GameCardStatusTask: rename first_notification -> skip_notification.
* GameCardStatusTask: fire event before displaying a notification.

* libs: update borealis fork.

* TitlesTab: store application metadata pointer array and size into local variables.
2024-05-10 12:18:57 +02:00
Pablo Curiel
d9c8d93180 TitleMetadataTask: use a struct instead of a vector
The struct has been typedef'd as TitleApplicationMetadataInfo. It holds the pointer to the array returned by titleGetApplicationMetadataEntries(), as well as the number of elements available in the array.

There's no point in populating a vector when we already have an array we can work with.
2024-05-06 00:41:41 +02:00
Pablo Curiel
5cc387c9b6 title: migrate application metadata filtering logic to background thread
titleGetApplicationMetadataEntries() and titleGetGameCardApplicationMetadataEntries() will now return dynamically allocated copies of internal pre-filtered / pre-processed arrays, which are generated using the background gamecard thread. This results in less overhead for any potential calls to these functions.

Other changes include:

* title: rename TitleGameCardApplicationMetadataEntry -> TitleGameCardApplicationMetadata.
* title: add `has_patch` field to TitleGameCardApplicationMetadata struct.
* title: declare internal TitleApplicationMetadata arrays to hold pre-filtered application metadata.
* title: declare internal TitleGameCardApplicationMetadata array to hold pre-processed gamecard application metadata.
* title: move filtering logic from titleGetApplicationMetadataEntries() to a new function: titleGenerateFilteredApplicationMetadataPointerArray().
* title: move processing logic from titleGetGameCardApplicationMetadataEntries() to a new function: titleGenerateGameCardApplicationMetadataArray().
* title: rename titleGetPatchVersionString() -> titleGetDisplayVersionString().
* title: add extra debug log messages to some functions.
* title: update titleFreeApplicationMetadata() to also free the new internal metadata arrays.
* title: update background thread logic in titleGameCardInfoThreadFunc() to also regenerate the pre-filtered application metadata and gamecard application metadata arrays right after a successful call to titleRefreshGameCardTitleInfo().
* title: update titleGetDisplayVersionString() to also support base application titles.
* title: simplify string generation logic in titleGenerateGameCardFileName() by using the cached gamecard application metadata array.

* GameCardStatusTask: add GetGameCardStatus() method.

* GameCardTab: fix callback argument type in class constructor.
* GameCardTab: update ProcessGameCardStatus() to block user inputs while processing the new gamecard status.

* RootView: add GetGameCardStatus() method.

* StatusInfoTask: turn IsInternetConnectionAvailable() into an inline method.

* TitleMetadataTask: turn GetApplicationMetadata() into an inline method.
* TitleMetadataTask: move debug log messages around.

* TitlesTab: update PopulateList() to block user inputs while updating the titles list.

* UmsTask: turn GetUmsDevices() into an inline method.

* UsbHostTask: turn GetUsbHostSpeed() into an inline method.
2024-05-05 21:42:32 +02:00
Pablo Curiel
6acdb38d11 FileWriter: remove call to ftruncate()
ftruncate() may severely delay the start of a dump process for certain UMS devices, and the write speed differences when using the SD card seem to be negligible.

Other changes include:

* FileWriter: add log messages throughout all class methods.

* log: update generic log macros to use __PRETTY_FUNCTION__ instead of __func__.
* log: add logFormatFunctionName() function, which takes an input __PRETTY_FUNCTION__ string and parses the info we need from it.
* log: update _logWriteFormattedStringToLogFile() and logWriteFormattedStringToBuffer() functions to reflect the other changes.
2024-05-03 15:14:32 +02:00
Pablo Curiel
7dc0f76224 Remove all references to NSWDB.
Other changes include:

* config: remove ConfigChecksumLookupMethod enum.
* config: remove "gamecard/checksum_lookup_method" integer field.
* config: add "gamecard/lookup_checksum" boolean field.
* config: update default configuration file.
* defines: remove all NSWDB macros.

* GameCardImageDumpTask: update class to reflect the changes made to the configuration interface.

* GameCardImageDumpOptionsFrame: update class to reflect the changes made to the configuration interface.

* OptionsTab: remove OptionsTabUpdateFileDialog class.
* OptionsTab: remove "Update NSWDB XML" element.

* i18n: update localization files to reflect the rest of the changes.
2024-05-02 15:38:39 +02:00
Pablo Curiel
daacdde44f workflow: fix issues + remove ccache support
Props to @Whovian9369 for helping me get the workflow to a working state once more.

This is only a temporary measure. We don't want any more people with broken nxdumptool builds. We'll reintroduce ccache support at a later time.
2024-05-02 14:27:32 +02:00
Pablo Curiel
34ada96e2f [ci skip] Update Makefile 2024-05-01 21:18:05 +02:00
Pablo Curiel
3356bfa89c Update Makefile 2024-05-01 20:24:41 +02:00
Pablo Curiel
9cdbbf096b Update rewrite.yml 2024-05-01 18:40:18 +02:00
Pablo Curiel
21f16ef020 OptionsTab: reset cached output storage value while resetting settings.
Other changes include:

* workflow: try manually cloning the repository instead of using the checkout action.
2024-05-01 13:56:49 +02:00
Pablo Curiel
1ff3df4eca OptionsTab: add reset settings option.
Other changes include:

* gamecard: set GameCardStatus_Processing as the current gamecard status before calling gamecardLoadInfo().

* workflow: try to fix the missing commit tag issue.
2024-05-01 12:50:36 +02:00
Pablo Curiel
50deeeb41b Improve directory layout while we still can.
The directory layout is partially based on the C++ namespaces we're currently using.

Other changes include:

* devoptab: move directory into "core".

* fatfs: move directory into "core".

* GameCardTab: move portions of logic from PopulateList() into their own methods.
* GameCardTab: use a macro to generate the properties table.
* GameCardTab: use a macro to add ListItem elements.
* GameCardTab: update AddApplicationMetadataItems() method to also display the number of DLCs available in the inserted gamecard for each application whenever possible.

* Makefile: remove all extra entries from the INCLUDES variable.

* nxdt_includes: move HOS version structs into their own header file.

* tasks: move code for each individual task into its own file(s).

* title: update titleGetGameCardApplicationMetadataEntries() to also count the number of DLCs available in the inserted gamecard for any given base application.
* title: reorder gamecard application metadata entries by name before returning the buffer in titleGetGameCardApplicationMetadataEntries().
2024-04-30 23:01:42 +02:00
Pablo Curiel
3e10421ec9 Add DataTransferTaskFrame and GameCardImageDumpTaskFrame classes
DataTransferTaskFrame is a template class that's derived from brls::AppletFrame, which automatically starts a background task using an internal object belonging to a class derived from DataTransferTask. A DataTransferProgressDisplay view is used to show progress updates. If the background task hits an error, the class takes care of switching to an ErrorFrame view with the corresponding error message.

GameCardImageDumpTaskFrame is a derived class of DataTransferTaskFrame that uses a GameCardImageDumpTask object as its background task. In layman's terms, this provides a way to fully dump gamecard images using the new UI.

DataTransferTaskFrame depends on the newly added is_base_template helper from goneskiing to check if the class for the provided task is derived from DataTransferTask.

Other changes include:

* DataTransferProgressDisplay: rename setProgress() method to SetProgress().

* DataTransferTask: move post-task-execution code into its own new private method, PostExecutionCallback(), and update both OnCancelled() and OnPostExecute() callbacks to invoke it.
* DataTransferTask: update OnProgressUpdate() to allow sending a last progress update to all event subscribers even if the background task was cancelled.
* DataTransferTask: update OnProgressUpdate() to allow sending a first progress update if no data has been transferred but the total transfer size is already known.
* DataTransferTask: update OnProgressUpdate() to avoid calculating the ETA if the speed isn't greater than 0.

* DumpOptionsFrame: remove UpdateOutputStorages() method.
* DumpOptionsFrame: update class to use the cached output storage value from our RootView.
* DumpOptionsFrame: add GenerateOutputStoragesVector() method, which is used to avoid setting dummy options while initializing the output storages SelectListItem.
* DumpOptionsFrame: update UMS task callback to add the rest of the leftover logic from UpdateOutputStorages().
* DumpOptionsFrame: update RegisterButtonListener() to use a wrapper callback around the user-provided callback to check if the USB host was selected as the output storage but no USB host connection is available.

* ErrorFrame: use const references for all input string arguments.

* FileWriter: fix a localization stirng name typo.
* FileWriter: fix an exception that was previously being thrown by a fmt::format() call because of a wrong format specifier.

* FocusableItem: add a static assert to check if the provided ViewType is derived from brls::View.

* gamecard: redefine global gamecard status variable as an atomic unsigned 8-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call gamecardGetStatus().

* GameCardImageDumpOptionsFrame: define GAMECARD_TOGGLE_ITEM macro, which is used to initialize all ToggleListItem elements from the view.
* GameCardImageDumpOptionsFrame: update button callback to push a GameCardImageDumpTaskFrame view onto the borealis stack.

* GameCardImageDumpTask: move class into its own header and module files.
* GameCardImageDumpTask: update class to also take in the checksum lookup method (not yet implemented).
* GameCardImageDumpTask: update class to send its first progress update as soon as the gamecard image size is known.
* GameCardImageDumpTask: update class to avoid returning a string if the task was cancelled -- DataTransferTaskFrame offers logic to display the appropiate cancel message on its own.

* GameCardTab: update PopulateList() method to display the new version information available in TitleGameCardApplicationMetadataEntry elements as part of the generated TitlesTabItem objects.

* i18n: add new localization strings.

* OptionsTab: update background task callback logic to handle task cancellation, reflecting the changes made to DataTransferTask.
* OptionsTab: reflect changes made to DataTransferProgressDisplay.

* RootView: cache the currently selected output storage value at all times, which is propagated throughout different parts of the UI. Getter and setter helpers have been added to operate with this value.
* RootView: add GetUsbHostSpeed() helper, which can be used by child views to retrieve the USB host speed on demand.
* RootView: update UMS task callback to automatically reset the cached output storage value back to the SD card if a UMS device was previously selected.

* title: define TitleGameCardApplicationMetadataEntry struct, which also holds version-specific information retrieved from the gamecard titles.
* title: refactor titleGetGameCardApplicationMetadataEntries() to return a dynamically allocated array of TitleGameCardApplicationMetadataEntry elements.

* usb: redefine global endpoint max packet size variable as an atomic unsigned 16-bit integer, which fixes a "status-hopping" issue previously experienced by repeating tasks running under other threads that periodically call usbIsReady().

* UsbHostTask: add GetUsbHostSpeed() method.
2024-04-29 15:26:12 +02:00
Pablo Curiel
32c097c055 [ci skip] Add GameCardImageDumpTask and FileWriter classes
GameCardImageDumpTask is a derived class of DataTransferTask, and it's designed to dump a gamecard image using the options selected by the user (which must be passed from a GameCardImageDumpOptionsFrame object). It uses std::optional<std::string> as its return type -- the idea behind this is to return error strings that may later be displayed by an ErrorFrame during the dump process (views not yet implemented).

FileWriter is a class that encapsulates write operations to different storage mediums (SD card, USB host and UMS devices), based on the provided input path. It is used by GameCardImageDumpTask to painlessly write data to the right output storage without explicitly having to implement multiple code paths for all storage types as part of the actual dump code. Furthermore, FileWriter also supports writing split files to FAT-formatted UMS devices if an output file is >= 4 GiB -- part file handling is completely abstracted away from any callers.

Other changes include:

* AsyncTask: rename all class methods to use PascalCase naming.
* AsyncTask: rename get() -> GetResult().

* DataTransferTask: reflect the changes made to AsyncTask.
* DataTransferTask: pause the RepeatingTask right after LoopCallback() returns true instead of pausing it in the cancel/post-execute callbacks.
* DataTransferTask: add private FormatTimeString() method.
* DataTransferTask: remove superfluous override for DoInBackground() -- classes derived from DataTransferTask must provide it on their own, anyway.
* DataTransferTask: add public GetDurationString() method.

* defines: update FAT32_FILESIZE_LIMIT macro to use UINT32_MAX.
* defines: add CONCATENATION_FILE_PART_SIZE macro (used by the new FileWriter class).

* DownloadTask: reflect the changes made to AsyncTask.

* DumpOptionsFrame: file extension is no longer stored as a class member, nor required by the class constructor.
* DumpOptionsFrame: change the return type for GetOutputFilePath() to bool. The method now saves its output to a variable passed by reference.

* GameCardImageDumpOptionsFrame: reflect the changes made to DumpOptionsFrame.

* i18n: update localization strings where applicable.

* nxdt_utils: fix a potential buffer overflow in utilsGetFileSystemStatsByPath().

* OptionsTab: reflect the changes made to AsyncTask.

* usb: add const qualifier to the input buffer required by usbSendFileData().
* usb: add const qualifier to the input buffer required by usbSendNspHeader().
2024-04-25 01:49:04 +02:00
Pablo Curiel
56053e8105 gamecard: add smarter delay to detection thread
Lets us respond in a better way to sudden gamecard status changes during the 3 second wait period.
2024-04-21 13:27:06 +02:00
Pablo Curiel
ec993864fd [ci skip] GameCardImageDumpOptionsFrame: add gamecard task subscription
Lets us pop the frame itself from the view stack as soon as the gamecard is ejected. We're all about making this as fool-proof as possible.
2024-04-21 13:05:55 +02:00
Pablo Curiel
1181a95d17 [ci skip] DumpOptionsFrame: add GetOutputFilePath method
Other changes include:

* DumpOptionsFrame: update contructors to also take a base output path string.

* GameCardImageDumpOptionsFrame: simplify constructor by letting it take care of retrieving the title on its own.

* nxdt_utils: remove utilsCreateOutputDirectories() function -- we'll be using utilsCreateDirectoryTree() anyway, so it's okay.
2024-04-20 23:52:56 +02:00
Pablo Curiel
17ec42d812 [ci skip] Add GameCardImageDumpOptionsFrame class
This commit turns DumpOptionsFrame into a non-polymorphic, non-instantiable class with an overloaded constructor, and moves most of the generic logic from its header file into a proper C++ module.

GameCardImageDumpOptionsFrame is an inherited class of DumpOptionsFrame, which adds the extra option items it needs on its own.
2024-04-20 00:42:11 +02:00
Pablo Curiel
4af144486a gamecard: add support for Header2-related areas
These changes include:

* gamecard: add GAMECARD_HEADER2_OFFSET and GAMECARD_HEADER2_CERT_OFFSET macros.
* gamecard: rename GAMECARD_CERTIFICATE_OFFSET macro to GAMECARD_CERT_OFFSET.
* gamecard: add GameCardFlags2 enum.
* gamecard: update GameCardHeader struct to reflect the new Flags2 field.
* gamecard: add GameCardHeader2, GameCardHeader2EncryptedData and GameCardHeader2Certificate structs.
* gamecard: update gamecardReadHeader() to check if the `Has10Certificate` flag is set in the gamecard header. If it is, the function will read and log both Header2 and Header2Certificate areas, and it will also attempt to verify the RSA signature from the Header2 area.
* gamecard: if a Header2 area is detected, an error will always be triggered for the time being. If anyone comes across this error, please get in touch me.

* gamecard, fs_ext: fix signature field comments.
2024-04-19 15:58:16 +02:00
Pablo Curiel
6dfbb301df [ci skip] Remove void keyword from C++ ctors/dtors 2024-04-19 12:08:44 +02:00
Pablo Curiel
de71768380 [ci skip] Improve UI element spacing 2024-04-18 22:20:45 +02:00