Formatter does now print the `far` modifier for the respective instructions

This commit is contained in:
flobernd 2017-09-23 19:46:27 +02:00
parent 6315e29aa5
commit 2145c399b5
3 changed files with 17 additions and 4 deletions

View File

@ -70,16 +70,16 @@ typedef uint32_t ZydisFormatterFlags;
/**
* @brief Formats the instruction in uppercase instead of lowercase.
*/
#define ZYDIS_FMTFLAG_UPPERCASE 0x00000001
#define ZYDIS_FMTFLAG_UPPERCASE 0x00000001 // (1 << 0)
/**
* @brief Forces the formatter to always print the segment register of memory-operands, instead
* of ommiting implicit DS/SS segments.
*/
#define ZYDIS_FMTFLAG_FORCE_SEGMENTS 0x00000002
#define ZYDIS_FMTFLAG_FORCE_SEGMENTS 0x00000002 // (1 << 1)
/**
* @brief Forces the formatter to always print the size of memory-operands.
*/
#define ZYDIS_FMTFLAG_FORCE_OPERANDSIZE 0x00000004
#define ZYDIS_FMTFLAG_FORCE_OPERANDSIZE 0x00000004 // (1 << 2)
/* ---------------------------------------------------------------------------------------------- */

View File

@ -2032,6 +2032,10 @@ static void ZydisSetAttributes(ZydisDecoderContext* context, ZydisDecodedInstruc
}
if (def->isFarBranch)
{
ZYDIS_ASSERT((instruction->meta.category == ZYDIS_CATEGORY_CALL) ||
(instruction->meta.category == ZYDIS_CATEGORY_COND_BR) ||
(instruction->meta.category == ZYDIS_CATEGORY_UNCOND_BR) ||
(instruction->meta.category == ZYDIS_CATEGORY_RET));
instruction->attributes |= ZYDIS_ATTRIB_IS_FAR_BRANCH;
}
if (def->acceptsLock)

View File

@ -97,12 +97,21 @@ static ZydisStatus ZydisFormatterPrintMnemonicIntel(const ZydisFormatter* format
return ZYDIS_STATUS_INVALID_PARAMETER;
}
char* bufEnd = *buffer + bufferLen;
const char* mnemonic = ZydisMnemonicGetString(instruction->mnemonic);
if (!mnemonic)
{
mnemonic = "invalid";
}
return ZydisPrintStr(buffer, bufferLen, mnemonic, ZYDIS_LETTER_CASE);
ZYDIS_CHECK(ZydisPrintStr(buffer, bufferLen, mnemonic, ZYDIS_LETTER_CASE));
if (instruction->attributes & ZYDIS_ATTRIB_IS_FAR_BRANCH)
{
return ZydisPrintStr(buffer, bufEnd - *buffer, " far", ZYDIS_LETTER_CASE);
}
return ZYDIS_STATUS_SUCCESS;
}
/* ---------------------------------------------------------------------------------------------- */