支持特殊的32位dump elf文件

支持不完整的dump elf文件
细节调整
This commit is contained in:
Perfare 2022-04-22 09:28:13 +08:00
parent 7159995e0e
commit 2f1a4b2a14
14 changed files with 38 additions and 24 deletions

View file

@ -15,5 +15,7 @@
public bool RequireAnyKey = true;
public bool ForceIl2CppVersion = false;
public double ForceVersion = 24.3;
public bool ForceDump = false;
public bool NoRedirectedPointer = false;
}
}

View file

@ -384,7 +384,7 @@ namespace Il2CppDumper
}
var data = dataList.ToArray();
var exec = execList.ToArray();
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);
sectionHelper.SetSection(SearchSectionType.Exec, exec);
sectionHelper.SetSection(SearchSectionType.Data, data);
sectionHelper.SetSection(SearchSectionType.Bss, data);

View file

@ -328,7 +328,7 @@ namespace Il2CppDumper
}
var data = dataList.ToArray();
var exec = execList.ToArray();
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);
sectionHelper.SetSection(SearchSectionType.Exec, exec);
sectionHelper.SetSection(SearchSectionType.Data, data);
sectionHelper.SetSection(SearchSectionType.Bss, data);

View file

@ -197,7 +197,7 @@ namespace Il2CppDumper
var data = sections.Where(x => x.sectname == "__const").ToArray();
var code = sections.Where(x => x.flags == 0x80000400).ToArray();
var bss = sections.Where(x => x.flags == 1u).ToArray();
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);
sectionHelper.SetSection(SearchSectionType.Exec, code);
sectionHelper.SetSection(SearchSectionType.Data, data);
sectionHelper.SetSection(SearchSectionType.Bss, bss);

View file

@ -259,7 +259,7 @@ namespace Il2CppDumper
var data = sections.Where(x => x.sectname == "__const" || x.sectname == "__cstring" || x.sectname == "__data").ToArray();
var code = sections.Where(x => x.flags == 0x80000400).ToArray();
var bss = sections.Where(x => x.flags == 1u).ToArray();
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);
sectionHelper.SetSection(SearchSectionType.Exec, code);
sectionHelper.SetSection(SearchSectionType.Data, data);
sectionHelper.SetSection(SearchSectionType.Bss, bss);

View file

@ -322,7 +322,7 @@ namespace Il2CppDumper
public override SectionHelper GetSectionHelper(int methodCount, int typeDefinitionsCount, int imageCount)
{
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);
sectionHelper.SetSection(SearchSectionType.Exec, header.TextSegment);
sectionHelper.SetSection(SearchSectionType.Data, header.DataSegment, header.RoDataSegment);
sectionHelper.SetSection(SearchSectionType.Bss, header.BssSegment);

View file

@ -116,7 +116,7 @@ namespace Il2CppDumper
break;
}
}
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);
var data = dataList.ToArray();
var exec = execList.ToArray();
sectionHelper.SetSection(SearchSectionType.Exec, ImageBase, exec);

View file

@ -60,7 +60,7 @@ namespace Il2CppDumper
address = Length,
addressEnd = long.MaxValue //hack
};
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, maxMetadataUsages, imageCount);
var sectionHelper = new SectionHelper(this, methodCount, typeDefinitionsCount, metadataUsagesCount, imageCount);
sectionHelper.SetSection(SearchSectionType.Exec, exec);
sectionHelper.SetSection(SearchSectionType.Data, data);
sectionHelper.SetSection(SearchSectionType.Bss, bss);

View file

@ -26,7 +26,7 @@ namespace Il2CppDumper
public Dictionary<int, List<Il2CppMethodSpec>> methodDefinitionMethodSpecs = new Dictionary<int, List<Il2CppMethodSpec>>();
public Dictionary<Il2CppMethodSpec, ulong> methodSpecGenericMethodPointers = new Dictionary<Il2CppMethodSpec, ulong>();
private bool fieldOffsetsArePointers;
protected long maxMetadataUsages;
protected long metadataUsagesCount;
public Dictionary<string, Il2CppCodeGenModule> codeGenModules;
public Dictionary<string, ulong[]> codeGenModuleMethodPointers;
public Dictionary<string, Dictionary<uint, Il2CppRGCTXDefinition[]>> rgctxsDictionary;
@ -42,10 +42,10 @@ namespace Il2CppDumper
protected Il2Cpp(Stream stream) : base(stream) { }
public void SetProperties(double version, long maxMetadataUsages)
public void SetProperties(double version, long metadataUsagesCount)
{
Version = version;
this.maxMetadataUsages = maxMetadataUsages;
this.metadataUsagesCount = metadataUsagesCount;
}
protected bool AutoPlusInit(ulong codeRegistration, ulong metadataRegistration)
@ -143,7 +143,7 @@ namespace Il2CppDumper
}
if (Version > 16 && Version < 27)
{
metadataUsages = MapVATR<ulong>(pMetadataRegistration.metadataUsages, maxMetadataUsages);
metadataUsages = MapVATR<ulong>(pMetadataRegistration.metadataUsages, metadataUsagesCount);
}
if (Version >= 22)
{

View file

@ -28,7 +28,7 @@ namespace Il2CppDumper
public int[] attributeTypes;
public int[] interfaceIndices;
public Dictionary<Il2CppMetadataUsage, SortedDictionary<uint, uint>> metadataUsageDic;
public long maxMetadataUsages;
public long metadataUsagesCount;
public int[] nestedTypeIndices;
public Il2CppEventDefinition[] eventDefs;
public Il2CppGenericContainer[] genericContainers;
@ -221,13 +221,18 @@ namespace Il2CppDumper
for (int i = 0; i < metadataUsageList.count; i++)
{
var offset = metadataUsageList.start + i;
if (offset >= metadataUsagePairs.Length)
{
continue;
}
var metadataUsagePair = metadataUsagePairs[offset];
var usage = GetEncodedIndexType(metadataUsagePair.encodedSourceIndex);
var decodedIndex = GetDecodedMethodIndex(metadataUsagePair.encodedSourceIndex);
metadataUsageDic[(Il2CppMetadataUsage)usage][metadataUsagePair.destinationIndex] = decodedIndex;
}
}
maxMetadataUsages = metadataUsageDic.Max(x => x.Value.Select(y => y.Key).DefaultIfEmpty().Max()) + 1;
//metadataUsagesCount = metadataUsagePairs.Max(x => x.destinationIndex) + 1;
metadataUsagesCount = metadataUsageDic.Max(x => x.Value.Select(y => y.Key).DefaultIfEmpty().Max()) + 1;
}
public uint GetEncodedIndexType(uint index)

