diff --git a/include/Zydis/CommonTypes.h b/include/Zydis/CommonTypes.h index 8b0fd39..fbc5da0 100644 --- a/include/Zydis/CommonTypes.h +++ b/include/Zydis/CommonTypes.h @@ -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; diff --git a/include/Zydis/Defines.h b/include/Zydis/Defines.h index 1f94c18..9dd70f0 100644 --- a/include/Zydis/Defines.h +++ b/include/Zydis/Defines.h @@ -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 /* ============================================================================================== */ diff --git a/src/FormatHelper.c b/src/FormatHelper.c index 213ddf9..e54018e 100644 --- a/src/FormatHelper.c +++ b/src/FormatHelper.c @@ -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)