mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-01 11:14:17 +01:00
nso: Make LoadModule take a VfsFile by const reference
This commit is contained in:
parent
0732786ddc
commit
bb9cf8a127
@ -141,7 +141,7 @@ ResultStatus AppLoader_DeconstructedRomDirectory::Load(Kernel::Process& process)
|
||||
const FileSys::VirtualFile module_file = dir->GetFile(module);
|
||||
if (module_file != nullptr) {
|
||||
const VAddr load_addr = next_load_addr;
|
||||
next_load_addr = AppLoader_NSO::LoadModule(module_file, load_addr,
|
||||
next_load_addr = AppLoader_NSO::LoadModule(*module_file, load_addr,
|
||||
std::strcmp(module, "rtld") == 0, pm);
|
||||
LOG_DEBUG(Loader, "loaded module {} @ 0x{:X}", module, load_addr);
|
||||
// Register module with GDBStub
|
||||
|
@ -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);
|
||||
|
@ -36,7 +36,8 @@ public:
|
||||
return IdentifyType(file);
|
||||
}
|
||||
|
||||
static VAddr LoadModule(FileSys::VirtualFile file, VAddr load_base, bool should_pass_arguments,
|
||||
static VAddr LoadModule(const FileSys::VfsFile& file, VAddr load_base,
|
||||
bool should_pass_arguments,
|
||||
boost::optional<FileSys::PatchManager> pm = boost::none);
|
||||
|
||||
ResultStatus Load(Kernel::Process& process) override;
|
||||
|
Loading…
Reference in New Issue
Block a user