Implement and output TypeInfo.InterfaceUsageIndices

This commit is contained in:
Katy Coe
2017-11-09 14:24:37 +01:00
parent 3722705301
commit 35db6cabd6
3 changed files with 16 additions and 3 deletions

View File

@@ -23,6 +23,7 @@ namespace Il2CppInspector
public Il2CppParameterDefinition[] Params { get; }
public Il2CppFieldDefinition[] Fields { get; }
public Il2CppFieldDefaultValue[] FieldDefaultValues { get; }
public int[] InterfaceUsageIndices { get; }
public Dictionary<int, string> Strings { get; } = new Dictionary<int, string>();
@@ -51,7 +52,8 @@ namespace Il2CppInspector
Params = ReadArray<Il2CppParameterDefinition>(Header.parametersOffset, Header.parametersCount / Sizeof(typeof(Il2CppParameterDefinition)));
Fields = ReadArray<Il2CppFieldDefinition>(Header.fieldsOffset, Header.fieldsCount / Sizeof(typeof(Il2CppFieldDefinition)));
FieldDefaultValues = ReadArray<Il2CppFieldDefaultValue>(Header.fieldDefaultValuesOffset, Header.fieldDefaultValuesCount / Sizeof(typeof(Il2CppFieldDefaultValue)));
// TODO: Events, Properties, ParameterDefaultValue, GenericParameters, ParameterConstraints, GenericContainers, Interfaces, MetadataUsage, CustomAttributes
InterfaceUsageIndices = ReadArray<int>(Header.interfacesOffset, Header.interfacesCount / sizeof(int));
// TODO: Events, Properties, ParameterDefaultValue, GenericParameters, ParameterConstraints, GenericContainers, MetadataUsage, CustomAttributes
// Get all string literals
Position = Header.stringOffset;

View File

@@ -67,6 +67,10 @@ namespace Il2CppInspector.Reflection {
public List<TypeInfo> GenericTypeParameters { get; }
public bool HasElementType => ElementType != null;
private Il2CppType[] implementedInterfaces;
public IEnumerable<TypeInfo> ImplementedInterfaces => implementedInterfaces.Select(x => Assembly.Model.GetType(x, MemberTypes.TypeInfo));
public bool IsAbstract => (Attributes & TypeAttributes.Abstract) == TypeAttributes.Abstract;
public bool IsArray { get; }
public bool IsByRef => throw new NotImplementedException();
@@ -140,6 +144,11 @@ namespace Il2CppInspector.Reflection {
if (!IsInterface)
Attributes |= TypeAttributes.Class;
// Add all implemented interfaces
implementedInterfaces = new Il2CppType[Definition.interfaces_count];
for (var i = 0; i < Definition.interfaces_count; i++)
implementedInterfaces[i] = pkg.TypeUsages[pkg.Metadata.InterfaceUsageIndices[Definition.interfacesStart + i]];
// Add all fields
for (var f = Definition.fieldStart; f < Definition.fieldStart + Definition.field_count; f++)
DeclaredFields.Add(new FieldInfo(pkg, f, this));