Model: Re-implement the handling of Il2CppType

This commit is contained in:
Katy Coe
2019-10-31 17:40:33 +01:00
parent edbf9dc2fa
commit 3560661f9c
8 changed files with 85 additions and 46 deletions

View File

@@ -37,8 +37,8 @@ namespace Il2CppInspector.Reflection {
public FieldAttributes Attributes { get; }
// Type of field
private readonly Il2CppType fieldType;
public TypeInfo FieldType => Assembly.Model.GetType(fieldType, MemberTypes.Field);
private readonly int fieldTypeUsage;
public TypeInfo FieldType => Assembly.Model.GetTypeFromUsage(fieldTypeUsage, MemberTypes.Field);
// For the Is* definitions below, see:
// https://docs.microsoft.com/en-us/dotnet/api/system.reflection.fieldinfo.isfamilyandassembly?view=netframework-4.7.1#System_Reflection_FieldInfo_IsFamilyAndAssembly
@@ -88,7 +88,9 @@ namespace Il2CppInspector.Reflection {
Offset = pkg.FieldOffsets[fieldIndex];
Name = pkg.Strings[Definition.nameIndex];
fieldType = pkg.TypeUsages[Definition.typeIndex];
fieldTypeUsage = Definition.typeIndex;
var fieldType = pkg.TypeUsages[fieldTypeUsage];
if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == Il2CppConstants.FIELD_ATTRIBUTE_PRIVATE)
Attributes |= FieldAttributes.Private;
if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == Il2CppConstants.FIELD_ATTRIBUTE_PUBLIC)