Miasm2
 All Classes Namespaces Files Functions Variables Typedefs Properties Macros
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
miasm2.arch.x86.arch.mn_x86 Class Reference
+ Inheritance diagram for miasm2.arch.x86.arch.mn_x86:
+ Collaboration diagram for miasm2.arch.x86.arch.mn_x86:

Public Member Functions

def getpc
 
def getsp
 
def v_opmode
 
def v_admode
 
def additional_info
 
def check_mnemo
 
def getmn
 
def mod_fields
 
def gen_modes
 
def fromstring
 
def pre_dis
 
def get_cls_instance
 
def post_dis
 
def dup_info
 
def reset_class
 
def add_pre_dis_info
 
def post_asm
 
def gen_prefix
 
def encodefields
 
def getnextflow
 
def ir_pre_instruction
 
def filter_asm_candidates
 
def guess_mnemo
 
def init_class
 
def getbits
 
def getbytes
 
def dis
 
def asm
 
def value
 
def decoded2bytes
 
def gen_args
 
def args2str
 
def __str__
 
def parse_prefix
 
def set_dst_symbol
 
def getdstflow
 

Public Attributes

 opmode
 
 admode
 
 prefix
 
 args_symb
 
 args
 
 fields_order
 
 to_decode
 

Static Public Attributes

string name = "x86"
 
 prefix_op_size = False
 
 prefix_ad_size = False
 
 regs = regs_module
 
list all_mn = []
 
tuple all_mn_mode = defaultdict(list)
 
tuple all_mn_name = defaultdict(list)
 
tuple all_mn_inst = defaultdict(list)
 
dictionary bintree = {}
 
int num = 0
 
int delayslot = 0
 
dictionary pc = {16: IP, 32: EIP, 64: RIP}
 
dictionary sp = {16: SP, 32: ESP, 64: RSP}
 
 instruction = instruction_x86
 
int max_instruction_len = 15
 
list args_symb = []
 
int alignment = 1
 

Detailed Description

Definition at line 606 of file arch.py.

Member Function Documentation

def miasm2.core.cpu.cls_mn.__str__ (   self)
inherited

Definition at line 1430 of file cpu.py.

1431  def __str__(self):
1432  o = "%-10s " % self.name
1433  args = []
1434  for arg in self.args:
1435  # XXX todo test
1436  if not (isinstance(arg, m2_expr.Expr) or
1437  isinstance(arg.expr, m2_expr.Expr)):
1438  raise ValueError('zarb arg type')
1439  x = str(arg)
1440  args.append(x)
1441 
1442  o += self.gen_args(args)
1443  return o

+ Here is the call graph for this function:

def miasm2.arch.x86.arch.mn_x86.add_pre_dis_info (   self,
  pre_dis_info = None 
)

Definition at line 796 of file arch.py.

797  def add_pre_dis_info(self, pre_dis_info=None):
798  if pre_dis_info is None:
799  return True
800  if hasattr(self, "prefixed") and self.prefixed.default == "\x66":
801  pre_dis_info['opmode'] = 0
802  self.opmode = pre_dis_info['opmode']
803  self.admode = pre_dis_info['admode']
804 
805  if hasattr(self, 'no_xmm_pref') and\
806  pre_dis_info['prefix'] and\
807  pre_dis_info['prefix'][-1] in '\x66\xf2\xf3':
808  return False
809  if (hasattr(self, "prefixed") and
810  not pre_dis_info['prefix'].endswith(self.prefixed.default)):
811  return False
812  if (self.rex_w.value is not None and
813  self.rex_w.value != pre_dis_info['rex_w']):
814  return False
815  else:
816  self.rex_w.value = pre_dis_info['rex_w']
817  self.rex_r.value = pre_dis_info['rex_r']
818  self.rex_b.value = pre_dis_info['rex_b']
819  self.rex_x.value = pre_dis_info['rex_x']
820  self.rex_p.value = pre_dis_info['rex_p']
821  self.g1.value = pre_dis_info['g1']
822  self.g2.value = pre_dis_info['g2']
823  self.prefix = pre_dis_info['prefix']
824  return True
def miasm2.arch.x86.arch.mn_x86.additional_info (   self)

