From 82b7599e15757fbb1990dea476233cca05a1f32a Mon Sep 17 00:00:00 2001 From: xorstream Date: Sat, 23 Jan 2016 09:47:29 +1100 Subject: [PATCH] Sorted uc_modes by CPU and added masks --- include/uc_priv.h | 9 +++++++++ include/unicorn/unicorn.h | 6 ------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/uc_priv.h b/include/uc_priv.h index 5cdf6557..6c7362bc 100644 --- a/include/uc_priv.h +++ b/include/uc_priv.h @@ -11,6 +11,15 @@ #include "unicorn/unicorn.h" #include "hook.h" +// These are masks of supported modes for each cpu/arch. +// They should be updated when changes are made to the uc_mode enum typedef. +#define UC_MODE_ARM_MASK (UC_MODE_ARM|UC_MODE_THUMB|UC_MODE_LITTLE_ENDIAN) +#define UC_MODE_MIPS_MASK (UC_MODE_MICRO|UC_MODE_MIPS3|UC_MODE_MIPS32R6|UC_MODE_MIPS32|UC_MODE_MIPS64|UC_MODE_LITTLE_ENDIAN|UC_MODE_BIG_ENDIAN) +#define UC_MODE_X86_MASK (UC_MODE_16|UC_MODE_32|UC_MODE_64|UC_MODE_LITTLE_ENDIAN) +#define UC_MODE_PPC_MASK (UC_MODE_PPC64|UC_MODE_QPX|UC_MODE_LITTLE_ENDIAN) +#define UC_MODE_SPARC_MASK (UC_MODE_V9|UC_MODE_LITTLE_ENDIAN) +#define UC_MODE_M68K_MASK (UC_MODE_LITTLE_ENDIAN) + #define ARR_SIZE(a) (sizeof(a)/sizeof(a[0])) QTAILQ_HEAD(CPUTailQ, CPUState); diff --git a/include/unicorn/unicorn.h b/include/unicorn/unicorn.h index ab1e65bb..5150d003 100644 --- a/include/unicorn/unicorn.h +++ b/include/unicorn/unicorn.h @@ -93,28 +93,22 @@ typedef enum uc_mode { UC_MODE_THUMB = 1 << 4, // ARM's Thumb mode, including Thumb-2 UC_MODE_MCLASS = 1 << 5, // ARM's Cortex-M series (currently unsupported) UC_MODE_V8 = 1 << 6, // ARMv8 A32 encodings for ARM (currently unsupported) - UC_MODE_ARM_MASK = UC_MODE_ARM|UC_MODE_THUMB|UC_MODE_LITTLE_ENDIAN, // mips UC_MODE_MICRO = 1 << 4, // MicroMips mode UC_MODE_MIPS3 = 1 << 5, // Mips III ISA UC_MODE_MIPS32R6 = 1 << 6, // Mips32r6 ISA UC_MODE_MIPS32 = 1 << 2, // Mips32 ISA UC_MODE_MIPS64 = 1 << 3, // Mips64 ISA - UC_MODE_MIPS_MASK = UC_MODE_MICRO|UC_MODE_MIPS3|UC_MODE_MIPS32R6|UC_MODE_MIPS32|UC_MODE_MIPS64|UC_MODE_LITTLE_ENDIAN|UC_MODE_BIG_ENDIAN, // x86 / x64 UC_MODE_16 = 1 << 1, // 16-bit mode UC_MODE_32 = 1 << 2, // 32-bit mode UC_MODE_64 = 1 << 3, // 64-bit mode - UC_MODE_X86_MASK = UC_MODE_16|UC_MODE_32|UC_MODE_64|UC_MODE_LITTLE_ENDIAN, // ppc UC_MODE_PPC64 = 1 << 3, // 64-bit mode UC_MODE_QPX = 1 << 4, // Quad Processing eXtensions mode - UC_MODE_PPC_MASK = UC_MODE_PPC64|UC_MODE_QPX|UC_MODE_LITTLE_ENDIAN, // sparc UC_MODE_V9 = 1 << 4, // SparcV9 mode - UC_MODE_SPARC_MASK = UC_MODE_V9|UC_MODE_LITTLE_ENDIAN, // m68k - UC_MODE_M68K_MASK = UC_MODE_LITTLE_ENDIAN, } uc_mode; // All type of errors encountered by Unicorn API.