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

Public Member Functions

def __init__
 
def getlen
 
def getbytes
 
def readbs
 
def setoffset
 
def __repr__
 
def hexdump
 
def getbits
 

Public Attributes

 offset
 
 base_offset
 
 vm
 

Detailed Description

Definition at line 166 of file bin_stream.py.

Constructor & Destructor Documentation

def miasm2.core.bin_stream.bin_stream_vm.__init__ (   self,
  vm,
  offset = 0L,
  base_offset = 0L 
)

Definition at line 168 of file bin_stream.py.

169  def __init__(self, vm, offset=0L, base_offset=0L):
170  self.offset = offset
171  self.base_offset = base_offset
172  self.vm = vm

Member Function Documentation

def miasm2.core.bin_stream.bin_stream.__repr__ (   self)
inherited

Definition at line 25 of file bin_stream.py.

25 
26  def __repr__(self):
27  return "<%s !!>" % self.__class__.__name__
def miasm2.core.bin_stream.bin_stream.getbits (   self,
  start,
  n 
)
inherited
Return the bits from the bit stream
@start: the offset in bits
@n: number of bits to read

Definition at line 34 of file bin_stream.py.

34 
35  def getbits(self, start, n):
36  """Return the bits from the bit stream
37  @start: the offset in bits
38  @n: number of bits to read
39  """
40  if not n:
41  return 0
42  o = 0
43  if n > self.getlen() * 8:
44  raise IOError('not enough bits %r %r' % (n, len(self.bin) * 8))
45  while n:
46  # print 'xxx', n, start
47  i = start / 8
48  c = self.getbytes(i)
49  if not c:
50  raise IOError('cannot get bytes')
51  c = ord(c)
52  # print 'o', hex(c)
53  r = 8 - start % 8
54  c &= (1 << r) - 1
55  # print 'm', hex(c)
56  l = min(r, n)
57  # print 'd', r-l
58  c >>= (r - l)
59  o <<= l
60  o |= c
61  n -= l
62  start += l
63  return o
64 

+ Here is the call graph for this function:

def miasm2.core.bin_stream.bin_stream_vm.getbytes (   self,
  start,
  l = 1 
)

Definition at line 176 of file bin_stream.py.

177  def getbytes(self, start, l=1):
178  try:
179  s = self.vm.get_mem(start + self.base_offset, l)
180  except:
181  raise IOError('cannot get mem ad', hex(start))
182  return s
def miasm2.core.bin_stream.bin_stream_vm.getlen (   self)

Definition at line 173 of file bin_stream.py.

174  def getlen(self):
175  return 0xFFFFFFFFFFFFFFFF

+ Here is the caller graph for this function:

def miasm2.core.bin_stream.bin_stream.hexdump (   self,
  offset,
  l 
)
inherited

Definition at line 28 of file bin_stream.py.

28 
29  def hexdump(self, offset, l):
30  return
def miasm2.core.bin_stream.bin_stream_vm.readbs (   self,
  l = 1 
)

Definition at line 183 of file bin_stream.py.

184  def readbs(self, l=1):
185  try:
186  s = self.vm.get_mem(self.offset + self.base_offset, l)
187  except:
188  raise IOError('cannot get mem ad', hex(self.offset))
189  self.offset += l
190  return s
def miasm2.core.bin_stream.bin_stream_vm.setoffset (   self,
  val 
)

Definition at line 191 of file bin_stream.py.

Member Data Documentation

miasm2.core.bin_stream.bin_stream_vm.base_offset

Definition at line 170 of file bin_stream.py.

miasm2.core.bin_stream.bin_stream_vm.offset

Definition at line 169 of file bin_stream.py.

miasm2.core.bin_stream.bin_stream_vm.vm

Definition at line 171 of file bin_stream.py.


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