summaryrefslogtreecommitdiff
path: root/src/core/loader/nro.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2018-12-04 12:26:12 -0500
committerGravatar GitHub2018-12-04 12:26:12 -0500
commit465f486160b59c72a85b0f75aca310647b38155c (patch)
tree915750cb850ecc8f8f8ce01d5a55e91063daadcc /src/core/loader/nro.cpp
parentMerge pull request #1853 from lioncash/event (diff)
parentloader/nso: Remove dependency on the System class (diff)
downloadyuzu-465f486160b59c72a85b0f75aca310647b38155c.tar.gz
yuzu-465f486160b59c72a85b0f75aca310647b38155c.tar.xz
yuzu-465f486160b59c72a85b0f75aca310647b38155c.zip
Merge pull request #1845 from lioncash/nro
loader/{nro, nso}: Remove dependency on the System class
Diffstat (limited to 'src/core/loader/nro.cpp')
-rw-r--r--src/core/loader/nro.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/core/loader/nro.cpp b/src/core/loader/nro.cpp
index fbbd6b0de..4fad0c0dd 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, 131static bool LoadNroImpl(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,9 @@ 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,
201 return AppLoader_NRO::LoadNro(file.ReadAllBytes(), file.GetName(), load_base); 199 VAddr load_base) {
200 return LoadNroImpl(process, file.ReadAllBytes(), file.GetName(), load_base);
202} 201}
203 202
204ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { 203ResultStatus AppLoader_NRO::Load(Kernel::Process& process) {
@@ -209,7 +208,7 @@ ResultStatus AppLoader_NRO::Load(Kernel::Process& process) {
209 // Load NRO 208 // Load NRO
210 const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress(); 209 const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress();
211 210
212 if (!LoadNro(*file, base_address)) { 211 if (!LoadNro(process, *file, base_address)) {
213 return ResultStatus::ErrorLoadingNRO; 212 return ResultStatus::ErrorLoadingNRO;
214 } 213 }
215 214