完善dump so的处理

bug修复
This commit is contained in:
Perfare 2019-11-08 19:26:43 +08:00
parent 6a4bcb1da3
commit 76d744af33
3 changed files with 31 additions and 20 deletions

View file

@ -130,7 +130,7 @@ namespace Il2CppDumper
}
//fieldOffset
var fieldOffset = il2cpp.GetFieldOffsetFromIndex(index, i - typeDef.fieldStart, i);
if (fieldOffset > 0)
if (fieldOffset >= 0)
{
var customAttribute = new CustomAttribute(typeDefinition.Module.ImportReference(fieldOffsetAttribute));
var offset = new CustomAttributeNamedArgument("Offset", new CustomAttributeArgument(stringType, $"0x{fieldOffset:X}"));

View file

@ -138,10 +138,10 @@ namespace Il2CppDumper
{
var result = (uint)resultList[0];
Position = result + 0x14;
codeRegistration = ReadUInt32() + result + 0xcu;
codeRegistration = ReadUInt32() + result + 0xcu + dumpAddr;
Position = result + 0x10;
var ptr = ReadUInt32() + result + 0x8;
Position = MapVATR(ptr);
Position = MapVATR(ptr + dumpAddr);
metadataRegistration = ReadUInt32();
}
}

View file

@ -15,7 +15,7 @@ namespace Il2CppDumper
public ulong[] customAttributeGenerators;
public ulong[] reversePInvokeWrappers;
public ulong[] unresolvedVirtualCallPointers;
private long[] fieldOffsets;
private ulong[] fieldOffsets;
public Il2CppType[] types;
private Dictionary<ulong, Il2CppType> typesdic = new Dictionary<ulong, Il2CppType>();
public ulong[] metadataUsages;
@ -71,7 +71,7 @@ namespace Il2CppDumper
if (is32Bit)
{
genericInsts = Array.ConvertAll(MapVATR<uint>(pMetadataRegistration.genericInsts, pMetadataRegistration.genericInstsCount), x => MapVATR<Il2CppGenericInst>(x));
fieldOffsets = Array.ConvertAll(MapVATR<int>(pMetadataRegistration.fieldOffsets, pMetadataRegistration.fieldOffsetsCount), x => (long)x);
fieldOffsets = Array.ConvertAll(MapVATR<uint>(pMetadataRegistration.fieldOffsets, pMetadataRegistration.fieldOffsetsCount), x => (ulong)x);
//在21版本中存在两种FieldOffset通过判断前5个数值是否为0确认是指针还是int
isNew21 = version > 21 || (version == 21 && fieldOffsets.ToList().FindIndex(x => x > 0) == 5);
var pTypes = MapVATR<uint>(pMetadataRegistration.types, pMetadataRegistration.typesCount);
@ -111,11 +111,11 @@ namespace Il2CppDumper
else
{
genericInsts = Array.ConvertAll(MapVATR<ulong>(pMetadataRegistration.genericInsts, pMetadataRegistration.genericInstsCount), x => MapVATR<Il2CppGenericInst>(x));
fieldOffsets = MapVATR<long>(pMetadataRegistration.fieldOffsets, pMetadataRegistration.fieldOffsetsCount);
fieldOffsets = MapVATR<ulong>(pMetadataRegistration.fieldOffsets, pMetadataRegistration.fieldOffsetsCount);
//在21版本中存在两种FieldOffset通过判断前5个数值是否为0确认是指针还是int
isNew21 = version > 21 || (version == 21 && fieldOffsets.ToList().FindIndex(x => x > 0) == 5);
if (!isNew21)
fieldOffsets = Array.ConvertAll(MapVATR<int>(pMetadataRegistration.fieldOffsets, pMetadataRegistration.fieldOffsetsCount), x => (long)x);
fieldOffsets = Array.ConvertAll(MapVATR<uint>(pMetadataRegistration.fieldOffsets, pMetadataRegistration.fieldOffsetsCount), x => (ulong)x);
var pTypes = MapVATR<ulong>(pMetadataRegistration.types, pMetadataRegistration.typesCount);
types = new Il2CppType[pMetadataRegistration.typesCount];
for (var i = 0; i < pMetadataRegistration.typesCount; ++i)
@ -183,28 +183,39 @@ namespace Il2CppDumper
return ReadClass<T>(MapVATR(addr));
}
public long GetFieldOffsetFromIndex(int typeIndex, int fieldIndexInType, int fieldIndex)
public int GetFieldOffsetFromIndex(int typeIndex, int fieldIndexInType, int fieldIndex)
{
if (isNew21)
try
{
var ptr = fieldOffsets[typeIndex];
if (ptr >= 0)
if (isNew21)
{
dynamic pos;
if (is32Bit)
pos = MapVATR((uint)ptr) + 4 * fieldIndexInType;
else
pos = MapVATR((ulong)ptr) + 4ul * (ulong)fieldIndexInType;
if ((long)pos <= BaseStream.Length - 4)
var ptr = fieldOffsets[typeIndex];
if (ptr > 0)
{
Position = pos;
if (is32Bit)
{
Position = MapVATR((uint)ptr) + 4 * fieldIndexInType;
}
else
{
Position = MapVATR(ptr) + 4ul * (ulong)fieldIndexInType;
}
return ReadInt32();
}
return -1;
else
{
return -1;
}
}
else
{
return (int)fieldOffsets[fieldIndex];
}
}
catch
{
return -1;
}
return fieldOffsets[fieldIndex];
}
public Il2CppType GetIl2CppType(ulong pointer)