View file

@ -269,7 +269,8 @@ namespace Il2CppDumper
foreach (var sec in sectionHelper.data)
{
il2Cpp.Position = sec.offset;
while (il2Cpp.Position < sec.offsetEnd - il2Cpp.PointerSize)
var end = Math.Min(sec.offsetEnd, il2Cpp.Length) - il2Cpp.PointerSize;
while (il2Cpp.Position < end)
{
var addr = il2Cpp.Position;
var metadataValue = il2Cpp.ReadUIntPtr();

View file

@ -182,9 +182,9 @@ namespace Il2CppDumper
break;
}
var version = config.ForceIl2CppVersion ? config.ForceVersion : metadata.Version;
il2Cpp.SetProperties(version, metadata.maxMetadataUsages);
il2Cpp.SetProperties(version, metadata.metadataUsagesCount);
Console.WriteLine($"Il2Cpp Version: {il2Cpp.Version}");
if (il2Cpp.CheckDump())
if (config.ForceDump || il2Cpp.CheckDump())
{
if (il2Cpp is ElfBase elf)
{
@ -195,7 +195,10 @@ namespace Il2CppDumper
{
il2Cpp.ImageBase = DumpAddr;
il2Cpp.IsDumped = true;
elf.Reload();
if (!config.NoRedirectedPointer)
{
elf.Reload();
}
}
}
else
@ -214,7 +217,7 @@ namespace Il2CppDumper
{
Console.WriteLine("Use custom PE loader");
il2Cpp = PELoader.Load(il2cppPath);
il2Cpp.SetProperties(version, metadata.maxMetadataUsages);
il2Cpp.SetProperties(version, metadata.metadataUsagesCount);
flag = il2Cpp.PlusSearch(metadata.methodDefs.Count(x => x.methodIndex >= 0), metadata.typeDefs.Length, metadata.imageDefs.Length);
}
}

View file

@ -9,18 +9,18 @@ namespace Il2CppDumper
private Il2Cpp il2Cpp;
private int methodCount;
private int typeDefinitionsCount;
private long maxMetadataUsages;
private long metadataUsagesCount;
private int imageCount;
public List<SearchSection> exec;
public List<SearchSection> data;
public List<SearchSection> bss;
public SectionHelper(Il2Cpp il2Cpp, int methodCount, int typeDefinitionsCount, long maxMetadataUsages, int imageCount)
public SectionHelper(Il2Cpp il2Cpp, int methodCount, int typeDefinitionsCount, long metadataUsagesCount, int imageCount)
{
this.il2Cpp = il2Cpp;
this.methodCount = methodCount;
this.typeDefinitionsCount = typeDefinitionsCount;
this.maxMetadataUsages = maxMetadataUsages;
this.metadataUsagesCount = metadataUsagesCount;
this.imageCount = imageCount;
}
@ -231,7 +231,7 @@ namespace Il2CppDumper
var pointer = il2Cpp.MapVATR(il2Cpp.ReadUIntPtr());
if (CheckPointerRangeDataRa(pointer))
{
var pointers = il2Cpp.ReadClassArray<ulong>(pointer, maxMetadataUsages);
var pointers = il2Cpp.ReadClassArray<ulong>(pointer, metadataUsagesCount);
if (CheckPointerRangeBssVa(pointers))
{
return addr - il2Cpp.PointerSize * 12 - section.offset + section.address;
@ -375,7 +375,8 @@ namespace Il2CppDumper
foreach (var dataSec in data)
{
il2Cpp.Position = dataSec.offset;
while (il2Cpp.Position < dataSec.offsetEnd - il2Cpp.PointerSize)
var end = Math.Min(dataSec.offsetEnd, il2Cpp.Length) - il2Cpp.PointerSize;
while (il2Cpp.Position < end)
{
var offset = il2Cpp.Position;
if (il2Cpp.ReadUIntPtr() == addr)

View file

@ -11,5 +11,7 @@
"DummyDllAddToken": true,
"RequireAnyKey": true,
"ForceIl2CppVersion": false,
"ForceVersion": 16
"ForceVersion": 16,
"ForceDump": false,
"NoRedirectedPointer": false
}