本文整理汇总了C++中Disassembler::Disassemble方法的典型用法代码示例。如果您正苦于以下问题:C++ Disassembler::Disassemble方法的具体用法?C++ Disassembler::Disassemble怎么用?C++ Disassembler::Disassemble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Disassembler
的用法示例。
在下文中一共展示了Disassembler::Disassemble方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, const char* argv[])
{
if (argc != 3)
{
std::cerr << "Wrong number of parameters. Should be 2." << std::endl;
return 0;
}
Disassembler disassembler;
if (disassembler.LoadAssembly(argv[2]))
disassembler.Disassemble(std::cout);
return 0;
}
示例2: PostInit
virtual bool PostInit() override
{
auto func_base = (uintptr_t)this->GetFuncAddr();
auto l_is_call_to_addr = [](const auto& insn, void *addr){
if (insn.ID() != X86_INS_CALL) return false;
auto operands = insn.Operands();
if (operands.size() != 1) return false;
auto op0 = operands[0];
if (op0.Type() != X86_OP_IMM || op0.Imm_U32() != (uintptr_t)addr) return false;
return true;
};
auto l_is_push_imm32_arg = [](const auto& insn, uint32_t esp_off, uint32_t imm_val){
if (insn.ID() != X86_INS_MOV) return false;
auto operands = insn.Operands();
if (operands.size() != 2) return false;
auto op0 = operands[0];
if (op0.Type() != X86_OP_MEM || op0.Size() != 4 || op0.Mem_Seg() != X86_REG_INVALID ||
op0.Mem_Base() != X86_REG_ESP || op0.Mem_Index() != X86_REG_INVALID || op0.Mem_Disp() != esp_off) return false;
auto op1 = operands[1];
if (op1.Type() != X86_OP_IMM || op1.Size() != 4 || op1.Imm_U32() != imm_val) return false;
return true;
};
auto l_is_test_al = [](const auto& insn){
if (insn.ID() != X86_INS_TEST) return false;
auto operands = insn.Operands();
if (operands.size() != 2) return false;
auto op0 = operands[0];
if (op0.Type() != X86_OP_REG || op0.Reg() != X86_REG_AL) return false;
auto op1 = operands[1];
if (op1.Type() != X86_OP_REG || op1.Reg() != X86_REG_AL) return false;
return true;
};
auto l_is_jcc_imm = [](const auto& insn){
switch (insn.ID()) {
case X86_INS_JAE:
case X86_INS_JA:
case X86_INS_JBE:
case X86_INS_JB:
case X86_INS_JE:
case X86_INS_JGE:
case X86_INS_JG:
case X86_INS_JLE:
case X86_INS_JL:
case X86_INS_JNE:
case X86_INS_JNO:
case X86_INS_JNP:
case X86_INS_JNS:
case X86_INS_JO:
case X86_INS_JP:
case X86_INS_JS:
break;
default:
return false;
}
auto operands = insn.Operands();
if (operands.size() != 1) return false;
auto op0 = operands[0];
if (op0.Type() != X86_OP_IMM) return false;
return true;
};
void *call_target = AddrManager::GetAddr("CTFPlayer::IsPlayerClass");
if (call_target == nullptr) return false;
Disassembler<true> disasm;
auto result = disasm.Disassemble(func_base, s_DisasmLimit);
auto it_arg4 = result.end();
auto it_call = result.end();
auto it_test = result.end();
auto it_jcc = result.end();
for (auto i = result.begin(); i != result.end(); ++i) {
// auto insn = *i;
// uintptr_t off = insn.Addr() - func_base;
// if (off >= 0x5e2 && off < 0x600) {
// DevMsg("\n+0x%03x: %s %s\n", off, insn.MnemonicStr(), insn.OperandStr());
//
// DevMsg("Bytes:");
// for (auto byte : insn.Bytes()) {
// DevMsg(" %02X", byte);
//.........这里部分代码省略.........