GUI: Support split APKs
This commit is contained in:
@@ -31,14 +31,13 @@ namespace Il2CppInspectorGUI
|
|||||||
private void StatusUpdate(object sender, string status) => OnStatusUpdate?.Invoke(sender, status);
|
private void StatusUpdate(object sender, string status) => OnStatusUpdate?.Invoke(sender, status);
|
||||||
|
|
||||||
// Attempt to load an IL2CPP application package (APK or IPA)
|
// Attempt to load an IL2CPP application package (APK or IPA)
|
||||||
public async Task<bool> LoadPackageAsync(string packageFile) {
|
public async Task<bool> LoadPackageAsync(IEnumerable<string> packageFiles) {
|
||||||
try {
|
try {
|
||||||
OnStatusUpdate?.Invoke(this, "Extracting package");
|
OnStatusUpdate?.Invoke(this, "Extracting package");
|
||||||
|
|
||||||
// TODO: Accept multiple APKs
|
var streams = Inspector.GetStreamsFromPackage(packageFiles);
|
||||||
var streams = Inspector.GetStreamsFromPackage(new string[] { packageFile });
|
|
||||||
if (streams == null)
|
if (streams == null)
|
||||||
throw new InvalidOperationException("The supplied package is not an APK or IPA file, or does not contain an IL2CPP application");
|
throw new InvalidOperationException("The supplied package is not an APK or IPA file, or does not contain a complete IL2CPP application");
|
||||||
|
|
||||||
return await LoadMetadataAsync(streams.Value.Metadata) && await LoadBinaryAsync(streams.Value.Binary);
|
return await LoadMetadataAsync(streams.Value.Metadata) && await LoadBinaryAsync(streams.Value.Binary);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -451,7 +451,7 @@
|
|||||||
<TextBlock TextAlignment="Center">
|
<TextBlock TextAlignment="Center">
|
||||||
<TextBlock FontSize="22">Option 2</TextBlock>
|
<TextBlock FontSize="22">Option 2</TextBlock>
|
||||||
<LineBreak/>
|
<LineBreak/>
|
||||||
<TextBlock>Select or drag & drop an APK or IPA file</TextBlock>
|
<TextBlock>Select or drag & drop one or more APK files or an 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>
|
||||||
|
|||||||
@@ -137,28 +137,30 @@ namespace Il2CppInspectorGUI
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Select APK or IPA package file
|
/// Select APK or IPA package files
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async void BtnSelectPackageFile_OnClick(object sender, RoutedEventArgs e) {
|
private async void BtnSelectPackageFile_OnClick(object sender, RoutedEventArgs e) {
|
||||||
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,
|
||||||
|
Multiselect = true
|
||||||
};
|
};
|
||||||
|
|
||||||
if (openFileDialog.ShowDialog() == true) {
|
if (openFileDialog.ShowDialog() == true) {
|
||||||
await LoadPackageAsync(openFileDialog.FileName);
|
await LoadPackageAsync(openFileDialog.FileNames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load the package file
|
// Load the package file
|
||||||
private async Task LoadPackageAsync(string filename) {
|
private async Task LoadPackageAsync(string filename) => await LoadPackageAsync(new[] { filename });
|
||||||
|
private async Task LoadPackageAsync(IEnumerable<string> filenames) {
|
||||||
var app = (App) Application.Current;
|
var app = (App) Application.Current;
|
||||||
|
|
||||||
areaBusyIndicator.Visibility = Visibility.Visible;
|
areaBusyIndicator.Visibility = Visibility.Visible;
|
||||||
grdFirstPage.Visibility = Visibility.Hidden;
|
grdFirstPage.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
// Load the package
|
// Load the package
|
||||||
if (await app.LoadPackageAsync(filename)) {
|
if (await app.LoadPackageAsync(filenames)) {
|
||||||
// Package loaded successfully
|
// Package loaded successfully
|
||||||
areaBusyIndicator.Visibility = Visibility.Hidden;
|
areaBusyIndicator.Visibility = Visibility.Hidden;
|
||||||
|
|
||||||
@@ -556,7 +558,7 @@ namespace Il2CppInspectorGUI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Metadata and binary
|
// Metadata and binary
|
||||||
else if (files.Length == 2) {
|
else if (files.Length == 2 && (files[0].ToLower().EndsWith(".dat") || files[1].ToLower().EndsWith(".dat"))) {
|
||||||
var metadataIndex = files[0].ToLower().EndsWith(".dat") ? 0 : 1;
|
var metadataIndex = files[0].ToLower().EndsWith(".dat") ? 0 : 1;
|
||||||
var binaryIndex = 1 - metadataIndex;
|
var binaryIndex = 1 - metadataIndex;
|
||||||
|
|
||||||
@@ -566,6 +568,10 @@ namespace Il2CppInspectorGUI
|
|||||||
if (btnSelectBinaryFile.Visibility == Visibility.Visible)
|
if (btnSelectBinaryFile.Visibility == Visibility.Visible)
|
||||||
await LoadBinaryAsync(files[binaryIndex]);
|
await LoadBinaryAsync(files[binaryIndex]);
|
||||||
}
|
}
|
||||||
|
// Split APK (files.Length >= 2)
|
||||||
|
else {
|
||||||
|
await LoadPackageAsync(files);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Binary (on 2nd page)
|
// Binary (on 2nd page)
|
||||||
else if (btnSelectBinaryFile.Visibility == Visibility.Visible)
|
else if (btnSelectBinaryFile.Visibility == Visibility.Visible)
|
||||||
|
|||||||
Reference in New Issue
Block a user