Model: Ensure all TypeRefs are initialized with the model

Ensures that all types are output in the IDA Python script
Includes TypeRefs that aren't used in any type definition or member
This commit is contained in:
Katy Coe
2020-01-30 07:54:45 +01:00
parent a1e332620c
commit 37f1c49828
7 changed files with 96 additions and 92 deletions

View File

@@ -30,8 +30,8 @@ namespace Il2CppInspector.Reflection {
public FieldAttributes Attributes { get; }
// Type of field
private readonly int fieldTypeUsage;
public TypeInfo FieldType => Assembly.Model.GetTypeFromUsage(fieldTypeUsage, MemberTypes.Field);
private readonly int fieldTypeReference;
public TypeInfo FieldType => Assembly.Model.TypesByReferenceIndex[fieldTypeReference];
// 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
@@ -81,8 +81,8 @@ namespace Il2CppInspector.Reflection {
Offset = pkg.FieldOffsets[fieldIndex];
Name = pkg.Strings[Definition.nameIndex];
fieldTypeUsage = Definition.typeIndex;
var fieldType = pkg.TypeReferences[fieldTypeUsage];
fieldTypeReference = Definition.typeIndex;
var fieldType = pkg.TypeReferences[fieldTypeReference];
if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == Il2CppConstants.FIELD_ATTRIBUTE_PRIVATE)
Attributes |= FieldAttributes.Private;