1
0
mirror of synced 2024-11-18 21:07:12 +01:00
ImHex/include/helpers/disassembler.hpp
Mary 45c29888b4 Abstract capstone architectures
This allows to support older version of Capstone (example 4.0.1).

Should help with ubuntu building issues.
2020-12-05 17:32:30 +01:00

55 lines
1.3 KiB
C++

#pragma once
#include <capstone/capstone.h>
#include <hex.hpp>
namespace hex {
enum class Architecture : s32 {
ARM,
ARM64,
MIPS,
X86,
PPC,
SPARC,
SYSZ,
XCORE,
M68K,
TMS320C64X,
M680X,
EVM,
MAX,
MIN = ARM
};
class Disassembler {
public:
static constexpr cs_arch toCapstoneArchictecture(Architecture architecture) {
return static_cast<cs_arch>(architecture);
}
static inline bool isSupported(Architecture architecture) {
return cs_support(toCapstoneArchictecture(architecture));
}
constexpr static const char * const ArchitectureNames[] = { "ARM32", "ARM64", "MIPS", "x86", "PowerPC", "Sparc", "SystemZ", "XCore", "68K", "TMS320C64x", "680X", "Ethereum" };
static inline s32 getArchitectureSupportedCount() {
static s32 supportedCount = -1;
if (supportedCount != -1) {
return supportedCount;
}
for (supportedCount = static_cast<s32>(Architecture::MIN); supportedCount < static_cast<s32>(Architecture::MAX); supportedCount++) {
if (!cs_support(supportedCount)) {
break;
}
}
return supportedCount;
}
};
}