1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-26 04:32:35 +01:00

unself: rename SelfHeader to ext_hdr

This commit is contained in:
Megamouse 2023-04-19 20:17:35 +02:00
parent 1041284384
commit e171f3af41
2 changed files with 39 additions and 39 deletions

View File

@ -610,18 +610,18 @@ void SceHeader::Load(const fs::file& f)
se_esize = Read64(f);
}
void SelfHeader::Load(const fs::file& f)
void ext_hdr::Load(const fs::file& f)
{
se_htype = Read64(f);
se_appinfooff = Read64(f);
se_elfoff = Read64(f);
se_phdroff = Read64(f);
se_shdroff = Read64(f);
se_secinfoff = Read64(f);
se_sceveroff = Read64(f);
se_controloff = Read64(f);
se_controlsize = Read64(f);
pad = Read64(f);
ext_hdr_version = Read64(f);
program_identification_hdr_offset = Read64(f);
ehdr_offset = Read64(f);
phdr_offset = Read64(f);
shdr_offset = Read64(f);
segment_ext_hdr_offset = Read64(f);
version_hdr_offset = Read64(f);
supplemental_hdr_offset = Read64(f);
supplemental_hdr_size = Read64(f);
padding = Read64(f);
}
SCEDecrypter::SCEDecrypter(const fs::file& s)
@ -884,10 +884,10 @@ bool SELFDecrypter::LoadHeaders(bool isElf32, SelfAdditionalInfo* out_info)
}
// Read SELF header.
self_hdr.Load(self_f);
m_ext_hdr.Load(self_f);
// Read the APP INFO.
self_f.seek(self_hdr.se_appinfooff);
self_f.seek(m_ext_hdr.program_identification_hdr_offset);
app_info.Load(self_f);
if (out_info)
@ -896,7 +896,7 @@ bool SELFDecrypter::LoadHeaders(bool isElf32, SelfAdditionalInfo* out_info)
}
// Read ELF header.
self_f.seek(self_hdr.se_elfoff);
self_f.seek(m_ext_hdr.ehdr_offset);
if (isElf32)
elf32_hdr.Load(self_f);
@ -912,7 +912,7 @@ bool SELFDecrypter::LoadHeaders(bool isElf32, SelfAdditionalInfo* out_info)
self_log.error("ELF program header offset is null!");
return false;
}
self_f.seek(self_hdr.se_phdroff);
self_f.seek(m_ext_hdr.phdr_offset);
for(u32 i = 0; i < elf32_hdr.e_phnum; ++i)
{
phdr32_arr.emplace_back();
@ -929,7 +929,7 @@ bool SELFDecrypter::LoadHeaders(bool isElf32, SelfAdditionalInfo* out_info)
return false;
}
self_f.seek(self_hdr.se_phdroff);
self_f.seek(m_ext_hdr.phdr_offset);
for (u32 i = 0; i < elf64_hdr.e_phnum; ++i)
{
@ -941,7 +941,7 @@ bool SELFDecrypter::LoadHeaders(bool isElf32, SelfAdditionalInfo* out_info)
// Read section info.
secinfo_arr.clear();
self_f.seek(self_hdr.se_secinfoff);
self_f.seek(m_ext_hdr.segment_ext_hdr_offset);
for(u32 i = 0; i < ((isElf32) ? elf32_hdr.e_phnum : elf64_hdr.e_phnum); ++i)
{
@ -950,14 +950,14 @@ bool SELFDecrypter::LoadHeaders(bool isElf32, SelfAdditionalInfo* out_info)
}
// Read SCE version info.
self_f.seek(self_hdr.se_sceveroff);
self_f.seek(m_ext_hdr.version_hdr_offset);
scev_info.Load(self_f);
// Read control info.
ctrlinfo_arr.clear();
self_f.seek(self_hdr.se_controloff);
self_f.seek(m_ext_hdr.supplemental_hdr_offset);
for (u64 i = 0; i < self_hdr.se_controlsize;)
for (u64 i = 0; i < m_ext_hdr.supplemental_hdr_size;)
{
ctrlinfo_arr.emplace_back();
ControlInfo &cinfo = ctrlinfo_arr.back();
@ -981,7 +981,7 @@ bool SELFDecrypter::LoadHeaders(bool isElf32, SelfAdditionalInfo* out_info)
return true;
}
self_f.seek(self_hdr.se_shdroff);
self_f.seek(m_ext_hdr.shdr_offset);
for(u32 i = 0; i < elf32_hdr.e_shnum; ++i)
{
@ -998,7 +998,7 @@ bool SELFDecrypter::LoadHeaders(bool isElf32, SelfAdditionalInfo* out_info)
return true;
}
self_f.seek(self_hdr.se_shdroff);
self_f.seek(m_ext_hdr.shdr_offset);
for(u32 i = 0; i < elf64_hdr.e_shnum; ++i)
{
@ -1023,7 +1023,7 @@ void SELFDecrypter::ShowHeaders(bool isElf32)
self_log.notice("----------------------------------------------------");
self_log.notice("SELF header");
self_log.notice("----------------------------------------------------");
self_hdr.Show();
m_ext_hdr.Show();
self_log.notice("----------------------------------------------------");
self_log.notice("APP INFO");
self_log.notice("----------------------------------------------------");
@ -1333,15 +1333,15 @@ static bool IsSelfElf32(const fs::file& f)
f.seek(0);
SceHeader hdr;
SelfHeader sh;
SceHeader hdr{};
ext_hdr sh{};
hdr.Load(f);
sh.Load(f);
// Locate the class byte and check it.
u8 elf_class[0x8];
f.seek(sh.se_elfoff);
f.seek(sh.ehdr_offset);
f.read(elf_class, 0x8);
return (elf_class[4] == 1);

View File

@ -317,18 +317,18 @@ struct SceHeader
bool CheckMagic() const { return se_magic == 0x53434500; }
};
struct SelfHeader
struct ext_hdr
{
u64 se_htype;
u64 se_appinfooff;
u64 se_elfoff;
u64 se_phdroff;
u64 se_shdroff;
u64 se_secinfoff;
u64 se_sceveroff;
u64 se_controloff;
u64 se_controlsize;
u64 pad;
u64 ext_hdr_version;
u64 program_identification_hdr_offset;
u64 ehdr_offset;
u64 phdr_offset;
u64 shdr_offset;
u64 segment_ext_hdr_offset;
u64 version_hdr_offset;
u64 supplemental_hdr_offset;
u64 supplemental_hdr_size;
u64 padding;
void Load(const fs::file& f);
static void Show(){}
@ -376,7 +376,7 @@ class SELFDecrypter
// SCE, SELF and APP headers.
SceHeader sce_hdr{};
SelfHeader self_hdr{};
ext_hdr m_ext_hdr{};
AppInfo app_info{};
// ELF64 header and program header/section header arrays.
@ -484,7 +484,7 @@ private:
}
// Write section headers.
if (self_hdr.se_shdroff != 0)
if (m_ext_hdr.shdr_offset != 0)
{
e.seek(ehdr.e_shoff);