GUI: Support split APKs

This commit is contained in:
Katy Coe
2020-09-12 13:56:23 +02:00
parent 49ec360f29
commit e384ec226e
3 changed files with 16 additions and 11 deletions

View File

@@ -31,14 +31,13 @@ namespace Il2CppInspectorGUI
private void StatusUpdate(object sender, string status) => OnStatusUpdate?.Invoke(sender, status);
// 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 {
OnStatusUpdate?.Invoke(this, "Extracting package");
// TODO: Accept multiple APKs
var streams = Inspector.GetStreamsFromPackage(new string[] { packageFile });
var streams = Inspector.GetStreamsFromPackage(packageFiles);
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);
}

View File

@@ -451,7 +451,7 @@
<TextBlock TextAlignment="Center">
<TextBlock FontSize="22">Option 2</TextBlock>
<LineBreak/>
<TextBlock>Select or drag &amp; drop an APK or IPA file</TextBlock>
<TextBlock>Select or drag &amp; drop one or more APK files or an IPA file</TextBlock>
<LineBreak/>
<TextBlock FontSize="16">Encrypted IPA files are not supported</TextBlock>
</TextBlock>

View File

@@ -137,28 +137,30 @@ namespace Il2CppInspectorGUI
}
/// <summary>
/// Select APK or IPA package file
/// Select APK or IPA package files
/// </summary>
private async void BtnSelectPackageFile_OnClick(object sender, RoutedEventArgs e) {
var openFileDialog = new OpenFileDialog {
Filter = "Android/iOS Application Package (*.apk;*.ipa;*.zip)|*.apk;*.ipa;*.zip|All files (*.*)|*.*",
CheckFileExists = true
CheckFileExists = true,
Multiselect = true
};
if (openFileDialog.ShowDialog() == true) {
await LoadPackageAsync(openFileDialog.FileName);
await LoadPackageAsync(openFileDialog.FileNames);
}
}
// 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;
areaBusyIndicator.Visibility = Visibility.Visible;
grdFirstPage.Visibility = Visibility.Hidden;
// Load the package
if (await app.LoadPackageAsync(filename)) {
if (await app.LoadPackageAsync(filenames)) {
// Package loaded successfully
areaBusyIndicator.Visibility = Visibility.Hidden;
@@ -556,7 +558,7 @@ namespace Il2CppInspectorGUI
}
}
// 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 binaryIndex = 1 - metadataIndex;
@@ -566,6 +568,10 @@ namespace Il2CppInspectorGUI
if (btnSelectBinaryFile.Visibility == Visibility.Visible)
await LoadBinaryAsync(files[binaryIndex]);
}
// Split APK (files.Length >= 2)
else {
await LoadPackageAsync(files);
}
}
// Binary (on 2nd page)
else if (btnSelectBinaryFile.Visibility == Visibility.Visible)