capstone-engine / capstone

Capstone disassembly/disassembler framework for ARM, ARM64 (ARMv8), Alpha, BPF, Ethereum VM, HPPA, LoongArch, M68K, M680X, Mips, MOS65XX, PPC, RISC-V(rv32G/rv64G), SH, Sparc, SystemZ, TMS320C64X, TriCore, Webassembly, XCore and X86.
http://www.capstone-engine.org
7.34k stars 1.54k forks source link

Basic Blocks #1143

Open fred26 opened 6 years ago

fred26 commented 6 years ago

Trying to create basic blocks in x86 x64 mode.

Using modified version of:

https://github.com/aquynh/capstone/blob/master/tests/test_x86.c

Is there away to ask cs_disasm to stop disassembling when an instruction belongs to a jump group (CALL/JNZ/CMOVNE)?

Thanks

aquynh commented 6 years ago

no.

pfalcon commented 6 years ago

Of course there's a way - you disassemble instructions one by one, check groups, and stop when groups match what you want. The issue, Capstone's group support across architectures leaves much to be desired, e.g. https://github.com/aquynh/capstone/issues/1072

r4dr3fr4d commented 6 years ago

@fred26, were you able to implement a solution for this? If not, I may have some code that can help; I've had to do the same thing.

niucool commented 11 months ago

@r4dr3fr4d can you show some code to get basic blocks with the help of capstone?

r4dr3fr4d commented 10 months ago

@niucool I no longer have it handy, but it's going to entail looking for the branching instructions manually. This feature is out of scope for capstone, I imagine. Recommend this issue be closed @aquynh