Definition at line 650 of file arch.py.

651  def additional_info(self):
652  info = additional_info()
653  info.g1.value = self.g1.value
654  info.g2.value = self.g2.value
655  info.stk = hasattr(self, 'stk')
656  info.v_opmode = self.v_opmode()
657  info.prefixed = ""
658  if hasattr(self, 'prefixed'):
659  info.prefixed = self.prefixed.default
660  return info

+ Here is the call graph for this function:

def miasm2.core.cpu.cls_mn.args2str (   self)
inherited

Definition at line 1419 of file cpu.py.

1420  def args2str(self):
1421  args = []
1422  for arg in self.args:
1423  # XXX todo test
1424  if not (isinstance(arg, m2_expr.Expr) or
1425  isinstance(arg.expr, m2_expr.Expr)):
1426  raise ValueError('zarb arg type')
1427  x = str(arg)
1428  args.append(x)
1429  return args
def miasm2.core.cpu.cls_mn.asm (   cls,
  instr,
  symbols = None 
)
inherited
Re asm instruction by searching mnemo using name and args. We then
can modify args and get the hex of a modified instruction

Definition at line 1287 of file cpu.py.

1288  def asm(cls, instr, symbols=None):
1289  """
1290  Re asm instruction by searching mnemo using name and args. We then
1291  can modify args and get the hex of a modified instruction
1292  """
1293  clist = cls.all_mn_name[instr.name]
1294  clist = [x for x in clist]
1295  vals = []
1296  candidates = []
1297  args = instr.resolve_args_with_symbols(symbols)
1298 
1299  for cc in clist:
1300 
1301  for c in cls.get_cls_instance(
1302  cc, instr.mode, instr.additional_info):
1303 
1304  cannot_parse = False
1305  if len(c.args) != len(instr.args):
1306  continue
1307 
1308  # only fix args expr
1309  for i in xrange(len(c.args)):
1310  c.args[i].expr = args[i]
1311 
1312  v = c.value(instr.mode)
1313  if not v:
1314  log.debug("cannot encode %r", c)
1315  cannot_parse = True
1316  if cannot_parse:
1317  continue
1318  vals += v
1319  candidates.append((c, v))
1320  if len(vals) == 0:
1321  raise ValueError('cannot asm %r %r' %
1322  (instr.name, [str(x) for x in instr.args]))
1323  if len(vals) != 1:
1324  log.debug('asm multiple args ret default')
1325 
1326  vals = cls.filter_asm_candidates(instr, candidates)
1327  return vals
def miasm2.arch.x86.arch.mn_x86.check_mnemo (   cls,
  fields 
)

Definition at line 662 of file arch.py.

663  def check_mnemo(cls, fields):
664  pass
def miasm2.core.cpu.cls_mn.decoded2bytes (   self,
  result 
)
inherited

Definition at line 1400 of file cpu.py.

1401  def decoded2bytes(self, result):
1402  if not result:
1403  return []
1404 
1405  out = []
1406  for decoded in result:
1407  decoded.sort()
1408 
1409  o = self.encodefields(decoded)
1410  if o is None:
1411  continue
1412  out.append(o)
1413  out = list(set(out))
1414  return out

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.core.cpu.cls_mn.dis (   cls,
  bs_o,
  mode_o = None,
  offset = 0 
)
inherited

Definition at line 1092 of file cpu.py.

