mirror of https://github.com/x64dbg/zydis
Minor changes to the operand formatter hooks
`ZYDIS_FORMATTER_HOOK_PRE_OPERAND` and `ZYDIS_FORMATTER_HOOK_POST_OPERAND` can be used to omit a specific operand, if you return a status-code different to `ZYDIS_STATUS_SUCCESS`.
This commit is contained in:
parent
ca9898fa42
commit
4e189721b2
|
@ -88,13 +88,16 @@ static ZydisStatus ZydisFormatInstrIntel(const ZydisFormatter* formatter, ZydisS
|
|||
ZYDIS_CHECK(ZydisStringAppendC(string, ", "));
|
||||
}
|
||||
|
||||
const ZydisUSize strLenPreOperand = string->length;
|
||||
if (formatter->funcPreOperand)
|
||||
{
|
||||
formatter->funcPreOperand(formatter, string, instruction, &instruction->operands[i],
|
||||
userData);
|
||||
if (!ZYDIS_SUCCESS(formatter->funcPreOperand(formatter, string, instruction,
|
||||
&instruction->operands[i], userData)))
|
||||
{
|
||||
goto SkipOperand;
|
||||
}
|
||||
}
|
||||
|
||||
const ZydisUSize strLenPreOperand = string->length;
|
||||
switch (instruction->operands[i].type)
|
||||
{
|
||||
case ZYDIS_OPERAND_TYPE_REGISTER:
|
||||
|
@ -125,9 +128,19 @@ static ZydisStatus ZydisFormatInstrIntel(const ZydisFormatter* formatter, ZydisS
|
|||
default:
|
||||
return ZYDIS_STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (formatter->funcPostOperand)
|
||||
{
|
||||
if (!ZYDIS_SUCCESS(formatter->funcPostOperand(formatter, string, instruction,
|
||||
&instruction->operands[i], userData)))
|
||||
{
|
||||
goto SkipOperand;
|
||||
}
|
||||
}
|
||||
|
||||
if (strLenPreOperand == string->length)
|
||||
{
|
||||
SkipOperand:
|
||||
// Omit whole operand, if the string did not change during the formatting-callback
|
||||
string->length = strLenRestore;
|
||||
|
||||
|
@ -140,12 +153,6 @@ static ZydisStatus ZydisFormatInstrIntel(const ZydisFormatter* formatter, ZydisS
|
|||
continue;
|
||||
}
|
||||
|
||||
if (formatter->funcPostOperand)
|
||||
{
|
||||
formatter->funcPostOperand(formatter, string, instruction, &instruction->operands[i],
|
||||
userData);
|
||||
}
|
||||
|
||||
if ((instruction->encoding == ZYDIS_INSTRUCTION_ENCODING_EVEX) ||
|
||||
(instruction->encoding == ZYDIS_INSTRUCTION_ENCODING_MVEX))
|
||||
{
|
||||
|
@ -902,6 +909,10 @@ ZydisStatus ZydisFormatterInit(ZydisFormatter* formatter, ZydisFormatterStyle st
|
|||
switch (style)
|
||||
{
|
||||
case ZYDIS_FORMATTER_STYLE_INTEL:
|
||||
formatter->funcPreInstruction = ZYDIS_NULL;
|
||||
formatter->funcPostInstruction = ZYDIS_NULL;
|
||||
formatter->funcPreOperand = ZYDIS_NULL;
|
||||
formatter->funcPostOperand = ZYDIS_NULL;
|
||||
formatter->funcFormatInstruction = &ZydisFormatInstrIntel;
|
||||
formatter->funcFormatOperandReg = &ZydisFormatOperandRegIntel;
|
||||
formatter->funcFormatOperandMem = &ZydisFormatOperandMemIntel;
|
||||
|
|
Loading…
Reference in New Issue