Implement new GUI and CLI, fix misc. smaller issues (#22)
* Initial commit of new UI c# component * Initial commit of new UI frontend component * target WinExe to hide console window in release mode, move ui exe into resources * force single file publishing and add initial gh workflow for publishing ui * fix workflow errors * update dependencies and remove cxxdemangler, as it was outdated * fix c# single file output due to invalid output path * smaller tweaks, hack around loops in cpp type layouting * process other queued exports even if one fails and show error message * add basic support for processing LC_DYLD_CHAINED_FIXUPS * ELF loading should not use the file offset for loading the dynamic section * fix symbol table loading in some modified elfs * add "start export" button on format selection screen, clear all toasts after selecting an export format * embed ui executable directly into c# assembly * only build tauri component in c# release builds * add il2cpp file (binary, metadata) export to advanced tab * fix and enable binary ninja fake string segment support * add support for metadata * unify logic for getting element type index * fix new ui not allowing script exports other than ida * new ui: clear out loaded binary if no IL2CPP images could be loaded * fix toAddr calls in ghidra script target * remove dependency on a section being named .text in loaded pe files * tweak symbol reading a bit and remove sht relocation reading * add initial support for required forward references in il2cpp types, also fix issues with type names clashing with il2cpp api types * reduce clang errors for header file, fix better array size struct, emit required forward definitions in header * expose forward definitions in AppModel, fix issue with method-only used types not being emitted * remove debug log line * fix spelling mistakes in gui outputs * fix il2cpp_array_size_t not being an actual type for later method definitions * change the default port for new ui dev to 5000 * show current version and hash in new ui footer * seperate redux ui impl into FrontendCore project * make inspector version a server api, split up output subtypes and tweak some option names * add redux CLI based on redux GUI output formats * replace all Console.WriteLine calls in core inspector with AnsiConsole calls * add workflow for new cli and add back old gui workflow * disable aot publish and enable single file for redux cli
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -4,8 +4,6 @@
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Il2CppInspector.Cpp
|
||||
{
|
||||
// A field in a C++ type
|
||||
|
||||
@@ -5,9 +5,6 @@
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Il2CppInspector.Cpp
|
||||
{
|
||||
/// <summary>
|
||||
@@ -65,9 +62,9 @@ namespace Il2CppInspector.Cpp
|
||||
// Uniquely name an object within the parent namespace
|
||||
public string GetName(T t) {
|
||||
// If we've named this particular object before, just return that name
|
||||
string name;
|
||||
if (names.TryGetValue(t, out name))
|
||||
if (names.TryGetValue(t, out var name))
|
||||
return name;
|
||||
|
||||
// Obtain the mangled name for the object
|
||||
name = keyFunc(t);
|
||||
// Check if the mangled name has been given to another object - if it has,
|
||||
|
||||
@@ -456,4 +456,14 @@ namespace Il2CppInspector.Cpp
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public class CppForwardDefinitionType : CppType
|
||||
{
|
||||
public CppForwardDefinitionType(string name) : base(name)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override string ToString(string format = "") => $"struct {Name};";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,15 +4,11 @@
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Il2CppInspector.Cpp.UnityHeaders;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Il2CppInspector.Cpp.UnityHeaders;
|
||||
|
||||
namespace Il2CppInspector.Cpp
|
||||
{
|
||||
@@ -23,7 +19,7 @@ namespace Il2CppInspector.Cpp
|
||||
public Dictionary<string, CppType> Types { get; }
|
||||
|
||||
// All of the literal typedef aliases
|
||||
public Dictionary<string, CppType> TypedefAliases { get; } = new Dictionary<string, CppType>();
|
||||
public Dictionary<string, CppType> TypedefAliases { get; } = [];
|
||||
|
||||
public CppType this[string s] => Types.ContainsKey(s)? Types[s] :
|
||||
TypedefAliases.ContainsKey(s)? TypedefAliases[s].AsAlias(s) : null;
|
||||
@@ -34,7 +30,8 @@ namespace Il2CppInspector.Cpp
|
||||
// Architecture width in bits (32/64) - to determine pointer sizes
|
||||
public int WordSize { get; }
|
||||
|
||||
private Dictionary<string, ComplexValueType> complexTypeMap = new Dictionary<string, ComplexValueType> {
|
||||
private Dictionary<string, ComplexValueType> complexTypeMap = new()
|
||||
{
|
||||
["struct"] = ComplexValueType.Struct,
|
||||
["union"] = ComplexValueType.Union,
|
||||
["enum"] = ComplexValueType.Enum
|
||||
@@ -44,22 +41,23 @@ namespace Il2CppInspector.Cpp
|
||||
private string currentGroup = string.Empty;
|
||||
public void SetGroup(string group) => currentGroup = group;
|
||||
|
||||
private static readonly List<CppType> primitiveTypes = new List<CppType> {
|
||||
new CppType("uint8_t", 8),
|
||||
new CppType("uint16_t", 16),
|
||||
new CppType("uint32_t", 32),
|
||||
new CppType("uint64_t", 64),
|
||||
new CppType("int8_t", 8),
|
||||
new CppType("int16_t", 16),
|
||||
new CppType("int32_t", 32),
|
||||
new CppType("int64_t", 64),
|
||||
new CppType("char", 8),
|
||||
new CppType("int", 32),
|
||||
new CppType("float", 32),
|
||||
new CppType("double", 64),
|
||||
new CppType("bool", 8),
|
||||
new CppType("void", 0)
|
||||
};
|
||||
private static readonly List<CppType> primitiveTypes =
|
||||
[
|
||||
new("uint8_t", 8),
|
||||
new("uint16_t", 16),
|
||||
new("uint32_t", 32),
|
||||
new("uint64_t", 64),
|
||||
new("int8_t", 8),
|
||||
new("int16_t", 16),
|
||||
new("int32_t", 32),
|
||||
new("int64_t", 64),
|
||||
new("char", 8),
|
||||
new("int", 32),
|
||||
new("float", 32),
|
||||
new("double", 64),
|
||||
new("bool", 8),
|
||||
new("void", 0)
|
||||
];
|
||||
|
||||
public CppTypeCollection(int wordSize) {
|
||||
if (wordSize != 32 && wordSize != 64)
|
||||
@@ -538,15 +536,18 @@ namespace Il2CppInspector.Cpp
|
||||
public CppComplexType Struct(string name = "", int alignmentBytes = 0) {
|
||||
if (!string.IsNullOrEmpty(name) && Types.TryGetValue(name, out var cppType))
|
||||
return (CppComplexType) cppType;
|
||||
|
||||
var type = new CppComplexType(ComplexValueType.Struct) {Name = name, Group = currentGroup, AlignmentBytes = alignmentBytes};
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
Add(type);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
public CppComplexType Union(string name = "", int alignmentBytes = 0) {
|
||||
if (!string.IsNullOrEmpty(name) && Types.TryGetValue(name, out var cppType))
|
||||
return (CppComplexType) cppType;
|
||||
|
||||
var type = new CppComplexType(ComplexValueType.Union) {Name = name, Group = currentGroup, AlignmentBytes = alignmentBytes};
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
Add(type);
|
||||
@@ -554,9 +555,13 @@ namespace Il2CppInspector.Cpp
|
||||
}
|
||||
|
||||
public CppEnumType Enum(CppType underlyingType, string name = "") {
|
||||
if (!string.IsNullOrEmpty(name) && Types.TryGetValue(name, out var cppType))
|
||||
return (CppEnumType)cppType;
|
||||
|
||||
var type = new CppEnumType(underlyingType) {Name = name, Group = currentGroup};
|
||||
if (!string.IsNullOrEmpty(name))
|
||||
Add(type);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -585,11 +590,17 @@ namespace Il2CppInspector.Cpp
|
||||
cppTypes.AddFromDeclarationText(apis);
|
||||
|
||||
// Don't allow any of the header type names or primitive type names to be re-used
|
||||
foreach (var type in cppTypes.Types.Values)
|
||||
declGen?.TypeNamespace.TryReserveName(type.Name);
|
||||
foreach (var type in cppTypes.Types.Keys)
|
||||
{
|
||||
declGen?.TypeNamespace.TryReserveName(type);
|
||||
declGen?.GlobalsNamespace.TryReserveName(type);
|
||||
}
|
||||
|
||||
foreach (var typedef in cppTypes.TypedefAliases.Values)
|
||||
declGen?.GlobalsNamespace.TryReserveName(typedef.Name);
|
||||
foreach (var typedef in cppTypes.TypedefAliases.Keys)
|
||||
{
|
||||
declGen?.TypeNamespace.TryReserveName(typedef);
|
||||
declGen?.GlobalsNamespace.TryReserveName(typedef);
|
||||
}
|
||||
|
||||
cppTypes.SetGroup("");
|
||||
|
||||
|
||||
@@ -5,13 +5,14 @@
|
||||
All rights reserved.
|
||||
*/
|
||||
|
||||
using Il2CppInspector.Next;
|
||||
using Spectre.Console;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using Il2CppInspector.Next;
|
||||
using VersionedSerialization;
|
||||
|
||||
namespace Il2CppInspector.Cpp.UnityHeaders
|
||||
@@ -140,7 +141,7 @@ namespace Il2CppInspector.Cpp.UnityHeaders
|
||||
// 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
|
||||
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,
|
||||
apis.Last(a => a.VersionRange.Intersect(t.VersionRange) != null))).ToList();
|
||||
@@ -161,7 +162,7 @@ namespace Il2CppInspector.Cpp.UnityHeaders
|
||||
|
||||
if (apiMatches.Any()) {
|
||||
// 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(
|
||||
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
|
||||
// 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,
|
||||
apis.Last(a => a.VersionRange.Intersect(t.VersionRange) != null))).ToList();
|
||||
|
||||
Reference in New Issue
Block a user