1093  def dis(cls, bs_o, mode_o = None, offset=0):
1094  if not isinstance(bs_o, bin_stream):
1095  bs_o = bin_stream_str(bs_o)
1096 
1097  offset_o = offset
1098  pre_dis_info, bs, mode, offset, prefix_len = cls.pre_dis(
1099  bs_o, mode_o, offset)
1100  candidates = cls.guess_mnemo(bs, mode, pre_dis_info, offset)
1101  out = []
1102  out_c = []
1103  if hasattr(bs, 'getlen'):
1104  bs_l = bs.getlen()
1105  else:
1106  bs_l = len(bs)
1107 
1108  alias = False
1109  for c in candidates:
1110  log.debug("*" * 40, mode, c.mode)
1111  log.debug(c.fields)
1112 
1113  c = cls.all_mn_inst[c][0]
1114 
1115  c.reset_class()
1116  c.mode = mode
1117 
1118  if not c.add_pre_dis_info(pre_dis_info):
1119  continue
1120 
1121  args = []
1122  todo = {}
1123  getok = True
1124  fname_values = dict(pre_dis_info)
1125  offset_b = offset * 8
1126 
1127  total_l = 0
1128  for i, f in enumerate(c.fields_order):
1129  if f.flen is not None:
1130  l = f.flen(mode, fname_values)
1131  else:
1132  l = f.l
1133  if l is not None:
1134  total_l += l
1135  f.l = l
1136  f.is_present = True
1137  log.debug("FIELD %s %s %s %s", f.__class__, f.fname,
1138  offset_b, l)
1139  if bs_l * 8 - offset_b < l:
1140  getok = False
1141  break
1142  bv = cls.getbits(bs, mode, offset_b, l)
1143  offset_b += l
1144  if not f.fname in fname_values:
1145  fname_values[f.fname] = bv
1146  todo[i] = bv
1147  else:
1148  f.is_present = False
1149  todo[i] = None
1150 
1151  if not getok:
1152  continue
1153 
1154  c.l = prefix_len + total_l / 8
1155  for i in c.to_decode:
1156  f = c.fields_order[i]
1157  if f.is_present:
1158  ret = f.decode(todo[i])
1159  if not ret:
1160  log.debug("cannot decode %r", f)
1161  break
1162 
1163  if not ret:
1164  continue
1165  for a in c.args:
1166  a.expr = expr_simp(a.expr)
1167 
1168  c.b = cls.getbytes(bs, offset_o, c.l)
1169  c.offset = offset_o
1170  c = c.post_dis()
1171  if c is None:
1172  continue
1173  c_args = [a.expr for a in c.args]
1174  instr = cls.instruction(c.name, mode, c_args,
1175  additional_info=c.additional_info())
1176  instr.l = prefix_len + total_l / 8
1177  instr.b = cls.getbytes(bs, offset_o, instr.l)
1178  instr.offset = offset_o
1179  instr.get_info(c)
1180  if c.alias:
1181  alias = True
1182  out.append(instr)
1183  out_c.append(c)
1184  if not out:
1185  raise Disasm_Exception('cannot disasm at %X' % offset_o)
1186  if len(out) != 1:
1187  if not alias:
1188  log.warning('dis multiple args ret default')
1189 
1190  assert(len(out) == 2)
1191  for i, o in enumerate(out_c):
1192  if o.alias:
1193  return out[i]
1194  raise NotImplementedError('not fully functional')
1195  return out[0]
def miasm2.arch.x86.arch.mn_x86.dup_info (   self,
  infos 
)

Definition at line 784 of file arch.py.

785  def dup_info(self, infos):
786  if infos is not None:
787  self.g1.value = infos.g1.value
788  self.g2.value = infos.g2.value
def miasm2.arch.x86.arch.mn_x86.encodefields (   self,
  decoded 
)

Definition at line 874 of file arch.py.

875  def encodefields(self, decoded):
876  v = super(mn_x86, self).encodefields(decoded)
877  prefix = self.gen_prefix()
878  if prefix is None:
879  return None
880  return prefix + v

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.mn_x86.filter_asm_candidates (   cls,
  instr,
  candidates 
)

