diff options
| -rw-r--r-- | src/core/loader/nro.cpp | 14 | ||||
| -rw-r--r-- | src/core/loader/nro.h | 9 |
2 files changed, 13 insertions, 10 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 | ||
| 200 | bool AppLoader_NRO::LoadNro(const FileSys::VfsFile& file, VAddr load_base) { | 198 | bool 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 | ||
| 204 | ResultStatus AppLoader_NRO::Load(Kernel::Process& process) { | 202 | ResultStatus 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 | ||
diff --git a/src/core/loader/nro.h b/src/core/loader/nro.h index 3e6959302..6a63d1a7a 100644 --- a/src/core/loader/nro.h +++ b/src/core/loader/nro.h | |||
| @@ -14,6 +14,10 @@ namespace FileSys { | |||
| 14 | class NACP; | 14 | class NACP; |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | namespace Kernel { | ||
| 18 | class Process; | ||
| 19 | } | ||
| 20 | |||
| 17 | namespace Loader { | 21 | namespace Loader { |
| 18 | 22 | ||
| 19 | /// Loads an NRO file | 23 | /// Loads an NRO file |
| @@ -41,10 +45,11 @@ public: | |||
| 41 | ResultStatus ReadTitle(std::string& title) override; | 45 | ResultStatus ReadTitle(std::string& title) override; |
| 42 | bool IsRomFSUpdatable() const override; | 46 | bool IsRomFSUpdatable() const override; |
| 43 | 47 | ||
| 44 | static bool LoadNro(const std::vector<u8>& data, const std::string& name, VAddr load_base); | 48 | static bool LoadNro(Kernel::Process& process, const std::vector<u8>& data, |
| 49 | const std::string& name, VAddr load_base); | ||
| 45 | 50 | ||
| 46 | private: | 51 | private: |
| 47 | bool LoadNro(const FileSys::VfsFile& file, VAddr load_base); | 52 | bool LoadNro(Kernel::Process& process, const FileSys::VfsFile& file, VAddr load_base); |
| 48 | 53 | ||
| 49 | std::vector<u8> icon_data; | 54 | std::vector<u8> icon_data; |
| 50 | std::unique_ptr<FileSys::NACP> nacp; | 55 | std::unique_ptr<FileSys::NACP> nacp; |