Rizin
unix-like reverse engineering framework and cli tools
Arm64.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.Arm64_const.*;
13 
14 public class Arm64 {
15 
16  public static class MemType extends Structure {
17  public int base;
18  public int index;
19  public int disp;
20 
21  @Override
22  public List getFieldOrder() {
23  return Arrays.asList("base", "index", "disp");
24  }
25  }
26 
27  public static class OpValue extends Union {
28  public int reg;
29  public long imm;
30  public double fp;
31  public MemType mem;
32  public int pstate;
33  public int sys;
34  public int prefetch;
35  public int barrier;
36 
37  @Override
38  public List getFieldOrder() {
39  return Arrays.asList("reg", "imm", "fp", "mem", "pstate", "sys", "prefetch", "barrier");
40  }
41  }
42 
43  public static class OpShift extends Structure {
44  public int type;
45  public int value;
46 
47  @Override
48  public List getFieldOrder() {
49  return Arrays.asList("type","value");
50  }
51  }
52 
53  public static class Operand extends Structure {
54  public int vector_index;
55  public int vas;
56  public int vess;
57  public OpShift shift;
58  public int ext;
59  public int type;
60  public OpValue value;
61 
62  public void read() {
63  readField("type");
64  if (type == ARM64_OP_MEM)
65  value.setType(MemType.class);
66  if (type == ARM64_OP_FP)
67  value.setType(Double.TYPE);
69  value.setType(Integer.TYPE);
70  if (type == ARM64_OP_INVALID)
71  return;
72  readField("value");
73  readField("ext");
74  readField("shift");
75  readField("vess");
76  readField("vas");
77  readField("vector_index");
78  }
79 
80  @Override
81  public List getFieldOrder() {
82  return Arrays.asList("vector_index", "vas", "vess", "shift", "ext", "type", "value");
83  }
84  }
85 
86  public static class UnionOpInfo extends Capstone.UnionOpInfo {
87  public int cc;
88  public byte _update_flags;
89  public byte _writeback;
90  public byte op_count;
91 
92  public Operand [] op;
93 
94  public UnionOpInfo() {
95  op = new Operand[8];
96  }
97 
98  public void read() {
99  readField("cc");
100  readField("_update_flags");
101  readField("_writeback");
102  readField("op_count");
103  op = new Operand[op_count];
104  if (op_count != 0)
105  readField("op");
106  }
107 
108  @Override
109  public List getFieldOrder() {
110  return Arrays.asList("cc", "_update_flags", "_writeback", "op_count", "op");
111  }
112  }
113 
114  public static class OpInfo extends Capstone.OpInfo {
115  public int cc;
116  public boolean updateFlags;
117  public boolean writeback;
118  public Operand [] op = null;
119 
120  public OpInfo(UnionOpInfo op_info) {
121  cc = op_info.cc;
122  updateFlags = (op_info._update_flags > 0);
123  writeback = (op_info._writeback > 0);
124  op = op_info.op;
125  }
126  }
127 }
@ ARM64_OP_FP
= CS_OP_FP (Floating-Point operand).
Definition: arm64.h:238
@ ARM64_OP_PSTATE
PState operand.
Definition: arm64.h:242
@ ARM64_OP_BARRIER
Memory barrier operand (ISB/DMB/DSB instructions).
Definition: arm64.h:245
@ ARM64_OP_REG
= CS_OP_REG (Register operand).
Definition: arm64.h:235
@ ARM64_OP_INVALID
= CS_OP_INVALID (Uninitialized).
Definition: arm64.h:234
@ ARM64_OP_PREFETCH
Prefetch operand (PRFM).
Definition: arm64.h:244
@ ARM64_OP_MEM
= CS_OP_MEM (Memory operand).
Definition: arm64.h:237
@ ARM64_OP_SYS
SYS operand for IC/DC/AT/TLBI instructions.
Definition: arm64.h:243
@ ARM64_OP_REG_MRS
MRS register operand.
Definition: arm64.h:240
@ ARM64_OP_CIMM
C-Immediate.
Definition: arm64.h:239
@ ARM64_OP_IMM
= CS_OP_IMM (Immediate operand).
Definition: arm64.h:236
@ ARM64_OP_REG_MSR
MSR register operand.
Definition: arm64.h:241
OpInfo(UnionOpInfo op_info)
Definition: Arm64.java:120
Definition: Arm.java:4
Definition: dis.c:32