Definition at line 889 of file arch.py.

890  def filter_asm_candidates(cls, instr, candidates):
891 
892  cand_same_mode = []
893  cand_diff_mode = []
894  out = []
895  for c, v in candidates:
896  if (hasattr(c, 'no_xmm_pref') and
897  (c.g1.value & 2 or c.g1.value & 4 or c.opmode)):
898  continue
899  if hasattr(c, "fopmode") and v_opmode(c) != c.fopmode.mode:
900  continue
901  if hasattr(c, "fadmode") and v_admode(c) != c.fadmode.mode:
902  continue
903  # relative dstflow must not have opmode set
904  # (affect IP instead of EIP for instance)
905  if (instr.dstflow() and
906  instr.name not in ["JCXZ", "JECXZ", "JRCXZ"] and
907  len(instr.args) == 1 and
908  isinstance(instr.args[0], ExprInt) and c.opmode):
909  continue
910 
911  out.append((c, v))
912  candidates = out
913  for c, v in candidates:
914  if v_opmode(c) == instr.mode:
915  cand_same_mode += v
916  for c, v in candidates:
917  if v_opmode(c) != instr.mode:
918  cand_diff_mode += v
919  cand_same_mode.sort(key=len)
920  cand_diff_mode.sort(key=len)
921  return cand_same_mode + cand_diff_mode
922 

+ Here is the call graph for this function:

def miasm2.arch.x86.arch.mn_x86.fromstring (   cls,
  s,
  mode 
)

Definition at line 680 of file arch.py.

681  def fromstring(cls, s, mode):
682  pref = 0
683  prefix, new_s = get_prefix(s)
684  if prefix == "LOCK":
685  pref |= 1
686  s = new_s
687  elif prefix == "REPNE":
688  pref |= 2
689  s = new_s
690  elif prefix == "REPE":
691  pref |= 4
692  s = new_s
693  c = super(mn_x86, cls).fromstring(s, mode)
694  c.additional_info.g1.value = pref
695  return c

+ Here is the call graph for this function:

def miasm2.core.cpu.cls_mn.gen_args (   self,
  args 
)
inherited

Definition at line 1415 of file cpu.py.

1416  def gen_args(self, args):
1417  out = ', '.join([str(x) for x in args])
1418  return out

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.mn_x86.gen_modes (   cls,
  subcls,
  name,
  bases,
  dct,
  fields 
)

Definition at line 675 of file arch.py.

676  def gen_modes(cls, subcls, name, bases, dct, fields):
677  dct['mode'] = None
678  return [(subcls, name, bases, dct, fields)]
def miasm2.arch.x86.arch.mn_x86.gen_prefix (   self)

Definition at line 829 of file arch.py.

830  def gen_prefix(self):
831  v = ""
832  rex = 0x40
833  if self.g1.value is None:
834  self.g1.value = 0
835  if self.g2.value is None:
836  self.g2.value = 0
837 
838  if self.rex_w.value:
839  rex |= 0x8
840  if self.rex_r.value:
841  rex |= 0x4
842  if self.rex_x.value:
843  rex |= 0x2
844  if self.rex_b.value:
845  rex |= 0x1
846  if rex != 0x40 or self.rex_p.value == 1:
847  v = chr(rex) + v
848 
849  if hasattr(self, 'prefixed'):
850  v = self.prefixed.default + v
851 
852  if self.g1.value & 1:
853  v = "\xf0" + v
854  if self.g1.value & 2:
855  if hasattr(self, 'no_xmm_pref'):
856  return None
857  v = "\xf2" + v
858  if self.g1.value & 4:
859  if hasattr(self, 'no_xmm_pref'):
860  return None
861  v = "\xf3" + v
862  if self.g2.value:
863  v = {1: '\x2e', 2: '\x36', 3: '\x3e', 4:
864  '\x26', 5: '\x64', 6: '\x65'}[self.g2.value] + v
865  # mode prefix
866  if hasattr(self, "admode") and self.admode:
867  v = "\x67" + v
868 
869  if hasattr(self, "opmode") and self.opmode:
870  if hasattr(self, 'no_xmm_pref'):
871  return None
872  v = "\x66" + v
873  return v

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.mn_x86.get_cls_instance (   cls,
  cc,
  mode,
  infos = None 
)

