diff options
| author | 2018-08-25 19:04:48 -0400 | |
|---|---|---|
| committer | 2018-09-04 16:23:15 -0400 | |
| commit | 97bf83bc56860be244077e9213468466f894c73d (patch) | |
| tree | c5b59ded4f150ded530b6f218e2ca52589f2628b /src/core | |
| parent | file_sys: Add class to manage game patches (diff) | |
| download | yuzu-97bf83bc56860be244077e9213468466f894c73d.tar.gz yuzu-97bf83bc56860be244077e9213468466f894c73d.tar.xz yuzu-97bf83bc56860be244077e9213468466f894c73d.zip | |
patch_manager: Add usages of patches to ExeFS
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/file_sys/romfs_factory.cpp | 11 | ||||
| -rw-r--r-- | src/core/file_sys/romfs_factory.h | 1 | ||||
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.cpp | 29 | ||||
| -rw-r--r-- | src/core/loader/deconstructed_rom_directory.h | 7 | ||||
| -rw-r--r-- | src/core/loader/nca.cpp | 2 |
5 files changed, 41 insertions, 9 deletions
diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index 66f9786e0..fc9cf1eca 100644 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp | |||
| @@ -6,7 +6,10 @@ | |||
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | #include "common/logging/log.h" | 8 | #include "common/logging/log.h" |
| 9 | #include "core/core.h" | ||
| 9 | #include "core/file_sys/content_archive.h" | 10 | #include "core/file_sys/content_archive.h" |
| 11 | #include "core/file_sys/nca_metadata.h" | ||
| 12 | #include "core/file_sys/patch_manager.h" | ||
| 10 | #include "core/file_sys/registered_cache.h" | 13 | #include "core/file_sys/registered_cache.h" |
| 11 | #include "core/file_sys/romfs_factory.h" | 14 | #include "core/file_sys/romfs_factory.h" |
| 12 | #include "core/hle/service/filesystem/filesystem.h" | 15 | #include "core/hle/service/filesystem/filesystem.h" |
| @@ -19,10 +22,16 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader) { | |||
| 19 | if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) { | 22 | if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) { |
| 20 | LOG_ERROR(Service_FS, "Unable to read RomFS!"); | 23 | LOG_ERROR(Service_FS, "Unable to read RomFS!"); |
| 21 | } | 24 | } |
| 25 | |||
| 26 | updatable = app_loader.IsRomFSUpdatable(); | ||
| 22 | } | 27 | } |
| 23 | 28 | ||
| 24 | ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() { | 29 | ResultVal<VirtualFile> RomFSFactory::OpenCurrentProcess() { |
| 25 | return MakeResult<VirtualFile>(file); | 30 | if (!updatable) |
| 31 | return MakeResult<VirtualFile>(file); | ||
| 32 | |||
| 33 | const PatchManager patch_manager(Core::CurrentProcess()->process_id); | ||
| 34 | return MakeResult<VirtualFile>(patch_manager.PatchRomFS(file)); | ||
| 26 | } | 35 | } |
| 27 | 36 | ||
| 28 | ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) { | 37 | ResultVal<VirtualFile> RomFSFactory::Open(u64 title_id, StorageId storage, ContentRecordType type) { |
diff --git a/src/core/file_sys/romfs_factory.h b/src/core/file_sys/romfs_factory.h index f38ddc4f7..168db1c46 100644 --- a/src/core/file_sys/romfs_factory.h +++ b/src/core/file_sys/romfs_factory.h | |||
| @@ -36,6 +36,7 @@ public: | |||
| 36 | 36 | ||
| 37 | private: | 37 | private: |
| 38 | VirtualFile file; | 38 | VirtualFile file; |
| 39 | bool updatable; | ||
| 39 | }; | 40 | }; |
| 40 | 41 | ||
| 41 | } // namespace FileSys | 42 | } // namespace FileSys |
diff --git a/src/core/loader/deconstructed_rom_directory.cpp b/src/core/loader/deconstructed_rom_directory.cpp index 1ae4bb656..04ef55da1 100644 --- a/src/core/loader/deconstructed_rom_directory.cpp +++ b/src/core/loader/deconstructed_rom_directory.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "core/core.h" | 9 | #include "core/core.h" |
| 10 | #include "core/file_sys/content_archive.h" | 10 | #include "core/file_sys/content_archive.h" |
| 11 | #include "core/file_sys/control_metadata.h" | 11 | #include "core/file_sys/control_metadata.h" |
| 12 | #include "core/file_sys/patch_manager.h" | ||
| 12 | #include "core/file_sys/romfs_factory.h" | 13 | #include "core/file_sys/romfs_factory.h" |
| 13 | #include "core/gdbstub/gdbstub.h" | 14 | #include "core/gdbstub/gdbstub.h" |
| 14 | #include "core/hle/kernel/kernel.h" | 15 | #include "core/hle/kernel/kernel.h" |
| @@ -21,8 +22,9 @@ | |||
| 21 | 22 | ||
| 22 | namespace Loader { | 23 | namespace Loader { |
| 23 | 24 | ||
| 24 | AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_) | 25 | AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_, |
| 25 | : AppLoader(std::move(file_)) { | 26 | bool override_update) |
| 27 | : AppLoader(std::move(file_)), override_update(override_update) { | ||
| 26 | const auto dir = file->GetContainingDirectory(); | 28 | const auto dir = file->GetContainingDirectory(); |
| 27 | 29 | ||
| 28 | // Icon | 30 | // Icon |
| @@ -66,8 +68,9 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys | |||
| 66 | } | 68 | } |
| 67 | 69 | ||
| 68 | AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory( | 70 | AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory( |
| 69 | FileSys::VirtualDir directory) | 71 | FileSys::VirtualDir directory, bool override_update) |
| 70 | : AppLoader(directory->GetFile("main")), dir(std::move(directory)) {} | 72 | : AppLoader(directory->GetFile("main")), dir(std::move(directory)), |
| 73 | override_update(override_update) {} | ||
| 71 | 74 | ||
| 72 | FileType AppLoader_DeconstructedRomDirectory::IdentifyType(const FileSys::VirtualFile& file) { | 75 | FileType AppLoader_DeconstructedRomDirectory::IdentifyType(const FileSys::VirtualFile& file) { |
| 73 | if (FileSys::IsDirectoryExeFS(file->GetContainingDirectory())) { | 76 | if (FileSys::IsDirectoryExeFS(file->GetContainingDirectory())) { |
| @@ -89,7 +92,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load( | |||
| 89 | dir = file->GetContainingDirectory(); | 92 | dir = file->GetContainingDirectory(); |
| 90 | } | 93 | } |
| 91 | 94 | ||
| 92 | const FileSys::VirtualFile npdm = dir->GetFile("main.npdm"); | 95 | // Read meta to determine title ID |
| 96 | FileSys::VirtualFile npdm = dir->GetFile("main.npdm"); | ||
| 93 | if (npdm == nullptr) | 97 | if (npdm == nullptr) |
| 94 | return ResultStatus::ErrorMissingNPDM; | 98 | return ResultStatus::ErrorMissingNPDM; |
| 95 | 99 | ||
| @@ -97,6 +101,21 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load( | |||
| 97 | if (result != ResultStatus::Success) { | 101 | if (result != ResultStatus::Success) { |
| 98 | return result; | 102 | return result; |
| 99 | } | 103 | } |
| 104 | |||
| 105 | if (override_update) { | ||
| 106 | const FileSys::PatchManager patch_manager(metadata.GetTitleID()); | ||
| 107 | dir = patch_manager.PatchExeFS(dir); | ||
| 108 | } | ||
| 109 | |||
| 110 | // Reread in case PatchExeFS affected the main.npdm | ||
| 111 | npdm = dir->GetFile("main.npdm"); | ||
| 112 | if (npdm == nullptr) | ||
| 113 | return ResultStatus::ErrorMissingNPDM; | ||
| 114 | |||
| 115 | ResultStatus result2 = metadata.Load(npdm); | ||
| 116 | if (result2 != ResultStatus::Success) { | ||
| 117 | return result2; | ||
| 118 | } | ||
| 100 | metadata.Print(); | 119 | metadata.Print(); |
| 101 | 120 | ||
| 102 | const FileSys::ProgramAddressSpaceType arch_bits{metadata.GetAddressSpaceType()}; | 121 | const FileSys::ProgramAddressSpaceType arch_bits{metadata.GetAddressSpaceType()}; |
diff --git a/src/core/loader/deconstructed_rom_directory.h b/src/core/loader/deconstructed_rom_directory.h index b20804f75..cb50f8bff 100644 --- a/src/core/loader/deconstructed_rom_directory.h +++ b/src/core/loader/deconstructed_rom_directory.h | |||
| @@ -20,10 +20,12 @@ namespace Loader { | |||
| 20 | */ | 20 | */ |
| 21 | class AppLoader_DeconstructedRomDirectory final : public AppLoader { | 21 | class AppLoader_DeconstructedRomDirectory final : public AppLoader { |
| 22 | public: | 22 | public: |
| 23 | explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file); | 23 | explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file, |
| 24 | bool override_update = false); | ||
| 24 | 25 | ||
| 25 | // Overload to accept exefs directory. Must contain 'main' and 'main.npdm' | 26 | // Overload to accept exefs directory. Must contain 'main' and 'main.npdm' |
| 26 | explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory); | 27 | explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory, |
| 28 | bool override_update = false); | ||
| 27 | 29 | ||
| 28 | /** | 30 | /** |
| 29 | * Returns the type of the file | 31 | * Returns the type of the file |
| @@ -51,6 +53,7 @@ private: | |||
| 51 | std::vector<u8> icon_data; | 53 | std::vector<u8> icon_data; |
| 52 | std::string name; | 54 | std::string name; |
| 53 | u64 title_id{}; | 55 | u64 title_id{}; |
| 56 | bool override_update; | ||
| 54 | }; | 57 | }; |
| 55 | 58 | ||
| 56 | } // namespace Loader | 59 | } // namespace Loader |
diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index c036a8a1c..6b1c27b47 100644 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp | |||
| @@ -48,7 +48,7 @@ ResultStatus AppLoader_NCA::Load(Kernel::SharedPtr<Kernel::Process>& process) { | |||
| 48 | if (exefs == nullptr) | 48 | if (exefs == nullptr) |
| 49 | return ResultStatus::ErrorNoExeFS; | 49 | return ResultStatus::ErrorNoExeFS; |
| 50 | 50 | ||
| 51 | directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs); | 51 | directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs, true); |
| 52 | 52 | ||
| 53 | const auto load_result = directory_loader->Load(process); | 53 | const auto load_result = directory_loader->Load(process); |
| 54 | if (load_result != ResultStatus::Success) | 54 | if (load_result != ResultStatus::Success) |