Added support for compiling on ARM target

This commit is contained in:
Joel Höner 2017-11-26 04:38:32 +01:00
parent a835185da2
commit 56f47f4863
3 changed files with 18 additions and 11 deletions

View File

@ -63,8 +63,13 @@
typedef __int16 ZydisI16;
typedef __int32 ZydisI32;
typedef __int64 ZydisI64;
typedef ZydisU64 ZydisUSize;
typedef ZydisI64 ZydisISize;
# if _WIN64
typedef ZydisU64 ZydisUSize;
typedef ZydisI64 ZydisISize;
# else
typedef ZydisU32 ZydisUSize;
typedef ZydisI32 ZydisISize;
# endif
# elif defined(ZYDIS_GNUC)
typedef __UINT8_TYPE__ ZydisU8;
typedef __UINT16_TYPE__ ZydisU16;

View File

@ -72,19 +72,21 @@
#elif defined(__posix)
# define ZYDIS_POSIX
#else
# error "Unsupported platform detected"
# define ZYDIS_UNKNOWN_PLATFORM
#endif
/* ============================================================================================== */
/* Architecture detection */
/* ============================================================================================== */
#if defined (_M_AMD64) || defined (__x86_64__)
#if defined(_M_AMD64) || defined(__x86_64__)
# define ZYDIS_X64
# define ZYDIS_WORD_SIZE 64
#elif defined (_M_IX86) || defined (__i386__)
#elif defined(_M_IX86) || defined(__i386__)
# define ZYDIS_X86
# define ZYDIS_WORD_SIZE 32
#elif defined(_M_ARM64) || defined(__aarch64__)
# define ZYDIS_AARCH64
#elif defined(_M_ARM) || defined(_M_ARMT) || defined(__arm__) || defined(__thumb__)
# define ZYDIS_ARM
#else
# error "Unsupported architecture detected"
#endif
@ -106,7 +108,7 @@
# define ZYDIS_DEBUG
# endif
#else
# error "Unsupported compiler detected"
# define ZYDIS_RELEASE
#endif
/* ============================================================================================== */

View File

@ -98,7 +98,7 @@ void ZydisToUpperCase(char* buffer, ZydisUSize bufferLen)
}
}
#ifdef ZYDIS_X86
#if defined(ZYDIS_X86) || defined(ZYDIS_ARM)
ZydisStatus ZydisPrintDecU32(char** buffer, ZydisUSize bufferLen, ZydisU32 value, ZydisU8 paddingLength)
{
ZYDIS_ASSERT(buffer);
@ -354,7 +354,7 @@ ZydisStatus ZydisPrintStr(char** buffer, ZydisUSize bufferLen, const char* text,
ZydisStatus ZydisPrintDecU(char** buffer, ZydisUSize bufferLen, ZydisU64 value, ZydisU8 paddingLength)
{
#ifdef ZYDIS_X64
#if defined(ZYDIS_X64) || defined(ZYDIS_AARCH64)
return ZydisPrintDecU64(buffer, bufferLen, value, paddingLength);
#else
if (value & 0xFFFFFFFF00000000)
@ -380,7 +380,7 @@ ZydisStatus ZydisPrintDecS(char** buffer, ZydisUSize bufferLen, ZydisI64 value,
ZydisStatus ZydisPrintHexU(char** buffer, ZydisUSize bufferLen, ZydisU64 value, ZydisU8 paddingLength,
ZydisBool uppercase, const char* prefix, const char* suffix)
{
#ifdef ZYDIS_X64
#if defined(ZYDIS_X64) || defined(ZYDIS_AARCH64)
return ZydisPrintHexU64(buffer, bufferLen, value, paddingLength, uppercase, prefix, suffix);
#else
if (value & 0xFFFFFFFF00000000)