Rizin
unix-like reverse engineering framework and cli tools
arm64.py
Go to the documentation of this file.
1 # Capstone Python bindings, by Nguyen Anh Quynnh <aquynh@gmail.com>
2 
3 import ctypes
4 from . import copy_ctypes_list
5 from .arm64_const import *
6 
7 # define the API
8 class Arm64OpMem(ctypes.Structure):
9  _fields_ = (
10  ('base', ctypes.c_uint),
11  ('index', ctypes.c_uint),
12  ('disp', ctypes.c_int32),
13  )
14 
15 class Arm64OpShift(ctypes.Structure):
16  _fields_ = (
17  ('type', ctypes.c_uint),
18  ('value', ctypes.c_uint),
19  )
20 
21 class Arm64OpValue(ctypes.Union):
22  _fields_ = (
23  ('reg', ctypes.c_uint),
24  ('imm', ctypes.c_int64),
25  ('fp', ctypes.c_double),
26  ('mem', Arm64OpMem),
27  ('pstate', ctypes.c_int),
28  ('sys', ctypes.c_uint),
29  ('prefetch', ctypes.c_int),
30  ('barrier', ctypes.c_int),
31  )
32 
33 class Arm64Op(ctypes.Structure):
34  _fields_ = (
35  ('vector_index', ctypes.c_int),
36  ('vas', ctypes.c_int),
37  ('vess', ctypes.c_int),
38  ('shift', Arm64OpShift),
39  ('ext', ctypes.c_uint),
40  ('type', ctypes.c_uint),
41  ('value', Arm64OpValue),
42  ('access', ctypes.c_uint8),
43  )
44 
45  @property
46  def imm(self):
47  return self.value.imm
48 
49  @property
50  def reg(self):
51  return self.value.reg
52 
53  @property
54  def fp(self):
55  return self.value.fp
56 
57  @property
58  def mem(self):
59  return self.value.mem
60 
61  @property
62  def pstate(self):
63  return self.value.pstate
64 
65  @property
66  def sys(self):
67  return self.value.sys
68 
69  @property
70  def prefetch(self):
71  return self.value.prefetch
72 
73  @property
74  def barrier(self):
75  return self.value.barrier
76 
77 
78 
79 class CsArm64(ctypes.Structure):
80  _fields_ = (
81  ('cc', ctypes.c_uint),
82  ('update_flags', ctypes.c_bool),
83  ('writeback', ctypes.c_bool),
84  ('op_count', ctypes.c_uint8),
85  ('operands', Arm64Op * 8),
86  )
87 
89  return (a.cc, a.update_flags, a.writeback, copy_ctypes_list(a.operands[:a.op_count]))
90 
def reg(self)
Definition: arm64.py:50
def mem(self)
Definition: arm64.py:58
def sys(self)
Definition: arm64.py:66
def barrier(self)
Definition: arm64.py:74
def pstate(self)
Definition: arm64.py:62
def imm(self)
Definition: arm64.py:46
def fp(self)
Definition: arm64.py:54
def prefetch(self)
Definition: arm64.py:70
def get_arch_info(a)
Definition: arm64.py:88
def copy_ctypes_list(src)
Definition: __init__.py:326