Commit Graph

52 Commits

Author SHA1 Message Date
281f2926bb common/fileutil: Convert namespace to Common::FS
Migrates a remaining common file over to the Common namespace, making it
consistent with the rest of common files.

This also allows for high-traffic FS related code to alias the
filesystem function namespace as

namespace FS = Common::FS;

for more concise typing.
2022-10-30 21:03:49 +02:00
bc6e45ab3b fix secure1 secondary key calc (#6149) 2022-10-06 09:22:01 +05:30
cbd5d1c15c Upgrade codebase to C++ 20 + fix warnings + update submodules (#6115) 2022-09-21 18:36:12 +02:00
f85bde3ca3 Replace &vec[0] with vec.data()
When the vector is empty, using `&vec[0]` involves undefined behaviour. While that works fine most of the time, Flatpak builds aborted on a failed `__builtin_expect`.

I searched for such occurences across the codebase with the regex `(?<!&)&\w+\[0\]` and fixed those that would potentially cause issues.
2021-07-14 17:01:14 +08:00
Ben
1722701c07 [WIP] NCCHContainer: support for partitions if container is NCSD (#5345)
* GetProgramLaunchInfo: improve to for 3ds files

* NCSD: allow to load other partitions

* fix typo

* Update src/core/hle/service/fs/fs_user.cpp

Co-authored-by: Valentin Vanelslande <vvanelslandedev@gmail.com>

* Update src/core/hle/service/fs/fs_user.cpp

Co-authored-by: Valentin Vanelslande <vvanelslandedev@gmail.com>

Co-authored-by: Marshall Mohror <mohror64@gmail.com>
Co-authored-by: Valentin Vanelslande <vvanelslandedev@gmail.com>
2020-07-14 09:14:30 -05:00
1d92343344 fix more review comments 2020-03-15 19:00:26 +01:00
2465fd423a fix review comments 2020-03-15 18:57:29 +01:00
ae4ba287d5 warn if cia contend is encrypted 2020-03-15 18:23:19 +01:00
0fe832bb49 Make the arrays const 2020-02-29 09:11:34 +08:00
9d57325a8b core/file_sys: Add alternative override pathes for ExeFS files
You can now directly place ExeFS overrides/patches inside the mod folder (instead of the exefs subfolder). This allows us to have drop-in compatibility with Luma3DS mods.
2020-02-28 23:36:17 +08:00
4273b967b5 core/file_sys: Do not apply the same mods to DLCs
Now you can apply separate mods to DLCs and mods for the original title won't be applied.
2020-02-11 14:03:07 +08:00
13e2d534e9 core: Add dump RomFS support
This is added to LayeredFS, then the NCCH container and then the loader interface.
2020-02-09 20:59:31 +08:00
eed9de2336 core/file_sys: Allow exheader replacement to be read from mods path
The previous method (filename.exheader) can still be used.
2020-02-07 15:55:35 +08:00
53d0c618a0 core/file_sys: Read mods for the original title for updates
Updates can override RomFS and ExeFS, therefore we should apply the mods to them as well.
2020-02-07 15:20:20 +08:00
91e5a39a08 core/file_sys: Allow exefs mods to be read from mods path
The original path (file_name.exefsdir) is still supported, but alternatively users can choose to put exefs patches in the same place as LayeredFS files (`load/mods/<Title ID>/exefs`).
2020-02-07 15:20:19 +08:00
8a570bf00c core: Use LayeredFS while reading RomFS
Only enabled for NCCHs that do not have an override romfs.

LayeredFS files should be put in the `load` directory in User Directory. The directory structure is similar to yuzu's but currently does not allow named mods yet. Replacement files should be put in `load/mods/<Title ID>/romfs` while patches/stubs should be put in `load/mods/<Title ID>/romfs_ext`.
2020-02-07 15:20:18 +08:00
756d231ff9 file_sys: Add support for BPS patches
The BPS format allows distributing patches that are smaller and that do
not contain copyrighted content if data is relocated
(unlike non-trivial IPS patches).

This is essential for games such as MM3D that have three barely
different code revisions. Supporting all three versions would
demand an unreasonable amount of work; with BPS patches only one
version has to be supported.
2019-12-22 10:46:47 +01:00
3140086c60 file_sys: Handle patch applying failures
This changes ApplyCodePatch to return a ResultStatus, which makes it
possible to determine whether patch applying has failed. Previously,
only a boolean was returned, and false was returned when no patch
was found OR when a patch was found but applying it failed.

This also changes AppLoader_NCCH to return an error if patching fails
because the executable is likely to be left in an inconsistent state
and we should not proceed booting in that case.
2019-12-22 10:46:47 +01:00
1377be9902 file_sys: Move IPS patching code into separate source file
In anticipation of a new BPS patcher.
2019-12-22 10:46:47 +01:00
7318913f5a ncch_container: Fix NCCH decryption heuristic when replacing exheader
Fixes a regression from #4862, which caused the NCCH title ID checking
heuristic to be skipped whenever the exheader is replaced.

I was thinking the heuristic wouldn't be needed in that case, but it
turns out that many users still have pathological NCCHs that indicate
they are encrypted but are actually decrypted...

Now the original exheader is always read and used for the heuristic
to determine whether the NCCH is actually encrypted; only then do we
load a replacement exheader (if it exists) to avoid affecting the
heuristic.
2019-08-22 17:52:30 +08:00
a2cde6e075 ncch_container: Assume override exheaders are decrypted
Require and assume that override exheaders are decrypted for
consistency with Luma's loader behaviour and to ensure consistent
behaviour regardless of whether the NCCH is marked as encrypted or not.
Currently, exheader overriding with an encrypted NCCH would cause
the title ID checking heuristic to mistakenly disable encryption,
which would then make exefs loading fail.
2019-08-07 18:41:37 +08:00
43d1ee6fb7 ncch_container: Apply IPS patch after allocating .bss
This allows an IPS patch to edit .bss. This is useful for game patches
that need to add code, as putting things in .bss allows adding new code
*without* editing .code and thus without having to relocate everything.
2019-07-10 12:57:30 +02:00
bc30412484 ncch_container: Add support for exheader replacement
This adds support for custom exheaders, which brings feature parity
with Luma3DS's code patching functionality and allows for injecting
new game code.
2019-07-06 18:01:54 +02:00
70fe0d22de ncch_container: Fix code.bin replacement
Currently, having a replacement code.bin causes Citra to crash as it is
trying to load icon data from code.bin because of a typo. This commit
fixes that typo.
2019-06-30 11:48:28 +02:00
1ded48f5a3 Merge branch 'master' of github.com:citra-emu/citra into ips-patches 2018-11-15 07:11:18 -06:00
896577044d Remove ApplyIPS from the class and header 2018-11-15 07:11:06 -06:00
5179915fb4 filesys/ncch: prevent buffer overflow on calculating SHA256 2018-11-10 22:58:32 -05:00
05c1816504 Stay in bounds 2018-10-21 07:48:54 -05:00
1c62bc06cf Add rle record support 2018-10-21 07:48:29 -05:00
d8284dfacc Log invalid IPS attempt 2018-10-21 07:47:27 -05:00
d0b54e9939 Check for EOF 2018-10-20 23:25:16 -05:00
2778801dc5 Updated based on review 2018-10-20 19:45:16 -05:00
2a5b56bb1d Be more intentional with check 2018-10-20 18:17:54 -05:00
bf50bb06f1 Minor style changes and use memcpy 2018-10-20 18:10:32 -05:00
2496ecbaf6 Added IPS patching 2018-10-20 13:09:05 -05:00
756a3d404a Merge pull request #4283 from valentinvanelslande/seed-db
Implement SeedDB & Seed Crypto
2018-10-08 14:18:42 -04:00
b067b5aa5a Implement SeedDB & Seed Crypto 2018-10-02 10:12:40 -05:00
8cf1132b2e ncch_container: choose the first id as extdata id when extended save data access is used 2018-10-02 08:15:10 +08:00
bbf391abb9 citra_qt, core: game list "Open XXX Location" improvements 2018-10-01 08:42:22 +08:00
7d8f115185 Prefix all size_t with std::
done automatically by executing regex replace `([^:0-9a-zA-Z_])size_t([^0-9a-zA-Z_])` -> `$1std::size_t$2`
2018-09-06 16:03:28 -04:00
bfbb6f13b4 NCCH_COntainer: Add file_path log to Load() 2018-08-31 11:00:34 +02:00
d4a808c885 ncch_container: support encrypted games 2018-08-07 18:53:06 +03:00
0eab948728 reformat all files with clang-format 2018-06-29 16:56:12 +03:00
7c5a76e58b log: replace all NGLOG with LOG 2018-06-29 14:18:07 +03:00
d81cacfb9e core/file_sys: Replace logging macros 2018-06-07 23:06:44 +08:00
3af976e41e ncch_container: Get rid of pointer casts in LZSS_GetDecompressedSize() and LZSS_Decompress()
These kinds of casts invoke undefined behavior, due to both the aliasing
rule, and from an alignment point-of-view. Use the way that's guaranteed
to always work instead.
2018-03-28 19:55:49 -04:00
542f14d3c5 Merge pull request #3249 from Subv/logo
NCCH: Load the "logo" file from the specified offset if it's present instead of the ExeFS.
2017-12-14 18:30:19 -05:00
c31f932afe common/core: Silence initialization order warnings 2017-12-10 19:50:45 -05:00
8e9b55e939 NCCH: Load the "logo" file from the specified offset if it's present instead of the ExeFS.
This is "new" behavior as of firmware 5.0.0-11, older titles have the logo offset and size set to 0, indicating that the logo is stored in the ExeFS.
2017-12-09 12:17:02 -05:00
549f11a40e file_sys/ncch_container: Expose ncch_offset during instantiation and in OpenFile 2017-11-15 17:43:15 -07:00