mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 18:46:06 +00:00
more work on elf header
This commit is contained in:
parent
e37e047c0e
commit
f58bb4abab
|
@ -98,6 +98,12 @@ void Elf::Open(const std::string& file_name)
|
|||
|
||||
m_elf_header = load_elf_header(*m_f);
|
||||
|
||||
if (!isElfFile())
|
||||
{
|
||||
delete m_elf_header;
|
||||
m_elf_header = nullptr;
|
||||
}
|
||||
|
||||
DebugDump();
|
||||
}
|
||||
|
||||
|
@ -134,6 +140,27 @@ bool Elf::isSelfFile() const
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Elf::isElfFile() const
|
||||
{
|
||||
if (m_f == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_elf_header == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (m_elf_header->e_ident[0] != '\x7f' || m_elf_header->e_ident[1] != '\x45' || m_elf_header->e_ident[2] != '\x4c' ||
|
||||
m_elf_header->e_ident[3] != '\x46')
|
||||
{
|
||||
printf("Not an ELF file magic is wrong!\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Elf::DebugDump() {
|
||||
printf("SELF header:\n");
|
||||
printf(" magic ..............: 0x%08" PRIx32 "\n", m_self->magic);
|
||||
|
|
|
@ -95,6 +95,7 @@ public:
|
|||
|
||||
void Open(const std::string & file_name);
|
||||
bool isSelfFile() const;
|
||||
bool isElfFile() const;
|
||||
void DebugDump();
|
||||
private:
|
||||
|
||||
|
|
Loading…
Reference in a new issue