Definition at line 754 of file arch.py.

755  def get_cls_instance(cls, cc, mode, infos=None):
756  for opmode in [0, 1]:
757  for admode in [0, 1]:
758  c = cc()
759  c.init_class()
760 
761  c.reset_class()
762  c.add_pre_dis_info()
763  c.dup_info(infos)
764  c.mode = mode
765  c.opmode = opmode
766  c.admode = admode
767 
768  if not hasattr(c, 'stk') and hasattr(c, "fopmode") and c.fopmode.mode == 64:
769  c.rex_w.value = 1
770  yield c
def miasm2.core.cpu.cls_mn.getbits (   cls,
  bs,
  attrib,
  offset_b,
  l 
)
inherited

Definition at line 1069 of file cpu.py.

1070  def getbits(cls, bs, attrib, offset_b, l):
1071  return bs.getbits(offset_b, l)
def miasm2.core.cpu.cls_mn.getbytes (   cls,
  bs,
  offset,
  l 
)
inherited

Definition at line 1073 of file cpu.py.

1074  def getbytes(cls, bs, offset, l):
1075  return bs.getbytes(offset, l)
def miasm2.core.cpu.cls_mn.getdstflow (   self,
  symbol_pool 
)
inherited

Definition at line 1460 of file cpu.py.

1461  def getdstflow(self, symbol_pool):
1462  return [self.args[0].expr]
1463 

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.mn_x86.getmn (   cls,
  name 
)

Definition at line 666 of file arch.py.

667  def getmn(cls, name):
668  return name.upper()
def miasm2.arch.x86.arch.mn_x86.getnextflow (   self,
  symbol_pool 
)

Definition at line 881 of file arch.py.

882  def getnextflow(self, symbol_pool):
883  raise NotImplementedError('not fully functional')
def miasm2.arch.x86.arch.mn_x86.getpc (   cls,
  attrib 
)

Definition at line 624 of file arch.py.

625  def getpc(cls, attrib):
626  return cls.pc[attrib]
def miasm2.arch.x86.arch.mn_x86.getsp (   cls,
  attrib 
)

Definition at line 628 of file arch.py.

629  def getsp(cls, attrib):
630  return cls.sp[attrib]
def miasm2.core.cpu.cls_mn.guess_mnemo (   cls,
  bs,
  attrib,
  pre_dis_info,
  offset 
)
inherited

Definition at line 987 of file cpu.py.

988  def guess_mnemo(cls, bs, attrib, pre_dis_info, offset):
989  candidates = []
990 
991  candidates = set()
992 
993  fname_values = pre_dis_info
994  todo = [(dict(fname_values), branch, offset * 8)
995  for branch in cls.bintree.items()]
996  cpt = 0
997  if hasattr(bs, 'getlen'):
998  bs_l = bs.getlen()
999  else:
1000  bs_l = len(bs)
1001  for fname_values, branch, offset_b in todo:
1002  (l, fmask, fbits, fname, flen), vals = branch
1003  cpt += 1
1004 
1005  if flen is not None:
1006  l = flen(attrib, fname_values)
1007  if l is not None:
1008  try:
1009  v = cls.getbits(bs, attrib, offset_b, l)
1010  except IOError:
1011  # Raised if offset is out of bound
1012  continue
1013  offset_b += l
1014  if v & fmask != fbits:
1015  continue
1016  if fname is not None and not fname in fname_values:
1017  fname_values[fname] = v
1018  for nb, v in vals.items():
1019  if 'mn' in nb:
1020  candidates.update(v)
1021  else:
1022  todo.append((dict(fname_values), (nb, v), offset_b))
1023 
1024  candidates = [c for c in candidates]
1025 
1026  if not candidates:
1027  raise Disasm_Exception('cannot disasm (guess) at %X' % offset)
1028  return candidates
def miasm2.core.cpu.cls_mn.init_class (   self)
inherited

