GUI: Create type models

This commit is contained in:
Katy Coe
2020-02-09 03:29:05 +01:00
parent c5999bb94f
commit 4129785e17
3 changed files with 17 additions and 13 deletions

View File

@@ -1,12 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows; using System.Windows;
using Il2CppInspector; using Il2CppInspector;
using Il2CppInspector.Reflection;
using Inspector = Il2CppInspector.Il2CppInspector; using Inspector = Il2CppInspector.Il2CppInspector;
namespace Il2CppInspectorGUI namespace Il2CppInspectorGUI
@@ -18,7 +17,7 @@ namespace Il2CppInspectorGUI
{ {
private Metadata metadata; private Metadata metadata;
public List<Inspector> Il2CppImages { get; } = new List<Inspector>(); public List<Il2CppModel> Il2CppModels { get; } = new List<Il2CppModel>();
public Exception LastException { get; private set; } public Exception LastException { get; private set; }
@@ -48,19 +47,22 @@ namespace Il2CppInspectorGUI
} }
// Multi-image binaries may contain more than one Il2Cpp image // Multi-image binaries may contain more than one Il2Cpp image
Il2CppImages.Clear(); Il2CppModels.Clear();
foreach (var image in stream.Images) { foreach (var image in stream.Images) {
// Architecture-agnostic load attempt // Architecture-agnostic load attempt
try { try {
// If we can't load the IL2CPP data here, it's probably packed or obfuscated; ignore it // If we can't load the IL2CPP data here, it's probably packed or obfuscated; ignore it
if (Il2CppBinary.Load(image, metadata.Version) is Il2CppBinary binary) { if (Il2CppBinary.Load(image, metadata.Version) is Il2CppBinary binary) {
Il2CppImages.Add(new Inspector(binary, metadata)); var inspector = new Inspector(binary, metadata);
// Build type model
Il2CppModels.Add(new Il2CppModel(inspector));
} }
} }
// Unsupported architecture; ignore it // Unsupported architecture; ignore it
catch (NotImplementedException) { } catch (NotImplementedException) { }
} }
if (!Il2CppImages.Any()) { if (!Il2CppModels.Any()) {
throw new InvalidOperationException("Could not auto-detect any IL2CPP binary images in the file. This may mean the binary file is packed, encrypted or obfuscated, that the file is not an IL2CPP image or that Il2CppInspector was not able to automatically find the required data. Please check the binary file in a disassembler to ensure that it is an unencrypted IL2CPP binary before submitting a bug report!"); throw new InvalidOperationException("Could not auto-detect any IL2CPP binary images in the file. This may mean the binary file is packed, encrypted or obfuscated, that the file is not an IL2CPP image or that Il2CppInspector was not able to automatically find the required data. Please check the binary file in a disassembler to ensure that it is an unencrypted IL2CPP binary before submitting a bug report!");
} }
return true; return true;

View File

