GUI: Load metadata file
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
<Application x:Class="App"
|
<Application x:Class="Il2CppInspectorGUI.App"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:local="clr-namespace:Il2CppInspector.GUI"
|
|
||||||
StartupUri="MainWindow.xaml">
|
StartupUri="MainWindow.xaml">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
||||||
|
|||||||
@@ -2,16 +2,34 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Configuration;
|
using System.Configuration;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
|
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;
|
||||||
|
|
||||||
namespace Il2CppInspector.GUI
|
namespace Il2CppInspectorGUI
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for App.xaml
|
/// Interaction logic for App.xaml
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
|
public Metadata CurrentMetadata { get; private set; }
|
||||||
|
|
||||||
|
public Exception LastException { get; private set; }
|
||||||
|
|
||||||
|
// Attempt to load an IL2CPP metadata file
|
||||||
|
public Task<bool> LoadMetadataAsync(string metadataFile) =>
|
||||||
|
Task.Run(() => {
|
||||||
|
try {
|
||||||
|
CurrentMetadata = new Metadata(new MemoryStream(File.ReadAllBytes(metadataFile)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex) {
|
||||||
|
LastException = ex;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<Window x:Class="Il2CppInspector.GUI.MainWindow"
|
<Window x:Class="Il2CppInspectorGUI.MainWindow"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:Il2CppInspector.GUI"
|
xmlns:local="clr-namespace:Il2CppInspectorGUI"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Il2CppInspector" Height="450" Width="800" Background="White">
|
Title="Il2CppInspector" Height="450" Width="800" Background="White">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
@@ -70,13 +70,26 @@
|
|||||||
<Grid>
|
<Grid>
|
||||||
<!-- Main content -->
|
<!-- Main content -->
|
||||||
<Grid>
|
<Grid>
|
||||||
<TextBlock>Content of window</TextBlock>
|
<!-- Information about the loaded metadata and binary -->
|
||||||
|
<Grid>
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height ="Auto" />
|
||||||
|
<RowDefinition Height ="Auto" />
|
||||||
|
<RowDefinition Height ="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Grid.ColumnDefinitions>
|
||||||
|
<ColumnDefinition Width="25*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="25*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="25*"></ColumnDefinition>
|
||||||
|
<ColumnDefinition Width="25*"></ColumnDefinition>
|
||||||
|
</Grid.ColumnDefinitions>
|
||||||
|
<Label Grid.Row="0" Grid.Column="0" Content="IL2CPP Metadata version"></Label>
|
||||||
|
<Label Name="lblMetadataVersion" Grid.Row="0" Grid.Column="1" Content="{Binding Path=Version}"></Label>
|
||||||
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- Light boxes -->
|
<!-- Light boxes -->
|
||||||
<Grid Name="areaLoadMetadata">
|
|
||||||
<Rectangle Name="rectModalLightBoxBackground" Fill="Black" Opacity="0.4"></Rectangle>
|
<Rectangle Name="rectModalLightBoxBackground" Fill="Black" Opacity="0.4"></Rectangle>
|
||||||
<Button Name="btnSelectMetadataFile" Style="{StaticResource LightBoxButton}" Click="BtnSelectMetadataFile_OnClick">Select an IL2CPP metadata file</Button>
|
<Button Name="btnSelectMetadataFile" Style="{StaticResource LightBoxButton}" Click="BtnSelectMetadataFile_OnClick">Select an IL2CPP metadata file</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -13,8 +15,9 @@ using System.Windows.Media.Imaging;
|
|||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
using Il2CppInspector;
|
||||||
|
|
||||||
namespace Il2CppInspector.GUI
|
namespace Il2CppInspectorGUI
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Interaction logic for MainWindow.xaml
|
/// Interaction logic for MainWindow.xaml
|
||||||
@@ -28,11 +31,26 @@ namespace Il2CppInspector.GUI
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Select global metadata file
|
/// Select global metadata file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void BtnSelectMetadataFile_OnClick(object sender, RoutedEventArgs e) {
|
private async void BtnSelectMetadataFile_OnClick(object sender, RoutedEventArgs e) {
|
||||||
var openFileDialog = new OpenFileDialog();
|
var app = (App) Application.Current;
|
||||||
openFileDialog.Filter = "IL2CPP global metadata file|global-metadata.dat|All files (*.*)|*.*";
|
|
||||||
|
var openFileDialog = new OpenFileDialog {
|
||||||
|
Filter = "IL2CPP global metadata file|global-metadata.dat|All files (*.*)|*.*",
|
||||||
|
CheckFileExists = true
|
||||||
|
};
|
||||||
|
|
||||||
|
btnSelectMetadataFile.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
if (openFileDialog.ShowDialog() == true) {
|
if (openFileDialog.ShowDialog() == true) {
|
||||||
// openFileDialog.FileName
|
// Load the metadata file
|
||||||
|
if (await app.LoadMetadataAsync(openFileDialog.FileName)) {
|
||||||
|
// Metadata loaded successfully
|
||||||
|
lblMetadataVersion.DataContext = app.CurrentMetadata;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox.Show(this, app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
|
btnSelectMetadataFile.Visibility = Visibility.Visible;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user