Rizin
unix-like reverse engineering framework and cli tools
Mips.java
Go to the documentation of this file.
1 // Capstone Java binding
2 // By Nguyen Anh Quynh & Dang Hoang Vu, 2013
3 
4 package capstone;
5 
6 import com.sun.jna.Structure;
7 import com.sun.jna.Union;
8 
9 import java.util.List;
10 import java.util.Arrays;
11 
12 import static capstone.Mips_const.*;
13 
14 public class Mips {
15 
16  public static class MemType extends Structure {
17  public int base;
18  public long disp;
19 
20  @Override
21  public List getFieldOrder() {
22  return Arrays.asList("base", "disp");
23  }
24  }
25 
26  public static class OpValue extends Union {
27  public int reg;
28  public long imm;
29  public MemType mem;
30 
31  @Override
32  public List getFieldOrder() {
33  return Arrays.asList("reg", "imm", "mem");
34  }
35  }
36 
37  public static class Operand extends Structure {
38  public int type;
39  public OpValue value;
40 
41  public void read() {
42  super.read();
43  if (type == MIPS_OP_MEM)
44  value.setType(MemType.class);
45  if (type == MIPS_OP_IMM)
46  value.setType(Long.TYPE);
47  if (type == MIPS_OP_REG)
48  value.setType(Integer.TYPE);
49  if (type == MIPS_OP_INVALID)
50  return;
51  readField("value");
52  }
53  @Override
54  public List getFieldOrder() {
55  return Arrays.asList("type", "value");
56  }
57  }
58 
59  public static class UnionOpInfo extends Capstone.UnionOpInfo {
60  public byte op_count;
61  public Operand [] op;
62 
63  public UnionOpInfo() {
64  op = new Operand[10];
65  }
66 
67  public void read() {
68  readField("op_count");
69  op = new Operand[op_count];
70  if (op_count != 0)
71  readField("op");
72  }
73 
74  @Override
75  public List getFieldOrder() {
76  return Arrays.asList("op_count", "op");
77  }
78  }
79 
80  public static class OpInfo extends Capstone.OpInfo {
81 
82  public Operand [] op;
83 
84  public OpInfo(UnionOpInfo e) {
85  op = e.op;
86  }
87  }
88 }
#define e(frag)
List getFieldOrder()
Definition: Mips.java:21
OpInfo(UnionOpInfo e)
Definition: Mips.java:84
Operand[] op
Definition: Mips.java:82
List getFieldOrder()
Definition: Mips.java:32
List getFieldOrder()
Definition: Mips.java:54
Definition: Arm.java:4
@ MIPS_OP_REG
= CS_OP_REG (Register operand).
Definition: mips.h:24
@ MIPS_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: mips.h:25
@ MIPS_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: mips.h:26
@ MIPS_OP_INVALID
= CS_OP_INVALID (Uninitialized).
Definition: mips.h:23
Definition: dis.c:32