diff options
Diffstat (limited to 'src/core/loader/nso.cpp')
| -rw-r--r-- | src/core/loader/nso.cpp | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index ef769dd91..3ccbbb824 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #include <vector> | 5 | #include <vector> |
| 6 | #include <lz4.h> | 6 | #include <lz4.h> |
| 7 | |||
| 8 | #include "common/common_funcs.h" | 7 | #include "common/common_funcs.h" |
| 8 | #include "common/file_util.h" | ||
| 9 | #include "common/logging/log.h" | 9 | #include "common/logging/log.h" |
| 10 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 11 | #include "core/hle/kernel/process.h" | 11 | #include "core/hle/kernel/process.h" |
| @@ -47,7 +47,10 @@ struct ModHeader { | |||
| 47 | }; | 47 | }; |
| 48 | static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size."); | 48 | static_assert(sizeof(ModHeader) == 0x1c, "ModHeader has incorrect size."); |
| 49 | 49 | ||
| 50 | FileType AppLoader_NSO::IdentifyType(FileUtil::IOFile& file) { | 50 | AppLoader_NSO::AppLoader_NSO(FileUtil::IOFile&& file, std::string filepath) |
| 51 | : AppLoader(std::move(file)), filepath(std::move(filepath)) {} | ||
| 52 | |||
| 53 | FileType AppLoader_NSO::IdentifyType(FileUtil::IOFile& file, const std::string&) { | ||
| 51 | u32 magic = 0; | 54 | u32 magic = 0; |
| 52 | file.Seek(0, SEEK_SET); | 55 | file.Seek(0, SEEK_SET); |
| 53 | if (1 != file.ReadArray<u32>(&magic, 1)) { | 56 | if (1 != file.ReadArray<u32>(&magic, 1)) { |
| @@ -88,7 +91,7 @@ static constexpr u32 PageAlignSize(u32 size) { | |||
| 88 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; | 91 | return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK; |
| 89 | } | 92 | } |
| 90 | 93 | ||
| 91 | VAddr AppLoader_NSO::LoadNso(const std::string& path, VAddr load_base) { | 94 | VAddr AppLoader_NSO::LoadModule(const std::string& path, VAddr load_base) { |
| 92 | FileUtil::IOFile file(path, "rb"); | 95 | FileUtil::IOFile file(path, "rb"); |
| 93 | if (!file.IsOpen()) { | 96 | if (!file.IsOpen()) { |
| 94 | return {}; | 97 | return {}; |
| @@ -153,21 +156,9 @@ ResultStatus AppLoader_NSO::Load(Kernel::SharedPtr<Kernel::Process>& process) { | |||
| 153 | 156 | ||
| 154 | process = Kernel::Process::Create("main"); | 157 | process = Kernel::Process::Create("main"); |
| 155 | 158 | ||
| 156 | // Load NSO modules | 159 | // Load module |
| 157 | VAddr next_load_addr{Memory::PROCESS_IMAGE_VADDR}; | 160 | LoadModule(filepath, Memory::PROCESS_IMAGE_VADDR); |
| 158 | for (const auto& module : | 161 | LOG_DEBUG(Loader, "loaded module %s @ 0x%llx", filepath.c_str(), Memory::PROCESS_IMAGE_VADDR); |
| 159 | {"rtld", "sdk", "subsdk0", "subsdk1", "subsdk2", "subsdk3", "subsdk4"}) { | ||
| 160 | const std::string path = filepath.substr(0, filepath.find_last_of("/\\")) + "/" + module; | ||
| 161 | const VAddr load_addr = next_load_addr; | ||
| 162 | next_load_addr = LoadNso(path, load_addr); | ||
| 163 | if (next_load_addr) { | ||
| 164 | LOG_DEBUG(Loader, "loaded module %s @ 0x%llx", module, load_addr); | ||
| 165 | } else { | ||
| 166 | next_load_addr = load_addr; | ||
| 167 | } | ||
| 168 | } | ||
| 169 | // Load "main" module | ||
| 170 | LoadNso(filepath, next_load_addr); | ||
| 171 | 162 | ||
| 172 | process->svc_access_mask.set(); | 163 | process->svc_access_mask.set(); |
| 173 | process->address_mappings = default_address_mappings; | 164 | process->address_mappings = default_address_mappings; |