summaryrefslogtreecommitdiff
path: root/src/core/loader/nro.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2018-12-02 22:13:50 -0500
committerGravatar Lioncash2018-12-02 22:18:52 -0500
commitb110d2176c68d8efe572766e9b7edd80e3dd4298 (patch)
tree7bd18c66f920000e940a7bb32ad63e4ce7401cd6 /src/core/loader/nro.cpp
parentMerge pull request #1827 from ReinUsesLisp/clip-and-shader (diff)
downloadyuzu-b110d2176c68d8efe572766e9b7edd80e3dd4298.tar.gz
yuzu-b110d2176c68d8efe572766e9b7edd80e3dd4298.tar.xz
yuzu-b110d2176c68d8efe572766e9b7edd80e3dd4298.zip
loader/nro: Remove dependency on the System class
Load() is already given the process instance as a parameter, so instead of coupling the class to the System class, we can just forward that parameter to LoadNro()
Diffstat (limited to 'src/core/loader/nro.cpp')
-rw-r--r--src/core/loader/nro.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index fbbd6b0de..16d5883ee 100644
--- a/src/core/loader/nro.cpp
+++ b/src/core/loader/nro.cpp
@@ -10,7 +10,6 @@
10#include "common/file_util.h" 10#include "common/file_util.h"
11#include "common/logging/log.h" 11#include "common/logging/log.h"
12#include "common/swap.h" 12#include "common/swap.h"
13#include "core/core.h"
14#include "core/file_sys/control_metadata.h" 13#include "core/file_sys/control_metadata.h"
15#include "core/file_sys/romfs_factory.h" 14#include "core/file_sys/romfs_factory.h"
16#include "core/file_sys/vfs_offset.h" 15#include "core/file_sys/vfs_offset.h"
@@ -129,9 +128,8 @@ static constexpr u32 PageAlignSize(u32 size) {
129 return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; 128 return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
130} 129}
131 130
132/*static*/ bool AppLoader_NRO::LoadNro(const std::vector<u8>& data, const std::string& name, 131/*static*/ bool AppLoader_NRO::LoadNro(Kernel::Process& process, const std::vector<u8>& data,
133 VAddr load_base) { 132 const std::string& name, VAddr load_base) {
134
135 if (data.size() < sizeof(NroHeader)) { 133 if (data.size() < sizeof(NroHeader)) {
136 return {}; 134 return {};
137 } 135 }
@@ -189,7 +187,7 @@ static constexpr u32 PageAlignSize(u32 size) {
189 187
190 // Load codeset for current process 188 // Load codeset for current process
191 codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image)); 189 codeset.memory = std::make_shared<std::vector<u8>>(std::move(program_image));
192 Core::CurrentProcess()->LoadModule(std::move(codeset), load_base); 190 process.LoadModule(std::move(codeset), load_base);
193 191
194 // Register module with GDBStub 192 // Register module with GDBStub
195 GDBStub::RegisterModule(name, load_base, load_base); 193 GDBStub::RegisterModule(name, load_base, load_base);
@@ -197,8 +195,8 @@ static constexpr u32 PageAlignSize(u32 size) {
197 return true; 195 return true;
198} 196}
199 197
200bool AppLoader_NRO::LoadNro(const FileSys::VfsFile& file, VAddr load_base) { 198bool AppLoader_NRO::LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, VAddr load_base) {
201 return AppLoader_NRO::LoadNro(file.ReadAllBytes(), file.GetName(), load_base); 199 return LoadNro(process, file.ReadAllBytes(), file.GetName(), load_base);
202} 200}
203 201
204ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { 202ResultStatus AppLoader_NRO::Load(Kernel::Process& process) {
@@ -209,7 +207,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::Process& process) {
209 // Load NRO 207 // Load NRO
210 const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); 208 const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress();
211 209
212 if (!LoadNro(*file, base_address)) { 210 if (!LoadNro(process, *file, base_address)) {
213 return ResultStatus::ErrorLoadingNRO; 211 return ResultStatus::ErrorLoadingNRO;
214 } 212 }
215 213