Refactor zydis wrapper

This commit is contained in:
G0lge 2024-06-14 21:37:10 +03:00
parent f518e507c2
commit bc9f7105fc
2 changed files with 10 additions and 8 deletions

View File

@ -101,8 +101,6 @@ bool Zydis::Disassemble(uint64_t addr, const unsigned char* data, size_t size)
nullptr)))
return false;
// Count explicit operands.
mVisibleOpCount = 0;
for(ZyanU8 i = 0; i < mInstr.info.operand_count; ++i)
{
auto & op = mInstr.operands[i];
@ -125,10 +123,6 @@ bool Zydis::Disassemble(uint64_t addr, const unsigned char* data, size_t size)
ZydisCalcAbsoluteAddress(&mInstr.info, &op, mAddr, (uint64_t*)&op.mem.disp.value);
}
if(op.visibility == ZYDIS_OPERAND_VISIBILITY_HIDDEN)
break;
++mVisibleOpCount;
}
mSuccess = true;
@ -369,11 +363,19 @@ std::string Zydis::InstructionText(bool replaceRipRelative) const
return result;
}
uint8_t Zydis::VisibleOpCount() const
{
if(!Success())
return 0;
return mInstr.info.operand_count_visible;
}
uint8_t Zydis::OpCount() const
{
if(!Success())
return 0;
return mVisibleOpCount;
return mInstr.info.operand_count;
}
const ZydisDecodedOperand & Zydis::operator[](uint8_t index) const

View File

@ -38,6 +38,7 @@ public:
ZydisMnemonic GetId() const;
std::string InstructionText(bool replaceRipRelative = true) const;
uint8_t OpCount() const;
uint8_t VisibleOpCount() const;
const ZydisDecodedOperand & operator[](uint8_t index) const;
std::string Mnemonic() const;
const char* MemSizeName(size_t size) const;
@ -125,5 +126,4 @@ private:
ZydisDisassembledInstruction mInstr;
char mInstrText[200];
bool mSuccess = false;
uint8_t mVisibleOpCount = 0;
};