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:
@@ -19,7 +19,7 @@ namespace Il2CppInspector
|
||||
public partial class FixedTests
|
||||
{
|
||||
[Test]
|
||||
public void TestCppTypes() {
|
||||
public void TestCppTypeDeclarations() {
|
||||
// NOTE: This test doesn't check for correct results, only that parsing doesn't fail!
|
||||
|
||||
var unityAllHeaders = UnityHeader.GetAllHeaders();
|
||||
@@ -30,16 +30,15 @@ namespace Il2CppInspector
|
||||
// Ensure we can interpret every header from every version of Unity without errors
|
||||
// This will throw InvalidOperationException if there is a problem
|
||||
foreach (var unityHeader in unityAllHeaders) {
|
||||
var cppTypes = CppTypes.FromUnityHeaders(unityHeader);
|
||||
|
||||
var cppTypes = CppTypeCollection.FromUnityHeaders(unityHeader);
|
||||
foreach (var cppType in cppTypes.Types)
|
||||
Debug.WriteLine("// " + cppType.Key + "\n" + cppType.Value.ToString("o") + "\n");
|
||||
Debug.WriteLine("// " + cppType.Key + "\n" + cppType.Value.ToString("o"));
|
||||
}
|
||||
|
||||
// Do a few sanity checks taken from real applications
|
||||
// NOTE: Does not provide full code coverage!
|
||||
|
||||
var cppTypes2 = CppTypes.FromUnityVersion(new UnityVersion("2019.3.1f1"), 64);
|
||||
var cppTypes2 = CppTypeCollection.FromUnityVersion(new UnityVersion("2019.3.1f1"), 64);
|
||||
|
||||
CppComplexType ct;
|
||||
CppField field;
|
||||
@@ -82,6 +81,39 @@ namespace Il2CppInspector
|
||||
field = fields["vtable"];
|
||||
|
||||
Assert.AreEqual(field.OffsetBytes, 0x128);
|
||||
|
||||
// Bitfield
|
||||
ct = (CppComplexType) cppTypes2["Il2CppType"];
|
||||
|
||||
field = ct.Fields[0xB * 8 + 7].First();
|
||||
|
||||
Assert.AreEqual(field.Name, "pinned");
|
||||
|
||||
// Nested fields
|
||||
ct = (CppComplexType) cppTypes2["Il2CppWin32Decimal"];
|
||||
fields = ct.Flattened;
|
||||
|
||||
field = fields[0x08].First();
|
||||
|
||||
Assert.AreEqual(field.Name, "lo32");
|
||||
|
||||
field = fields[0x08].Last();
|
||||
|
||||
Assert.AreEqual(field.Name, "lo64");
|
||||
|
||||
field = fields[0x0C].First();
|
||||
|
||||
Assert.AreEqual(field.Name, "mid32");
|
||||
|
||||
// Pointer alias
|
||||
var alias = (CppAlias) cppTypes2.GetType("Il2CppHString");
|
||||
|
||||
Assert.AreEqual(alias.ElementType.GetType(), typeof(CppPointerType));
|
||||
Assert.AreEqual(alias.ElementType.Name, "Il2CppHString__ *");
|
||||
|
||||
// Typedef struct with no tag
|
||||
Assert.True(cppTypes2.Types.ContainsKey("Il2CppGenericMethodIndices"));
|
||||
Assert.True(((CppComplexType)cppTypes2["Il2CppGenericMethodIndices"]).ComplexValueType == ComplexValueType.Struct);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019-2020 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
||||
Copyright 2019-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
|
||||
|
||||
All rights reserved.
|
||||
*/
|
||||
@@ -25,7 +25,7 @@ namespace Il2CppInspector
|
||||
|
||||
// Build model
|
||||
var inspectors = Il2CppInspector.LoadFromFile(testPath + @"\GenericTypes-ARMv7.so", testPath + @"\global-metadata.dat");
|
||||
var model = new Il2CppModel(inspectors[0]);
|
||||
var model = new TypeModel(inspectors[0]);
|
||||
|
||||
var asm = model.GetAssembly("GenericTypes.dll");
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright 2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com
|
||||
Copyright 2019 Katy Coe - http://www.djkaty.com - https://github.com/djkaty
|
||||
|
||||
All rights reserved.
|
||||
*/
|
||||
@@ -23,7 +23,7 @@ namespace Il2CppInspector
|
||||
|
||||
// Build model
|
||||
var inspectors = Il2CppInspector.LoadFromFile(testPath + @"\References-ARMv7.so", testPath + @"\global-metadata.dat");
|
||||
var model = new Il2CppModel(inspectors[0]);
|
||||
var model = new TypeModel(inspectors[0]);
|
||||
|
||||
var asm = model.GetAssembly("References.dll");
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Il2CppInspector.Reflection;
|
||||
using Il2CppInspector.Model;
|
||||
using Il2CppInspector.Outputs;
|
||||
using Il2CppInspector.Reflection;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Il2CppInspector
|
||||
@@ -20,6 +20,8 @@ namespace Il2CppInspector
|
||||
private void runTest(string testPath) {
|
||||
// Android
|
||||
var testFile = testPath + @"\" + Path.GetFileName(testPath) + ".so";
|
||||
if (!File.Exists(testFile))
|
||||
testFile = testPath + @"\libil2cpp.so";
|
||||
// Windows
|
||||
if (!File.Exists(testFile))
|
||||
testFile = testPath + @"\" + Path.GetFileName(testPath) + ".dll";
|
||||
@@ -28,9 +30,6 @@ namespace Il2CppInspector
|
||||
// iOS
|
||||
if (!File.Exists(testFile))
|
||||
testFile = testPath + @"\" + Path.GetFileName(testPath);
|
||||
// Android
|
||||
if (!File.Exists(testFile))
|
||||
testFile = testPath + @"\libil2cpp.so";
|
||||
|
||||
var inspectors = Il2CppInspector.LoadFromFile(testFile, testPath + @"\global-metadata.dat");
|
||||
|
||||
@@ -44,7 +43,8 @@ namespace Il2CppInspector
|
||||
// Dump each image in the binary separately
|
||||
int i = 0;
|
||||
foreach (var il2cpp in inspectors) {
|
||||
var model = new Il2CppModel(il2cpp);
|
||||
var model = new TypeModel(il2cpp);
|
||||
var appModel = new AppModel(model).Build();
|
||||
var nameSuffix = i++ > 0 ? "-" + (i - 1) : "";
|
||||
|
||||
new CSharpCodeStubs(model) {
|
||||
@@ -53,10 +53,10 @@ namespace Il2CppInspector
|
||||
MustCompile = true
|
||||
}.WriteSingleFile(testPath + $@"\test-result{nameSuffix}.cs");
|
||||
|
||||
new IDAPythonScript(model)
|
||||
new IDAPythonScript(appModel)
|
||||
.WriteScriptToFile(testPath + $@"\test-ida-result{nameSuffix}.py");
|
||||
|
||||
new CppScaffolding(model)
|
||||
new CppScaffolding(appModel)
|
||||
.WriteCppToFile(testPath + $@"\test-result{nameSuffix}.h");
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace Il2CppInspector
|
||||
var suffix = (i > 0 ? "-" + i : "");
|
||||
|
||||
compareFiles(testPath, suffix + ".cs", $"test-result{suffix}.cs");
|
||||
compareFiles(testPath, suffix + ".py", $"test-ida-result{suffix}.py");
|
||||
compareFiles(testPath, suffix + ".h", $"test-result{suffix}.h");
|
||||
compareFiles(testPath, suffix + ".py", $"test-ida-result{suffix}.py");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user