Definition at line 1040 of file cpu.py.

1041  def init_class(self):
1042  args = []
1043  fields_order = []
1044  to_decode = []
1045  off = 0
1046  for i, fc in enumerate(self.fields):
1047  f = fc.gen(self)
1048  f.offset = off
1049  off += f.l
1050  fields_order.append(f)
1051  to_decode.append((i, f))
1052 
1053  if isinstance(f, m_arg):
1054  args.append(f)
1055  if f.fname:
1056  setattr(self, f.fname, f)
1057  if hasattr(self, 'args_permut'):
1058  args = [args[self.args_permut[i]]
1059  for i in xrange(len(self.args_permut))]
1060  to_decode.sort(key=lambda x: (x[1].order, x[0]))
1061  to_decode = [fields_order.index(f[1]) for f in to_decode]
1062  self.args = args
1063  self.fields_order = fields_order
1064  self.to_decode = to_decode
def miasm2.arch.x86.arch.mn_x86.ir_pre_instruction (   self)

Definition at line 884 of file arch.py.

885  def ir_pre_instruction(self):
886  return [ExprAff(mRIP[self.mode],
887  ExprInt_from(mRIP[self.mode], self.offset + self.l))]

+ Here is the call graph for this function:

def miasm2.arch.x86.arch.mn_x86.mod_fields (   cls,
  fields 
)

Definition at line 670 of file arch.py.

671  def mod_fields(cls, fields):
672  prefix = [d_g1, d_g2, d_rex_p, d_rex_w, d_rex_r, d_rex_x, d_rex_b]
673  return prefix + fields
def miasm2.core.cpu.cls_mn.parse_prefix (   self,
  v 
)
inherited

Definition at line 1444 of file cpu.py.

1445  def parse_prefix(self, v):
1446  return 0
def miasm2.arch.x86.arch.mn_x86.post_asm (   self,
  v 
)

Definition at line 825 of file arch.py.

826  def post_asm(self, v):
827  return v
828 
def miasm2.arch.x86.arch.mn_x86.post_dis (   self)

Definition at line 771 of file arch.py.

772  def post_dis(self):
773  if self.g2.value:
774  for a in self.args:
775  if not isinstance(a.expr, ExprMem):
776  continue
777  m = a.expr
778  a.expr = ExprMem(
779  ExprOp('segm', enc2segm[self.g2.value], m.arg), m.size)
780  if self.name in ['LEA', 'LDS', 'LES', 'LFS', 'LGS', 'LSS']:
781  if not isinstance(self.args[1].expr, ExprMem):
782  return None
783  return self
def miasm2.arch.x86.arch.mn_x86.pre_dis (   cls,
  v,
  mode,
  offset 
)

Definition at line 697 of file arch.py.

