Model: Groundwork for custom attribute processisng
This commit is contained in:
@@ -31,8 +31,6 @@ namespace Il2CppInspector.Reflection
|
||||
// List of all methods ordered by their MethodDefinitionIndex
|
||||
public MethodBase[] MethodsByDefinitionIndex { get; }
|
||||
|
||||
// List of all types
|
||||
|
||||
public Il2CppModel(Il2CppInspector package) {
|
||||
Package = package;
|
||||
TypesByDefinitionIndex = new TypeInfo[package.TypeDefinitions.Length];
|
||||
@@ -108,5 +106,19 @@ namespace Il2CppInspector.Reflection
|
||||
TypesByVirtualAddress.Add(ptr, newUsage);
|
||||
return newUsage;
|
||||
}
|
||||
|
||||
// Attribute management
|
||||
private int getCustomAttributeIndex(Assembly asm, uint token, int customAttributeIndex) {
|
||||
var image = asm.Definition;
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int GetCustomAttributeIndex(Assembly asm) => getCustomAttributeIndex(asm, asm.Definition.token, -1);
|
||||
public int GetCustomAttributeIndex(EventInfo evt) => getCustomAttributeIndex(evt.Assembly, evt.Definition.token, evt.Definition.customAttributeIndex);
|
||||
public int GetCustomAttributeIndex(FieldInfo field) => getCustomAttributeIndex(field.Assembly, field.Definition.token, field.Definition.customAttributeIndex);
|
||||
public int GetCustomAttributeIndex(MethodBase method) => getCustomAttributeIndex(method.Assembly, method.Definition.token, method.Definition.customAttributeIndex);
|
||||
public int GetCustomAttributeIndex(ParameterInfo param) => getCustomAttributeIndex(param.Member.Assembly, param.Definition.token, param.Definition.customAttributeIndex);
|
||||
public int GetCustomAttributeIndex(PropertyInfo prop) => getCustomAttributeIndex(prop.Assembly, prop.Definition.token, prop.Definition.customAttributeIndex);
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,11 @@ namespace Il2CppInspector
|
||||
public Il2CppEventDefinition[] Events { get; }
|
||||
public Il2CppGenericContainer[] GenericContainers { get; }
|
||||
public Il2CppGenericParameter[] GenericParameters { get; }
|
||||
public Il2CppCustomAttributeTypeRange[] AttributeTypeRanges { get; }
|
||||
|
||||
public int[] InterfaceUsageIndices { get; }
|
||||
public int[] NestedTypeIndices { get; }
|
||||
public int[] AttributeRangeIndices { get; }
|
||||
|
||||
public Dictionary<int, string> Strings { get; } = new Dictionary<int, string>();
|
||||
|
||||
@@ -102,7 +104,12 @@ namespace Il2CppInspector
|
||||
NestedTypeIndices = ReadArray<int>(Header.nestedTypesOffset, Header.nestedTypesCount / sizeof(int));
|
||||
GenericContainers = ReadArray<Il2CppGenericContainer>(Header.genericContainersOffset, Header.genericContainersCount / Sizeof(typeof(Il2CppGenericContainer)));
|
||||
GenericParameters = ReadArray<Il2CppGenericParameter>(Header.genericParametersOffset, Header.genericParametersCount / Sizeof(typeof(Il2CppGenericParameter)));
|
||||
// TODO: ParameterDefaultValue, ParameterConstraints, MetadataUsage, CustomAttributes
|
||||
|
||||
if (Version >= 21) {
|
||||
AttributeRangeIndices = ReadArray<int>(Header.attributeTypesOffset, Header.attributeTypesCount / sizeof(int));
|
||||
AttributeTypeRanges = ReadArray<Il2CppCustomAttributeTypeRange>(Header.attributesInfoOffset, Header.attributesInfoCount / Sizeof(typeof(Il2CppCustomAttributeTypeRange)));
|
||||
}
|
||||
// TODO: ParameterDefaultValue, ParameterConstraints, MetadataUsage
|
||||
|
||||
// Get all string literals
|
||||
Position = Header.stringOffset;
|
||||
|
||||
@@ -322,4 +322,13 @@ namespace Il2CppInspector
|
||||
public ushort num;
|
||||
public ushort flags;
|
||||
}
|
||||
|
||||
public class Il2CppCustomAttributeTypeRange
|
||||
{
|
||||
[Version(Min = 24.1)]
|
||||
public uint token;
|
||||
|
||||
public int start;
|
||||
public int count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
|
||||
namespace Il2CppInspector.Reflection
|
||||
{
|
||||
// See: https://docs.microsoft.com/en-us/dotnet/api/system.reflection.customattributedata?view=netframework-4.8
|
||||
|
||||
public class CustomAttributeData
|
||||
{
|
||||
// TODO
|
||||
// TODO: CustomAttributeData
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user