ELF boot: scan segments for Wii mode detection, not sections
This commit is contained in:
parent
3f11879640
commit
a6742d9cf7
|
@ -35,12 +35,12 @@ bool CBoot::IsElfWii(const std::string& filename)
|
||||||
u32 HID4_mask = Common::swap32(0xfc1fffff);
|
u32 HID4_mask = Common::swap32(0xfc1fffff);
|
||||||
ElfReader reader(elf.get());
|
ElfReader reader(elf.get());
|
||||||
|
|
||||||
for (int i = 0; i < reader.GetNumSections(); ++i)
|
for (int i = 0; i < reader.GetNumSegments(); ++i)
|
||||||
{
|
{
|
||||||
if (reader.IsCodeSection(i))
|
if (reader.IsCodeSegment(i))
|
||||||
{
|
{
|
||||||
u32* code = (u32*)reader.GetSectionDataPtr(i);
|
u32* code = (u32*)reader.GetSegmentPtr(i);
|
||||||
for (u32 j = 0; j < reader.GetSectionSize(i) / sizeof(u32); ++j)
|
for (u32 j = 0; j < reader.GetSegmentSize(i) / sizeof(u32); ++j)
|
||||||
{
|
{
|
||||||
if ((code[j] & HID4_mask) == HID4_pattern)
|
if ((code[j] & HID4_mask) == HID4_pattern)
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -55,8 +55,9 @@ public:
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
bool IsCodeSection(int section) const { return sections[section].sh_type == SHT_PROGBITS; }
|
bool IsCodeSegment(int segment) const { return segments[segment].p_flags & PF_X; }
|
||||||
const u8* GetSegmentPtr(int segment) { return GetPtr(segments[segment].p_offset); }
|
const u8* GetSegmentPtr(int segment) { return GetPtr(segments[segment].p_offset); }
|
||||||
|
int GetSegmentSize(int segment) const { return segments[segment].p_filesz; }
|
||||||
u32 GetSectionAddr(SectionID section) const { return sectionAddrs[section]; }
|
u32 GetSectionAddr(SectionID section) const { return sectionAddrs[section]; }
|
||||||
int GetSectionSize(SectionID section) const { return sections[section].sh_size; }
|
int GetSectionSize(SectionID section) const { return sections[section].sh_size; }
|
||||||
SectionID GetSectionByName(const char* name, int firstSection = 0) const; //-1 for not found
|
SectionID GetSectionByName(const char* name, int firstSection = 0) const; //-1 for not found
|
||||||
|
|
Loading…
Reference in New Issue