summaryrefslogtreecommitdiffstats
path: root/src/core/loader/nso.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-10-15 02:36:57 +0200
committerLioncash <mathew1800@gmail.com>2018-10-15 02:38:19 +0200
commitbb9cf8a127baf83aa3ebdef5b17d9bdd69869b4a (patch)
tree03898f15baeb092ddfc7a59e9bcda97c2c8cd386 /src/core/loader/nso.cpp
parentnro: Make LoadNro take a VfsFile by const reference (diff)
downloadyuzu-bb9cf8a127baf83aa3ebdef5b17d9bdd69869b4a.tar
yuzu-bb9cf8a127baf83aa3ebdef5b17d9bdd69869b4a.tar.gz
yuzu-bb9cf8a127baf83aa3ebdef5b17d9bdd69869b4a.tar.bz2
yuzu-bb9cf8a127baf83aa3ebdef5b17d9bdd69869b4a.tar.lz
yuzu-bb9cf8a127baf83aa3ebdef5b17d9bdd69869b4a.tar.xz
yuzu-bb9cf8a127baf83aa3ebdef5b17d9bdd69869b4a.tar.zst
yuzu-bb9cf8a127baf83aa3ebdef5b17d9bdd69869b4a.zip
Diffstat (limited to '')
-rw-r--r--src/core/loader/nso.cpp15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp
index ba57db9bf..d26fa482c 100644
--- a/src/core/loader/nso.cpp
+++ b/src/core/loader/nso.cpp
@@ -93,17 +93,14 @@ static constexpr u32 PageAlignSize(u32 size) {
return (size + Memory::PAGE_MASK) & ~Memory::PAGE_MASK;
}
-VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base,
+VAddr AppLoader_NSO::LoadModule(const FileSys::VfsFile& file, VAddr load_base,
bool should_pass_arguments,
boost::optional<FileSys::PatchManager> pm) {
- if (file == nullptr)
- return {};
-
- if (file->GetSize() < sizeof(NsoHeader))
+ if (file.GetSize() < sizeof(NsoHeader))
return {};
NsoHeader nso_header{};
- if (sizeof(NsoHeader) != file->ReadObject(&nso_header))
+ if (sizeof(NsoHeader) != file.ReadObject(&nso_header))
return {};
if (nso_header.magic != Common::MakeMagic('N', 'S', 'O', '0'))
@@ -114,7 +111,7 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base,
std::vector<u8> program_image;
for (std::size_t i = 0; i < nso_header.segments.size(); ++i) {
std::vector<u8> data =
- file->ReadBytes(nso_header.segments_compressed_size[i], nso_header.segments[i].offset);
+ file.ReadBytes(nso_header.segments_compressed_size[i], nso_header.segments[i].offset);
if (nso_header.IsSegmentCompressed(i)) {
data = DecompressSegment(data, nso_header.segments[i]);
}
@@ -172,7 +169,7 @@ VAddr AppLoader_NSO::LoadModule(FileSys::VirtualFile file, VAddr load_base,
Core::CurrentProcess()->LoadModule(std::move(codeset), load_base);
// Register module with GDBStub
- GDBStub::RegisterModule(file->GetName(), load_base, load_base);
+ GDBStub::RegisterModule(file.GetName(), load_base, load_base);
return load_base + image_size;
}
@@ -184,7 +181,7 @@ ResultStatus AppLoader_NSO::Load(Kernel::Process& process) {
// Load module
const VAddr base_address = process.VMManager().GetCodeRegionBaseAddress();
- LoadModule(file, base_address, true);
+ LoadModule(*file, base_address, true);
LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", file->GetName(), base_address);
process.Run(base_address, Kernel::THREADPRIO_DEFAULT, Memory::DEFAULT_STACK_SIZE);