AppModel: First iteration of ApplicationModel API

Integrate with C++ scaffolding
Add new tests
Rename Il2CppModel to TypeModel
Incomplete IDAPython integration
CLI and GUI support
Update README.md
This commit is contained in:
Katy Coe
2020-07-09 03:48:50 +02:00
parent 9fff9678aa
commit 873a6c98f6
25 changed files with 809 additions and 588 deletions

View File

@@ -1,6 +1,5 @@
/*
Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
Copyright 2017-2019 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
All rights reserved.
*/
@@ -12,7 +11,7 @@ namespace Il2CppInspector.Reflection {
public class Assembly
{
// IL2CPP-specific data
public Il2CppModel Model { get; }
public TypeModel Model { get; }
public Il2CppImageDefinition ImageDefinition { get; }
public Il2CppAssemblyDefinition AssemblyDefinition { get; }
public Il2CppCodeGenModule ModuleDefinition { get; }
@@ -37,7 +36,7 @@ namespace Il2CppInspector.Reflection {
public TypeInfo GetType(string typeName) => DefinedTypes.FirstOrDefault(x => x.FullName == typeName);
// Initialize from specified assembly index in package
public Assembly(Il2CppModel model, int imageIndex) {
public Assembly(TypeModel model, int imageIndex) {
Model = model;
ImageDefinition = Model.Package.Images[imageIndex];
AssemblyDefinition = Model.Package.Assemblies[ImageDefinition.assemblyIndex];

View File

@@ -1,5 +1,5 @@
/*
Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
Copyright 2017-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
All rights reserved.
*/
@@ -15,7 +15,7 @@ namespace Il2CppInspector.Reflection
public class CustomAttributeData
{
// IL2CPP-specific data
public Il2CppModel Model => AttributeType.Assembly.Model;
public TypeModel Model => AttributeType.Assembly.Model;
public int Index { get; set; }
// The type of the attribute

View File

@@ -1,6 +1,5 @@
/*
Copyright 2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
Copyright 2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
All rights reserved.
*/
@@ -48,7 +47,7 @@ namespace Il2CppInspector.Reflection
}
// The invokers use Object for all reference types, and SByte for booleans
private TypeInfo mapParameterType(Il2CppModel model, TypeInfo type) => type switch {
private TypeInfo mapParameterType(TypeModel model, TypeInfo type) => type switch {
{ IsValueType: false } => model.TypesByFullName["System.Object"],
{ FullName: "System.Boolean" } => model.TypesByFullName["System.SByte"],
_ => type

View File

@@ -1,5 +1,5 @@
/*
Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
Copyright 2017-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
Copyright 2020 Robert Xiao - https://robertxiao.ca
All rights reserved.
@@ -12,7 +12,7 @@ using System.Linq;
namespace Il2CppInspector.Reflection
{
public class Il2CppModel
public class TypeModel
{
public Il2CppInspector Package { get; }
public List<Assembly> Assemblies { get; } = new List<Assembly>();
@@ -62,7 +62,7 @@ namespace Il2CppInspector.Reflection
&& m.GetGenericArguments().SequenceEqual(typeArguments));
// Create type model
public Il2CppModel(Il2CppInspector package) {
public TypeModel(Il2CppInspector package) {
Package = package;
TypesByDefinitionIndex = new TypeInfo[package.TypeDefinitions.Length];
TypesByReferenceIndex = new TypeInfo[package.TypeReferences.Count];

View File

@@ -1,5 +1,5 @@
/*
Copyright 2017-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
Copyright 2017-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
Copyright 2020 Robert Xiao - https://robertxiao.ca
All rights reserved.
@@ -11,7 +11,7 @@ namespace Il2CppInspector.Reflection
/// A class which lazily refers to a TypeInfo instance
/// </summary>
internal class TypeRef {
private Il2CppModel model;
private TypeModel model;
private int referenceIndex = -1;
private int definitionIndex = -1;
private TypeInfo typeInfo = null;
@@ -28,10 +28,10 @@ namespace Il2CppInspector.Reflection
}
}
public static TypeRef FromReferenceIndex(Il2CppModel model, int index)
public static TypeRef FromReferenceIndex(TypeModel model, int index)
=> new TypeRef { model = model, referenceIndex = index };
public static TypeRef FromDefinitionIndex(Il2CppModel model, int index)
public static TypeRef FromDefinitionIndex(TypeModel model, int index)
=> new TypeRef { model = model, definitionIndex = index };
public static TypeRef FromTypeInfo(TypeInfo type)