Fix idaclang support for 8.3

This commit is contained in:
LukeFZ
2024-02-16 09:49:00 +01:00
parent 939bedac57
commit 42d97813df
2 changed files with 16 additions and 6 deletions

View File

@@ -46,7 +46,7 @@ namespace Il2CppInspector.Outputs
// Write primitive type definitions for when we're not including other headers
writeCode($"""
#if defined(_GHIDRA_) || defined(_IDA_) || defined(_IDACLANG_)
#if defined(_GHIDRA_) || defined(_IDA_)
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
@@ -56,13 +56,21 @@ namespace Il2CppInspector.Outputs
typedef __int32 int32_t;
typedef __int64 int64_t;
#endif
#ifdef _IDACLANG_
typedef unsigned char uint8_t;
typedef unsigned short uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long uint64_t;
typedef char int8_t;
typedef short int16_t;
typedef int int32_t;
typedef long int64_t;
#endif
#if defined(_GHIDRA_) || defined(_IDACLANG_)
typedef int{_model.Package.BinaryImage.Bits}_t intptr_t;
typedef uint{_model.Package.BinaryImage.Bits}_t uintptr_t;
#endif
#if defined(_GHIDRA_)
typedef uint{_model.Package.BinaryImage.Bits}_t size_t;
#endif

View File

@@ -48,7 +48,7 @@ def script_prologue(status):
if IDACLANG_AVAILABLE:
header_path = os.path.join(get_script_directory(), "%TYPE_HEADER_RELATIVE_PATH%")
ida_srclang.set_parser_argv("clang", "-x c++ -D_IDACLANG_=1")
ida_srclang.set_parser_argv("clang", "-target x86_64-pc-linux -x c++ -D_IDACLANG_=1") # -target required for 8.3+
ida_srclang.parse_decls_with_parser("clang", None, header_path, True)
else:
original_macros = ida_typeinf.get_c_macros()
@@ -70,6 +70,8 @@ def script_epilogue(status):
global cached_genflags
ida_ida.inf_set_genflags(cached_genflags)
# Utility methods
def set_name(addr, name):
ida_name.set_name(addr, name, ida_name.SN_NOWARN | ida_name.SN_NOCHECK | ida_name.SN_FORCE)