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:
@@ -44,8 +44,13 @@ namespace Il2CppInspector.Outputs
|
||||
|
||||
// Write primitive type definitions for when we're not including other headers
|
||||
writeCode($"""
|
||||
#define IS_LIBCLANG_DECOMPILER (defined(_IDACLANG_) || defined(_BINARYNINJA_))
|
||||
#define IS_DECOMPILER (defined(_GHIDRA_) || defined(_IDA_) || IS_LIBCLANG_DECOMPILER)
|
||||
#if defined(_IDACLANG_) || defined(_BINARYNINJA_)
|
||||
#define IS_LIBCLANG_DECOMPILER
|
||||
#endif
|
||||
|
||||
#if defined(_GHIDRA_) || defined(_IDA_) || defined(IS_LIBCLANG_DECOMPILER)
|
||||
#define IS_DECOMPILER
|
||||
#endif
|
||||
|
||||
#if defined(_GHIDRA_) || defined(_IDA_)
|
||||
typedef unsigned __int8 uint8_t;
|
||||
@@ -58,7 +63,7 @@ namespace Il2CppInspector.Outputs
|
||||
typedef __int64 int64_t;
|
||||
#endif
|
||||
|
||||
#if IS_LIBCLANG_DECOMPILER
|
||||
#if defined(IS_LIBCLANG_DECOMPILER)
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
@@ -67,21 +72,26 @@ namespace Il2CppInspector.Outputs
|
||||
typedef short int16_t;
|
||||
typedef int int32_t;
|
||||
typedef long int64_t;
|
||||
|
||||
#ifdef linux
|
||||
#undef linux
|
||||
#endif
|
||||
|
||||
#if defined(_GHIDRA_) || IS_LIBCLANG_DECOMPILER
|
||||
#endif
|
||||
|
||||
#if defined(_GHIDRA_) || defined(IS_LIBCLANG_DECOMPILER)
|
||||
typedef int{_model.Package.BinaryImage.Bits}_t intptr_t;
|
||||
typedef uint{_model.Package.BinaryImage.Bits}_t uintptr_t;
|
||||
typedef uint{_model.Package.BinaryImage.Bits}_t size_t;
|
||||
#endif
|
||||
|
||||
#if !IS_DECOMPILER
|
||||
#ifndef IS_DECOMPILER
|
||||
#define _CPLUSPLUS_
|
||||
#endif
|
||||
""");
|
||||
|
||||
if (_useBetterArraySize)
|
||||
writeCode("#define actual_il2cpp_array_size_t il2cpp_array_size_t");
|
||||
writeCode("#define il2cpp_array_size_t actual_il2cpp_array_size_t");
|
||||
|
||||
writeSectionHeader("IL2CPP internal types");
|
||||
writeCode(_model.UnityHeaders.GetTypeHeaderText(_model.WordSizeBits));
|
||||
@@ -94,9 +104,7 @@ namespace Il2CppInspector.Outputs
|
||||
{
|
||||
int32_t size;
|
||||
actual_il2cpp_array_size_t value;
|
||||
} better_il2cpp_array_size_t;
|
||||
|
||||
#define better_il2cpp_array_size_t il2cpp_array_size_t
|
||||
} il2cpp_array_size_t;
|
||||
""");
|
||||
|
||||
if (_model.TargetCompiler == CppCompilerType.MSVC)
|
||||
@@ -115,17 +123,20 @@ namespace Il2CppInspector.Outputs
|
||||
}
|
||||
|
||||
// C does not support namespaces
|
||||
writeCode("#if !IS_DECOMPILER");
|
||||
writeCode("#ifndef IS_DECOMPILER");
|
||||
writeCode("namespace app {");
|
||||
writeCode("#endif");
|
||||
writeLine("");
|
||||
|
||||
writeForwardDefinitions();
|
||||
|
||||
writeTypesForGroup("Required forward definitions", "required_forward_definitions");
|
||||
writeTypesForGroup("Application types from method calls", "types_from_methods");
|
||||
writeTypesForGroup("Application types from generic methods", "types_from_generic_methods");
|
||||
writeTypesForGroup("Application types from usages", "types_from_usages");
|
||||
writeTypesForGroup("Application unused value types", "unused_concrete_types");
|
||||
|
||||
writeCode("#if !IS_DECOMPILER");
|
||||
writeCode("#ifndef IS_DECOMPILER");
|
||||
writeCode("}");
|
||||
writeCode("#endif");
|
||||
}
|
||||
@@ -306,19 +317,32 @@ namespace Il2CppInspector.Outputs
|
||||
writeLine("");
|
||||
}
|
||||
|
||||
private void writeTypesForGroup(string header, string group) {
|
||||
private void writeForwardDefinitions()
|
||||
{
|
||||
writeSectionHeader("Required forward definitions");
|
||||
foreach (var cppType in _model.RequiredForwardDefinitions)
|
||||
writeCode(cppType.ToString());
|
||||
}
|
||||
|
||||
private void writeTypesForGroup(string header, string group)
|
||||
{
|
||||
writeSectionHeader(header);
|
||||
foreach (var cppType in _model.GetDependencyOrderedCppTypeGroup(group))
|
||||
if (cppType is CppEnumType) {
|
||||
{
|
||||
if (cppType is CppEnumType)
|
||||
{
|
||||
// Ghidra can't process C++ enum base types
|
||||
writeCode("#if defined(_CPLUSPLUS_)");
|
||||
writeCode(cppType.ToString());
|
||||
writeCode("#else");
|
||||
writeCode(cppType.ToString("c"));
|
||||
writeCode("#endif");
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
writeCode(cppType.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void writeCode(string text) {
|
||||
|
||||
Reference in New Issue
Block a user