Inspector: Make custom attribute constructor pointers available
This commit is contained in:
@@ -34,6 +34,9 @@ namespace Il2CppInspector
|
|||||||
// Pointers to field offsets
|
// Pointers to field offsets
|
||||||
public long[] FieldOffsetPointers { get; private set; }
|
public long[] FieldOffsetPointers { get; private set; }
|
||||||
|
|
||||||
|
// Generated functions which call constructors on custom attributes
|
||||||
|
public long[] CustomAttributeGenerators { get; private set; }
|
||||||
|
|
||||||
// Every defined type
|
// Every defined type
|
||||||
public List<Il2CppType> Types { get; private set; }
|
public List<Il2CppType> Types { get; private set; }
|
||||||
|
|
||||||
@@ -176,6 +179,9 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
// Type definitions (pointer array)
|
// Type definitions (pointer array)
|
||||||
Types = image.ReadMappedObjectPointerArray<Il2CppType>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount);
|
Types = image.ReadMappedObjectPointerArray<Il2CppType>(MetadataRegistration.ptypes, (int) MetadataRegistration.typesCount);
|
||||||
|
|
||||||
|
// Custom attribute constructors
|
||||||
|
CustomAttributeGenerators = Image.ReadMappedWordArray(CodeRegistration.customAttributeGenerators, (int) CodeRegistration.customAttributeCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace Il2CppInspector
|
|||||||
public List<long> FieldOffsets { get; }
|
public List<long> FieldOffsets { get; }
|
||||||
public List<Il2CppType> TypeUsages => Binary.Types;
|
public List<Il2CppType> TypeUsages => Binary.Types;
|
||||||
public Dictionary<string, Il2CppCodeGenModule> Modules => Binary.Modules;
|
public Dictionary<string, Il2CppCodeGenModule> Modules => Binary.Modules;
|
||||||
|
public long[] CustomAttributeGenerators => Binary.CustomAttributeGenerators;
|
||||||
|
|
||||||
// TODO: Finish all file access in the constructor and eliminate the need for this
|
// TODO: Finish all file access in the constructor and eliminate the need for this
|
||||||
public IFileFormatReader BinaryImage => Binary.Image;
|
public IFileFormatReader BinaryImage => Binary.Image;
|
||||||
|
|||||||
@@ -12,10 +12,14 @@ namespace Il2CppInspector.Reflection
|
|||||||
// See: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.customattributedata?view=netframework-4.8
|
// See: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.customattributedata?view=netframework-4.8
|
||||||
public class CustomAttributeData
|
public class CustomAttributeData
|
||||||
{
|
{
|
||||||
|
// IL2CPP-specific data
|
||||||
|
private Il2CppInspector package => AttributeType.Assembly.Model.Package;
|
||||||
|
public int Index { get; set; }
|
||||||
|
|
||||||
// The type of the attribute
|
// The type of the attribute
|
||||||
public TypeInfo AttributeType { get; set; }
|
public TypeInfo AttributeType { get; set; }
|
||||||
|
|
||||||
// TODO Constructor, ConstructorArguments, NamedArguments
|
public long VirtualAddress => package.CustomAttributeGenerators[Index];
|
||||||
|
|
||||||
public override string ToString() => "[" + AttributeType.FullName + "]";
|
public override string ToString() => "[" + AttributeType.FullName + "]";
|
||||||
|
|
||||||
@@ -33,7 +37,7 @@ namespace Il2CppInspector.Reflection
|
|||||||
var range = pkg.AttributeTypeRanges[customAttributeIndex];
|
var range = pkg.AttributeTypeRanges[customAttributeIndex];
|
||||||
for (var i = range.start; i < range.start + range.count; i++) {
|
for (var i = range.start; i < range.start + range.count; i++) {
|
||||||
var typeIndex = pkg.AttributeTypeIndices[i];
|
var typeIndex = pkg.AttributeTypeIndices[i];
|
||||||
yield return new CustomAttributeData { AttributeType = asm.Model.GetTypeFromUsage(typeIndex) };
|
yield return new CustomAttributeData { Index = customAttributeIndex, AttributeType = asm.Model.GetTypeFromUsage(typeIndex) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user