Renamed disassembler mode constants

ZYDIS_DISASSEMBLER_MODE_* -> ZYDIS_OPERATING_MODE_*
This commit is contained in:
Joel Höner 2017-04-12 21:12:18 +02:00
parent 71a6d786d7
commit 40d6c39dbe
7 changed files with 44 additions and 44 deletions

View File

@ -195,7 +195,7 @@ void disassembleBuffer(uint8_t* data, size_t length, ZydisBool installHooks)
ZydisInstructionInfo info;
char buffer[256];
while (ZYDIS_SUCCESS(
ZydisDecode(ZYDIS_DISASSEMBLER_MODE_64BIT, data, length, instructionPointer, &info)))
ZydisDecode(ZYDIS_OPERATING_MODE_64BIT, data, length, instructionPointer, &info)))
{
data += info.length;
length -= info.length;

View File

@ -401,13 +401,13 @@ typedef struct ZydisOperandInfo_
typedef uint8_t ZydisOperatingMode;
/**
* @brief Values that represent disassembler-modes.
* @brief Values that represent operating modes.
*/
enum ZydisDisassemblerModes
enum ZydisOperatingModes
{
ZYDIS_DISASSEMBLER_MODE_16BIT = 16,
ZYDIS_DISASSEMBLER_MODE_32BIT = 32,
ZYDIS_DISASSEMBLER_MODE_64BIT = 64
ZYDIS_OPERATING_MODE_16BIT = 16,
ZYDIS_OPERATING_MODE_32BIT = 32,
ZYDIS_OPERATING_MODE_64BIT = 64
};
/* ---------------------------------------------------------------------------------------------- */

View File

@ -512,7 +512,7 @@ static ZydisStatus ZydisCollectOptionalPrefixes(ZydisDecoderContext* ctx,
++info->details.prefixes.has67;
break;
default:
if ((ctx->operatingMode == ZYDIS_DISASSEMBLER_MODE_64BIT) &&
if ((ctx->operatingMode == ZYDIS_OPERATING_MODE_64BIT) &&
(prefixByte & 0xF0) == 0x40)
{
info->details.rex.data[0] = prefixByte;
@ -722,13 +722,13 @@ static ZydisStatus ZydisDecodeOperandModrmRm(ZydisDecoderContext* ctx,
}
switch (ctx->operatingMode)
{
case ZYDIS_DISASSEMBLER_MODE_16BIT: // TODO: Set ZYDIS_ATTRIB_ACCEPTS_ADDRESSSIZE and ZYDIS_ATTRIB_HAS_ADDRESSSIZE after getting the instruction definition
case ZYDIS_OPERATING_MODE_16BIT: // TODO: Set ZYDIS_ATTRIB_ACCEPTS_ADDRESSSIZE and ZYDIS_ATTRIB_HAS_ADDRESSSIZE after getting the instruction definition
operand->mem.addressSize = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 32 : 16;
break;
case ZYDIS_DISASSEMBLER_MODE_32BIT:
case ZYDIS_OPERATING_MODE_32BIT:
operand->mem.addressSize = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 16 : 32;
break;
case ZYDIS_DISASSEMBLER_MODE_64BIT:
case ZYDIS_OPERATING_MODE_64BIT:
operand->mem.addressSize = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 32 : 64;
break;
default:
@ -772,7 +772,7 @@ static ZydisStatus ZydisDecodeOperandModrmRm(ZydisDecoderContext* ctx,
case 0:
if (modrm_rm == 5)
{
if (ctx->operatingMode == ZYDIS_DISASSEMBLER_MODE_64BIT)
if (ctx->operatingMode == ZYDIS_OPERATING_MODE_64BIT)
{
info->attributes |= ZYDIS_ATTRIB_IS_RELATIVE;
operand->mem.base = ZYDIS_REGISTER_EIP;
@ -1035,11 +1035,11 @@ static ZydisStatus ZydisDecodeOperand(ZydisDecoderContext* ctx, ZydisInstruction
registerClass = ZYDIS_REGCLASS_TEST;
break;
case ZYDIS_SEM_OPERAND_TYPE_CR:
operand->size = (ctx->operatingMode == ZYDIS_DISASSEMBLER_MODE_64BIT) ? 64 : 32;
operand->size = (ctx->operatingMode == ZYDIS_OPERATING_MODE_64BIT) ? 64 : 32;
registerClass = ZYDIS_REGCLASS_CONTROL;
break;
case ZYDIS_SEM_OPERAND_TYPE_DR:
operand->size = (ctx->operatingMode == ZYDIS_DISASSEMBLER_MODE_64BIT) ? 64 : 32;
operand->size = (ctx->operatingMode == ZYDIS_OPERATING_MODE_64BIT) ? 64 : 32;
registerClass = ZYDIS_REGCLASS_DEBUG;
break;
case ZYDIS_SEM_OPERAND_TYPE_FPR:
@ -1512,13 +1512,13 @@ static ZydisStatus ZydisDecodeOperand(ZydisDecoderContext* ctx, ZydisInstruction
}
switch (ctx->operatingMode)
{
case ZYDIS_DISASSEMBLER_MODE_16BIT:
case ZYDIS_OPERATING_MODE_16BIT:
operand->mem.addressSize = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 32 : 16;
break;
case ZYDIS_DISASSEMBLER_MODE_32BIT:
case ZYDIS_OPERATING_MODE_32BIT:
operand->mem.addressSize = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 16 : 32;
break;
case ZYDIS_DISASSEMBLER_MODE_64BIT:
case ZYDIS_OPERATING_MODE_64BIT:
operand->mem.addressSize = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 32 : 64;
break;
default:
@ -1949,7 +1949,7 @@ static ZydisStatus ZydisNodeHandlerMode(ZydisDecoderContext* ctx, uint16_t* inde
ZYDIS_ASSERT(ctx);
ZYDIS_ASSERT(index);
*index = (ctx->operatingMode == ZYDIS_DISASSEMBLER_MODE_64BIT) ? 0 : 1;
*index = (ctx->operatingMode == ZYDIS_OPERATING_MODE_64BIT) ? 0 : 1;
return ZYDIS_STATUS_SUCCESS;
}
@ -2074,11 +2074,11 @@ static ZydisStatus ZydisNodeHandlerOperandSize(ZydisDecoderContext* ctx,
switch (ctx->operatingMode)
{
case ZYDIS_DISASSEMBLER_MODE_16BIT:
case ZYDIS_OPERATING_MODE_16BIT:
*index = (info->attributes & ZYDIS_ATTRIB_HAS_OPERANDSIZE) ? 1 : 0;
break;
case ZYDIS_DISASSEMBLER_MODE_32BIT:
case ZYDIS_DISASSEMBLER_MODE_64BIT:
case ZYDIS_OPERATING_MODE_32BIT:
case ZYDIS_OPERATING_MODE_64BIT:
*index = (info->attributes & ZYDIS_ATTRIB_HAS_OPERANDSIZE) ? 0 : 1;
break;
default:
@ -2102,13 +2102,13 @@ static ZydisStatus ZydisNodeHandlerAddressSize(ZydisDecoderContext* ctx,
switch (ctx->operatingMode)
{
case ZYDIS_DISASSEMBLER_MODE_16BIT:
case ZYDIS_OPERATING_MODE_16BIT:
*index = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 1 : 0;
break;
case ZYDIS_DISASSEMBLER_MODE_32BIT:
case ZYDIS_OPERATING_MODE_32BIT:
*index = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 0 : 1;
break;
case ZYDIS_DISASSEMBLER_MODE_64BIT:
case ZYDIS_OPERATING_MODE_64BIT:
*index = (info->attributes & ZYDIS_ATTRIB_HAS_ADDRESSSIZE) ? 1 : 2;
break;
default:
@ -2357,9 +2357,9 @@ ZydisStatus ZydisDecode(ZydisOperatingMode operatingMode, const void* buffer, si
ZydisStatus ZydisDecodeEx(ZydisOperatingMode operatingMode, const void* buffer, size_t bufferLen,
uint64_t instructionPointer, ZydisDecodeGranularity granularity, ZydisInstructionInfo* info)
{
if ((operatingMode != ZYDIS_DISASSEMBLER_MODE_16BIT) &&
(operatingMode != ZYDIS_DISASSEMBLER_MODE_32BIT) &&
(operatingMode != ZYDIS_DISASSEMBLER_MODE_64BIT))
if ((operatingMode != ZYDIS_OPERATING_MODE_16BIT) &&
(operatingMode != ZYDIS_OPERATING_MODE_32BIT) &&
(operatingMode != ZYDIS_OPERATING_MODE_64BIT))
{
return ZYDIS_STATUS_INVALID_PARAMETER;
}

View File

@ -607,7 +607,7 @@ static ZydisStatus ZydisPrepareMemoryOperand(ZydisEncoderContext* ctx,
ctx->dispBitSize = 32;
// In 32 bit mode, ModRM allows for a shortcut here.
if (ctx->info->mode == ZYDIS_DISASSEMBLER_MODE_32BIT)
if (ctx->info->mode == ZYDIS_OPERATING_MODE_32BIT)
{
ctx->info->details.modrm.mod = 0x00;
ctx->info->details.modrm.rm = 0x05 /* memory */;
@ -630,7 +630,7 @@ static ZydisStatus ZydisPrepareMemoryOperand(ZydisEncoderContext* ctx,
if (ZydisIsIPReg(operand->mem.base))
{
// rIP addressing is only available since AMD64.
if (ctx->info->mode != ZYDIS_DISASSEMBLER_MODE_64BIT)
if (ctx->info->mode != ZYDIS_OPERATING_MODE_64BIT)
{
return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO
}
@ -664,12 +664,12 @@ static ZydisStatus ZydisPrepareMemoryOperand(ZydisEncoderContext* ctx,
case ZYDIS_REGCLASS_GPR16:
switch (ctx->info->mode)
{
case ZYDIS_DISASSEMBLER_MODE_16BIT:
case ZYDIS_OPERATING_MODE_16BIT:
break; // Nothing to do.
case ZYDIS_DISASSEMBLER_MODE_32BIT:
case ZYDIS_OPERATING_MODE_32BIT:
ctx->info->attributes |= ZYDIS_ATTRIB_HAS_ADDRESSSIZE;
break;
case ZYDIS_DISASSEMBLER_MODE_64BIT:
case ZYDIS_OPERATING_MODE_64BIT:
// AMD64 doesn't allow for 16 bit addressing.
return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO
default:
@ -679,18 +679,18 @@ static ZydisStatus ZydisPrepareMemoryOperand(ZydisEncoderContext* ctx,
case ZYDIS_REGCLASS_GPR32:
switch (ctx->info->mode)
{
case ZYDIS_DISASSEMBLER_MODE_16BIT:
case ZYDIS_OPERATING_MODE_16BIT:
return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO
case ZYDIS_DISASSEMBLER_MODE_32BIT:
case ZYDIS_OPERATING_MODE_32BIT:
break; // Nothing to do.
case ZYDIS_DISASSEMBLER_MODE_64BIT:
case ZYDIS_OPERATING_MODE_64BIT:
ctx->info->attributes |= ZYDIS_ATTRIB_HAS_ADDRESSSIZE;
default:
return ZYDIS_STATUS_INVALID_PARAMETER; // TODO
}
break;
case ZYDIS_REGCLASS_GPR64:
if (ctx->info->mode != ZYDIS_DISASSEMBLER_MODE_64BIT)
if (ctx->info->mode != ZYDIS_OPERATING_MODE_64BIT)
{
return ZYDIS_STATUS_IMPOSSIBLE_INSTRUCTION; // TODO
}
@ -966,9 +966,9 @@ static ZydisStatus ZydisFindMatchingDef(const ZydisInstructionInfo* info,
if (curEntry->mnemonic != info->mnemonic ||
curEntry->operandCount != info->operandCount ||
curEntry->encoding != info->encoding ||
(info->mode == ZYDIS_DISASSEMBLER_MODE_64BIT &&
(info->mode == ZYDIS_OPERATING_MODE_64BIT &&
curEntry->modeConstraint == ZYDIS_MODE_CONSTR_EXCLUDE64) ||
(info->mode != ZYDIS_DISASSEMBLER_MODE_64BIT &&
(info->mode != ZYDIS_OPERATING_MODE_64BIT &&
curEntry->modeConstraint == ZYDIS_MODE_CONSTR_REQUIRE64))
{
continue;

View File

@ -393,11 +393,11 @@ static ZydisStatus ZydisFormatterPrintAddressIntel(ZydisInstructionFormatter* fo
switch (info->mode)
{
case ZYDIS_DISASSEMBLER_MODE_16BIT:
case ZYDIS_DISASSEMBLER_MODE_32BIT:
case ZYDIS_OPERATING_MODE_16BIT:
case ZYDIS_OPERATING_MODE_32BIT:
return ZydisStringBufferAppendFormat(buffer, bufferLen, ZYDIS_STRBUF_APPEND_MODE_DEFAULT,
"0x%08"PRIX64, address);
case ZYDIS_DISASSEMBLER_MODE_64BIT:
case ZYDIS_OPERATING_MODE_64BIT:
return ZydisStringBufferAppendFormat(buffer, bufferLen, ZYDIS_STRBUF_APPEND_MODE_DEFAULT,
"0x%016"PRIX64, address);
default:

View File

@ -68,14 +68,14 @@ ZydisStatus ZydisUtilsCalcAbsoluteTargetAddress(const ZydisInstructionInfo* info
(uint64_t)((int64_t)info->instrPointer + info->length + operand->imm.value.sqword);
switch (info->mode)
{
case ZYDIS_DISASSEMBLER_MODE_16BIT:
case ZYDIS_DISASSEMBLER_MODE_32BIT:
case ZYDIS_OPERATING_MODE_16BIT:
case ZYDIS_OPERATING_MODE_32BIT:
if (operand->size == 16)
{
*address &= 0xFFFF;
}
break;
case ZYDIS_DISASSEMBLER_MODE_64BIT:
case ZYDIS_OPERATING_MODE_64BIT:
break;
default:
return ZYDIS_STATUS_INVALID_PARAMETER;

View File

@ -70,7 +70,7 @@ int main(int argc, char** argv)
ZydisStatus status;
size_t readOffs = 0;
while ((status = ZydisDecode(
ZYDIS_DISASSEMBLER_MODE_64BIT,
ZYDIS_OPERATING_MODE_64BIT,
readBuf + readOffs,
numBytesRead - readOffs,
readOffs,