1
0
Fork 0
mirror of https://github.com/DarkMatterCore/nxdumptool.git synced 2024-11-23 02:36:41 +00:00
Commit graph

190 commits

Author SHA1 Message Date
Pablo Curiel
5eb96cbece services: completely ditch smRegisterService() and just use the AtmosphereHasService SM API extension.
This extension was already being used - however, smRegisterService() was also being used as a fallback method.

More than a year and a half has already passed since this feature was introduced, and both SX OS and ReiNX apparently support it now, so it's a justified change.
2021-02-24 23:36:53 -04:00
Pablo Curiel
a90d8f2074 Title handler changes.
* Renamed titleRetrieveContentMetaKeysFromDatabase() to titleGenerateTitleInfoFromStorage().

* Moved linked lists generation from titleRetrieveContentMetaKeysFromDatabase() into its own function: titleUpdateTitleInfoLinkedLists().

* Adjusted orphan title checks. It is now explicitly verified if application metadata is available before treating a title as orphan, instead of checking if the parent user application is available.

* Code cleanup in titleRefreshGameCardTitleInfo().

* titleRefreshGameCardTitleInfo() now attempts to update the application metadata pointer in orphan title entries if new application metadata was retrieved after a gamecard was inserted *and* if the orphan title count is currently non-zero.

* Updated titleRemoveGameCardTitleInfoEntries() to make it use titleUpdateTitleInfoLinkedLists().
2021-02-22 17:30:47 -04:00
Pablo Curiel
6df7ff0cba Fix output filenames not being updated in usb_gc_dumper. 2021-02-20 14:52:07 -04:00
Pablo Curiel
85a045ba38 Add a Python-based companion script.
Serves the same purpose as the modded ns-usbloader builds. Supports the full USB ABI command set.

Also fixed a small issue related to ES IPC calls not writing the total number of available rights IDs.
2021-02-18 04:24:16 -04:00
Pablo Curiel
de076f4908 More USB changes.
* usb: copy command ID and block size before moving command data within the USB transfer buffer.

* nsp_dumper_usb: now spans a background thread for the dump process, progress is now displayed, process can now be cancelled by holding B, updated to properly make use of the new usbCancelFileTransfer() behavior.

* usb_gc_dumper: updated to properly make use of the new usbCancelFileTransfer() behavior.

* usb_romfs_dumper: updated to properly make use of the new usbCancelFileTransfer() behavior.

* Updated ns-usbloader patch. Must be used on commit `8771d551a4e6fa2d645e519d504a377e34cbd730`.
2021-02-16 08:22:14 -04:00
Pablo Curiel
b6759f764b Gracefully cancel ongoing USB file transfers.
Keeps alive the current USB session by informing the host device that the user cancelled an ongoing USB transfer, instead of stalling the endpoints.

Also updated the USB ABI specs once again.
2021-02-15 17:07:47 -04:00
Pablo Curiel
c3555431d4 Prevent ALIGN_DOWN() from overflowing. 2021-02-13 19:53:30 -04:00
Pablo Curiel
1d0cc9c45b USB changes (breaks ns-usbloader compatibility).
* Updated usbSendCommand() to make it send the command header first, and then the command block. Makes it easier for host applications to read and parse command data.

* Let usbSendCommand() take care of handling ZLT packets if required by any command block (only SendNspHeader at this moment), as well as logging status data via usbLogStatusDetail().

* Updated USB ABI specs doc.
2021-02-13 17:49:05 -04:00
Pablo Curiel
9bac8f3bdc Some more changes.
* 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.
2021-02-13 02:09:18 -04:00
Pablo Curiel
69d9c2d732 Update ffconf.h 2021-02-13 00:26:23 -04:00
Pablo Curiel
054c9be41b Define constants using C preprocessor. 2021-02-12 18:41:14 -04:00
Pablo Curiel
2795ed14eb Fix codestyle. 2021-02-12 18:01:33 -04:00
Pablo Curiel
e77c72b0db Some changes.
* gamecard: added more comments, modified gamecardGetBundledFirmwareUpdateVersion() to fill a VersionType1 pointer instead of a u32, fallback to manually reading the gamecard certificate if fsDeviceOperatorGetGameCardDeviceCertificate() fails, updated GameCardFwVersion enum.

* title: tweaked conditions for some functions.

* usb: explicitly defined values for previously omitted struct members while initializing USB comms, imported libusb structs to make it easier to work with the USB BOS, added a few more comments and changed around some code.

* utils: tweaked the illegal filesystem character array to remove some chars that are actually allowed.
2021-02-12 16:35:23 -04:00
Pablo Curiel
ed2061ae3e Update nca.h 2021-01-31 05:21:50 -04:00
Pablo Curiel
88793eceea Populate app_metadata pointer in TitleInfo elements that aren't system titles or user applications. 2021-01-31 05:16:05 -04:00
Pablo Curiel
232fe05587 Use LIBUSBHSFS_FS_TYPE_STR() macro from libusbhsfs instead of our own one. 2020-12-24 07:16:16 -04:00
Pablo Curiel
b4bf505d4f UMS changes.
* Temporarily changed tracked libusbhsfs branch from main to dev.

* Minor improvements in ums.c/h.

* Refactored nsp_dumper_sd into nsp_dumper_stor - now capable of dumping NSPs to a mounted partition from a UMS device.

* Fixed utilsWaitForButtonPress() when no button mask is provided.

