Rizin
unix-like reverse engineering framework and cli tools
arm.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
.arm_const
import
*
6
7
# define the API
8
class
ArmOpMem
(ctypes.Structure):
9
_fields_ = (
10
(
'base'
, ctypes.c_uint),
11
(
'index'
, ctypes.c_uint),
12
(
'scale'
, ctypes.c_int),
13
(
'disp'
, ctypes.c_int),
14
(
'lshift'
, ctypes.c_int),
15
)
16
17
class
ArmOpShift
(ctypes.Structure):
18
_fields_ = (
19
(
'type'
, ctypes.c_uint),
20
(
'value'
, ctypes.c_uint),
21
)
22
23
class
ArmOpValue
(ctypes.Union):
24
_fields_ = (
25
(
'reg'
, ctypes.c_uint),
26
(
'imm'
, ctypes.c_int32),
27
(
'fp'
, ctypes.c_double),
28
(
'mem'
, ArmOpMem),
29
(
'setend'
, ctypes.c_int),
30
)
31
32
class
ArmOp
(ctypes.Structure):
33
_fields_ = (
34
(
'vector_index'
, ctypes.c_int),
35
(
'shift'
, ArmOpShift),
36
(
'type'
, ctypes.c_uint),
37
(
'value'
, ArmOpValue),
38
(
'subtracted'
, ctypes.c_bool),
39
(
'access'
, ctypes.c_uint8),
40
(
'neon_lane'
, ctypes.c_int8),
41
)
42
43
@property
44
def
imm
(self):
45
return
self.value.imm
46
47
@property
48
def
reg
(self):
49
return
self.value.reg
50
51
@property
52
def
fp
(self):
53
return
self.value.fp
54
55
@property
56
def
mem
(self):
57
return
self.value.mem
58
59
@property
60
def
setend
(self):
61
return
self.value.setend
62
63
64
class
CsArm
(ctypes.Structure):
65
_fields_ = (
66
(
'usermode'
, ctypes.c_bool),
67
(
'vector_size'
, ctypes.c_int),
68
(
'vector_data'
, ctypes.c_int),
69
(
'cps_mode'
, ctypes.c_int),
70
(
'cps_flag'
, ctypes.c_int),
71
(
'cc'
, ctypes.c_uint),
72
(
'update_flags'
, ctypes.c_bool),
73
(
'writeback'
, ctypes.c_bool),
74
(
'mem_barrier'
, ctypes.c_int),
75
(
'op_count'
, ctypes.c_uint8),
76
(
'operands'
, ArmOp * 36),
77
)
78
79
def
get_arch_info
(a):
80
return
(a.usermode, a.vector_size, a.vector_data, a.cps_mode, a.cps_flag, a.cc, a.update_flags, \
81
a.writeback, a.mem_barrier,
copy_ctypes_list
(a.operands[:a.op_count]))
82
capstone.arm.ArmOpMem
Definition:
arm.py:8
capstone.arm.ArmOpShift
Definition:
arm.py:17
capstone.arm.ArmOpValue
Definition:
arm.py:23
capstone.arm.ArmOp
Definition:
arm.py:32
capstone.arm.ArmOp.imm
def imm(self)
Definition:
arm.py:44
capstone.arm.ArmOp.mem
def mem(self)
Definition:
arm.py:56
capstone.arm.ArmOp.reg
def reg(self)
Definition:
arm.py:48
capstone.arm.ArmOp.setend
def setend(self)
Definition:
arm.py:60
capstone.arm.ArmOp.fp
def fp(self)
Definition:
arm.py:52
capstone.arm.CsArm
Definition:
arm.py:64
capstone.arm.get_arch_info
def get_arch_info(a)
Definition:
arm.py:79
capstone.copy_ctypes_list
def copy_ctypes_list(src)
Definition:
__init__.py:326
subprojects
capstone-bundled
bindings
python
capstone
arm.py
Generated by
1.9.1