From 3f62d06b384687a14aaf259fe56dee0f38c170d8 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Fri, 28 Dec 2018 00:03:38 -0500 Subject: core: Port current uses of RegisteredCache to ContentProvider --- src/core/file_sys/patch_manager.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/core/file_sys/patch_manager.cpp') diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index e11217708a..ccb38ba030 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -10,6 +10,7 @@ #include "common/file_util.h" #include "common/hex_util.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/ips_layer.h" @@ -69,7 +70,7 @@ VirtualDir PatchManager::PatchExeFS(VirtualDir exefs) const { } } - const auto installed = Service::FileSystem::GetUnionContents(); + const auto& installed = Core::System::GetInstance().GetContentProvider(); const auto& disabled = Settings::values.disabled_addons[title_id]; const auto update_disabled = @@ -345,7 +346,7 @@ VirtualFile PatchManager::PatchRomFS(VirtualFile romfs, u64 ivfc_offset, Content if (romfs == nullptr) return romfs; - const auto installed = Service::FileSystem::GetUnionContents(); + const auto& installed = Core::System::GetInstance().GetContentProvider(); // Game Updates const auto update_tid = GetUpdateTitleID(title_id); @@ -392,7 +393,7 @@ static bool IsDirValidAndNonEmpty(const VirtualDir& dir) { std::map> PatchManager::GetPatchVersionNames( VirtualFile update_raw) const { std::map> out; - const auto installed = Service::FileSystem::GetUnionContents(); + const auto& installed = Core::System::GetInstance().GetContentProvider(); const auto& disabled = Settings::values.disabled_addons[title_id]; // Game Updates @@ -466,10 +467,10 @@ std::map> PatchManager::GetPatchVersionNam // DLC const auto dlc_entries = installed.ListEntriesFilter(TitleType::AOC, ContentRecordType::Data); - std::vector dlc_match; + std::vector dlc_match; dlc_match.reserve(dlc_entries.size()); std::copy_if(dlc_entries.begin(), dlc_entries.end(), std::back_inserter(dlc_match), - [this, &installed](const RegisteredCacheEntry& entry) { + [this, &installed](const ContentProviderEntry& entry) { return (entry.title_id & DLC_BASE_TITLE_ID_MASK) == title_id && installed.GetEntry(entry)->GetStatus() == Loader::ResultStatus::Success; }); @@ -492,7 +493,7 @@ std::map> PatchManager::GetPatchVersionNam } std::pair, VirtualFile> PatchManager::GetControlMetadata() const { - const auto installed{Service::FileSystem::GetUnionContents()}; + const auto& installed = Core::System::GetInstance().GetContentProvider(); const auto base_control_nca = installed.GetEntry(title_id, ContentRecordType::Control); if (base_control_nca == nullptr) -- cgit v1.2.3 From d6744d9b06a951efaae1c246ce257263648866c5 Mon Sep 17 00:00:00 2001 From: Zach Hilman Date: Wed, 27 Mar 2019 20:08:56 -0400 Subject: patch_manager: Dump NSO name with build ID --- src/core/file_sys/patch_manager.cpp | 9 +++++---- src/core/file_sys/patch_manager.h | 2 +- src/core/hle/service/am/applets/web_browser.cpp | 3 +-- src/core/loader/nso.cpp | 6 ++++-- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src/core/file_sys/patch_manager.cpp') diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index ccb38ba030..78dbadee3c 100644 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -156,7 +156,7 @@ std::vector PatchManager::CollectPatches(const std::vector PatchManager::PatchNSO(const std::vector& nso) const { +std::vector PatchManager::PatchNSO(const std::vector& nso, const std::string& name) const { if (nso.size() < sizeof(Loader::NSOHeader)) { return nso; } @@ -172,18 +172,19 @@ std::vector PatchManager::PatchNSO(const std::vector& nso) const { const auto build_id = build_id_raw.substr(0, build_id_raw.find_last_not_of('0') + 1); if (Settings::values.dump_nso) { - LOG_INFO(Loader, "Dumping NSO for build_id={}, title_id={:016X}", build_id, title_id); + LOG_INFO(Loader, "Dumping NSO for name={}, build_id={}, title_id={:016X}", name, build_id, + title_id); const auto dump_dir = Service::FileSystem::GetModificationDumpRoot(title_id); if (dump_dir != nullptr) { const auto nso_dir = GetOrCreateDirectoryRelative(dump_dir, "/nso"); - const auto file = nso_dir->CreateFile(fmt::format("{}.nso", build_id)); + const auto file = nso_dir->CreateFile(fmt::format("{}-{}.nso", name, build_id)); file->Resize(nso.size()); file->WriteBytes(nso); } } - LOG_INFO(Loader, "Patching NSO for build_id={}", build_id); + LOG_INFO(Loader, "Patching NSO for name={}, build_id={}", name, build_id); const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); auto patch_dirs = load_dir->GetSubdirectories(); diff --git a/src/core/file_sys/patch_manager.h b/src/core/file_sys/patch_manager.h index de2672c76e..769f8c6f03 100644 --- a/src/core/file_sys/patch_manager.h +++ b/src/core/file_sys/patch_manager.h @@ -44,7 +44,7 @@ public: // Currently tracked NSO patches: // - IPS // - IPSwitch - std::vector PatchNSO(const std::vector& nso) const; + std::vector PatchNSO(const std::vector& nso, const std::string& name) const; // Checks to see if PatchNSO() will have any effect given the NSO's build ID. // Used to prevent expensive copies in NSO loader. diff --git a/src/core/hle/service/am/applets/web_browser.cpp b/src/core/hle/service/am/applets/web_browser.cpp index 70d840a672..7e17df98a6 100644 --- a/src/core/hle/service/am/applets/web_browser.cpp +++ b/src/core/hle/service/am/applets/web_browser.cpp @@ -154,8 +154,7 @@ void WebBrowser::Execute() { auto& frontend{Core::System::GetInstance().GetWebBrowser()}; - frontend.OpenPage( - filename, [this] { UnpackRomFS(); }, [this] { Finalize(); }); + frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); }); } void WebBrowser::UnpackRomFS() { diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index 714d85a59f..c766070e77 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp @@ -20,6 +20,8 @@ #include "core/memory.h" #include "core/settings.h" +#pragma optimize("", off) + namespace Loader { namespace { struct MODHeader { @@ -139,13 +141,13 @@ std::optional AppLoader_NSO::LoadModule(Kernel::Process& process, // Apply patches if necessary if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { - std::vector pi_header(sizeof(NSOHeader) + program_image.size()); + std::vector pi_header; pi_header.insert(pi_header.begin(), reinterpret_cast(&nso_header), reinterpret_cast(&nso_header) + sizeof(NSOHeader)); pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.begin(), program_image.end()); - pi_header = pm->PatchNSO(pi_header); + pi_header = pm->PatchNSO(pi_header, file.GetName()); std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.begin()); } -- cgit v1.2.3