diff --git a/bindings/java/capstone/Capstone.java b/bindings/java/capstone/Capstone.java index 0c9d3136..0c1475cf 100644 --- a/bindings/java/capstone/Capstone.java +++ b/bindings/java/capstone/Capstone.java @@ -33,12 +33,19 @@ public class Capstone { } protected static class _cs_insn extends Structure { + // instruction ID. public int id; + // instruction address. public long address; + // instruction size. public short size; + // machine bytes of instruction. public byte[] bytes; + // instruction mnemonic. NOTE: irrelevant for diet engine. public byte[] mnemonic; + // instruction operands. NOTE: irrelevant for diet engine. public byte[] operands; + // detail information of instruction. public _cs_detail.ByReference cs_detail; public _cs_insn() { @@ -62,10 +69,13 @@ public class Capstone { protected static class _cs_detail extends Structure { public static class ByReference extends _cs_detail implements Structure.ByReference {}; + // list of all implicit registers being read. public byte[] regs_read = new byte[12]; public byte regs_read_count; + // list of all implicit registers being written. public byte[] regs_write = new byte[20]; public byte regs_write_count; + // list of semantic groups this instruction belongs to. public byte[] groups = new byte[8]; public byte groups_count; @@ -83,38 +93,51 @@ public class Capstone { private _cs_insn raw; private int arch; + // instruction ID. public int id; + // instruction address. public long address; + // instruction size. public short size; + // instruction mnemonic. NOTE: irrelevant for diet engine. public String mnemonic; + // instruction operands. NOTE: irrelevant for diet engine. public String opStr; + // list of all implicit registers being read. public byte[] regsRead; + // list of all implicit registers being written. public byte[] regsWrite; + // list of semantic groups this instruction belongs to. public byte[] groups; public OpInfo operands; - public CsInsn (_cs_insn insn, int _arch, NativeLong _csh, CS _cs) { + public CsInsn (_cs_insn insn, int _arch, NativeLong _csh, CS _cs, boolean diet) { id = insn.id; address = insn.address; size = insn.size; - mnemonic = new String(insn.mnemonic).replace("\u0000",""); - opStr = new String(insn.operands).replace("\u0000",""); + if (!diet) { + mnemonic = new String(insn.mnemonic).replace("\u0000",""); + opStr = new String(insn.operands).replace("\u0000",""); + } + + cs = _cs; arch = _arch; raw = insn; csh = _csh; - cs = _cs; if (insn.cs_detail != null) { - regsRead = new byte[insn.cs_detail.regs_read_count]; - for (int i=0; i