This commit is contained in:
Perfare 2020-03-06 19:41:06 +08:00
parent 5e61444f4e
commit 4525df6334
3 changed files with 50 additions and 12 deletions

View file

@ -30,11 +30,7 @@ namespace Il2CppDumper
Is32Bit = true;
elfHeader = ReadClass<Elf32_Ehdr>();
programSegment = ReadClassArray<Elf32_Phdr>(elfHeader.e_phoff, elfHeader.e_phnum);
try
{
sectionTable = ReadClassArray<Elf32_Shdr>(elfHeader.e_shoff, elfHeader.e_shnum);
}
catch
if (!CheckSection())
{
Console.WriteLine("Detected this may be a dump file. If not, it must be protected.");
isDumped = true;
@ -59,6 +55,29 @@ namespace Il2CppDumper
}
}
public bool CheckSection()
{
try
{
var names = new List<string>();
sectionTable = ReadClassArray<Elf32_Shdr>(elfHeader.e_shoff, elfHeader.e_shnum);
var shstrndx = sectionTable[elfHeader.e_shstrndx].sh_offset;
foreach (var section in sectionTable)
{
names.Add(ReadStringToNull(shstrndx + section.sh_name));
}
if (!names.Contains(".text"))
{
return false;
}
return true; ;
}
catch
{
return false;
}
}
public override ulong MapVATR(ulong addr)
{
var phdr = programSegment.First(x => addr >= x.p_vaddr && addr <= x.p_vaddr + x.p_memsz);

View file

@ -21,11 +21,7 @@ namespace Il2CppDumper
{
elfHeader = ReadClass<Elf64_Ehdr>();
programSegment = ReadClassArray<Elf64_Phdr>(elfHeader.e_phoff, elfHeader.e_phnum);
try
{
sectionTable = ReadClassArray<Elf64_Shdr>(elfHeader.e_shoff, elfHeader.e_shnum);
}
catch
if(!CheckSection())
{
Console.WriteLine("Detected this may be a dump file. If not, it must be protected.");
isDumped = true;
@ -50,6 +46,29 @@ namespace Il2CppDumper
}
}
public bool CheckSection()
{
try
{
var names = new List<string>();
sectionTable = ReadClassArray<Elf64_Shdr>(elfHeader.e_shoff, elfHeader.e_shnum);
var shstrndx = sectionTable[elfHeader.e_shstrndx].sh_offset;
foreach (var section in sectionTable)
{
names.Add(ReadStringToNull(shstrndx + section.sh_name));
}
if (!names.Contains(".text"))
{
return false;
}
return true; ;
}
catch
{
return false;
}
}
public override ulong MapVATR(ulong addr)
{
var phdr = programSegment.First(x => addr >= x.p_vaddr && addr <= x.p_vaddr + x.p_memsz);

View file

@ -24,7 +24,7 @@ namespace Il2CppDumper
public ushort e_phnum;
public ushort e_shentsize;
public ushort e_shnum;
public ushort e_shtrndx;
public ushort e_shstrndx;
}
public class Elf32_Phdr
@ -97,7 +97,7 @@ namespace Il2CppDumper
public ushort e_phnum;
public ushort e_shentsize;
public ushort e_shnum;
public ushort e_shtrndx;
public ushort e_shstrndx;
}
public class Elf64_Phdr