I am looking for a Java x86 disassembler library that should have following features:
So, if I have some code that would disassemble like this:
MOV EAX, EBX
CALL 1234
JMP 88
then the library should create three objects for MOV, CALL and JMP. Then I implement a visitor that does diverse things (ex: interpreting, converting to x64 or to an instruction for another processor architecture).
Thanks in advance.
I don't know about any such library implemented entirely Java. Although, I do heard about distorm disassembler. It is developed in C. But Java wrappers are available for this library. Have a look at it. It may be useful for you.
Well, not quite. But there are Java bindings for e.g. Capstone.
Here are maven bindings. Here you can download the native libraries. Here is a Java code example.
// Test.java
import capstone.Capstone;
public class Test {
  public static byte [] CODE = { 0x55, 0x48, (byte) 0x8b, 0x05, (byte) 0xb8,
    0x13, 0x00, 0x00 };
  public static void main(String argv[]) {
    Capstone cs = new Capstone(Capstone.CS_ARCH_X86, Capstone.CS_MODE_64);
    Capstone.CsInsn[] allInsn = cs.disasm(CODE, 0x1000);
    for (int i=0; i<allInsn.length; i++)
      System.out.printf("0x%x:\t%s\t%s\n", allInsn[i].address,
          allInsn[i].mnemonic, allInsn[i].opStr);
  }
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With