Skip to content

Java binding broken: Considered registers not in sync with the binding code #3054

Description

@PAX523

Work environment

Questions Answers
System Capstone runs on OS/arch/bits Debian
Capstone module affected x86
Source of Capstone git clone
Version/git commit v6, (next)

Expected behavior

If you leverage the Java binding for disassembling, you successfully receive the assembly

Actual behavior

The Java binding fails at the very beginning due to an illegal array index access on the Java binding-side

Steps to reproduce the behavior

I've attached a very simple Portable Executable: example-portable-executable.zip

  • inline-strings.pe: the original Portable Executable created with Flat Assembler
  • inline-strings.hex: only the opcodes to be disassembled in hex notation
  • inline-strings.asm: the original assembly used in Flat Assembler
Capstone disassembler = new Capstone(Capstone.CS_ARCH_X86, Capstone.CS_MODE_32);
disassembler.disasm(bytesToDisassemble, 4198400);

See: Example.java

Additional Logs, screenshots, source code, configuration dump, ...

It's eye-catching that the C header file Capstone.h specifies this constant:

#define MAX_IMPL_R_REGS 20

But the corresponding Java binding Capstone.java specifies an old size from before the refactoring:

public short[] regs_read = new short[16];

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething is not working as it shouldjavabindings

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions