AppModel: Wrap AddressMap TypeInfo/TypeRef/MethodInfo in AppReference
This commit is contained in:
@@ -22,6 +22,19 @@ namespace Il2CppInspector.Model
|
||||
public AppModel Model { get; }
|
||||
|
||||
// Underlying collection
|
||||
// Objects this can return (subject to change):
|
||||
// - AppMethod (for method function body)
|
||||
// - AppMethodReference (for MethodInfo *)
|
||||
// - List<CustomAttributeData> (for custom attributes generator)
|
||||
// - MethodInvoker (for a Method.Invoke think)
|
||||
// - string (System.String) (for a string literal)
|
||||
// - Il2CppCodeRegistration
|
||||
// - Il2CppMetadataRegistration
|
||||
// - Dictionary<string, ulong> (for Il2CppCodeGenModules *[])
|
||||
// - Il2CppCodeGenModule
|
||||
// - CppFnPtrType (for il2cpp_codegen_register, Il2CPP API exports, unknown functions)
|
||||
// - Export (for exports)
|
||||
// - Symbol (for symbols)
|
||||
public SortedDictionary<ulong, object> Items { get; } = new SortedDictionary<ulong, object>();
|
||||
|
||||
#region Surrogate implementation of IDictionary
|
||||
@@ -67,7 +80,11 @@ namespace Il2CppInspector.Model
|
||||
|
||||
// Method reference (MethodInfo *)
|
||||
if (method.HasMethodInfo)
|
||||
Add(method.MethodInfoPtrAddress, new CppField($"{method.CppFnPtrType.Name}__MethodInfo", methodInfoPtrType));
|
||||
Add(method.MethodInfoPtrAddress,
|
||||
new AppMethodReference {
|
||||
Field = new CppField($"{method.CppFnPtrType.Name}__MethodInfo", methodInfoPtrType),
|
||||
Method = method
|
||||
});
|
||||
}
|
||||
|
||||
// Add all custom attributes generators
|
||||
@@ -89,10 +106,16 @@ namespace Il2CppInspector.Model
|
||||
var classRefPtrType = cppTypes.GetType("Il2CppType *");
|
||||
foreach (var type in Model.Types.Values) {
|
||||
if (type.TypeClassAddress != 0xffffffff_ffffffff)
|
||||
Add(type.TypeClassAddress, new CppField($"{type.Name}__TypeInfo", classPtrType));
|
||||
Add(type.TypeClassAddress, new AppTypeReference {
|
||||
Field = new CppField($"{type.Name}__TypeInfo", classPtrType),
|
||||
Type = type
|
||||
});
|
||||
|
||||
if (type.TypeRefPtrAddress != 0xffffffff_ffffffff)
|
||||
Add(type.TypeRefPtrAddress, new CppField($"{type.Name}__TypeRef", classRefPtrType));
|
||||
Add(type.TypeRefPtrAddress, new AppTypeReference {
|
||||
Field = new CppField($"{type.Name}__TypeRef", classRefPtrType),
|
||||
Type = type
|
||||
});
|
||||
}
|
||||
|
||||
// Internal metadata
|
||||
|
||||
29
Il2CppInspector.Common/Model/AppReference.cs
Normal file
29
Il2CppInspector.Common/Model/AppReference.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
Copyright 2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
|
||||
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
using Il2CppInspector.Cpp;
|
||||
|
||||
namespace Il2CppInspector.Model
|
||||
{
|
||||
// Class that represents a single pointer in the address map which references a method or type
|
||||
public class AppReference
|
||||
{
|
||||
public CppField Field { get; set; }
|
||||
}
|
||||
|
||||
// Reference to a method (MethodInfo *)
|
||||
public class AppMethodReference : AppReference
|
||||
{
|
||||
public AppMethod Method { get; set; }
|
||||
}
|
||||
|
||||
// Reference to a type (Il2CppObject * or Il2CppType *, use Field to determine which)
|
||||
public class AppTypeReference : AppReference
|
||||
{
|
||||
// The corresponding C++ function pointer type
|
||||
public AppType Type { get; set; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user