Rizin
unix-like reverse engineering framework and cli tools
Arm.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.Arm_const.*;
13 
14 public class Arm {
15 
16  public static class MemType extends Structure {
17  public int base;
18  public int index;
19  public int scale;
20  public int disp;
21  public int lshift;
22 
23  @Override
24  public List getFieldOrder() {
25  return Arrays.asList("base", "index", "scale", "disp", "lshift");
26  }
27  }
28 
29  public static class OpValue extends Union {
30  public int reg;
31  public int imm;
32  public double fp;
33  public MemType mem;
34  public int setend;
35 
36  @Override
37  public List getFieldOrder() {
38  return Arrays.asList("reg", "imm", "fp", "mem", "setend");
39  }
40  }
41 
42  public static class OpShift extends Structure {
43  public int type;
44  public int value;
45 
46  @Override
47  public List getFieldOrder() {
48  return Arrays.asList("type","value");
49  }
50  }
51 
52  public static class Operand extends Structure {
53  public int vector_index;
54  public OpShift shift;
55  public int type;
56  public OpValue value;
57  public boolean subtracted;
58  public byte access;
59  public byte neon_lane;
60 
61  public void read() {
62  readField("vector_index");
63  readField("type");
64  if (type == ARM_OP_MEM)
65  value.setType(MemType.class);
66  if (type == ARM_OP_FP)
67  value.setType(Double.TYPE);
68  if (type == ARM_OP_PIMM || type == ARM_OP_IMM || type == ARM_OP_CIMM)
69  value.setType(Integer.TYPE);
70  if (type == ARM_OP_REG)
71  value.setType(Integer.TYPE);
72  if (type == ARM_OP_INVALID)
73  return;
74  readField("value");
75  readField("shift");
76  readField("subtracted");
77  readField("access");
78  readField("neon_lane");
79  }
80 
81  @Override
82  public List getFieldOrder() {
83  return Arrays.asList("vector_index", "shift", "type", "value", "subtracted", "access", "neon_lane");
84  }
85  }
86 
87  public static class UnionOpInfo extends Capstone.UnionOpInfo {
88  public boolean usermode;
89  public int vector_size;
90  public int vector_data;
91  public int cps_mode;
92  public int cps_flag;
93  public int cc;
94  public byte update_flags;
95  public byte writeback;
96  public int mem_barrier;
97  public byte op_count;
98 
99  public Operand [] op;
100 
101  public UnionOpInfo() {
102  op = new Operand[36];
103  }
104 
105  public void read() {
106  readField("usermode");
107  readField("vector_size");
108  readField("vector_data");
109  readField("cps_mode");
110  readField("cps_flag");
111  readField("cc");
112  readField("update_flags");
113  readField("writeback");
114  readField("mem_barrier");
115  readField("op_count");
116  op = new Operand[op_count];
117  if (op_count != 0)
118  readField("op");
119  }
120 
121  @Override
122  public List getFieldOrder() {
123  return Arrays.asList("usermode", "vector_size", "vector_data",
124  "cps_mode", "cps_flag", "cc", "update_flags", "writeback", "mem_barrier", "op_count", "op");
125  }
126  }
127 
128  public static class OpInfo extends Capstone.OpInfo {
129  public boolean usermode;
130  public int vectorSize;
131  public int vectorData;
132  public int cpsMode;
133  public int cpsFlag;
134  public int cc;
135  public boolean updateFlags;
136  public boolean writeback;
137  public int memBarrier;
138  public Operand [] op = null;
139 
140  public OpInfo(UnionOpInfo op_info) {
141  usermode = op_info.usermode;
142  vectorSize = op_info.vector_size;
143  vectorData = op_info.vector_data;
144  cpsMode = op_info.cps_mode;
145  cpsFlag = op_info.cps_flag;
146  cc = op_info.cc;
147  updateFlags = (op_info.update_flags > 0);
148  writeback = (op_info.writeback > 0);
149  memBarrier = op_info.mem_barrier;
150  op = op_info.op;
151  }
152  }
153 }
@ ARM_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: arm.h:164
@ ARM_OP_REG
= CS_OP_REG (Register operand).
Definition: arm.h:163
@ ARM_OP_CIMM
C-Immediate (coprocessor registers)
Definition: arm.h:167
@ ARM_OP_PIMM
P-Immediate (coprocessor registers)
Definition: arm.h:168
@ ARM_OP_INVALID
= CS_OP_INVALID (Uninitialized).
Definition: arm.h:162
@ ARM_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: arm.h:165
@ ARM_OP_FP
= CS_OP_FP (Floating-Point operand).
Definition: arm.h:166
List getFieldOrder()
Definition: Arm.java:24
OpInfo(UnionOpInfo op_info)
Definition: Arm.java:140
boolean writeback
Definition: Arm.java:136
boolean usermode
Definition: Arm.java:129
boolean updateFlags
Definition: Arm.java:135
List getFieldOrder()
Definition: Arm.java:47
List getFieldOrder()
Definition: Arm.java:37
boolean subtracted
Definition: Arm.java:57
OpShift shift
Definition: Arm.java:54
OpValue value
Definition: Arm.java:56
List getFieldOrder()
Definition: Arm.java:82
Definition: Arm.java:4
Definition: dis.c:32