summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/file_sys/patch_manager.cpp9
-rw-r--r--src/core/file_sys/patch_manager.h2
-rw-r--r--src/core/hle/service/am/applets/web_browser.cpp3
-rw-r--r--src/core/loader/nso.cpp6
4 files changed, 11 insertions, 9 deletions
diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp
index ccb38ba03..78dbadee3 100644
--- a/src/core/file_sys/patch_manager.cpp
+++ b/src/core/file_sys/patch_manager.cpp
@@ -156,7 +156,7 @@ std::vector<VirtualFile> PatchManager::CollectPatches(const std::vector<VirtualD
156 return out; 156 return out;
157} 157}
158 158
159std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso) const { 159std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso, const std::string& name) const {
160 if (nso.size() < sizeof(Loader::NSOHeader)) { 160 if (nso.size() < sizeof(Loader::NSOHeader)) {
161 return nso; 161 return nso;
162 } 162 }
@@ -172,18 +172,19 @@ std::vector<u8> PatchManager::PatchNSO(const std::vector<u8>& nso) const {
172 const auto build_id = build_id_raw.substr(0, build_id_raw.find_last_not_of('0') + 1); 172 const auto build_id = build_id_raw.substr(0, build_id_raw.find_last_not_of('0') + 1);
173 173
174 if (Settings::values.dump_nso) { 174 if (Settings::values.dump_nso) {
175 LOG_INFO(Loader, "Dumping NSO for build_id={}, title_id={:016X}", build_id, title_id); 175 LOG_INFO(Loader, "Dumping NSO for name={}, build_id={}, title_id={:016X}", name, build_id,
176 title_id);
176 const auto dump_dir = Service::FileSystem::GetModificationDumpRoot(title_id); 177 const auto dump_dir = Service::FileSystem::GetModificationDumpRoot(title_id);
177 if (dump_dir != nullptr) { 178 if (dump_dir != nullptr) {
178 const auto nso_dir = GetOrCreateDirectoryRelative(dump_dir, "/nso"); 179 const auto nso_dir = GetOrCreateDirectoryRelative(dump_dir, "/nso");
179 const auto file = nso_dir->CreateFile(fmt::format("{}.nso", build_id)); 180 const auto file = nso_dir->CreateFile(fmt::format("{}-{}.nso", name, build_id));
180 181
181 file->Resize(nso.size()); 182 file->Resize(nso.size());
182 file->WriteBytes(nso); 183 file->WriteBytes(nso);
183 } 184 }
184 } 185 }
185 186
186 LOG_INFO(Loader, "Patching NSO for build_id={}", build_id); 187 LOG_INFO(Loader, "Patching NSO for name={}, build_id={}", name, build_id);
187 188
188 const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id); 189 const auto load_dir = Service::FileSystem::GetModificationLoadRoot(title_id);
189 auto patch_dirs = load_dir->GetSubdirectories(); 190 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 de2672c76..769f8c6f0 100644
--- a/src/core/file_sys/patch_manager.h
+++ b/src/core/file_sys/patch_manager.h
@@ -44,7 +44,7 @@ public:
44 // Currently tracked NSO patches: 44 // Currently tracked NSO patches:
45 // - IPS 45 // - IPS
46 // - IPSwitch 46 // - IPSwitch
47 std::vector<u8> PatchNSO(const std::vector<u8>& nso) const; 47 std::vector<u8> PatchNSO(const std::vector<u8>& nso, const std::string& name) const;
48 48
49 // Checks to see if PatchNSO() will have any effect given the NSO's build ID. 49 // Checks to see if PatchNSO() will have any effect given the NSO's build ID.
50 // Used to prevent expensive copies in NSO loader. 50 // 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 70d840a67..7e17df98a 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() {
154 154
155 auto& frontend{Core::System::GetInstance().GetWebBrowser()}; 155 auto& frontend{Core::System::GetInstance().GetWebBrowser()};
156 156
157 frontend.OpenPage( 157 frontend.OpenPage(filename, [this] { UnpackRomFS(); }, [this] { Finalize(); });
158 filename, [this] { UnpackRomFS(); }, [this] { Finalize(); });
159} 158}
160 159
161void WebBrowser::UnpackRomFS() { 160void WebBrowser::UnpackRomFS() {
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index 714d85a59..c766070e7 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -20,6 +20,8 @@
20#include "core/memory.h" 20#include "core/memory.h"
21#include "core/settings.h" 21#include "core/settings.h"
22 22
23#pragma optimize("", off)
24
23namespace Loader { 25namespace Loader {
24namespace { 26namespace {
25struct MODHeader { 27struct MODHeader {
@@ -139,13 +141,13 @@ std::optional<VAddr> AppLoader_NSO::LoadModule(Kernel::Process& process,
139 141
140 // Apply patches if necessary 142 // Apply patches if necessary
141 if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) { 143 if (pm && (pm->HasNSOPatch(nso_header.build_id) || Settings::values.dump_nso)) {
142 std::vector<u8> pi_header(sizeof(NSOHeader) + program_image.size()); 144 std::vector<u8> pi_header;
143 pi_header.insert(pi_header.begin(), reinterpret_cast<u8*>(&nso_header), 145 pi_header.insert(pi_header.begin(), reinterpret_cast<u8*>(&nso_header),
144 reinterpret_cast<u8*>(&nso_header) + sizeof(NSOHeader)); 146 reinterpret_cast<u8*>(&nso_header) + sizeof(NSOHeader));
145 pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.begin(), 147 pi_header.insert(pi_header.begin() + sizeof(NSOHeader), program_image.begin(),
146 program_image.end()); 148 program_image.end());
147 149
148 pi_header = pm->PatchNSO(pi_header); 150 pi_header = pm->PatchNSO(pi_header, file.GetName());
149 151
150 std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.begin()); 152 std::copy(pi_header.begin() + sizeof(NSOHeader), pi_header.end(), program_image.begin());
151 } 153 }