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

Public Member Functions

def __init__
 
def v_opmode
 
def v_admode
 
def dstflow
 
def dstflow2label
 
def breakflow
 
def splitflow
 
def setdstflow
 
def is_subcall
 
def getdstflow
 
def get_symbol_size
 
def fixDstOffset
 
def get_info
 
def __str__
 
def get_args_expr
 
def gen_args
 
def get_asm_offset
 
def resolve_args_with_symbols
 

Static Public Member Functions

def arg2str
 

Public Attributes

 name
 
 mode
 
 args
 
 additional_info
 

Static Public Attributes

int delayslot = 0
 

Detailed Description

Definition at line 467 of file arch.py.

Constructor & Destructor Documentation

def miasm2.arch.x86.arch.instruction_x86.__init__ (   self,
  args,
  kargs 
)

Definition at line 470 of file arch.py.

471  def __init__(self, *args, **kargs):
472  super(instruction_x86, self).__init__(*args, **kargs)

Member Function Documentation

def miasm2.arch.x86.arch.instruction_x86.__str__ (   self)

Definition at line 562 of file arch.py.

563  def __str__(self):
564  o = super(instruction_x86, self).__str__()
565  if self.additional_info.g1.value & 1:
566  o = "LOCK %s" % o
567  if self.additional_info.g1.value & 2:
568  if getattr(self.additional_info.prefixed, 'default', "") != "\xF2":
569  o = "REPNE %s" % o
570  if self.additional_info.g1.value & 4:
571  if getattr(self.additional_info.prefixed, 'default', "") != "\xF3":
572  o = "REPE %s" % o
573  return o
def miasm2.arch.x86.arch.instruction_x86.arg2str (   expr,
  pos = None 
)
static

Definition at line 582 of file arch.py.

583  def arg2str(expr, pos=None):
584  if isinstance(expr, ExprId) or isinstance(expr, ExprInt):
585  o = str(expr)
586  elif isinstance(expr, ExprMem):
587  sz = SIZE2MEMPREFIX[expr.size]
588  segm = ""
589  if expr.is_op_segm():
590  segm = "%s:" % expr.arg.args[0]
591  expr = expr.arg.args[1]
592  else:
593  expr = expr.arg
594  if isinstance(expr, ExprOp):
595  s = str(expr).replace('(', '').replace(')', '')
596  else:
597  s = str(expr)
598  o = sz + ' PTR %s[%s]' % (segm, s)
599  elif isinstance(expr, ExprOp) and expr.op == 'segm':
600  o = "%s:%s" % (expr.args[0], expr.args[1])
601  else:
602  raise ValueError('check this %r' % expr)
603  return "%s" % o
604 
605 

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.instruction_x86.breakflow (   self)

Definition at line 501 of file arch.py.

502  def breakflow(self):
503  if self.name in conditional_branch + unconditional_branch:
504  return True
505  if self.name.startswith('LOOP'):
506  return True
507  if self.name.startswith('RET'):
508  return True
509  if self.name.startswith('INT'):
510  return True
511  if self.name.startswith('SYS'):
512  return True
513  return self.name in ['CALL', 'HLT', 'IRET', 'IRETD', 'IRETQ', 'ICEBP']
def miasm2.arch.x86.arch.instruction_x86.dstflow (   self)

Definition at line 479 of file arch.py.

480  def dstflow(self):
481  if self.name in conditional_branch + unconditional_branch:
482  return True
483  if self.name.startswith('LOOP'):
484  return True
485  return self.name in ['CALL']
def miasm2.arch.x86.arch.instruction_x86.dstflow2label (   self,
  symbol_pool 
)

Definition at line 486 of file arch.py.

487  def dstflow2label(self, symbol_pool):
488  if self.additional_info.g1.value & 6 and self.name in repeat_mn:
489  return
490  expr = self.args[0]
491  if isinstance(expr, ExprId):
492  if not isinstance(expr.name, asm_label) and expr not in all_regs_ids:
493  raise ValueError("ExprId must be a label or a register")
494  elif isinstance(expr, ExprInt):
495  ad = expr.arg + int(self.offset)
496  l = symbol_pool.getby_offset_create(ad)
497  s = ExprId(l, expr.size)
498  self.args[0] = s
499  else:
500  return
def miasm2.arch.x86.arch.instruction_x86.fixDstOffset (   self)

Definition at line 544 of file arch.py.

545  def fixDstOffset(self):
546  expr = self.args[0]
547  if self.offset is None:
548  raise ValueError('symbol not resolved %s' % l)
549  if not isinstance(expr, ExprInt):
550  log.warning('dynamic dst %r', expr)
551  return
552  self.args[0] = ExprInt(int(expr.arg) - self.offset, self.mode)
def miasm2.core.cpu.instruction.gen_args (   self,
  args 
)
inherited

Definition at line 920 of file cpu.py.