@@ -74,9 +74,9 @@
<TextBlock> <TextBlock>
<TextBlock.Text> <TextBlock.Text>
<MultiBinding StringFormat="{}{2}-bit {1} ({0})"> <MultiBinding StringFormat="{}{2}-bit {1} ({0})">
<Binding Path="BinaryImage.Format"></Binding> <Binding Path="Package.BinaryImage.Format"></Binding>
<Binding Path="BinaryImage.Arch"></Binding> <Binding Path="Package.BinaryImage.Arch"></Binding>
<Binding Path="BinaryImage.Bits"></Binding> <Binding Path="Package.BinaryImage.Bits"></Binding>
</MultiBinding> </MultiBinding>
</TextBlock.Text> </TextBlock.Text>
</TextBlock> </TextBlock>
@@ -100,7 +100,7 @@
<Label DockPanel.Dock="Top" Foreground="{StaticResource WindowsBlue}" FontSize="18">Select image</Label> <Label DockPanel.Dock="Top" Foreground="{StaticResource WindowsBlue}" FontSize="18">Select image</Label>
<ListBox DockPanel.Dock="Top" Name="lstImages" ItemTemplate="{StaticResource ImageListTemplate}" Height="80"/> <ListBox DockPanel.Dock="Top" Name="lstImages" ItemTemplate="{StaticResource ImageListTemplate}" Height="80"/>
<Label DockPanel.Dock="Top" Foreground="{StaticResource WindowsBlue}" FontSize="18">Image information</Label> <Label DockPanel.Dock="Top" Foreground="{StaticResource WindowsBlue}" FontSize="18">Image information</Label>
<Grid DockPanel.Dock="Top" Name="gridImageDetails" DataContext="{Binding ElementName=lstImages, Path=SelectedItem}"> <Grid DockPanel.Dock="Top" Name="gridImageDetails" DataContext="{Binding ElementName=lstImages, Path=SelectedItem.Package}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition>
<RowDefinition Height="Auto"></RowDefinition> <RowDefinition Height="Auto"></RowDefinition>
@@ -154,7 +154,7 @@
<!-- Busy indicator --> <!-- Busy indicator -->
<Border Name="areaBusyIndicator" BorderThickness="1" CornerRadius="2" BorderBrush="Gray" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#F8F8F8" SnapsToDevicePixels="True" Visibility="Hidden"> <Border Name="areaBusyIndicator" BorderThickness="1" CornerRadius="2" BorderBrush="Gray" HorizontalAlignment="Center" VerticalAlignment="Center" Background="#F8F8F8" SnapsToDevicePixels="True" Visibility="Hidden">
<StackPanel Margin="60,40,60,40"> <StackPanel Margin="60,40,60,40">
<TextBlock Foreground="{StaticResource WindowsBlue}" FontSize="24">Getting things ready...</TextBlock> <TextBlock Name="txtBusyStatus" Foreground="{StaticResource WindowsBlue}" FontSize="24">Getting things ready...</TextBlock>
<Image gif:AnimationBehavior.SourceUri="Resources/pizza.gif" Width="100" Margin="0,20,0,0" RenderOptions.BitmapScalingMode="Fant" /> <Image gif:AnimationBehavior.SourceUri="Resources/pizza.gif" Width="100" Margin="0,20,0,0" RenderOptions.BitmapScalingMode="Fant" />
</StackPanel> </StackPanel>
</Border> </Border>

View File

@@ -40,6 +40,7 @@ namespace Il2CppInspectorGUI
}; };
if (openFileDialog.ShowDialog() == true) { if (openFileDialog.ShowDialog() == true) {
txtBusyStatus.Text = "Processing metadata...";
areaBusyIndicator.Visibility = Visibility.Visible; areaBusyIndicator.Visibility = Visibility.Visible;
btnSelectMetadataFile.Visibility = Visibility.Hidden; btnSelectMetadataFile.Visibility = Visibility.Hidden;
@@ -72,6 +73,7 @@ namespace Il2CppInspectorGUI
btnBack.IsEnabled = false; btnBack.IsEnabled = false;
if (openFileDialog.ShowDialog() == true) { if (openFileDialog.ShowDialog() == true) {
txtBusyStatus.Text = "Processing binary...";
areaBusyIndicator.Visibility = Visibility.Visible; areaBusyIndicator.Visibility = Visibility.Visible;
btnSelectBinaryFile.Visibility = Visibility.Hidden; btnSelectBinaryFile.Visibility = Visibility.Hidden;
@@ -81,12 +83,12 @@ namespace Il2CppInspectorGUI
areaBusyIndicator.Visibility = Visibility.Hidden; areaBusyIndicator.Visibility = Visibility.Hidden;
rectModalLightBoxBackground.Visibility = Visibility.Hidden; rectModalLightBoxBackground.Visibility = Visibility.Hidden;
lstImages.ItemsSource = app.Il2CppImages; lstImages.ItemsSource = app.Il2CppModels;
} }
else { else {
areaBusyIndicator.Visibility = Visibility.Hidden; areaBusyIndicator.Visibility = Visibility.Hidden;
btnSelectBinaryFile.Visibility = Visibility.Visible; btnSelectBinaryFile.Visibility = Visibility.Visible;
MessageBox.Show(this, app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); MessageBox.Show(this, "Something went wrong! " + app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
} }
} }