优化MakeFunction

This commit is contained in:
Perfare 2017-12-19 13:38:51 +08:00
parent 3a80f7b59f
commit 6816a92f29
4 changed files with 21 additions and 4 deletions

View file

@ -10,6 +10,8 @@ namespace Il2CppDumper
private Il2CppMetadataRegistration pMetadataRegistration;
private Il2CppCodeRegistration pCodeRegistration;
public ulong[] methodPointers;
public ulong[] genericMethodPointers;
public ulong[] invokerPointers;
public ulong[] customAttributeGenerators;
protected long[] fieldOffsets;
public Il2CppType[] types;
@ -31,6 +33,8 @@ namespace Il2CppDumper
pCodeRegistration = MapVATR<Il2CppCodeRegistration>(codeRegistration);
pMetadataRegistration = MapVATR<Il2CppMetadataRegistration>(metadataRegistration);
methodPointers = Array.ConvertAll(MapVATR<uint>(pCodeRegistration.methodPointers, (long)pCodeRegistration.methodPointersCount), x => (ulong)x);
genericMethodPointers = Array.ConvertAll(MapVATR<uint>(pCodeRegistration.genericMethodPointers, (long)pCodeRegistration.genericMethodPointersCount), x => (ulong)x);
invokerPointers = Array.ConvertAll(MapVATR<uint>(pCodeRegistration.invokerPointers, (long)pCodeRegistration.invokerPointersCount), x => (ulong)x);
customAttributeGenerators = Array.ConvertAll(MapVATR<uint>(pCodeRegistration.customAttributeGenerators, pCodeRegistration.customAttributeCount), x => (ulong)x);
fieldOffsets = Array.ConvertAll(MapVATR<int>(pMetadataRegistration.fieldOffsets, pMetadataRegistration.fieldOffsetsCount), x => (long)x);
//TODO 在21版本中存在两种FieldOffset通过判断前5个数值是否为0确认是指针还是int
@ -52,6 +56,8 @@ namespace Il2CppDumper
pCodeRegistration = MapVATR<Il2CppCodeRegistration>(codeRegistration);
pMetadataRegistration = MapVATR<Il2CppMetadataRegistration>(metadataRegistration);
methodPointers = MapVATR<ulong>(pCodeRegistration.methodPointers, (long)pCodeRegistration.methodPointersCount);
genericMethodPointers = MapVATR<ulong>(pCodeRegistration.genericMethodPointers, (long)pCodeRegistration.genericMethodPointersCount);
invokerPointers = MapVATR<ulong>(pCodeRegistration.invokerPointers, (long)pCodeRegistration.invokerPointersCount);
customAttributeGenerators = MapVATR<ulong>(pCodeRegistration.customAttributeGenerators, pCodeRegistration.customAttributeCount);
fieldOffsets = MapVATR<long>(pMetadataRegistration.fieldOffsets, pMetadataRegistration.fieldOffsetsCount);
//TODO 在21版本中存在两种FieldOffset通过判断前5个数值是否为0确认是指针还是int

View file

@ -407,10 +407,14 @@ namespace Il2CppDumper
}
}
//--MakeFunction
var orderedPointers = il2cpp.methodPointers.OrderBy(x => x).ToArray();
for (int i = 0; i < orderedPointers.Length - 1; i++)
var orderedPointers = il2cpp.methodPointers.ToList();
orderedPointers.AddRange(il2cpp.genericMethodPointers.Where(x => x > 0));
orderedPointers.AddRange(il2cpp.invokerPointers);
orderedPointers.AddRange(il2cpp.customAttributeGenerators);
orderedPointers = orderedPointers.OrderBy(x => x).ToList();
for (int i = 0; i < orderedPointers.Count - 1; i++)
{
scriptwriter.WriteLine($"idc.MakeFunction(0x{orderedPointers[i]:X}, 0x{orderedPointers[i + 1]:X})");
scriptwriter.WriteLine($"MakeFunction(0x{orderedPointers[i]:X}, 0x{orderedPointers[i + 1]:X})");
}
//
writer.Close();

View file

@ -80,7 +80,8 @@ namespace Il2CppDumper {
/// ret = idc.MakeNameEx(addr, str(new_name), SN_NOWARN)
/// i = i + 1
///
///index = 1 的本地化字符串。
///def MakeFunction(start, end):
/// if GetFuncti [字符串的其余部分被截断]&quot;; 的本地化字符串。
/// </summary>
internal static string ida {
get {

View file

@ -137,6 +137,12 @@ def SetMethod(addr, name):
ret = idc.MakeNameEx(addr, str(new_name), SN_NOWARN)
i = i + 1
def MakeFunction(start, end):
if GetFunctionAttr(start, FUNCATTR_START) == 0xFFFFFFFF:
idc.MakeFunction(start, end)
else:
idc.SetFunctionEnd(start, end)
index = 1</value>
</data>
</root>