1 # Capstone Python bindings, by Nguyen Anh Quynnh <aquynh (at] gmail.com> 2 3 import ctypes 4 from . import copy_ctypes_list 5 from .mips_const import * 6 7 # define the API 8 class MipsOpMem(ctypes.Structure): 9 _fields_ = ( 10 ('base', ctypes.c_uint), 11 ('disp', ctypes.c_int64), 12 ) 13 14 class MipsOpValue(ctypes.Union): 15 _fields_ = ( 16 ('reg', ctypes.c_uint), 17 ('imm', ctypes.c_int64), 18 ('mem', MipsOpMem), 19 ) 20 21 class 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 40 class CsMips(ctypes.Structure): 41 _fields_ = ( 42 ('op_count', ctypes.c_uint8), 43 ('operands', MipsOp * 8), 44 ) 45 46 def get_arch_info(a): 47 return copy_ctypes_list(a.operands[:a.op_count]) 48 49