今天我试着从顶石开始。按照他们的例子,这里,我想开始使用这个库。不幸的是,capstone并没有产生asm指令的最后一行,它将其反汇编。它只产生一个空行。
代码:
#include <stdio.h>
#include <inttypes.h>
#include <string>
#include <iostream>
#include <capstone/capstone.h>
int main(void)
{
csh handle;
cs_insn *insn;
size_t count;
const uint8_t CODE[] = {0x55,0x48,0x8b,0x05,0xb8,0x13,0x00,0x00};
if (cs_open(CS_ARCH_X86, CS_MODE_64, &handle) != CS_ERR_OK)
return -1;
count = cs_disasm_ex(handle, CODE, sizeof(CODE)-1, 0x1000, 0, &insn);
if (count > 0) {
size_t j;
for (j = 0; j < count; j++) {
printf("0x%" PRIx64":\t%s\t\t%s\n", insn[j].address, insn[j].mnemonic,
insn[j].op_str);
}
cs_free(insn, count);
} else
printf("ERROR: Failed to disassemble given code!\n");
cs_close(&handle);
return 0;
}而不是得到
0x1000: push rbp
0x1001: mov rax, qword ptr [rip + 0x13b8]我得到了
0x1000: push rbp最后一行是打印的,但是是空的。
有人能帮我解决这个问题吗?
发布于 2014-07-17 08:30:07
你不该这么做吗
cs_disasm_ex(handle, CODE, sizeof(CODE), 0x1000, 0, &insn);而不是
cs_disasm_ex(handle, CODE, sizeof(CODE)-1, 0x1000, 0, &insn);https://stackoverflow.com/questions/24798006
复制相似问题