• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Capstone Python bindings, by Nguyen Anh Quynnh <aquynh@gmail.com>
2
3import ctypes
4from . import copy_ctypes_list
5from .mips_const import *
6
7# define the API
8class MipsOpMem(ctypes.Structure):
9    _fields_ = (
10        ('base', ctypes.c_uint),
11        ('disp', ctypes.c_int64),
12    )
13
14class MipsOpValue(ctypes.Union):
15    _fields_ = (
16        ('reg', ctypes.c_uint),
17        ('imm', ctypes.c_int64),
18        ('mem', MipsOpMem),
19    )
20
21class MipsOp(ctypes.Structure):
22    _fields_ = (
23        ('type', ctypes.c_uint),
24        ('value', MipsOpValue),
25    )
26
27    @property
28    def imm(self):
29        return self.value.imm
30
31    @property
32    def reg(self):
33        return self.value.reg
34
35    @property
36    def mem(self):
37        return self.value.mem
38
39
40class CsMips(ctypes.Structure):
41    _fields_ = (
42        ('op_count', ctypes.c_uint8),
43        ('operands', MipsOp * 10),
44    )
45
46def get_arch_info(a):
47    return copy_ctypes_list(a.operands[:a.op_count])
48
49