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.x86_rm_m80 Class Reference
+ Inheritance diagram for miasm2.arch.x86.arch.x86_rm_m80:
+ Collaboration diagram for miasm2.arch.x86.arch.x86_rm_m80:

Public Member Functions

def encode
 
def decode
 
def fromstring
 
def get_modrm
 
def gen_cand
 

Public Attributes

 expr
 

Static Public Attributes

int msize = 80
 
 parser = rmarg
 

Detailed Description

Definition at line 2173 of file arch.py.

Member Function Documentation

def miasm2.arch.x86.arch.x86_rm_m64.decode (   self,
  v 
)
inherited

Definition at line 2155 of file arch.py.

2156  def decode(self, v):
2157  p = self.parent
2158  xx = self.get_modrm()
2159  expr = modrm2expr(xx, p, 1)
2160  if not isinstance(expr, ExprMem):
2161  return False
2162  self.expr = ExprMem(expr.arg, self.msize)
2163  return self.expr is not None

+ Here is the call graph for this function:

def miasm2.arch.x86.arch.x86_rm_m80.encode (   self)

Definition at line 2176 of file arch.py.

2177  def encode(self):
2178  if isinstance(self.expr, ExprInt):
2179  raise StopIteration
2180  if not isinstance(self.expr, ExprMem) or self.expr.size != self.msize:
2181  raise StopIteration
2182  p = self.parent
2183  mode = p.mode
2184  if mode == 64:
2185  mode = 32
2186  self.expr = ExprMem(self.expr.arg, mode)
2187  v_cand, segm, ok = expr2modrm(self.expr, p, 1)
2188  for x in self.gen_cand(v_cand, p.v_admode()):
2189  yield x
2190 
def miasm2.arch.x86.arch.x86_rm_arg.fromstring (   self,
  s,
  parser_result = None 
)
inherited

Definition at line 1899 of file arch.py.

1900  def fromstring(self, s, parser_result=None):
1901  start, stop = super(x86_rm_arg, self).fromstring(s, parser_result)
1902  p = self.parent
1903  if start is None:
1904  return None, None
1905  s = self.expr.size
1906  return start, stop
def miasm2.arch.x86.arch.x86_rm_arg.gen_cand (   self,
  v_cand,
  admode 
)
inherited

Definition at line 1936 of file arch.py.

1937  def gen_cand(self, v_cand, admode):
1938  if not admode in modrm2byte:
1939  # XXX TODO: 64bit
1940  raise StopIteration
1941  if not v_cand:
1942  raise StopIteration
1943 
1944  p = self.parent
1945  o_rex_x = p.rex_x.value
1946  o_rex_b = p.rex_b.value
1947  # add candidate without 0 imm
1948  new_v_cand = []
1949  moddd = False
1950  for v in v_cand:
1951  new_v_cand.append(v)
1952  if f_imm in v and int(v[f_imm][1].arg) == 0:
1953  v = dict(v)
1954  del(v[f_imm])
1955  new_v_cand.append(v)
1956  moddd = True
1957 
1958  v_cand = new_v_cand
1959 
1960  out_c = []
1961  for v in v_cand:
1962  disp = None
1963  # patch value in modrm
1964  if f_imm in v:
1965  size, disp = v[f_imm]
1966  disp = int(disp.arg)
1967 
1968  v[f_imm] = size
1969  vo = v
1970  v = v.items()
1971  v.sort()
1972  v = tuple(v)
1973  if not v in modrm2byte[admode]:
1974  continue
1975  xx = modrm2byte[admode][v]
1976 
1977  # default case
1978  for x in xx:
1979  if type(x) == tuple:
1980  modrm, sib = x
1981  else:
1982  modrm = x
1983  sib = None
1984 
1985  # 16 bit cannot have sib
1986  if (not sib is None) and admode == 16:
1987  continue
1988  rex = modrm >> 8 # 0# XXX HACK REM temporary REX modrm>>8
1989  if rex and admode != 64:
1990  continue
1991 
1992  p.rex_x.value = (rex >> 1) & 1
1993  p.rex_b.value = rex & 1
1994 
1995  if o_rex_x is not None and p.rex_x.value != o_rex_x:
1996  continue
1997  if o_rex_b is not None and p.rex_b.value != o_rex_b:
1998  continue
1999 
2000  mod, re, rm = getmodrm(modrm)
2001  # check re on parent
2002  if re != p.reg.value:
2003  continue
2004 
2005  if sib:
2006  s_scale, s_index, s_base = getmodrm(sib)
2007  else:
2008  s_scale, s_index, s_base = None, None, None
2009 
2010  p.mod.value = mod
2011  p.rm.value = rm
2012  p.sib_scale.value = s_scale
2013  p.sib_index.value = s_index
2014  p.sib_base.value = s_base
2015  p.disp.value = disp
2016  if disp is not None:
2017  p.disp.l = f_imm2size[vo[f_imm]]
2018 
2019  yield True
2020 
2021  raise StopIteration

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

def miasm2.arch.x86.arch.x86_rm_arg.get_modrm (   self)
inherited

Definition at line 1907 of file arch.py.

1908  def get_modrm(self):
1909  p = self.parent
1910  admode = p.v_admode()
1911 
1912  if not admode in [16, 32, 64]:
1913  raise ValueError('strange admode %r', admode)
1914  v = setmodrm(p.mod.value, 0, p.rm.value)
1915  v |= p.rex_b.value << 8
1916  v |= p.rex_x.value << 9
1917  if p.mode == 64:
1918  # XXXx to check
1919  admode = 64
1920 
1921  xx = byte2modrm[admode][v]
1922  if isinstance(xx, list):
1923  if not p.sib_scale:
1924  return False
1925  v = setmodrm(p.sib_scale.value,
1926  p.sib_index.value,
1927  p.sib_base.value)
1928  xx = xx[v]
1929  return xx

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

miasm2.arch.x86.arch.x86_rm_m80.expr

Definition at line 2185 of file arch.py.

int miasm2.arch.x86.arch.x86_rm_m80.msize = 80
static

Definition at line 2174 of file arch.py.

miasm2.arch.x86.arch.x86_rm_arg.parser = rmarg
staticinherited

Definition at line 1897 of file arch.py.


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