summaryrefslogtreecommitdiffstats
path: root/src/core/loader/elf.cpp
diff options
context:
space:
mode:
authorZach Hilman <DarkLordZach@users.noreply.github.com>2018-07-19 03:07:11 +0200
committerbunnei <bunneidev@gmail.com>2018-07-19 03:07:11 +0200
commit29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef (patch)
tree3202e2ce55ab6387a4ca366a509eccdd963434c3 /src/core/loader/elf.cpp
parentMerge pull request #683 from DarkLordZach/touch (diff)
downloadyuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar
yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.gz
yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.bz2
yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.lz
yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.xz
yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.tar.zst
yuzu-29aff8d5ab46c8d0199aa4bfa7eeff5d4fa2d7ef.zip
Diffstat (limited to 'src/core/loader/elf.cpp')
-rw-r--r--src/core/loader/elf.cpp24
1 files changed, 7 insertions, 17 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index b69e5c6ef..4bfd5f536 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -365,20 +365,17 @@ SectionID ElfReader::GetSectionByName(const char* name, int firstSection) const
namespace Loader {
-AppLoader_ELF::AppLoader_ELF(FileUtil::IOFile&& file, std::string filename)
- : AppLoader(std::move(file)), filename(std::move(filename)) {}
+AppLoader_ELF::AppLoader_ELF(FileSys::VirtualFile file) : AppLoader(std::move(file)) {}
-FileType AppLoader_ELF::IdentifyType(FileUtil::IOFile& file, const std::string&) {
+FileType AppLoader_ELF::IdentifyType(const FileSys::VirtualFile& file) {
static constexpr u16 ELF_MACHINE_ARM{0x28};
u32 magic = 0;
- file.Seek(0, SEEK_SET);
- if (1 != file.ReadArray<u32>(&magic, 1))
+ if (4 != file->ReadObject(&magic))
return FileType::Error;
u16 machine = 0;
- file.Seek(18, SEEK_SET);
- if (1 != file.ReadArray<u16>(&machine, 1))
+ if (2 != file->ReadObject(&machine, 18))
return FileType::Error;
if (Common::MakeMagic('\x7f', 'E', 'L', 'F') == magic && ELF_MACHINE_ARM == machine)
@@ -391,20 +388,13 @@ ResultStatus AppLoader_ELF::Load(Kernel::SharedPtr<Kernel::Process>& process) {
if (is_loaded)
return ResultStatus::ErrorAlreadyLoaded;
- if (!file.IsOpen())
- return ResultStatus::Error;
-
- // Reset read pointer in case this file has been read before.
- file.Seek(0, SEEK_SET);
-
- size_t size = file.GetSize();
- std::unique_ptr<u8[]> buffer(new u8[size]);
- if (file.ReadBytes(&buffer[0], size) != size)
+ std::vector<u8> buffer = file->ReadAllBytes();
+ if (buffer.size() != file->GetSize())
return ResultStatus::Error;
ElfReader elf_reader(&buffer[0]);
SharedPtr<CodeSet> codeset = elf_reader.LoadInto(Memory::PROCESS_IMAGE_VADDR);
- codeset->name = filename;
+ codeset->name = file->GetName();
process->LoadModule(codeset, codeset->entrypoint);
process->svc_access_mask.set();