Add fields to script export (PrivateImplementationDetails)
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace Il2CppInspector.Outputs
|
||||
writeApis();
|
||||
writeExports();
|
||||
writeSymbols();
|
||||
writeFields();
|
||||
},
|
||||
"Address map of methods, internal functions, type pointers and string literals in the binary file"
|
||||
);
|
||||
@@ -215,6 +216,20 @@ namespace Il2CppInspector.Outputs
|
||||
}, "Symbol table");
|
||||
}
|
||||
|
||||
private void writeFields()
|
||||
{
|
||||
writeArray("fields", () =>
|
||||
{
|
||||
foreach (var field in model.Fields)
|
||||
{
|
||||
writeObject(() =>
|
||||
{
|
||||
writeName(field.Key, field.Value);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// JSON helpers
|
||||
private void writeObject(Action objectWriter) => writeObject(null, objectWriter);
|
||||
|
||||
|
||||
@@ -95,6 +95,11 @@ def ProcessJSON(jsonData):
|
||||
for d in jsonData['methodInfoPointers']:
|
||||
DefineILMethodInfo(d)
|
||||
|
||||
# FieldInfo
|
||||
print('Processing FieldInfo pointers')
|
||||
for d in jsonData['fields']:
|
||||
DefineField(d['virtualAddress'], d['name'], r"uint64_t")
|
||||
|
||||
# Function boundaries
|
||||
print('Processing function boundaries')
|
||||
functionAddresses = jsonData['functionAddresses']
|
||||
|
||||
Reference in New Issue
Block a user