698  def pre_dis(cls, v, mode, offset):
699  offset_o = offset
700  pre_dis_info = {'opmode': 0,
701  'admode': 0,
702  'g1': 0,
703  'g2': 0,
704  'rex_p': 0,
705  'rex_w': 0,
706  'rex_r': 0,
707  'rex_x': 0,
708  'rex_b': 0,
709  'prefix': "",
710  'prefixed': "",
711  }
712  while True:
713  c = v.getbytes(offset)
714  if c == '\x66':
715  pre_dis_info['opmode'] = 1
716  elif c == '\x67':
717  pre_dis_info['admode'] = 1
718  elif c == '\xf0':
719  pre_dis_info['g1'] = 1
720  elif c == '\xf2':
721  pre_dis_info['g1'] = 2
722  elif c == '\xf3':
723  pre_dis_info['g1'] = 4
724 
725  elif c == '\x2e':
726  pre_dis_info['g2'] = 1
727  elif c == '\x36':
728  pre_dis_info['g2'] = 2
729  elif c == '\x3e':
730  pre_dis_info['g2'] = 3
731  elif c == '\x26':
732  pre_dis_info['g2'] = 4
733  elif c == '\x64':
734  pre_dis_info['g2'] = 5
735  elif c == '\x65':
736  pre_dis_info['g2'] = 6
737 
738  elif mode == 64 and c in '@ABCDEFGHIJKLMNO':
739  x = ord(c)
740  pre_dis_info['rex_p'] = 1
741  pre_dis_info['rex_w'] = (x >> 3) & 1
742  pre_dis_info['rex_r'] = (x >> 2) & 1
743  pre_dis_info['rex_x'] = (x >> 1) & 1
744  pre_dis_info['rex_b'] = (x >> 0) & 1
745  offset += 1
746  break
747  else:
748  c = ''
749  break
750  pre_dis_info['prefix'] += c
751  offset += 1
752  return pre_dis_info, v, mode, offset, offset - offset_o
def miasm2.arch.x86.arch.mn_x86.reset_class (   self)

Definition at line 789 of file arch.py.

790  def reset_class(self):
791  super(mn_x86, self).reset_class()
792  if hasattr(self, "opmode"):
793  del(self.opmode)
794  if hasattr(self, "admode"):
795  del(self.admode)
def miasm2.core.cpu.cls_mn.set_dst_symbol (   self,
  symbol_pool 
)
inherited

Definition at line 1447 of file cpu.py.

1448  def set_dst_symbol(self, symbol_pool):
1449  dst = self.getdstflow(symbol_pool)
1450  args = []
1451  for d in dst:
1452  if isinstance(d, m2_expr.ExprInt):
1453  l = symbol_pool.getby_offset_create(int(d.arg))
1454 
1455  a = m2_expr.ExprId(l.name, d.size)
1456  else:
1457  a = d
1458  args.append(a)
1459  self.args_symb = args

+ Here is the call graph for this function:

def miasm2.arch.x86.arch.mn_x86.v_admode (   self)

Definition at line 638 of file arch.py.

639  def v_admode(self):
640  size, opmode, admode = self.mode, self.opmode, self.admode
641  if size in [16, 32]:
642  if admode:
643  return invmode[size]
644  else:
645  return size
646  elif size == 64:
647  if admode == 1:
648  return 32
649  return 64

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.mn_x86.v_opmode (   self)

Definition at line 631 of file arch.py.

632  def v_opmode(self):
633  if hasattr(self, 'stk'):
634  stk = 1
635  else:
636  stk = 0
637  return v_opmode_info(self.mode, self.opmode, self.rex_w.value, stk)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.core.cpu.cls_mn.value (   self,
  mode 
)
inherited

Definition at line 1336 of file cpu.py.

