2024-09-08 21:04:31 -04:00
|
|
|
#ifndef SYSTEM_DETECT_H
|
|
|
|
|
#define SYSTEM_DETECT_H
|
|
|
|
|
|
2025-03-06 16:40:31 -05:00
|
|
|
#if !defined(__GNUC__) && !defined(IDA) && !defined(GHIDRA) && !defined(BINANA_GENERATOR)
|
2024-09-08 21:04:31 -04:00
|
|
|
#error "Preprocessor mode not detected! You must define either IDA or GHIDRA or BINANA_GENERATOR"
|
|
|
|
|
#endif
|
|
|
|
|
|
2026-04-01 17:36:35 -04:00
|
|
|
#if defined(BINANA_GENERATOR)
|
|
|
|
|
// add custom generator defines here
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
#define BITFIELDS_SUPPORTED
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2024-09-08 21:04:31 -04:00
|
|
|
#if defined(IDA)
|
|
|
|
|
|
2026-04-01 17:36:35 -04:00
|
|
|
// why does this work?
|
2024-09-08 21:04:31 -04:00
|
|
|
#define DECLARE_ENUM(E) typedef enum E##__ E
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
#define DECLARE_ENUM(E) typedef enum E E
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define DECLARE_STRUCT(T) typedef struct T T
|
|
|
|
|
|
2026-04-01 17:36:35 -04:00
|
|
|
#define DECLARE_UNION(T) typedef union T T
|
|
|
|
|
|
2026-04-30 01:32:19 -04:00
|
|
|
#if defined(IDA) || defined(CLANGD)
|
|
|
|
|
// void Method(int32_t a1);
|
|
|
|
|
#define P_METHOD(__result__, name, ...) __result__(__thiscall* name)(INTERFACE * this, __VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
// void Method();
|
|
|
|
|
#define E_METHOD(__result__, name) __result__(__thiscall* name)(INTERFACE * this)
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
|
|
// ghidra doesn't support calling conventions in function pointer types :(
|
|
|
|
|
// this hides autoanalysis for the 'this' pointer but at least has correct
|
|
|
|
|
// parameter types
|
|
|
|
|
|
|
|
|
|
#define P_METHOD(__result__, name, ...) __result__ (*name)(__VA_ARGS__)
|
|
|
|
|
|
|
|
|
|
#define E_METHOD(__result__, name) __result__ (*name)()
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
2026-04-01 17:36:35 -04:00
|
|
|
#endif
|