diff --git a/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs b/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs index 399acf6..f30e5c8 100644 --- a/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/FileFormatReader.cs @@ -52,7 +52,7 @@ namespace Il2CppInspector U ReadObject() where U : new(); string ReadMappedNullTerminatedString(ulong uiAddr); List ReadMappedObjectPointerArray(ulong uiAddr, int count) where U : new(); - event EventHandler OnStatusUpdate; + EventHandler OnStatusUpdate { get; set; } } public class FileFormatReader @@ -99,7 +99,7 @@ namespace Il2CppInspector public virtual int Bits => throw new NotImplementedException(); - public event EventHandler OnStatusUpdate; + public EventHandler OnStatusUpdate { get; set; } protected void StatusUpdate(string status) => OnStatusUpdate?.Invoke(this, status); @@ -118,7 +118,9 @@ namespace Il2CppInspector public static T Load(Stream stream, EventHandler statusCallback = null) { // Copy the original stream in case we modify it var ms = new MemoryStream(); - stream.Position = 0; + + if (stream.CanSeek) + stream.Position = 0; stream.CopyTo(ms); ms.Position = 0; @@ -127,7 +129,7 @@ namespace Il2CppInspector } private bool InitImpl(EventHandler statusCallback = null) { - OnStatusUpdate += statusCallback; + OnStatusUpdate = statusCallback; return Init(); } diff --git a/Il2CppInspector.Common/FileFormatReaders/UBReader.cs b/Il2CppInspector.Common/FileFormatReaders/UBReader.cs index 58fe4b6..6c72034 100644 --- a/Il2CppInspector.Common/FileFormatReaders/UBReader.cs +++ b/Il2CppInspector.Common/FileFormatReaders/UBReader.cs @@ -1,5 +1,5 @@ /* - Copyright 2017-2019 Katy Coe - http://www.hearthcode.org - http://www.djkaty.com + Copyright 2017-2020 Katy Coe - http://www.djkaty.com - https://github.com/djkaty All rights reserved. */ @@ -39,7 +39,7 @@ namespace Il2CppInspector Endianness = Endianness.Little; using var s = new MemoryStream(ReadBytes((int) arch.Size)); - return (IFileFormatReader) MachOReader32.Load(s) ?? MachOReader64.Load(s); + return (IFileFormatReader) MachOReader32.Load(s, OnStatusUpdate) ?? MachOReader64.Load(s, OnStatusUpdate); } } } diff --git a/Il2CppInspector.GUI/App.xaml.cs b/Il2CppInspector.GUI/App.xaml.cs index 34fc8a8..d78ffda 100644 --- a/Il2CppInspector.GUI/App.xaml.cs +++ b/Il2CppInspector.GUI/App.xaml.cs @@ -33,6 +33,8 @@ namespace Il2CppInspectorGUI // Attempt to load an IL2CPP application package (APK or IPA) public async Task LoadPackageAsync(string packageFile) { try { + OnStatusUpdate?.Invoke(this, "Extracting package"); + var streams = Inspector.GetStreamsFromPackage(packageFile); if (streams == null) throw new InvalidOperationException("The supplied package is not an APK or IPA file, or does not contain an IL2CPP application"); @@ -55,6 +57,7 @@ namespace Il2CppInspectorGUI Task.Run(() => { try { OnStatusUpdate?.Invoke(this, "Processing metadata"); + metadata = new Metadata(metadataStream); return true; } @@ -73,19 +76,21 @@ namespace Il2CppInspectorGUI public Task LoadBinaryAsync(Stream binaryStream) => Task.Run(() => { try { + OnStatusUpdate?.Invoke(this, "Processing binary"); + // This may throw other exceptions from the individual loaders as well IFileFormatReader stream = FileFormatReader.Load(binaryStream, StatusUpdate); if (stream == null) { throw new InvalidOperationException("Could not determine the binary file format"); } - if (!stream.Images.Any()) { + if (stream.NumImages == 0) { throw new InvalidOperationException("Could not find any binary images in the file"); } // Multi-image binaries may contain more than one Il2Cpp image AppModels.Clear(); foreach (var image in stream.Images) { - OnStatusUpdate?.Invoke(this, "Analyzing IL2CPP data"); + OnStatusUpdate?.Invoke(this, $"Analyzing IL2CPP data for {image.Format}/{image.Arch} image"); // Architecture-agnostic load attempt try { @@ -94,7 +99,7 @@ namespace Il2CppInspectorGUI var inspector = new Inspector(binary, metadata); // Build type model - OnStatusUpdate?.Invoke(this, "Building .NET type model"); + OnStatusUpdate?.Invoke(this, $"Building .NET type model for {image.Format}/{image.Arch} image"); var typeModel = new TypeModel(inspector); // Initialize (but don't build) application model diff --git a/Il2CppInspector.GUI/MainWindow.xaml b/Il2CppInspector.GUI/MainWindow.xaml index a8e6a35..9590b2d 100644 --- a/Il2CppInspector.GUI/MainWindow.xaml +++ b/Il2CppInspector.GUI/MainWindow.xaml @@ -471,7 +471,7 @@ - + Getting things ready... diff --git a/Il2CppInspector.GUI/MainWindow.xaml.cs b/Il2CppInspector.GUI/MainWindow.xaml.cs index d4bb0d8..3afc91c 100644 --- a/Il2CppInspector.GUI/MainWindow.xaml.cs +++ b/Il2CppInspector.GUI/MainWindow.xaml.cs @@ -118,7 +118,6 @@ namespace Il2CppInspectorGUI private async Task LoadBinaryAsync(string filename) { var app = (App) Application.Current; - txtBusyStatus.Text = "Processing binary..."; areaBusyIndicator.Visibility = Visibility.Visible; btnSelectBinaryFile.Visibility = Visibility.Hidden; @@ -155,7 +154,6 @@ namespace Il2CppInspectorGUI private async Task LoadPackageAsync(string filename) { var app = (App) Application.Current; - txtBusyStatus.Text = "Extracting package..."; areaBusyIndicator.Visibility = Visibility.Visible; grdFirstPage.Visibility = Visibility.Hidden; @@ -439,7 +437,7 @@ namespace Il2CppInspectorGUI var selectedPyUnityVersion = ((UnityHeaders) cboPyUnityVersion.SelectedItem)?.VersionRange.Min; var selectedPyTarget = (string) cboPyTarget.SelectedItem; await Task.Run(() => { - OnStatusUpdate(this, "Building C++ application model"); + OnStatusUpdate(this, "Building application model"); model.Build(selectedPyUnityVersion, CppCompilerType.GCC); OnStatusUpdate(this, $"Generating {selectedPyTarget} Python script"); @@ -464,7 +462,7 @@ namespace Il2CppInspectorGUI var selectedCppUnityVersion = ((UnityHeaders) cboCppUnityVersion.SelectedItem)?.VersionRange.Min; var cppCompiler = (CppCompilerType) Enum.Parse(typeof(CppCompilerType), cboCppCompiler.SelectionBoxItem.ToString()); await Task.Run(() => { - OnStatusUpdate(this, "Building C++ application model"); + OnStatusUpdate(this, "Building application model"); model.Build(selectedCppUnityVersion, cppCompiler); OnStatusUpdate(this, "Generating C++ scaffolding"); @@ -490,7 +488,7 @@ namespace Il2CppInspectorGUI areaBusyIndicator.Visibility = Visibility.Visible; var selectedJsonUnityVersion = ((UnityHeaders) cboJsonUnityVersion.SelectedItem)?.VersionRange.Min; await Task.Run(() => { - OnStatusUpdate(this, "Building C++ application model"); + OnStatusUpdate(this, "Building application model"); model.Build(selectedJsonUnityVersion, CppCompilerType.GCC); OnStatusUpdate(this, "Generating JSON metadata file");