replace all Console.WriteLine calls in core inspector with AnsiConsole calls
This commit is contained in:
@@ -5,13 +5,14 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using Il2CppInspector.Next;
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Il2CppInspector.Next;
|
|
||||||
using VersionedSerialization;
|
using VersionedSerialization;
|
||||||
|
|
||||||
namespace Il2CppInspector.Cpp.UnityHeaders
|
namespace Il2CppInspector.Cpp.UnityHeaders
|
||||||
@@ -140,7 +141,7 @@ namespace Il2CppInspector.Cpp.UnityHeaders
|
|||||||
// No il2cpp exports? Just return the earliest version from the header range
|
// No il2cpp exports? Just return the earliest version from the header range
|
||||||
// The API version may be incorrect but should be a subset of the real API and won't cause C++ compile errors
|
// The API version may be incorrect but should be a subset of the real API and won't cause C++ compile errors
|
||||||
if (!exports.Any()) {
|
if (!exports.Any()) {
|
||||||
Console.WriteLine("No IL2CPP API exports found in binary - IL2CPP APIs will be unavailable in C++ project");
|
AnsiConsole.WriteLine("No IL2CPP API exports found in binary - IL2CPP APIs will be unavailable in C++ project");
|
||||||
|
|
||||||
return typeHeaders.Select(t => new UnityHeaders(t,
|
return typeHeaders.Select(t => new UnityHeaders(t,
|
||||||
apis.Last(a => a.VersionRange.Intersect(t.VersionRange) != null))).ToList();
|
apis.Last(a => a.VersionRange.Intersect(t.VersionRange) != null))).ToList();
|
||||||
@@ -161,7 +162,7 @@ namespace Il2CppInspector.Cpp.UnityHeaders
|
|||||||
|
|
||||||
if (apiMatches.Any()) {
|
if (apiMatches.Any()) {
|
||||||
// Intersect all API ranges with all header ranges to produce final list of possible ranges
|
// Intersect all API ranges with all header ranges to produce final list of possible ranges
|
||||||
Console.WriteLine("IL2CPP API discovery was successful");
|
AnsiConsole.WriteLine("IL2CPP API discovery was successful");
|
||||||
|
|
||||||
return typeHeaders.SelectMany(
|
return typeHeaders.SelectMany(
|
||||||
t => apiMatches.Where(a => t.VersionRange.Intersect(a.VersionRange) != null)
|
t => apiMatches.Where(a => t.VersionRange.Intersect(a.VersionRange) != null)
|
||||||
@@ -170,7 +171,7 @@ namespace Il2CppInspector.Cpp.UnityHeaders
|
|||||||
|
|
||||||
// None of the possible API versions match the binary
|
// None of the possible API versions match the binary
|
||||||
// Select the oldest API version from the group - C++ project compilation will fail
|
// Select the oldest API version from the group - C++ project compilation will fail
|
||||||
Console.WriteLine("No exact match for IL2CPP APIs found in binary - IL2CPP API availability in C++ project will be partial");
|
AnsiConsole.WriteLine("No exact match for IL2CPP APIs found in binary - IL2CPP API availability in C++ project will be partial");
|
||||||
|
|
||||||
return typeHeaders.Select(t => new UnityHeaders(t,
|
return typeHeaders.Select(t => new UnityHeaders(t,
|
||||||
apis.Last(a => a.VersionRange.Intersect(t.VersionRange) != null))).ToList();
|
apis.Last(a => a.VersionRange.Intersect(t.VersionRange) != null))).ToList();
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -51,7 +52,7 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
public override IFileFormatStream this[uint index] {
|
public override IFileFormatStream this[uint index] {
|
||||||
get {
|
get {
|
||||||
Console.WriteLine($"Extracting binary from {binaryFiles[index].FullName}");
|
AnsiConsole.WriteLine($"Extracting binary from {binaryFiles[index].FullName}");
|
||||||
IFileFormatStream loaded = null;
|
IFileFormatStream loaded = null;
|
||||||
|
|
||||||
// ZipArchiveEntry does not support seeking so we have to close and re-open for each possible load format
|
// ZipArchiveEntry does not support seeking so we have to close and re-open for each possible load format
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -51,7 +52,7 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
public override IFileFormatStream this[uint index] {
|
public override IFileFormatStream this[uint index] {
|
||||||
get {
|
get {
|
||||||
Console.WriteLine($"Extracting binary from {binaryFiles[index].FullName}");
|
AnsiConsole.WriteLine($"Extracting binary from {binaryFiles[index].FullName}");
|
||||||
IFileFormatStream loaded = null;
|
IFileFormatStream loaded = null;
|
||||||
|
|
||||||
// ZipArchiveEntry does not support seeking so we have to close and re-open for each possible load format
|
// ZipArchiveEntry does not support seeking so we have to close and re-open for each possible load format
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -160,7 +161,7 @@ namespace Il2CppInspector
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Got exception {ex} while parsing SHT - reverting to PHT");
|
AnsiConsole.WriteLine($"Got exception {ex} while parsing SHT - reverting to PHT");
|
||||||
preferPHT = true;
|
preferPHT = true;
|
||||||
SHT = [];
|
SHT = [];
|
||||||
}
|
}
|
||||||
@@ -170,12 +171,12 @@ namespace Il2CppInspector
|
|||||||
// These can happen as a result of conversions from other formats to ELF,
|
// These can happen as a result of conversions from other formats to ELF,
|
||||||
// or if the SHT has been deliberately stripped
|
// or if the SHT has been deliberately stripped
|
||||||
if (!SHT.Any()) {
|
if (!SHT.Any()) {
|
||||||
Console.WriteLine("ELF binary has no SHT - reverting to PHT");
|
AnsiConsole.WriteLine("ELF binary has no SHT - reverting to PHT");
|
||||||
preferPHT = true;
|
preferPHT = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (SHT.All(s => conv.ULong(s.sh_addr) == 0ul)) {
|
else if (SHT.All(s => conv.ULong(s.sh_addr) == 0ul)) {
|
||||||
Console.WriteLine("ELF binary SHT is all-zero - reverting to PHT");
|
AnsiConsole.WriteLine("ELF binary SHT is all-zero - reverting to PHT");
|
||||||
preferPHT = true;
|
preferPHT = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,7 +193,7 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
// If the first file offset of the first PHT is zero, assume a dumped image
|
// If the first file offset of the first PHT is zero, assume a dumped image
|
||||||
if (PHT.Any(t => conv.ULong(t.p_vaddr) == 0ul)) {
|
if (PHT.Any(t => conv.ULong(t.p_vaddr) == 0ul)) {
|
||||||
Console.WriteLine("ELF binary appears to be a dumped memory image");
|
AnsiConsole.WriteLine("ELF binary appears to be a dumped memory image");
|
||||||
isMemoryImage = true;
|
isMemoryImage = true;
|
||||||
}
|
}
|
||||||
preferPHT = true;
|
preferPHT = true;
|
||||||
@@ -202,7 +203,7 @@ namespace Il2CppInspector
|
|||||||
else {
|
else {
|
||||||
var shtOverlap = shtShouldBeOrdered.Aggregate((x, y) => x <= y? y : ulong.MaxValue) == ulong.MaxValue;
|
var shtOverlap = shtShouldBeOrdered.Aggregate((x, y) => x <= y? y : ulong.MaxValue) == ulong.MaxValue;
|
||||||
if (shtOverlap) {
|
if (shtOverlap) {
|
||||||
Console.WriteLine("ELF binary SHT contains invalid ranges - reverting to PHT");
|
AnsiConsole.WriteLine("ELF binary SHT contains invalid ranges - reverting to PHT");
|
||||||
preferPHT = true;
|
preferPHT = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -361,7 +362,7 @@ namespace Il2CppInspector
|
|||||||
WriteWord(result.newValue);
|
WriteWord(result.newValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Console.WriteLine($"Processed {rels.Count} relocations");
|
AnsiConsole.WriteLine($"Processed {rels.Count} relocations");
|
||||||
|
|
||||||
// Build symbol and export tables
|
// Build symbol and export tables
|
||||||
processSymbols();
|
processSymbols();
|
||||||
|
|||||||
@@ -4,12 +4,13 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using NoisyCowStudios.Bin2Object;
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using NoisyCowStudios.Bin2Object;
|
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
{
|
{
|
||||||
@@ -194,7 +195,7 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
// TODO: Implement Mach-O relocations
|
// TODO: Implement Mach-O relocations
|
||||||
if (rels.Any()) {
|
if (rels.Any()) {
|
||||||
Console.WriteLine("Mach-O file contains relocations (feature not yet implemented)");
|
AnsiConsole.WriteLine("Mach-O file contains relocations (feature not yet implemented)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,7 +289,7 @@ namespace Il2CppInspector
|
|||||||
: SymbolType.Unknown;
|
: SymbolType.Unknown;
|
||||||
|
|
||||||
if (type == SymbolType.Unknown) {
|
if (type == SymbolType.Unknown) {
|
||||||
Console.WriteLine($"Unknown symbol type: {((int) ntype):x2} {value:x16} {name}");
|
AnsiConsole.WriteLine($"Unknown symbol type: {((int) ntype):x2} {value:x16} {name}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ignore duplicates
|
// Ignore duplicates
|
||||||
@@ -301,13 +302,13 @@ namespace Il2CppInspector
|
|||||||
var chainedFixupsHeader = ReadVersionedObject<MachODyldChainedFixupsHeader>(info.Offset);
|
var chainedFixupsHeader = ReadVersionedObject<MachODyldChainedFixupsHeader>(info.Offset);
|
||||||
if (chainedFixupsHeader.FixupsVersion != 0)
|
if (chainedFixupsHeader.FixupsVersion != 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Unsupported chained fixups version: {chainedFixupsHeader.FixupsVersion}");
|
AnsiConsole.WriteLine($"Unsupported chained fixups version: {chainedFixupsHeader.FixupsVersion}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chainedFixupsHeader.ImportsFormat != 1 /* DYLD_CHAINED_IMPORT */)
|
if (chainedFixupsHeader.ImportsFormat != 1 /* DYLD_CHAINED_IMPORT */)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Unsupported chained fixups import format: {chainedFixupsHeader.ImportsFormat}");
|
AnsiConsole.WriteLine($"Unsupported chained fixups import format: {chainedFixupsHeader.ImportsFormat}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,14 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using NoisyCowStudios.Bin2Object;
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NoisyCowStudios.Bin2Object;
|
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
{
|
{
|
||||||
@@ -102,7 +103,7 @@ namespace Il2CppInspector
|
|||||||
// Unpacking must be done starting here, one byte after the end of the headers
|
// Unpacking must be done starting here, one byte after the end of the headers
|
||||||
// Packed or previously packed with Themida? This is purely for information
|
// Packed or previously packed with Themida? This is purely for information
|
||||||
if (sections.FirstOrDefault(x => x.Name == ".themida") is PESection _)
|
if (sections.FirstOrDefault(x => x.Name == ".themida") is PESection _)
|
||||||
Console.WriteLine("Themida protection detected");
|
AnsiConsole.WriteLine("Themida protection detected");
|
||||||
|
|
||||||
// Packed with anything (including Themida)?
|
// Packed with anything (including Themida)?
|
||||||
mightBePacked = sections.FirstOrDefault(x => x.Name == ".rdata") is null;
|
mightBePacked = sections.FirstOrDefault(x => x.Name == ".rdata") is null;
|
||||||
|
|||||||
@@ -4,11 +4,12 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using NoisyCowStudios.Bin2Object;
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using NoisyCowStudios.Bin2Object;
|
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
{
|
{
|
||||||
@@ -100,7 +101,7 @@ namespace Il2CppInspector
|
|||||||
// Get the entire remaining chunk, or to the end of the file if it doesn't contain the end of the chunk
|
// Get the entire remaining chunk, or to the end of the file if it doesn't contain the end of the chunk
|
||||||
var length = (uint) Math.Min(chunk.Memory.End - memoryNext, source.Length);
|
var length = (uint) Math.Min(chunk.Memory.End - memoryNext, source.Length);
|
||||||
|
|
||||||
Console.WriteLine($"Writing {length:x8} bytes from {Path.GetFileName(file.Name)} +{fileStart:x8} ({memoryNext:x8}) to target {il2cpp.Position:x8}");
|
AnsiConsole.WriteLine($"Writing {length:x8} bytes from {Path.GetFileName(file.Name)} +{fileStart:x8} ({memoryNext:x8}) to target {il2cpp.Position:x8}");
|
||||||
|
|
||||||
// Can't use Stream.CopyTo as it doesn't support length parameter
|
// Can't use Stream.CopyTo as it doesn't support length parameter
|
||||||
var buffer = new byte[length];
|
var buffer = new byte[length];
|
||||||
|
|||||||
@@ -6,12 +6,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using Il2CppInspector.Next;
|
using Il2CppInspector.Next;
|
||||||
|
using Il2CppInspector.Next.BinaryMetadata;
|
||||||
|
using Il2CppInspector.Next.Metadata;
|
||||||
|
using Spectre.Console;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using Il2CppInspector.Next.BinaryMetadata;
|
|
||||||
using Il2CppInspector.Next.Metadata;
|
|
||||||
using VersionedSerialization;
|
using VersionedSerialization;
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
@@ -191,7 +192,7 @@ namespace Il2CppInspector
|
|||||||
var symbols = Image.GetSymbolTable();
|
var symbols = Image.GetSymbolTable();
|
||||||
|
|
||||||
if (symbols.Any()) {
|
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_CodeRegistration", out var code);
|
||||||
symbols.TryGetValue("g_MetadataRegistration", out var metadata);
|
symbols.TryGetValue("g_MetadataRegistration", out var metadata);
|
||||||
@@ -202,13 +203,13 @@ namespace Il2CppInspector
|
|||||||
symbols.TryGetValue("_g_MetadataRegistration", out metadata);
|
symbols.TryGetValue("_g_MetadataRegistration", out metadata);
|
||||||
|
|
||||||
if (code != null && metadata != null) {
|
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);
|
return (code.VirtualAddress, metadata.VirtualAddress);
|
||||||
} else {
|
} else {
|
||||||
Console.WriteLine("No matches in symbol table");
|
AnsiConsole.WriteLine("No matches in symbol table");
|
||||||
}
|
}
|
||||||
} else if (symbols != null) {
|
} else if (symbols != null) {
|
||||||
Console.WriteLine("No symbol table present in binary file");
|
AnsiConsole.WriteLine("No symbol table present in binary file");
|
||||||
} else {
|
} else {
|
||||||
Console.WriteLine("Symbol table search not implemented for this binary format");
|
Console.WriteLine("Symbol table search not implemented for this binary format");
|
||||||
}
|
}
|
||||||
@@ -227,12 +228,12 @@ namespace Il2CppInspector
|
|||||||
var (code, metadata) = ConsiderCode(Image, loc);
|
var (code, metadata) = ConsiderCode(Image, loc);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
RegistrationFunctionPointer = loc + Image.GlobalOffset;
|
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);
|
return (code, metadata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("No matches via code heuristics");
|
AnsiConsole.WriteLine("No matches via code heuristics");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,11 +245,11 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
var (codePtr, metadataPtr) = ImageScan(Metadata);
|
var (codePtr, metadataPtr) = ImageScan(Metadata);
|
||||||
if (codePtr == 0) {
|
if (codePtr == 0) {
|
||||||
Console.WriteLine("No matches via data heuristics");
|
AnsiConsole.WriteLine("No matches via data heuristics");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.WriteLine("Required structures acquired from data heuristics");
|
AnsiConsole.WriteLine("Required structures acquired from data heuristics");
|
||||||
return (codePtr, metadataPtr);
|
return (codePtr, metadataPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -274,8 +275,8 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
var pointerSize = Image.Bits == 32 ? 4u : 8u;
|
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));
|
AnsiConsole.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("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
|
// Root structures from which we find everything else
|
||||||
CodeRegistration = Image.ReadMappedVersionedObject<Il2CppCodeRegistration>(codeRegistration);
|
CodeRegistration = Image.ReadMappedVersionedObject<Il2CppCodeRegistration>(codeRegistration);
|
||||||
|
|||||||
@@ -5,8 +5,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
using Il2CppInspector.Next;
|
using Il2CppInspector.Next;
|
||||||
|
using Il2CppInspector.Next.BinaryMetadata;
|
||||||
|
using Il2CppInspector.Next.Metadata;
|
||||||
using Il2CppInspector.Utils;
|
using Il2CppInspector.Utils;
|
||||||
using NoisyCowStudios.Bin2Object;
|
using NoisyCowStudios.Bin2Object;
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.Immutable;
|
using System.Collections.Immutable;
|
||||||
@@ -14,8 +17,6 @@ using System.IO;
|
|||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Il2CppInspector.Next.BinaryMetadata;
|
|
||||||
using Il2CppInspector.Next.Metadata;
|
|
||||||
using VersionedSerialization;
|
using VersionedSerialization;
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
@@ -410,7 +411,7 @@ namespace Il2CppInspector
|
|||||||
if (metadataFile != null) {
|
if (metadataFile != null) {
|
||||||
// Extract the metadata file to memory
|
// Extract the metadata file to memory
|
||||||
if (!silent)
|
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();
|
metadataMemoryStream = new MemoryStream();
|
||||||
using var metadataStream = metadataFile.Open();
|
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)
|
// IPAs will only have one binary (which may or may not be a UB covering multiple architectures)
|
||||||
if (ipaBinaryFolder != null) {
|
if (ipaBinaryFolder != null) {
|
||||||
if (!silent)
|
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
|
// Extract the binary file or package to memory
|
||||||
binaryMemoryStream = new MemoryStream();
|
binaryMemoryStream = new MemoryStream();
|
||||||
@@ -531,7 +532,7 @@ namespace Il2CppInspector
|
|||||||
return null;
|
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)
|
// Load the il2cpp code file (try all available file formats)
|
||||||
IFileFormatStream stream;
|
IFileFormatStream stream;
|
||||||
@@ -559,16 +560,16 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
var processors = new List<Il2CppInspector>();
|
var processors = new List<Il2CppInspector>();
|
||||||
foreach (var image in stream.Images) {
|
foreach (var image in stream.Images) {
|
||||||
Console.WriteLine("Container format: " + image.Format);
|
AnsiConsole.WriteLine("Container format: " + image.Format);
|
||||||
Console.WriteLine("Container endianness: " + ((BinaryObjectStream) image).Endianness);
|
AnsiConsole.WriteLine("Container endianness: " + ((BinaryObjectStream) image).Endianness);
|
||||||
Console.WriteLine("Architecture word size: {0}-bit", image.Bits);
|
AnsiConsole.WriteLine("Architecture word size: {0}-bit", image.Bits);
|
||||||
Console.WriteLine("Instruction set: " + image.Arch);
|
AnsiConsole.WriteLine("Instruction set: " + image.Arch);
|
||||||
Console.WriteLine("Global offset: 0x{0:X16}", image.GlobalOffset);
|
AnsiConsole.WriteLine("Global offset: 0x{0:X16}", image.GlobalOffset);
|
||||||
|
|
||||||
// Architecture-agnostic load attempt
|
// Architecture-agnostic load attempt
|
||||||
try {
|
try {
|
||||||
if (Il2CppBinary.Load(image, metadata, statusCallback) is Il2CppBinary binary) {
|
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));
|
processors.Add(new Il2CppInspector(binary, metadata));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="dnlib" Version="4.4.0" />
|
<PackageReference Include="dnlib" Version="4.4.0" />
|
||||||
<PackageReference Include="McMaster.NETCore.Plugins" Version="2.0.0" />
|
<PackageReference Include="McMaster.NETCore.Plugins" Version="2.0.0" />
|
||||||
|
<PackageReference Include="Spectre.Console" Version="0.50.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ using Il2CppInspector.Cpp;
|
|||||||
using Il2CppInspector.Cpp.UnityHeaders;
|
using Il2CppInspector.Cpp.UnityHeaders;
|
||||||
using Il2CppInspector.Next;
|
using Il2CppInspector.Next;
|
||||||
using Il2CppInspector.Reflection;
|
using Il2CppInspector.Reflection;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace Il2CppInspector.Model
|
namespace Il2CppInspector.Model
|
||||||
{
|
{
|
||||||
@@ -152,12 +153,12 @@ namespace Il2CppInspector.Model
|
|||||||
UnityHeaders = unityVersion != null ? UnityHeaders.GetHeadersForVersion(unityVersion) : UnityHeaders.GuessHeadersForBinary(TypeModel.Package.Binary).Last();
|
UnityHeaders = unityVersion != null ? UnityHeaders.GetHeadersForVersion(unityVersion) : UnityHeaders.GuessHeadersForBinary(TypeModel.Package.Binary).Last();
|
||||||
UnityVersion = unityVersion ?? UnityHeaders.VersionRange.Min;
|
UnityVersion = unityVersion ?? UnityHeaders.VersionRange.Min;
|
||||||
|
|
||||||
Console.WriteLine($"Selected Unity version(s) {UnityHeaders.VersionRange} (types: {UnityHeaders.TypeHeaderResource.VersionRange}, APIs: {UnityHeaders.APIHeaderResource.VersionRange})");
|
AnsiConsole.WriteLine($"Selected Unity version(s) {UnityHeaders.VersionRange} (types: {UnityHeaders.TypeHeaderResource.VersionRange}, APIs: {UnityHeaders.APIHeaderResource.VersionRange})");
|
||||||
|
|
||||||
// Check for matching metadata and binary versions
|
// Check for matching metadata and binary versions
|
||||||
if (UnityHeaders.MetadataVersion != Image.Version) {
|
if (UnityHeaders.MetadataVersion != Image.Version) {
|
||||||
Console.WriteLine($"Warning: selected version {UnityVersion} (metadata version {UnityHeaders.MetadataVersion})" +
|
AnsiConsole.WriteLine($"Warning: selected version {UnityVersion} (metadata version {UnityHeaders.MetadataVersion})" +
|
||||||
$" does not match metadata version {Image.Version}.");
|
$" does not match metadata version {Image.Version}.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize declaration generator to process every type in the binary
|
// Initialize declaration generator to process every type in the binary
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
All rights reserved.
|
All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
using Il2CppInspector.PluginAPI;
|
||||||
|
// This is the ONLY line to update when the API version changes
|
||||||
|
using Il2CppInspector.PluginAPI.V100;
|
||||||
|
using McMaster.NETCore.Plugins;
|
||||||
|
using Spectre.Console;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
@@ -12,11 +17,6 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using McMaster.NETCore.Plugins;
|
|
||||||
using Il2CppInspector.PluginAPI;
|
|
||||||
|
|
||||||
// This is the ONLY line to update when the API version changes
|
|
||||||
using Il2CppInspector.PluginAPI.V100;
|
|
||||||
|
|
||||||
namespace Il2CppInspector
|
namespace Il2CppInspector
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Diagnostics;
|
|||||||
using Il2CppInspector.Next;
|
using Il2CppInspector.Next;
|
||||||
using Il2CppInspector.Next.BinaryMetadata;
|
using Il2CppInspector.Next.BinaryMetadata;
|
||||||
using Il2CppInspector.Next.Metadata;
|
using Il2CppInspector.Next.Metadata;
|
||||||
|
using Spectre.Console;
|
||||||
|
|
||||||
namespace Il2CppInspector.Utils;
|
namespace Il2CppInspector.Utils;
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ public static class BlobReader
|
|||||||
}
|
}
|
||||||
catch (InvalidDataException)
|
catch (InvalidDataException)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Found invalid compressed int at metadata address 0x{address:x8}. Reading as normal int.");
|
AnsiConsole.WriteLine($"Found invalid compressed int at metadata address 0x{address:x8}. Reading as normal int.");
|
||||||
return blob.ReadInt32(address);
|
return blob.ReadInt32(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +143,7 @@ public static class BlobReader
|
|||||||
}
|
}
|
||||||
catch (InvalidDataException)
|
catch (InvalidDataException)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Found invalid compressed uint at metadata address 0x{address:x8}. Reading as normal uint.");
|
AnsiConsole.WriteLine($"Found invalid compressed uint at metadata address 0x{address:x8}. Reading as normal uint.");
|
||||||
return blob.ReadUInt32(address);
|
return blob.ReadUInt32(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user