Collect asm operation type data.

This commit is contained in:
Bartosz Taudul 2022-09-11 00:30:37 +02:00
parent ad23932e9f
commit 9372d9fb28
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
2 changed files with 25 additions and 1 deletions

View File

@ -701,6 +701,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
const auto& detail = *op.detail;
bool hasJump = false;
bool jumpConditional = false;
OpType opType = OpType::None;
for( auto j=0; j<detail.groups_count; j++ )
{
if( detail.groups[j] == CS_GRP_JUMP || detail.groups[j] == CS_GRP_CALL || detail.groups[j] == CS_GRP_RET )
@ -709,6 +710,18 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
break;
}
}
for( auto j=0; j<detail.groups_count; j++ )
{
if( detail.groups[j] == CS_GRP_JUMP && opType < OpType::Jump ) opType = OpType::Jump;
else if( detail.groups[j] == CS_GRP_BRANCH_RELATIVE && opType < OpType::Branch ) opType = OpType::Branch;
else if( detail.groups[j] == CS_GRP_CALL && opType < OpType::Call ) opType = OpType::Call;
else if( detail.groups[j] == CS_GRP_RET && opType < OpType::Ret ) opType = OpType::Ret;
else if( detail.groups[j] == CS_GRP_PRIVILEGE && opType < OpType::Privileged )
{
opType = OpType::Privileged;
break;
}
}
uint64_t jumpAddr = 0;
if( hasJump )
{
@ -875,7 +888,7 @@ bool SourceView::Disassemble( uint64_t symAddr, const Worker& worker )
}
}
}
m_asm.emplace_back( AsmLine { op.address, jumpAddr, op.mnemonic, op.op_str, (uint8_t)op.size, leaData, jumpConditional, std::move( params ) } );
m_asm.emplace_back( AsmLine { op.address, jumpAddr, op.mnemonic, op.op_str, (uint8_t)op.size, leaData, opType, jumpConditional, std::move( params ) } );
#if CS_API_MAJOR >= 4
auto& entry = m_asm.back();

View File

@ -77,6 +77,16 @@ private:
enum { RegMask = 0x0FF };
enum { FlagMask = 0xF00 };
enum class OpType : uint8_t
{
None,
Jump,
Branch,
Call,
Ret,
Privileged
};
struct AsmLine
{
uint64_t addr;
@ -85,6 +95,7 @@ private:
std::string operands;
uint8_t len;
LeaData leaData;
OpType opType;
bool jumpConditional;
std::vector<AsmOpParams> params;
union