mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-28 06:13:18 +00:00
started work on elf class
This commit is contained in:
parent
1290756b3d
commit
9c3e9b3bef
7 changed files with 243 additions and 28 deletions
19
emulator/Loader/Elf.cpp
Normal file
19
emulator/Loader/Elf.cpp
Normal file
|
@ -0,0 +1,19 @@
|
|||
#include "Elf.h"
|
||||
|
||||
|
||||
static self_header* load_self(FsFile& f)
|
||||
{
|
||||
//read self header
|
||||
auto* self = new self_header;
|
||||
f.Read(self, sizeof(self_header));
|
||||
return self;
|
||||
}
|
||||
|
||||
void Elf::Open(const std::string& file_name)
|
||||
{
|
||||
m_f = new FsFile;
|
||||
m_f->Open(file_name, fsOpenMode::fsRead);
|
||||
|
||||
m_self = load_self(*m_f);
|
||||
|
||||
}
|
44
emulator/Loader/Elf.h
Normal file
44
emulator/Loader/Elf.h
Normal file
|
@ -0,0 +1,44 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include "../types.h"
|
||||
#include "../Core/FsFile.h"
|
||||
|
||||
struct self_header
|
||||
{
|
||||
static const u32 signature = 0x1D3D154Fu;
|
||||
|
||||
u32 magic;
|
||||
u08 version;
|
||||
u08 mode;
|
||||
u08 endian;// 1 is little endian
|
||||
u08 attributes;
|
||||
u08 category;
|
||||
u08 program_type;
|
||||
u16 padding1;
|
||||
u16 header_size;
|
||||
u16 meta_size;
|
||||
u32 file_size;
|
||||
u32 padding2;
|
||||
u16 segment_count;
|
||||
u16 unknown1A; //always 0x22
|
||||
u32 padding3;
|
||||
};
|
||||
|
||||
struct self_segment_header
|
||||
{
|
||||
u64 flags;
|
||||
u64 offset;
|
||||
u64 encrypted_compressed_size;
|
||||
u64 decrypted_decompressed_size;
|
||||
};
|
||||
|
||||
class Elf
|
||||
{
|
||||
public:
|
||||
void Open(const std::string & file_name);
|
||||
|
||||
private:
|
||||
FsFile* m_f = nullptr;
|
||||
self_header* m_self = nullptr;
|
||||
};
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue