Model/C#: Provide FieldHasRVA flag; output metadata preview for static array initializer implementations (#59)
This commit is contained in:
@@ -399,7 +399,14 @@ namespace Il2CppInspector.Outputs
|
||||
sb.Append($" // 0x{(uint) field.Offset:X2}");
|
||||
// Output metadata file offset for const fields
|
||||
if (field.IsLiteral && !SuppressMetadata)
|
||||
sb.Append($" // Metadata: 0x{(uint) field.DefaultValueMetadataAddress:X8}");
|
||||
sb.Append($" // Metadata: {field.DefaultValueMetadataAddress.ToAddressString()}");
|
||||
// For static array initializers, output metadata address and preview
|
||||
if (field.HasFieldRVA && !SuppressMetadata) {
|
||||
var preview = model.Package.Metadata.ReadBytes((long) field.DefaultValueMetadataAddress, 8);
|
||||
var previewText = string.Join(" ", preview.Select(b => $"{b:x2}"));
|
||||
|
||||
sb.Append($" // Starts with: {previewText} - Metadata: {field.DefaultValueMetadataAddress.ToAddressString()}");
|
||||
}
|
||||
sb.Append("\n");
|
||||
}
|
||||
codeBlocks.Add("Fields", sb.ToString());
|
||||
|
||||
@@ -25,7 +25,8 @@ namespace Il2CppInspector.Reflection {
|
||||
private readonly long rawOffset;
|
||||
public long Offset => DeclaringType.ContainsGenericParameters? 0 :
|
||||
rawOffset - (DeclaringType.IsValueType && !IsStatic? (Assembly.Model.Package.BinaryImage.Bits / 8) * 2 : 0);
|
||||
|
||||
|
||||
public bool HasFieldRVA => (Attributes & FieldAttributes.HasFieldRVA) != 0;
|
||||
public ulong DefaultValueMetadataAddress { get; }
|
||||
|
||||
// Custom attributes for this member
|
||||
@@ -126,6 +127,8 @@ namespace Il2CppInspector.Reflection {
|
||||
Attributes |= FieldAttributes.PinvokeImpl;
|
||||
if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_HAS_DEFAULT) != 0)
|
||||
Attributes |= FieldAttributes.HasDefault;
|
||||
if ((fieldType.attrs & Il2CppConstants.FIELD_ATTRIBUTE_HAS_FIELD_RVA) != 0)
|
||||
Attributes |= FieldAttributes.HasFieldRVA;
|
||||
|
||||
// Default initialization value if present
|
||||
if (pkg.FieldDefaultValue.TryGetValue(fieldIndex, out (ulong address, object variant) value)) {
|
||||
|
||||
Reference in New Issue
Block a user