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, ", "));
|
ZYDIS_CHECK(ZydisStringAppendC(string, ", "));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ZydisUSize strLenPreOperand = string->length;
|
||||||
if (formatter->funcPreOperand)
|
if (formatter->funcPreOperand)
|
||||||
{
|
{
|
||||||
formatter->funcPreOperand(formatter, string, instruction, &instruction->operands[i],
|
if (!ZYDIS_SUCCESS(formatter->funcPreOperand(formatter, string, instruction,
|
||||||
userData);
|
&instruction->operands[i], userData)))
|
||||||
|
{
|
||||||
|
goto SkipOperand;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ZydisUSize strLenPreOperand = string->length;
|
|
||||||
switch (instruction->operands[i].type)
|
switch (instruction->operands[i].type)
|
||||||
{
|
{
|
||||||
case ZYDIS_OPERAND_TYPE_REGISTER:
|
case ZYDIS_OPERAND_TYPE_REGISTER:
|
||||||
|
@ -126,8 +129,18 @@ static ZydisStatus ZydisFormatInstrIntel(const ZydisFormatter* formatter, ZydisS
|
||||||
return ZYDIS_STATUS_INVALID_PARAMETER;
|
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)
|
if (strLenPreOperand == string->length)
|
||||||
{
|
{
|
||||||
|
SkipOperand:
|
||||||
// Omit whole operand, if the string did not change during the formatting-callback
|
// Omit whole operand, if the string did not change during the formatting-callback
|
||||||
string->length = strLenRestore;
|
string->length = strLenRestore;
|
||||||
|
|
||||||
|
@ -140,12 +153,6 @@ static ZydisStatus ZydisFormatInstrIntel(const ZydisFormatter* formatter, ZydisS
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formatter->funcPostOperand)
|
|
||||||
{
|
|
||||||
formatter->funcPostOperand(formatter, string, instruction, &instruction->operands[i],
|
|
||||||
userData);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((instruction->encoding == ZYDIS_INSTRUCTION_ENCODING_EVEX) ||
|
if ((instruction->encoding == ZYDIS_INSTRUCTION_ENCODING_EVEX) ||
|
||||||
(instruction->encoding == ZYDIS_INSTRUCTION_ENCODING_MVEX))
|
(instruction->encoding == ZYDIS_INSTRUCTION_ENCODING_MVEX))
|
||||||
{
|
{
|
||||||
|
@ -902,6 +909,10 @@ ZydisStatus ZydisFormatterInit(ZydisFormatter* formatter, ZydisFormatterStyle st
|
||||||
switch (style)
|
switch (style)
|
||||||
{
|
{
|
||||||
case ZYDIS_FORMATTER_STYLE_INTEL:
|
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->funcFormatInstruction = &ZydisFormatInstrIntel;
|
||||||
formatter->funcFormatOperandReg = &ZydisFormatOperandRegIntel;
|
formatter->funcFormatOperandReg = &ZydisFormatOperandRegIntel;
|
||||||
formatter->funcFormatOperandMem = &ZydisFormatOperandMemIntel;
|
formatter->funcFormatOperandMem = &ZydisFormatOperandMemIntel;
|
||||||
|
|
Loading…
Reference in New Issue