1337  def value(self, mode):
1338  todo = [(0, 0, [(x, self.fields_order[x]) for x in self.to_decode[::-1]])]
1339 
1340  result = []
1341  done = []
1342  cpt = 0
1343 
1344  while todo:
1345  index, cur_len, to_decode = todo.pop()
1346  # TEST XXX
1347  for i, f in to_decode:
1348  setattr(self, f.fname, f)
1349  if (index, [x[1].value for x in to_decode]) in done:
1350  continue
1351  done.append((index, [x[1].value for x in to_decode]))
1352 
1353  cpt += 1
1354  can_encode = True
1355  for i, f in to_decode[index:]:
1356  f.parent.l = cur_len
1357  ret = f.encode()
1358  if not ret:
1359  log.debug('cannot encode %r', f)
1360  can_encode = False
1361  break
1362  if f.value is not None and f.l:
1363  cur_len += f.l
1364  index += 1
1365  if ret is True:
1366  continue
1367 
1368  gcpt = 0
1369  for i in ret:
1370  gcpt += 1
1371  o = []
1372  if ((index, cur_len, [xx[1].value for xx in to_decode]) in todo or
1373  (index, cur_len, [xx[1].value for xx in to_decode]) in done):
1374  raise NotImplementedError('not fully functional')
1375 
1376  for p, f in to_decode:
1377  fnew = f.clone()
1378  o.append((p, fnew))
1379  todo.append((index, cur_len, o))
1380  can_encode = False
1381 
1382  break
1383  if not can_encode:
1384  continue
1385  result.append(to_decode)
1386 
1387  return self.decoded2bytes(result)

+ Here is the call graph for this function:

Member Data Documentation

miasm2.arch.x86.arch.mn_x86.admode

Definition at line 802 of file arch.py.

int miasm2.core.cpu.cls_mn.alignment = 1
staticinherited

Definition at line 984 of file cpu.py.

list miasm2.arch.x86.arch.mn_x86.all_mn = []
static

Definition at line 611 of file arch.py.

tuple miasm2.arch.x86.arch.mn_x86.all_mn_inst = defaultdict(list)
static

Definition at line 614 of file arch.py.

tuple miasm2.arch.x86.arch.mn_x86.all_mn_mode = defaultdict(list)
static

Definition at line 612 of file arch.py.

tuple miasm2.arch.x86.arch.mn_x86.all_mn_name = defaultdict(list)
static

Definition at line 613 of file arch.py.

miasm2.core.cpu.cls_mn.args
inherited

Definition at line 1061 of file cpu.py.

list miasm2.core.cpu.cls_mn.args_symb = []
staticinherited

Definition at line 981 of file cpu.py.

miasm2.core.cpu.cls_mn.args_symb
inherited

Definition at line 1458 of file cpu.py.

dictionary miasm2.arch.x86.arch.mn_x86.bintree = {}
static

Definition at line 615 of file arch.py.

int miasm2.arch.x86.arch.mn_x86.delayslot = 0
static

Definition at line 617 of file arch.py.

miasm2.core.cpu.cls_mn.fields_order
inherited

Definition at line 1062 of file cpu.py.

miasm2.arch.x86.arch.mn_x86.instruction = instruction_x86
static

Definition at line 620 of file arch.py.

int miasm2.arch.x86.arch.mn_x86.max_instruction_len = 15
static

Definition at line 621 of file arch.py.

string miasm2.arch.x86.arch.mn_x86.name = "x86"
static

Definition at line 607 of file arch.py.

int miasm2.arch.x86.arch.mn_x86.num = 0
static

Definition at line 616 of file arch.py.

miasm2.arch.x86.arch.mn_x86.opmode

Definition at line 801 of file arch.py.

dictionary miasm2.arch.x86.arch.mn_x86.pc = {16: IP, 32: EIP, 64: RIP}
static

Definition at line 618 of file arch.py.

miasm2.arch.x86.arch.mn_x86.prefix

Definition at line 822 of file arch.py.

miasm2.arch.x86.arch.mn_x86.prefix_ad_size = False
static

Definition at line 609 of file arch.py.

miasm2.arch.x86.arch.mn_x86.prefix_op_size = False
static

Definition at line 608 of file arch.py.

miasm2.arch.x86.arch.mn_x86.regs = regs_module
static

Definition at line 610 of file arch.py.

dictionary miasm2.arch.x86.arch.mn_x86.sp = {16: SP, 32: ESP, 64: RSP}
static

Definition at line 619 of file arch.py.

miasm2.core.cpu.cls_mn.to_decode
inherited

Definition at line 1063 of file cpu.py.


The documentation for this class was generated from the following file: