diff --git a/Il2CppDumper/Il2CppDumper.cs b/Il2CppDumper/Il2CppDumper.cs index e87bcb9..0d74b9a 100644 --- a/Il2CppDumper/Il2CppDumper.cs +++ b/Il2CppDumper/Il2CppDumper.cs @@ -36,7 +36,11 @@ namespace Il2CppInspector writer.Write("interface "); else writer.Write("class "); - writer.Write($"{type.Name} // TypeDefIndex: {type.Index}\n{{\n"); + + var baseText = type.BaseType?.CSharpName ?? "object"; + baseText = baseText == "object" ? string.Empty : " : " + baseText; + + writer.Write($"{type.Name}{baseText} // TypeDefIndex: {type.Index}\n{{\n"); if (type.DeclaredFields.Count > 0) writer.Write("\t// Fields\n"); @@ -56,6 +60,8 @@ namespace Il2CppInspector writer.Write($" = {field.DefaultValueString}"); writer.Write("; // 0x{0:X}\n", field.Offset); } + if (type.DeclaredFields.Count > 0) + writer.Write("\n"); if (type.DeclaredMethods.Count > 0) writer.Write("\t// Methods\n"); diff --git a/Il2CppInspector/Reflection/TypeInfo.cs b/Il2CppInspector/Reflection/TypeInfo.cs index ce0f1ba..755a141 100644 --- a/Il2CppInspector/Reflection/TypeInfo.cs +++ b/Il2CppInspector/Reflection/TypeInfo.cs @@ -21,7 +21,8 @@ namespace Il2CppInspector.Reflection { public TypeAttributes Attributes { get; } // Type that this type inherits from - public TypeInfo BaseType => throw new NotImplementedException(); + private Il2CppType baseType; + public TypeInfo BaseType => baseType != null? Assembly.Model.GetType(baseType, MemberTypes.TypeInfo) : null; // True if the type contains unresolved generic type parameters public bool ContainsGenericParameters { get; } @@ -121,6 +122,9 @@ namespace Il2CppInspector.Reflection { Namespace = pkg.Strings[Definition.namespaceIndex]; Name = pkg.Strings[pkg.TypeDefinitions[typeIndex].nameIndex]; + if (Definition.parentIndex >= 0) + baseType = pkg.TypeUsages[Definition.parentIndex]; + if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_SERIALIZABLE) != 0) Attributes |= TypeAttributes.Serializable; if ((Definition.flags & Il2CppConstants.TYPE_ATTRIBUTE_VISIBILITY_MASK) == Il2CppConstants.TYPE_ATTRIBUTE_PUBLIC)