Add fields to script export (PrivateImplementationDetails)

This commit is contained in:
LukeFZ
2023-11-29 19:59:48 +01:00
parent e6355bb1b4
commit 2d73e28cea
3 changed files with 445 additions and 413 deletions

View File

@@ -51,6 +51,8 @@ namespace Il2CppInspector.Model
// For il2cpp < 19, the key is the string literal ordinal instead of the address
public Dictionary<ulong, string> Strings { get; } = new Dictionary<ulong, string>();
public Dictionary<ulong, string> Fields { get; } = new Dictionary<ulong, string>();
public bool StringIndexesAreOrdinals => Package.Version < 19;
// The .NET type model for the application
@@ -243,6 +245,16 @@ namespace Il2CppInspector.Model
}
Methods[method].MethodInfoPtrAddress = address;
break;
case MetadataUsageType.FieldInfo:
if (usage.SourceIndex > TypeModel.Package.Metadata.FieldRefs.Length)
break;
var fieldRef = TypeModel.Package.FieldRefs[usage.SourceIndex];
var fieldType = TypeModel.GetMetadataUsageType(usage);
var field = fieldType.DeclaredFields.First(f => f.Index == fieldType.Definition.fieldStart + fieldRef.fieldIndex);
Fields.Add(usage.VirtualAddress, $"{fieldType.Name}.{field.Name}".ToCIdentifier());
break;
}
}