Virtual Filesystem (#597)
* Add VfsFile and VfsDirectory classes * Finish abstract Vfs classes * Implement RealVfsFile (computer fs backend) * Finish RealVfsFile and RealVfsDirectory * Finished OffsetVfsFile * More changes * Fix import paths * Major refactor * Remove double const * Use experimental/filesystem or filesystem depending on compiler * Port partition_filesystem * More changes * More Overhaul * FSP_SRV fixes * Fixes and testing * Try to get filesystem to compile * Filesystem on linux * Remove std::filesystem and document/test * Compile fixes * Missing include * Bug fixes * Fixes * Rename v_file and v_dir * clang-format fix * Rename NGLOG_* to LOG_* * Most review changes * Fix TODO * Guess 'main' to be Directory by filename
This commit is contained in:
parent
51bd76a5fd
commit
77c684c114
45 changed files with 1796 additions and 1688 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue