mirror of https://github.com/x64dbg/zydis
Added information for VEX/EVEX/MVEX instructions with static broadcast-factor
This commit is contained in:
parent
cd3bf5586b
commit
b3d508850f
|
@ -752,8 +752,14 @@ enum ZydisBroadcastModes
|
||||||
ZYDIS_BROADCAST_MODE_1_TO_4,
|
ZYDIS_BROADCAST_MODE_1_TO_4,
|
||||||
ZYDIS_BROADCAST_MODE_1_TO_8,
|
ZYDIS_BROADCAST_MODE_1_TO_8,
|
||||||
ZYDIS_BROADCAST_MODE_1_TO_16,
|
ZYDIS_BROADCAST_MODE_1_TO_16,
|
||||||
|
ZYDIS_BROADCAST_MODE_1_TO_32,
|
||||||
|
ZYDIS_BROADCAST_MODE_1_TO_64,
|
||||||
|
ZYDIS_BROADCAST_MODE_2_TO_4,
|
||||||
|
ZYDIS_BROADCAST_MODE_2_TO_8,
|
||||||
|
ZYDIS_BROADCAST_MODE_2_TO_16,
|
||||||
ZYDIS_BROADCAST_MODE_4_TO_8,
|
ZYDIS_BROADCAST_MODE_4_TO_8,
|
||||||
ZYDIS_BROADCAST_MODE_4_TO_16
|
ZYDIS_BROADCAST_MODE_4_TO_16,
|
||||||
|
ZYDIS_BROADCAST_MODE_8_TO_16
|
||||||
};
|
};
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -541,6 +541,54 @@ enum ZydisMVEXFunctionalities
|
||||||
|
|
||||||
/* ---------------------------------------------------------------------------------------------- */
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Defines the @c ZydisVEXStaticBroadcast datatype.
|
||||||
|
*/
|
||||||
|
typedef uint8_t ZydisVEXStaticBroadcast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Values that represent static VEX-broadcasts.
|
||||||
|
*/
|
||||||
|
enum ZydisVEXStaticBroadcasts
|
||||||
|
{
|
||||||
|
ZYDIS_VEX_STATIC_BROADCAST_NONE,
|
||||||
|
ZYDIS_VEX_STATIC_BROADCAST_1_TO_2,
|
||||||
|
ZYDIS_VEX_STATIC_BROADCAST_1_TO_4,
|
||||||
|
ZYDIS_VEX_STATIC_BROADCAST_1_TO_8,
|
||||||
|
ZYDIS_VEX_STATIC_BROADCAST_1_TO_16,
|
||||||
|
ZYDIS_VEX_STATIC_BROADCAST_1_TO_32,
|
||||||
|
ZYDIS_VEX_STATIC_BROADCAST_2_TO_4
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Defines the @c ZydisEVEXStaticBroadcast datatype.
|
||||||
|
*/
|
||||||
|
typedef uint8_t ZydisEVEXStaticBroadcast;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Values that represent static EVEX-broadcasts.
|
||||||
|
*/
|
||||||
|
enum ZydisEVEXStaticBroadcasts
|
||||||
|
{
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_NONE,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_2,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_4,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_8,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_16,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_32,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_64,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_2_TO_4,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_2_TO_8,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_2_TO_16,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_4_TO_8,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_4_TO_16,
|
||||||
|
ZYDIS_EVEX_STATIC_BROADCAST_8_TO_16
|
||||||
|
};
|
||||||
|
|
||||||
|
/* ---------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Defines the @c ZydisMVEXStaticBroadcast datatype.
|
* @brief Defines the @c ZydisMVEXStaticBroadcast datatype.
|
||||||
*/
|
*/
|
||||||
|
@ -629,7 +677,8 @@ typedef struct ZydisInstructionDefinitionXOP_
|
||||||
|
|
||||||
typedef struct ZydisInstructionDefinitionVEX_
|
typedef struct ZydisInstructionDefinitionVEX_
|
||||||
{
|
{
|
||||||
ZydisInstructionDefinition base;
|
ZYDIS_INSTRUCTION_DEFINITION_BASE;
|
||||||
|
ZydisVEXStaticBroadcast broadcast : 3;
|
||||||
} ZydisInstructionDefinitionVEX;
|
} ZydisInstructionDefinitionVEX;
|
||||||
|
|
||||||
typedef struct ZydisInstructionDefinitionEVEX_
|
typedef struct ZydisInstructionDefinitionEVEX_
|
||||||
|
@ -640,6 +689,7 @@ typedef struct ZydisInstructionDefinitionEVEX_
|
||||||
ZydisInternalElementSize elementSize : 4;
|
ZydisInternalElementSize elementSize : 4;
|
||||||
ZydisEVEXFunctionality functionality : 2;
|
ZydisEVEXFunctionality functionality : 2;
|
||||||
ZydisMaskPolicy maskPolicy : 2;
|
ZydisMaskPolicy maskPolicy : 2;
|
||||||
|
ZydisEVEXStaticBroadcast broadcast : 4;
|
||||||
} ZydisInstructionDefinitionEVEX;
|
} ZydisInstructionDefinitionEVEX;
|
||||||
|
|
||||||
typedef struct ZydisInstructionDefinitionMVEX_
|
typedef struct ZydisInstructionDefinitionMVEX_
|
||||||
|
|
135
src/Decoder.c
135
src/Decoder.c
|
@ -2258,6 +2258,61 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
|
||||||
|
|
||||||
switch (info->encoding)
|
switch (info->encoding)
|
||||||
{
|
{
|
||||||
|
case ZYDIS_INSTRUCTION_ENCODING_XOP:
|
||||||
|
{
|
||||||
|
// Vector length
|
||||||
|
static const ZydisVectorLength lookup[2] =
|
||||||
|
{
|
||||||
|
ZYDIS_VECTOR_LENGTH_128,
|
||||||
|
ZYDIS_VECTOR_LENGTH_256
|
||||||
|
};
|
||||||
|
ZYDIS_ASSERT(context->cache.LL < ZYDIS_ARRAY_SIZE(lookup));
|
||||||
|
info->avx.vectorLength = lookup[context->cache.LL];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case ZYDIS_INSTRUCTION_ENCODING_VEX:
|
||||||
|
{
|
||||||
|
// Vector length
|
||||||
|
static const ZydisVectorLength lookup[2] =
|
||||||
|
{
|
||||||
|
ZYDIS_VECTOR_LENGTH_128,
|
||||||
|
ZYDIS_VECTOR_LENGTH_256
|
||||||
|
};
|
||||||
|
ZYDIS_ASSERT(context->cache.LL < ZYDIS_ARRAY_SIZE(lookup));
|
||||||
|
info->avx.vectorLength = lookup[context->cache.LL];
|
||||||
|
|
||||||
|
// Static broadcast-factor
|
||||||
|
const ZydisInstructionDefinitionVEX* def =
|
||||||
|
(const ZydisInstructionDefinitionVEX*)definition;
|
||||||
|
if (def->broadcast)
|
||||||
|
{
|
||||||
|
info->avx.broadcast.isStatic = ZYDIS_TRUE;
|
||||||
|
switch (def->broadcast)
|
||||||
|
{
|
||||||
|
case ZYDIS_VEX_STATIC_BROADCAST_1_TO_2:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_2;
|
||||||
|
break;
|
||||||
|
case ZYDIS_VEX_STATIC_BROADCAST_1_TO_4:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_4;
|
||||||
|
break;
|
||||||
|
case ZYDIS_VEX_STATIC_BROADCAST_1_TO_8:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_8;
|
||||||
|
break;
|
||||||
|
case ZYDIS_VEX_STATIC_BROADCAST_1_TO_16:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_16;
|
||||||
|
break;
|
||||||
|
case ZYDIS_VEX_STATIC_BROADCAST_1_TO_32:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_32;
|
||||||
|
break;
|
||||||
|
case ZYDIS_VEX_STATIC_BROADCAST_2_TO_4:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_2_TO_4;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ZYDIS_UNREACHABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case ZYDIS_INSTRUCTION_ENCODING_EVEX:
|
case ZYDIS_INSTRUCTION_ENCODING_EVEX:
|
||||||
{
|
{
|
||||||
const ZydisInstructionDefinitionEVEX* def =
|
const ZydisInstructionDefinitionEVEX* def =
|
||||||
|
@ -2269,20 +2324,15 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
|
||||||
{
|
{
|
||||||
vectorLength = def->vectorLength - 1;
|
vectorLength = def->vectorLength - 1;
|
||||||
}
|
}
|
||||||
switch (vectorLength)
|
// Vector length
|
||||||
{
|
static const ZydisVectorLength lookup[3] =
|
||||||
case 0:
|
{
|
||||||
info->avx.vectorLength = ZYDIS_VECTOR_LENGTH_128;
|
ZYDIS_VECTOR_LENGTH_128,
|
||||||
break;
|
ZYDIS_VECTOR_LENGTH_256,
|
||||||
case 1:
|
ZYDIS_VECTOR_LENGTH_512
|
||||||
info->avx.vectorLength = ZYDIS_VECTOR_LENGTH_256;
|
};
|
||||||
break;
|
ZYDIS_ASSERT(context->cache.LL < ZYDIS_ARRAY_SIZE(lookup));
|
||||||
case 2:
|
info->avx.vectorLength = lookup[context->cache.LL];
|
||||||
info->avx.vectorLength = ZYDIS_VECTOR_LENGTH_512;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ZYDIS_UNREACHABLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
context->evex.tupleType = def->tupleType;
|
context->evex.tupleType = def->tupleType;
|
||||||
if (def->tupleType)
|
if (def->tupleType)
|
||||||
|
@ -2585,6 +2635,54 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
|
||||||
ZYDIS_ASSERT(info->details.modrm.mod == 3);
|
ZYDIS_ASSERT(info->details.modrm.mod == 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Static broadcast-factor
|
||||||
|
if (def->broadcast)
|
||||||
|
{
|
||||||
|
ZYDIS_ASSERT(!info->avx.broadcast.mode);
|
||||||
|
info->avx.broadcast.isStatic = ZYDIS_TRUE;
|
||||||
|
switch (def->broadcast)
|
||||||
|
{
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_1_TO_2:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_2;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_1_TO_4:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_4;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_1_TO_8:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_8;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_1_TO_16:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_16;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_1_TO_32:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_32;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_1_TO_64:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_1_TO_64;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_2_TO_4:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_2_TO_4;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_2_TO_8:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_2_TO_8;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_2_TO_16:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_2_TO_16;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_4_TO_8:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_4_TO_8;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_4_TO_16:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_4_TO_16;
|
||||||
|
break;
|
||||||
|
case ZYDIS_EVEX_STATIC_BROADCAST_8_TO_16:
|
||||||
|
info->avx.broadcast.mode = ZYDIS_BROADCAST_MODE_8_TO_16;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ZYDIS_UNREACHABLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Rounding mode and SAE
|
// Rounding mode and SAE
|
||||||
if (info->details.evex.b)
|
if (info->details.evex.b)
|
||||||
{
|
{
|
||||||
|
@ -2617,7 +2715,7 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
|
||||||
const ZydisInstructionDefinitionMVEX* def =
|
const ZydisInstructionDefinitionMVEX* def =
|
||||||
(const ZydisInstructionDefinitionMVEX*)definition;
|
(const ZydisInstructionDefinitionMVEX*)definition;
|
||||||
|
|
||||||
// Compressed disp8 scale and broadcast-factor
|
// Static broadcast-factor
|
||||||
uint8_t index = def->hasElementGranularity;
|
uint8_t index = def->hasElementGranularity;
|
||||||
ZYDIS_ASSERT(!index || !def->broadcast);
|
ZYDIS_ASSERT(!index || !def->broadcast);
|
||||||
if (!index && def->broadcast)
|
if (!index && def->broadcast)
|
||||||
|
@ -2645,6 +2743,8 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
|
||||||
ZYDIS_UNREACHABLE;
|
ZYDIS_UNREACHABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compressed disp8 scale and broadcast-factor
|
||||||
switch (def->functionality)
|
switch (def->functionality)
|
||||||
{
|
{
|
||||||
case ZYDIS_MVEX_FUNC_INVALID:
|
case ZYDIS_MVEX_FUNC_INVALID:
|
||||||
|
@ -2772,6 +2872,9 @@ static void ZydisSetAVXInformation(ZydisDecoderContext* context,
|
||||||
case 4:
|
case 4:
|
||||||
info->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT8;
|
info->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT8;
|
||||||
break;
|
break;
|
||||||
|
case 5:
|
||||||
|
info->avx.conversionMode = ZYDIS_CONVERSION_MODE_SINT8;
|
||||||
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
info->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT16;
|
info->avx.conversionMode = ZYDIS_CONVERSION_MODE_UINT16;
|
||||||
break;
|
break;
|
||||||
|
@ -3602,7 +3705,7 @@ static ZydisStatus ZydisDecodeInstruction(ZydisDecoderContext* context, ZydisIns
|
||||||
// ZYDIS_MVEX_FUNC_SWIZZLE_64
|
// ZYDIS_MVEX_FUNC_SWIZZLE_64
|
||||||
{ 1, 1, 1, 1, 1, 1, 1, 1 },
|
{ 1, 1, 1, 1, 1, 1, 1, 1 },
|
||||||
// ZYDIS_MVEX_FUNC_SF_32
|
// ZYDIS_MVEX_FUNC_SF_32
|
||||||
{ 1, 1, 1, 1, 1, 0, 1, 1 },
|
{ 1, 1, 1, 1, 1, 1, 1, 1 },
|
||||||
// ZYDIS_MVEX_FUNC_SF_32_BCST
|
// ZYDIS_MVEX_FUNC_SF_32_BCST
|
||||||
{ 1, 1, 1, 0, 0, 0, 0, 0 },
|
{ 1, 1, 1, 0, 0, 0, 0, 0 },
|
||||||
// ZYDIS_MVEX_FUNC_SF_32_BCST_4TO16
|
// ZYDIS_MVEX_FUNC_SF_32_BCST_4TO16
|
||||||
|
|
Loading…
Reference in New Issue