Add header files for every known Unity version.

We want to get types into the IDA output, and to do that we need
accurate types for the Il2Cpp structures. Unfortunately, some crucial
types like Il2CppClass change between versions without any corresponding
metadata changes, meaning that we have to manually identify the version
outside of the Inspector somehow (e.g. by looking at the version number
embedded in Unity asset files). This patch adds header files for *every*
known Unity version from 5.3.0 to 2019.3.8, merging them into version
ranges where header files don't change.

It also adds front-end support for supplying the version number in both
the CLI and GUI. The GUI is given the ability to guess the version
number approximately to reduce the number of choices presented to the
user.
This commit is contained in:
Robert Xiao
2020-04-14 02:09:39 -07:00
committed by Katy
parent b87d82fd11
commit 34f0d4ceef
32 changed files with 27176 additions and 9 deletions

View File

@@ -28,6 +28,7 @@ using Il2CppInspector.Outputs;
using Il2CppInspector.Reflection;
using Ookii.Dialogs.Wpf;
using Path = System.IO.Path;
using Il2CppInspector.Outputs.UnityHeaders;
namespace Il2CppInspectorGUI
{
@@ -167,13 +168,13 @@ namespace Il2CppInspectorGUI
/// </summary>
private void LstImages_OnSelectionChanged(object sender, SelectionChangedEventArgs e) {
// Selection has been removed?
if (((ListBox) sender).SelectedItem == null) {
if (((ListBox)sender).SelectedItem == null) {
trvNamespaces.ItemsSource = null;
return;
}
// Get selected image
var model = (Il2CppModel) ((ListBox) sender).SelectedItem;
var model = (Il2CppModel)((ListBox)sender).SelectedItem;
// Get namespaces
var namespaces = model.Assemblies.SelectMany(x => x.DefinedTypes).GroupBy(t => t.Namespace).Select(n => n.Key);
@@ -196,6 +197,14 @@ namespace Il2CppInspectorGUI
// Populate TreeView with namespace hierarchy
trvNamespaces.ItemsSource = namespaceTree;
var prevSelection = cboUnityVersion.SelectedItem;
cboUnityVersion.Items.Clear();
foreach (var version in UnityHeader.GuessHeadersForModel(model))
cboUnityVersion.Items.Add(version);
cboUnityVersion.SelectedIndex = 0;
if (prevSelection != null)
cboUnityVersion.SelectedItem = prevSelection;
}
private IEnumerable<CheckboxNode> deconstructNamespaces(IEnumerable<string> input) {
@@ -388,9 +397,11 @@ namespace Il2CppInspectorGUI
txtBusyStatus.Text = "Generating IDAPython script...";
areaBusyIndicator.Visibility = Visibility.Visible;
var selectedVersion = ((UnityHeader)cboUnityVersion.SelectedItem)?.MinVersion;
await Task.Run(() => {
var idaWriter = new IDAPythonScript(model);
var idaWriter = new IDAPythonScript(model) {
UnityVersion = selectedVersion,
};
idaWriter.WriteScriptToFile(outFile);
});
break;