921  def gen_args(self, args):
922  out = ', '.join([str(x) for x in args])
923  return out

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.instruction_x86.get_args_expr (   self)

Definition at line 574 of file arch.py.

575  def get_args_expr(self):
576  args = []
577  for a in self.args:
578  a = a.replace_expr(replace_regs[self.mode])
579  args.append(a)
580  return args
def miasm2.core.cpu.instruction.get_asm_offset (   self,
  expr 
)
inherited

Definition at line 935 of file cpu.py.

936  def get_asm_offset(self, expr):
937  return m2_expr.ExprInt_from(expr, self.offset)

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.instruction_x86.get_info (   self,
  c 
)

Definition at line 553 of file arch.py.

554  def get_info(self, c):
555  self.additional_info.g1.value = c.g1.value
556  self.additional_info.g2.value = c.g2.value
557  self.additional_info.stk = hasattr(c, 'stk')
558  self.additional_info.v_opmode = c.v_opmode()
559  self.additional_info.v_admode = c.v_admode()
560  self.additional_info.prefix = c.prefix
561  self.additional_info.prefixed = getattr(c, "prefixed", "")
def miasm2.arch.x86.arch.instruction_x86.get_symbol_size (   self,
  symbol,
  symbol_pool 
)

Definition at line 541 of file arch.py.

542  def get_symbol_size(self, symbol, symbol_pool):
543  return self.mode

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.instruction_x86.getdstflow (   self,
  symbol_pool 
)

Definition at line 533 of file arch.py.

534  def getdstflow(self, symbol_pool):
535  if self.additional_info.g1.value & 6 and self.name in repeat_mn:
536  ad = int(self.offset)
537  l = symbol_pool.getby_offset_create(ad)
538  s = ExprId(l, self.v_opmode())
539  return [s]
540  return [self.args[0]]

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.instruction_x86.is_subcall (   self)

Definition at line 530 of file arch.py.

531  def is_subcall(self):
532  return self.name in ['CALL']
def miasm2.core.cpu.instruction.resolve_args_with_symbols (   self,
  symbols = None 
)
inherited

Definition at line 938 of file cpu.py.

939  def resolve_args_with_symbols(self, symbols=None):
940  if symbols is None:
941  symbols = {}
942  args_out = []
943  for a in self.args:
944  e = a
945  # try to resolve symbols using symbols (0 for default value)
946  ids = m2_expr.get_expr_ids(e)
947  fixed_ids = {}
948  for x in ids:
949  if isinstance(x.name, asmbloc.asm_label):
950  name = x.name.name
951  # special symbol $
952  if name == '$':
953  fixed_ids[x] = self.get_asm_offset(x)
954  continue
955  if not name in symbols:
956  raise ValueError('unresolved symbol! %r' % x)
957  else:
958  name = x.name
959  if not name in symbols:
960  continue
961  if symbols[name].offset is None:
962  raise ValueError('The offset of label "%s" cannot be '
963  'determined' % name)
964  else:
965  size = x.size
966  if size is None:
967  default_size = self.get_symbol_size(x, symbols)
968  size = default_size
969  value = m2_expr.ExprInt(symbols[name].offset, size)
970  fixed_ids[x] = value
971  e = e.replace_expr(fixed_ids)
972  e = expr_simp(e)
973  args_out.append(e)
974  return args_out

+ Here is the call graph for this function:

def miasm2.arch.x86.arch.instruction_x86.setdstflow (   self,
  a 
)

Definition at line 527 of file arch.py.

528  def setdstflow(self, a):
529  return
def miasm2.arch.x86.arch.instruction_x86.splitflow (   self)

Definition at line 514 of file arch.py.

515  def splitflow(self):
516  if self.name in conditional_branch:
517  return True
518  if self.name in unconditional_branch:
519  return False
520  if self.name.startswith('LOOP'):
521  return True
522  if self.name.startswith('INT'):
523  return True
524  if self.name.startswith('SYS'):
525  return True
526  return self.name in ['CALL']
def miasm2.arch.x86.arch.instruction_x86.v_admode (   self)

Definition at line 476 of file arch.py.

477  def v_admode(self):
478  return self.additional_info.v_admode
def miasm2.arch.x86.arch.instruction_x86.v_opmode (   self)

Definition at line 473 of file arch.py.

474  def v_opmode(self):
475  return self.additional_info.v_opmode

+ Here is the caller graph for this function:

Member Data Documentation

miasm2.core.cpu.instruction.additional_info
inherited

Definition at line 918 of file cpu.py.

miasm2.core.cpu.instruction.args
inherited

Definition at line 917 of file cpu.py.

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

Definition at line 468 of file arch.py.

miasm2.core.cpu.instruction.mode
inherited

Definition at line 916 of file cpu.py.

miasm2.core.cpu.instruction.name
inherited

Definition at line 915 of file cpu.py.


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