summaryrefslogtreecommitdiffstats
path: root/src/core/loader
diff options
context:
space:
mode:
authorZach Hilman <zachhilman@gmail.com>2018-08-26 01:04:48 +0200
committerZach Hilman <zachhilman@gmail.com>2018-09-04 22:23:15 +0200
commit97bf83bc56860be244077e9213468466f894c73d (patch)
treec5b59ded4f150ded530b6f218e2ca52589f2628b /src/core/loader
parentfile_sys: Add class to manage game patches (diff)
downloadyuzu-97bf83bc56860be244077e9213468466f894c73d.tar
yuzu-97bf83bc56860be244077e9213468466f894c73d.tar.gz
yuzu-97bf83bc56860be244077e9213468466f894c73d.tar.bz2
yuzu-97bf83bc56860be244077e9213468466f894c73d.tar.lz
yuzu-97bf83bc56860be244077e9213468466f894c73d.tar.xz
yuzu-97bf83bc56860be244077e9213468466f894c73d.tar.zst
yuzu-97bf83bc56860be244077e9213468466f894c73d.zip
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/deconstructed_rom_directory.cpp29
-rw-r--r--src/core/loader/deconstructed_rom_directory.h7
-rw-r--r--src/core/loader/nca.cpp2
3 files changed, 30 insertions, 8 deletions
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 @@
#include "core/core.h"
#include "core/file_sys/content_archive.h"
#include "core/file_sys/control_metadata.h"
+#include "core/file_sys/patch_manager.h"
#include "core/file_sys/romfs_factory.h"
#include "core/gdbstub/gdbstub.h"
#include "core/hle/kernel/kernel.h"
@@ -21,8 +22,9 @@
namespace Loader {
-AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_)
- : AppLoader(std::move(file_)) {
+AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile file_,
+ bool override_update)
+ : AppLoader(std::move(file_)), override_update(override_update) {
const auto dir = file->GetContainingDirectory();
// Icon
@@ -66,8 +68,9 @@ AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(FileSys
}
AppLoader_DeconstructedRomDirectory::AppLoader_DeconstructedRomDirectory(
- FileSys::VirtualDir directory)
- : AppLoader(directory->GetFile("main")), dir(std::move(directory)) {}
+ FileSys::VirtualDir directory, bool override_update)
+ : AppLoader(directory->GetFile("main")), dir(std::move(directory)),
+ override_update(override_update) {}
FileType AppLoader_DeconstructedRomDirectory::IdentifyType(const FileSys::VirtualFile& file) {
if (FileSys::IsDirectoryExeFS(file->GetContainingDirectory())) {
@@ -89,7 +92,8 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
dir = file->GetContainingDirectory();
}
- const FileSys::VirtualFile npdm = dir->GetFile("main.npdm");
+ // Read meta to determine title ID
+ FileSys::VirtualFile npdm = dir->GetFile("main.npdm");
if (npdm == nullptr)
return ResultStatus::ErrorMissingNPDM;
@@ -97,6 +101,21 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(
if (result != ResultStatus::Success) {
return result;
}
+
+ if (override_update) {
+ const FileSys::PatchManager patch_manager(metadata.GetTitleID());
+ dir = patch_manager.PatchExeFS(dir);
+ }
+
+ // Reread in case PatchExeFS affected the main.npdm
+ npdm = dir->GetFile("main.npdm");
+ if (npdm == nullptr)
+ return ResultStatus::ErrorMissingNPDM;
+
+ ResultStatus result2 = metadata.Load(npdm);
+ if (result2 != ResultStatus::Success) {
+ return result2;
+ }
metadata.Print();
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 {
*/
class AppLoader_DeconstructedRomDirectory final : public AppLoader {
public:
- explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file);
+ explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualFile main_file,
+ bool override_update = false);
// Overload to accept exefs directory. Must contain 'main' and 'main.npdm'
- explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory);
+ explicit AppLoader_DeconstructedRomDirectory(FileSys::VirtualDir directory,
+ bool override_update = false);
/**
* Returns the type of the file
@@ -51,6 +53,7 @@ private:
std::vector<u8> icon_data;
std::string name;
u64 title_id{};
+ bool override_update;
};
} // 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) {
if (exefs == nullptr)
return ResultStatus::ErrorNoExeFS;
- directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs);
+ directory_loader = std::make_unique<AppLoader_DeconstructedRomDirectory>(exefs, true);
const auto load_result = directory_loader->Load(process);
if (load_result != ResultStatus::Success)