Skip to content

Commit

Permalink
修复错误的虚函数表
Browse files Browse the repository at this point in the history
  • Loading branch information
Perfare committed Feb 22, 2021
1 parent 25b5c22 commit be9f65d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
33 changes: 25 additions & 8 deletions Il2CppDumper/Outputs/StructGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,14 +618,21 @@ private void AddVTableMethod(StructInfo structInfo, Il2CppTypeDefinition typeDef
{
methodDef = metadata.methodDefs[index];
}
dic[methodDef.slot] = methodDef;
if (methodDef.slot != ushort.MaxValue)
{
dic[methodDef.slot] = methodDef;
}
}
foreach (var i in dic)
if (typeDef.vtable_count > 0)
{
var methodInfo = new StructVTableMethodInfo();
structInfo.VTableMethod.Add(methodInfo);
var methodDef = i.Value;
methodInfo.MethodName = $"_{methodDef.slot}_{FixName(metadata.GetStringFromIndex(methodDef.nameIndex))}";
structInfo.VTableMethod = new StructVTableMethodInfo[dic.Last().Key + 1];
foreach (var i in dic)
{
var methodInfo = new StructVTableMethodInfo();
structInfo.VTableMethod[i.Key] = methodInfo;
var methodDef = i.Value;
methodInfo.MethodName = $"{FixName(metadata.GetStringFromIndex(methodDef.nameIndex))}";
}
}
}

Expand Down Expand Up @@ -842,9 +849,19 @@ private string RecursionStructInfo(StructInfo info)
sb.Append("};\n");

sb.Append($"struct {info.TypeName}_VTable {{\n");
foreach (var method in info.VTableMethod)
for (int i = 0; i < info.VTableMethod.Length; i++)
{
sb.Append($"\tVirtualInvokeData {method.MethodName};\n");
sb.Append($"\tVirtualInvokeData _{i}_");
var method = info.VTableMethod[i];
if (method != null)
{
sb.Append(method.MethodName);
}
else
{
sb.Append("unknown");
}
sb.Append(";\n");
}
sb.Append("};\n");

Expand Down
5 changes: 3 additions & 2 deletions Il2CppDumper/Outputs/StructInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;

namespace Il2CppDumper
{
Expand All @@ -9,7 +10,7 @@ public class StructInfo
public string Parent;
public List<StructFieldInfo> Fields = new List<StructFieldInfo>();
public List<StructFieldInfo> StaticFields = new List<StructFieldInfo>();
public List<StructVTableMethodInfo> VTableMethod = new List<StructVTableMethodInfo>();
public StructVTableMethodInfo[] VTableMethod = Array.Empty<StructVTableMethodInfo>();
public List<StructRGCTXInfo> RGCTXs = new List<StructRGCTXInfo>();
}

Expand Down

0 comments on commit be9f65d

Please sign in to comment.