* Refactored utilsGetFreeSpaceFromFileSystemByPath() into utilsGetFileSystemStatsByPath().
2020-12-24 04:49:38 -04:00
Pablo Curiel
6f43764e1b Improved UMS interface. 2020-12-23 14:43:12 -04:00
Pablo Curiel
736f2e155b Add DisableDeviceAddressSpaceMerge NPDM meta flag.
Also updated the Makefile to link the application against lwext4.
2020-12-23 14:02:02 -04:00
Pablo Curiel
fbd250a417 Update copyright years. 2020-12-23 13:48:57 -04:00
Pablo Curiel
ae12e48678 Added UMS interface based around libusbhsfs.
Also normalized Initialized -> Init in names from global variables.
2020-12-07 00:26:59 -04:00
Pablo Curiel
5a070f624c Use UsbState enum values from latest libnx. 2020-12-06 18:45:30 -04:00
Pablo Curiel
c29f994b35 Support for HOS 11.0.0.
* Updated hardcoded system title list to match HOS 11.0.0.
* Updated NcaKeyGeneration_Current.
* Updated button input handling to match the new pad API from libnx.
2020-12-04 02:38:44 -04:00
Pablo Curiel
9732bf9adf libusbhsfs-related changes.
* Free space is now retrieved via statvfs() for all filesystems, including the SD card.
* Updated Makefile to reflect latest libusbhsfs changes (dev branch).
2020-12-02 02:28:35 -04:00
Pablo Curiel
7899fc419c Update usbHsFsInitialize() call to reflect changes in libusbhsfs. 2020-11-28 02:56:54 -04:00
Pablo Curiel
457f468519 Fix comments. 2020-11-28 02:38:53 -04:00
Pablo Curiel
dff9b1defa Revert "Rename FatFs functions to avoid linking issues with libusbhsfs."
This reverts commit 6715242fed.
2020-11-28 02:38:01 -04:00
Pablo Curiel
477c321773 Remove unnecessary code.
libusbhsfs doesn't return FsFileSystem objects, that's why.
2020-11-21 06:29:29 -04:00
Pablo Curiel
6715242fed Rename FatFs functions to avoid linking issues with libusbhsfs. 2020-11-20 04:56:12 -04:00
Pablo Curiel
e8956c0e4b Various changes.
* Cancel USB file transfer if something goes wrong during a NSP transfer via USB.
* Added SD card RomFS dumper.
* Further optimizations to the *WriteNcaPatch() functions.
* Change struct naming in nso.c/h (thanks @0Liam !).
* Replace fsp-usb with libusbhsfs. ( ͡° ͜ʖ ͡°)
2020-11-08 15:08:30 -04:00
Pablo Curiel
5f0f281e2d Added USB ABI specs. 2020-11-01 11:04:38 -04:00
Pablo Curiel
bceff64da4 Fix parent layer chunk size calculation while generating HierarchicalSha256 / HierarchicalIntegrity patches. 2020-10-29 03:51:17 -04:00
Pablo Curiel
0229124173 NACP changes.
Fixed types for some NACP struct entries (thanks @0Liam !) + added functions to generate and write NACP patches.
2020-10-28 18:48:46 -04:00
Pablo Curiel
2b8e80c283 Remove unused code. 2020-10-28 01:03:48 -04:00
Pablo Curiel
57162b5634 CNMT: fixed support for patches. 2020-10-28 00:30:13 -04:00
Pablo Curiel
278afbabfa Title handler bugfixes.
* Fixed possible invalid memory accesses using TitleInfo pointers from gamecard titles if the gamecard they belong to is taken out.
* Fixed invalid for loop condition in _titleGetInfoFromStorageByTitleId() if no gamecard titles have been retrieved.
2020-10-27 17:23:19 -04:00
Pablo Curiel
5c5f388feb Add NSP transfer mode to USB code + implement SendNspHeader USB command.
Completely untested.
2020-10-26 02:39:33 -04:00
Pablo Curiel
da5290189b Optimize modified NCA header(s) write code. 2020-10-25 20:03:02 -04:00
Pablo Curiel
ae6defb0e6 Another typo. 2020-10-25 11:43:22 -04:00
Pablo Curiel
c44b9c998e Add endpoint max packet size field to the UsbStatus response block.
And fix typos. lol
2020-10-25 11:42:53 -04:00
Pablo Curiel
7e2aa976b4 Rename KEY_NONE definition. 2020-10-22 16:13:00 -04:00
Pablo Curiel
974790944f More changes.
* 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.
2020-10-22 00:38:14 -04:00
Pablo Curiel
15431ec2c8 Many changes.
* 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.
2020-10-21 00:27:48 -04:00
Pablo Curiel
bd98fd4c32 Replace unnecessary strlen() calls with pointer dereferences or calculations using info available at runtime (when possible).
This should probably improve performance a little bit in certain sections.
2020-10-14 20:06:53 -04:00
Pablo Curiel
6f4cb98033 Cleanup startup logfile messages. 2020-10-14 19:08:01 -04:00
Pablo Curiel
5b22fe07f2 More code cleanup. 2020-10-14 14:58:33 -04:00
Pablo Curiel
13efdb6074 Update bfttf.h 2020-10-14 09:24:56 -04:00
Pablo Curiel
e6bb15d608 Implemented BFTTF font loading and decoding.
Some people may call me a madman but I don't want to see any more nxdumptool screenshots with a Disney-like font. *war flashbacks*
2020-10-14 09:23:49 -04:00
Pablo Curiel
44965430b3 Even more code cleanup.
* 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.
2020-10-13 20:15:21 -04:00
Pablo Curiel
ba4fdcd01c Code cleanup.
* 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.
2020-10-13 10:00:03 -04:00