Add processing of v24+ modules and double-indirected method pointers
This commit is contained in:
@@ -14,6 +14,7 @@ namespace Il2CppInspector.Reflection {
|
||||
// IL2CPP-specific data
|
||||
public Il2CppReflector Model { get; }
|
||||
public Il2CppImageDefinition Definition { get; }
|
||||
public Il2CppCodeGenModule Module { get; }
|
||||
public int Index { get; }
|
||||
|
||||
// TODO: CustomAttributes
|
||||
@@ -41,6 +42,10 @@ namespace Il2CppInspector.Reflection {
|
||||
// TODO: Generate EntryPoint method from entryPointIndex
|
||||
}
|
||||
|
||||
// Find corresponding module (we'll need this for method pointers)
|
||||
if (Model.Package.Metadata.Version >= 24.1)
|
||||
Module = Model.Package.Binary.Modules[FullName];
|
||||
|
||||
// Generate types in DefinedTypes from typeStart to typeStart+typeCount-1
|
||||
for (var t = Definition.typeStart; t < Definition.typeStart + Definition.typeCount; t++)
|
||||
DefinedTypes.Add(new TypeInfo(Model.Package, t, this));
|
||||
|
||||
@@ -33,11 +33,26 @@ namespace Il2CppInspector.Reflection
|
||||
base(declaringType) {
|
||||
Definition = pkg.Metadata.Methods[methodIndex];
|
||||
Index = methodIndex;
|
||||
Name = pkg.Strings[Definition.nameIndex];
|
||||
|
||||
// Find method pointer
|
||||
if (Definition.methodIndex >= 0) {
|
||||
VirtualAddress = pkg.Binary.MethodPointers[Definition.methodIndex];
|
||||
|
||||
// Global method pointer array
|
||||
if (pkg.Metadata.Version < 24.1) {
|
||||
VirtualAddress = pkg.Binary.MethodPointers[Definition.methodIndex];
|
||||
}
|
||||
|
||||
// Per-module method pointer array uses the bottom 24 bits of the method's metadata token
|
||||
// Derived from il2cpp::vm::MetadataCache::GetMethodPointer
|
||||
else {
|
||||
var method = (Definition.token & 0xffffff) - 1;
|
||||
pkg.Binary.Image.Position = pkg.Binary.Image.MapVATR(Assembly.Module.methodPointers + method * 4);
|
||||
VirtualAddress = pkg.Binary.Image.ReadUInt32();
|
||||
}
|
||||
|
||||
HasBody = true;
|
||||
}
|
||||
Name = pkg.Strings[Definition.nameIndex];
|
||||
|
||||
if ((Definition.flags & Il2CppConstants.METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == Il2CppConstants.METHOD_ATTRIBUTE_PRIVATE)
|
||||
Attributes |= MethodAttributes.Private;
|
||||
|
||||
Reference in New Issue
Block a user