replace all Console.WriteLine calls in core inspector with AnsiConsole calls
This commit is contained in:
@@ -6,12 +6,13 @@
|
||||
*/
|
||||
|
||||
using Il2CppInspector.Next;
|
||||
using Il2CppInspector.Next.BinaryMetadata;
|
||||
using Il2CppInspector.Next.Metadata;
|
||||
using Spectre.Console;
|
||||
using System.Collections.Immutable;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using Il2CppInspector.Next.BinaryMetadata;
|
||||
using Il2CppInspector.Next.Metadata;
|
||||
using VersionedSerialization;
|
||||
|
||||
namespace Il2CppInspector
|
||||
@@ -191,7 +192,7 @@ namespace Il2CppInspector
|
||||
var symbols = Image.GetSymbolTable();
|
||||
|
||||
if (symbols.Any()) {
|
||||
Console.WriteLine($"Symbol table(s) found with {symbols.Count} entries");
|
||||
AnsiConsole.WriteLine($"Symbol table(s) found with {symbols.Count} entries");
|
||||
|
||||
symbols.TryGetValue("g_CodeRegistration", out var code);
|
||||
symbols.TryGetValue("g_MetadataRegistration", out var metadata);
|
||||
@@ -202,13 +203,13 @@ namespace Il2CppInspector
|
||||
symbols.TryGetValue("_g_MetadataRegistration", out metadata);
|
||||
|
||||
if (code != null && metadata != null) {
|
||||
Console.WriteLine("Required structures acquired from symbol lookup");
|
||||
AnsiConsole.WriteLine("Required structures acquired from symbol lookup");
|
||||
return (code.VirtualAddress, metadata.VirtualAddress);
|
||||
} else {
|
||||
Console.WriteLine("No matches in symbol table");
|
||||
AnsiConsole.WriteLine("No matches in symbol table");
|
||||
}
|
||||
} else if (symbols != null) {
|
||||
Console.WriteLine("No symbol table present in binary file");
|
||||
AnsiConsole.WriteLine("No symbol table present in binary file");
|
||||
} else {
|
||||
Console.WriteLine("Symbol table search not implemented for this binary format");
|
||||
}
|
||||
@@ -227,12 +228,12 @@ namespace Il2CppInspector
|
||||
var (code, metadata) = ConsiderCode(Image, loc);
|
||||
if (code != 0) {
|
||||
RegistrationFunctionPointer = loc + Image.GlobalOffset;
|
||||
Console.WriteLine("Required structures acquired from code heuristics. Initialization function: 0x{0:X16}", RegistrationFunctionPointer);
|
||||
AnsiConsole.WriteLine("Required structures acquired from code heuristics. Initialization function: 0x{0:X16}", RegistrationFunctionPointer);
|
||||
return (code, metadata);
|
||||
}
|
||||
}
|
||||
|
||||
Console.WriteLine("No matches via code heuristics");
|
||||
AnsiConsole.WriteLine("No matches via code heuristics");
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -244,11 +245,11 @@ namespace Il2CppInspector
|
||||
|
||||
var (codePtr, metadataPtr) = ImageScan(Metadata);
|
||||
if (codePtr == 0) {
|
||||
Console.WriteLine("No matches via data heuristics");
|
||||
AnsiConsole.WriteLine("No matches via data heuristics");
|
||||
return null;
|
||||
}
|
||||
|
||||
Console.WriteLine("Required structures acquired from data heuristics");
|
||||
AnsiConsole.WriteLine("Required structures acquired from data heuristics");
|
||||
return (codePtr, metadataPtr);
|
||||
}
|
||||
|
||||
@@ -274,8 +275,8 @@ namespace Il2CppInspector
|
||||
|
||||
var pointerSize = Image.Bits == 32 ? 4u : 8u;
|
||||
|
||||
Console.WriteLine("CodeRegistration struct found at 0x{0:X16} (file offset 0x{1:X8})", Image.Bits == 32 ? codeRegistration & 0xffff_ffff : codeRegistration, Image.MapVATR(codeRegistration));
|
||||
Console.WriteLine("MetadataRegistration struct found at 0x{0:X16} (file offset 0x{1:X8})", Image.Bits == 32 ? metadataRegistration & 0xffff_ffff : metadataRegistration, Image.MapVATR(metadataRegistration));
|
||||
AnsiConsole.WriteLine("CodeRegistration struct found at 0x{0:X16} (file offset 0x{1:X8})", Image.Bits == 32 ? codeRegistration & 0xffff_ffff : codeRegistration, Image.MapVATR(codeRegistration));
|
||||
AnsiConsole.WriteLine("MetadataRegistration struct found at 0x{0:X16} (file offset 0x{1:X8})", Image.Bits == 32 ? metadataRegistration & 0xffff_ffff : metadataRegistration, Image.MapVATR(metadataRegistration));
|
||||
|
||||
// Root structures from which we find everything else
|
||||
CodeRegistration = Image.ReadMappedVersionedObject<Il2CppCodeRegistration>(codeRegistration);
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
*/
|
||||
|
||||
using Il2CppInspector.Next;
|
||||
using Il2CppInspector.Next.BinaryMetadata;
|
||||
using Il2CppInspector.Next.Metadata;
|
||||
using Il2CppInspector.Utils;
|
||||
using NoisyCowStudios.Bin2Object;
|
||||
using Spectre.Console;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
@@ -14,8 +17,6 @@ using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Il2CppInspector.Next.BinaryMetadata;
|
||||
using Il2CppInspector.Next.Metadata;
|
||||
using VersionedSerialization;
|
||||
|
||||
namespace Il2CppInspector
|
||||
@@ -410,7 +411,7 @@ namespace Il2CppInspector
|
||||
if (metadataFile != null) {
|
||||
// Extract the metadata file to memory
|
||||
if (!silent)
|
||||
Console.WriteLine($"Extracting metadata from (archive){Path.DirectorySeparatorChar}{metadataFile.FullName}");
|
||||
AnsiConsole.WriteLine($"Extracting metadata from (archive){Path.DirectorySeparatorChar}{metadataFile.FullName}");
|
||||
|
||||
metadataMemoryStream = new MemoryStream();
|
||||
using var metadataStream = metadataFile.Open();
|
||||
@@ -428,7 +429,7 @@ namespace Il2CppInspector
|
||||
// IPAs will only have one binary (which may or may not be a UB covering multiple architectures)
|
||||
if (ipaBinaryFolder != null) {
|
||||
if (!silent)
|
||||
Console.WriteLine($"Extracting binary from {zipStreams.First()}{Path.DirectorySeparatorChar}{binaryFiles.First().FullName}");
|
||||
AnsiConsole.WriteLine($"Extracting binary from {zipStreams.First()}{Path.DirectorySeparatorChar}{binaryFiles.First().FullName}");
|
||||
|
||||
// Extract the binary file or package to memory
|
||||
binaryMemoryStream = new MemoryStream();
|
||||
@@ -531,7 +532,7 @@ namespace Il2CppInspector
|
||||
return null;
|
||||
}
|
||||
|
||||
Console.WriteLine("Detected metadata version " + metadata.Version);
|
||||
AnsiConsole.WriteLine("Detected metadata version " + metadata.Version);
|
||||
|
||||
// Load the il2cpp code file (try all available file formats)
|
||||
IFileFormatStream stream;
|
||||
@@ -559,16 +560,16 @@ namespace Il2CppInspector
|
||||
|
||||
var processors = new List<Il2CppInspector>();
|
||||
foreach (var image in stream.Images) {
|
||||
Console.WriteLine("Container format: " + image.Format);
|
||||
Console.WriteLine("Container endianness: " + ((BinaryObjectStream) image).Endianness);
|
||||
Console.WriteLine("Architecture word size: {0}-bit", image.Bits);
|
||||
Console.WriteLine("Instruction set: " + image.Arch);
|
||||
Console.WriteLine("Global offset: 0x{0:X16}", image.GlobalOffset);
|
||||
AnsiConsole.WriteLine("Container format: " + image.Format);
|
||||
AnsiConsole.WriteLine("Container endianness: " + ((BinaryObjectStream) image).Endianness);
|
||||
AnsiConsole.WriteLine("Architecture word size: {0}-bit", image.Bits);
|
||||
AnsiConsole.WriteLine("Instruction set: " + image.Arch);
|
||||
AnsiConsole.WriteLine("Global offset: 0x{0:X16}", image.GlobalOffset);
|
||||
|
||||
// Architecture-agnostic load attempt
|
||||
try {
|
||||
if (Il2CppBinary.Load(image, metadata, statusCallback) is Il2CppBinary binary) {
|
||||
Console.WriteLine("IL2CPP binary version " + image.Version);
|
||||
AnsiConsole.WriteLine("IL2CPP binary version " + image.Version);
|
||||
|
||||
processors.Add(new Il2CppInspector(binary, metadata));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user