GUI: Enable drag & drop for all file combinations
This commit is contained in:
@@ -8,7 +8,8 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="Il2CppInspector" Height="850" Width="1080" Background="White"
|
Title="Il2CppInspector" Height="850" Width="1080" Background="White"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
ContentRendered="MainWindow_OnContentRendered">
|
ContentRendered="MainWindow_OnContentRendered"
|
||||||
|
Drop="MainWindow_OnDrop">
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<!-- Our favourite colours -->
|
<!-- Our favourite colours -->
|
||||||
<SolidColorBrush x:Key="MicrosoftBlue" Color="#00A2ED"/>
|
<SolidColorBrush x:Key="MicrosoftBlue" Color="#00A2ED"/>
|
||||||
@@ -92,6 +93,20 @@
|
|||||||
</HierarchicalDataTemplate>
|
</HierarchicalDataTemplate>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
|
<!-- Enable/disable drag & drop dynamically -->
|
||||||
|
<Window.Style>
|
||||||
|
<Style TargetType="{x:Type Window}">
|
||||||
|
<Style.Triggers>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=grdFirstPage, Path=Visibility}" Value="Visible">
|
||||||
|
<Setter Property="AllowDrop" Value="True"/>
|
||||||
|
</DataTrigger>
|
||||||
|
<DataTrigger Binding="{Binding ElementName=btnSelectBinaryFile, Path=Visibility}" Value="Visible">
|
||||||
|
<Setter Property="AllowDrop" Value="True"/>
|
||||||
|
</DataTrigger>
|
||||||
|
</Style.Triggers>
|
||||||
|
</Style>
|
||||||
|
</Window.Style>
|
||||||
|
|
||||||
<!-- Window content -->
|
<!-- Window content -->
|
||||||
<Grid>
|
<Grid>
|
||||||
<!-- Main content -->
|
<!-- Main content -->
|
||||||
@@ -407,20 +422,22 @@
|
|||||||
<TextBlock TextAlignment="Center">
|
<TextBlock TextAlignment="Center">
|
||||||
<TextBlock FontSize="22">Option 1</TextBlock>
|
<TextBlock FontSize="22">Option 1</TextBlock>
|
||||||
<LineBreak/>
|
<LineBreak/>
|
||||||
<TextBlock>Select an IL2CPP metadata file</TextBlock>
|
<TextBlock>Select or drag & drop an IL2CPP metadata file</TextBlock>
|
||||||
|
<LineBreak/>
|
||||||
|
<TextBlock FontSize="16">You can drag & drop both the metadata and binary together</TextBlock>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</Button>
|
</Button>
|
||||||
<Button Grid.Row="1" Name="btnSelectPackageFile" Style="{StaticResource LightBoxButton}" Margin="100,50,100,100" Click="BtnSelectPackageFile_OnClick">
|
<Button Grid.Row="1" Name="btnSelectPackageFile" Style="{StaticResource LightBoxButton}" Margin="100,50,100,100" Click="BtnSelectPackageFile_OnClick">
|
||||||
<TextBlock TextAlignment="Center">
|
<TextBlock TextAlignment="Center">
|
||||||
<TextBlock FontSize="22">Option 2</TextBlock>
|
<TextBlock FontSize="22">Option 2</TextBlock>
|
||||||
<LineBreak/>
|
<LineBreak/>
|
||||||
<TextBlock>Select an APK or IPA file</TextBlock>
|
<TextBlock>Select or drag & drop an APK or IPA file</TextBlock>
|
||||||
<LineBreak/>
|
<LineBreak/>
|
||||||
<TextBlock FontSize="16">Encrypted IPA files are not supported</TextBlock>
|
<TextBlock FontSize="16">Encrypted IPA files are not supported</TextBlock>
|
||||||
</TextBlock>
|
</TextBlock>
|
||||||
</Button>
|
</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Button Name="btnSelectBinaryFile" Style="{StaticResource LightBoxButton}" Margin="100" Click="BtnSelectBinaryFile_OnClick" Visibility="Hidden">Select an IL2CPP binary file</Button>
|
<Button Name="btnSelectBinaryFile" Style="{StaticResource LightBoxButton}" Margin="100" Click="BtnSelectBinaryFile_OnClick" Visibility="Hidden">Select or drag & drop an IL2CPP binary file</Button>
|
||||||
|
|
||||||
<!-- Back button -->
|
<!-- Back button -->
|
||||||
<Button Name="btnBack" Margin="7" HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="18" Width="120" Click="BtnBack_OnClick" Content="<< Back">
|
<Button Name="btnBack" Margin="7" HorizontalAlignment="Left" VerticalAlignment="Bottom" FontSize="18" Width="120" Click="BtnBack_OnClick" Content="<< Back">
|
||||||
|
|||||||
@@ -67,28 +67,32 @@ namespace Il2CppInspectorGUI
|
|||||||
/// Select global metadata file
|
/// Select global metadata file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async void BtnSelectMetadataFile_OnClick(object sender, RoutedEventArgs e) {
|
private async void BtnSelectMetadataFile_OnClick(object sender, RoutedEventArgs e) {
|
||||||
var app = (App) Application.Current;
|
|
||||||
|
|
||||||
var openFileDialog = new OpenFileDialog {
|
var openFileDialog = new OpenFileDialog {
|
||||||
Filter = "IL2CPP global metadata file|global-metadata.dat|All files (*.*)|*.*",
|
Filter = "IL2CPP global metadata file|global-metadata.dat|All files (*.*)|*.*",
|
||||||
CheckFileExists = true
|
CheckFileExists = true
|
||||||
};
|
};
|
||||||
|
|
||||||
if (openFileDialog.ShowDialog() == true) {
|
if (openFileDialog.ShowDialog() == true) {
|
||||||
areaBusyIndicator.Visibility = Visibility.Visible;
|
await LoadMetadataAsync(openFileDialog.FileName);
|
||||||
grdFirstPage.Visibility = Visibility.Hidden;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Load the metadata file
|
// Load the metadata file
|
||||||
if (await app.LoadMetadataAsync(openFileDialog.FileName)) {
|
private async Task LoadMetadataAsync(string filename) {
|
||||||
// Metadata loaded successfully
|
var app = (App) Application.Current;
|
||||||
btnSelectBinaryFile.Visibility = Visibility.Visible;
|
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||||
}
|
grdFirstPage.Visibility = Visibility.Hidden;
|
||||||
else {
|
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
if (await app.LoadMetadataAsync(filename)) {
|
||||||
grdFirstPage.Visibility = Visibility.Visible;
|
// Metadata loaded successfully
|
||||||
MessageBox.Show(this, app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
btnSelectBinaryFile.Visibility = Visibility.Visible;
|
||||||
}
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
grdFirstPage.Visibility = Visibility.Visible;
|
||||||
|
MessageBox.Show(this, app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,31 +100,36 @@ namespace Il2CppInspectorGUI
|
|||||||
/// Select binary file
|
/// Select binary file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async void BtnSelectBinaryFile_OnClick(object sender, RoutedEventArgs e) {
|
private async void BtnSelectBinaryFile_OnClick(object sender, RoutedEventArgs e) {
|
||||||
var app = (App) Application.Current;
|
|
||||||
|
|
||||||
var openFileDialog = new OpenFileDialog {
|
var openFileDialog = new OpenFileDialog {
|
||||||
Filter = "Binary executable file (*.exe;*.dll;*.so;*.bin;*.prx;*.sprx)|*.exe;*.dll;*.so;*.bin;*.prx;*.sprx|All files (*.*)|*.*",
|
Filter = "Binary executable file (*.exe;*.dll;*.so;*.bin;*.prx;*.sprx)|*.exe;*.dll;*.so;*.bin;*.prx;*.sprx|All files (*.*)|*.*",
|
||||||
CheckFileExists = true
|
CheckFileExists = true
|
||||||
};
|
};
|
||||||
|
|
||||||
if (openFileDialog.ShowDialog() == true) {
|
if (openFileDialog.ShowDialog() == true) {
|
||||||
txtBusyStatus.Text = "Processing binary...";
|
await LoadBinaryAsync(openFileDialog.FileName);
|
||||||
areaBusyIndicator.Visibility = Visibility.Visible;
|
}
|
||||||
btnSelectBinaryFile.Visibility = Visibility.Hidden;
|
}
|
||||||
|
|
||||||
// Load the binary file
|
// Load the binary file
|
||||||
if (await app.LoadBinaryAsync(openFileDialog.FileName)) {
|
private async Task LoadBinaryAsync(string filename) {
|
||||||
// Binary loaded successfully
|
var app = (App) Application.Current;
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
|
||||||
|
|
||||||
lstImages.ItemsSource = app.AppModels;
|
txtBusyStatus.Text = "Processing binary...";
|
||||||
lstImages.SelectedIndex = 0;
|
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||||
}
|
btnSelectBinaryFile.Visibility = Visibility.Hidden;
|
||||||
else {
|
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
// Load the binary file
|
||||||
btnSelectBinaryFile.Visibility = Visibility.Visible;
|
if (await app.LoadBinaryAsync(filename)) {
|
||||||
MessageBox.Show(this, app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
// Binary loaded successfully
|
||||||
}
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
|
lstImages.ItemsSource = app.AppModels;
|
||||||
|
lstImages.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
btnSelectBinaryFile.Visibility = Visibility.Visible;
|
||||||
|
MessageBox.Show(this, app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,31 +137,36 @@ namespace Il2CppInspectorGUI
|
|||||||
/// Select APK or IPA package file
|
/// Select APK or IPA package file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async void BtnSelectPackageFile_OnClick(object sender, RoutedEventArgs e) {
|
private async void BtnSelectPackageFile_OnClick(object sender, RoutedEventArgs e) {
|
||||||
var app = (App) Application.Current;
|
|
||||||
|
|
||||||
var openFileDialog = new OpenFileDialog {
|
var openFileDialog = new OpenFileDialog {
|
||||||
Filter = "Android/iOS Application Package (*.apk;*.ipa;*.zip)|*.apk;*.ipa;*.zip|All files (*.*)|*.*",
|
Filter = "Android/iOS Application Package (*.apk;*.ipa;*.zip)|*.apk;*.ipa;*.zip|All files (*.*)|*.*",
|
||||||
CheckFileExists = true
|
CheckFileExists = true
|
||||||
};
|
};
|
||||||
|
|
||||||
if (openFileDialog.ShowDialog() == true) {
|
if (openFileDialog.ShowDialog() == true) {
|
||||||
txtBusyStatus.Text = "Extracting package...";
|
await LoadPackageAsync(openFileDialog.FileName);
|
||||||
areaBusyIndicator.Visibility = Visibility.Visible;
|
}
|
||||||
grdFirstPage.Visibility = Visibility.Hidden;
|
}
|
||||||
|
|
||||||
// Load the package
|
// Load the package file
|
||||||
if (await app.LoadPackageAsync(openFileDialog.FileName)) {
|
private async Task LoadPackageAsync(string filename) {
|
||||||
// Package loaded successfully
|
var app = (App) Application.Current;
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
|
||||||
|
|
||||||
lstImages.ItemsSource = app.AppModels;
|
txtBusyStatus.Text = "Extracting package...";
|
||||||
lstImages.SelectedIndex = 0;
|
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||||
}
|
grdFirstPage.Visibility = Visibility.Hidden;
|
||||||
else {
|
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
// Load the package
|
||||||
grdFirstPage.Visibility = Visibility.Visible;
|
if (await app.LoadPackageAsync(filename)) {
|
||||||
MessageBox.Show(this, app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
// Package loaded successfully
|
||||||
}
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
|
lstImages.ItemsSource = app.AppModels;
|
||||||
|
lstImages.SelectedIndex = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
grdFirstPage.Visibility = Visibility.Visible;
|
||||||
|
MessageBox.Show(this, app.LastException.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,6 +493,45 @@ namespace Il2CppInspectorGUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Surface to handle dropped files
|
||||||
|
/// </summary>
|
||||||
|
private async void MainWindow_OnDrop(object sender, DragEventArgs e) {
|
||||||
|
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
|
||||||
|
string[] files = (string[]) e.Data.GetData(DataFormats.FileDrop);
|
||||||
|
|
||||||
|
if (grdFirstPage.Visibility == Visibility.Visible) {
|
||||||
|
// Metadata or APK/IPA
|
||||||
|
if (files.Length == 1) {
|
||||||
|
switch (files[0].ToLower()) {
|
||||||
|
case var s when s.EndsWith(".dat"):
|
||||||
|
await LoadMetadataAsync(s);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case var s when s.EndsWith(".apk") || s.EndsWith(".ipa") || s.EndsWith(".zip"):
|
||||||
|
await LoadPackageAsync(s);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Metadata and binary
|
||||||
|
else if (files.Length == 2) {
|
||||||
|
var metadataIndex = files[0].ToLower().EndsWith(".dat") ? 0 : 1;
|
||||||
|
var binaryIndex = 1 - metadataIndex;
|
||||||
|
|
||||||
|
await LoadMetadataAsync(files[metadataIndex]);
|
||||||
|
|
||||||
|
// Only load binary if metadata was successful
|
||||||
|
if (btnSelectBinaryFile.Visibility == Visibility.Visible)
|
||||||
|
await LoadBinaryAsync(files[binaryIndex]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Binary (on 2nd page)
|
||||||
|
else if (btnSelectBinaryFile.Visibility == Visibility.Visible)
|
||||||
|
if (files.Length == 1)
|
||||||
|
await LoadBinaryAsync(files[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replacement for TreeViewItem that includes checkbox state
|
// Replacement for TreeViewItem that includes checkbox state
|
||||||
|
|||||||
Reference in New Issue
Block a user