DBG: updated capstone wrapper functionality
This commit is contained in:
parent
f76d7c1933
commit
4429453728
|
@ -16,6 +16,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include <unordered_map>
|
||||
#include <tlhelp32.h>
|
||||
#include "..\x64_dbg_bridge\bridgemain.h"
|
||||
|
|
|
@ -27,12 +27,19 @@ Capstone::~Capstone()
|
|||
|
||||
bool Capstone::Disassemble(uint addr, unsigned char data[MAX_DISASM_BUFFER])
|
||||
{
|
||||
if(mInstr) //free last disassembled instruction
|
||||
return Disassemble(addr, data, MAX_DISASM_BUFFER);
|
||||
}
|
||||
|
||||
bool Capstone::Disassemble(uint addr, const unsigned char* data, int size)
|
||||
{
|
||||
if(!data)
|
||||
return false;
|
||||
if(mInstr) //free last disassembled instruction
|
||||
{
|
||||
cs_free(mInstr, 1);
|
||||
mInstr = 0;
|
||||
}
|
||||
return !!cs_disasm(mHandle, (const uint8_t*)data, MAX_DISASM_BUFFER, addr, 1, &mInstr);
|
||||
return !!cs_disasm(mHandle, (const uint8_t*)data, size, addr, 1, &mInstr);
|
||||
}
|
||||
|
||||
const cs_insn* Capstone::GetInstr()
|
||||
|
@ -120,4 +127,25 @@ String Capstone::OperandText(int opindex)
|
|||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
const int Capstone::Size()
|
||||
{
|
||||
return GetInstr()->size;
|
||||
}
|
||||
|
||||
const uint Capstone::Address()
|
||||
{
|
||||
return (uint)GetInstr()->address;
|
||||
}
|
||||
|
||||
const cs_x86 & Capstone::x86()
|
||||
{
|
||||
return GetInstr()->detail->x86;
|
||||
}
|
||||
|
||||
bool Capstone::IsFilling()
|
||||
{
|
||||
uint8_t opcode = x86().opcode[0];
|
||||
return opcode == 0x90 || opcode == 0xCC;
|
||||
}
|
|
@ -12,11 +12,16 @@ public:
|
|||
Capstone();
|
||||
~Capstone();
|
||||
bool Disassemble(uint addr, unsigned char data[MAX_DISASM_BUFFER]);
|
||||
bool Disassemble(uint addr, const unsigned char* data, int size);
|
||||
const cs_insn* GetInstr();
|
||||
const cs_err GetError();
|
||||
const char* RegName(x86_reg reg);
|
||||
bool InGroup(cs_group_type group);
|
||||
String OperandText(int opindex);
|
||||
const int Size();
|
||||
const uint Address();
|
||||
const cs_x86 & x86();
|
||||
bool IsFilling();
|
||||
|
||||
private:
|
||||
csh mHandle;
|
||||
|
|
Loading…
Reference in New Issue