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

Public Member Functions

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

Public Attributes

 offset
 
 bin
 
 shift
 
 l
 

Private Attributes

 _getlen
 

Detailed Description

bin_stream implementation for IDA

Don't generate xrange using address computation:
It can raise error on overflow 7FFFFFFF with 32 bit python

Definition at line 7 of file bin_stream_ida.py.

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_ida.bin_stream_ida.__str__ (   self)

Definition at line 27 of file bin_stream_ida.py.

27 
28  def __str__(self):
29  raise NotImplementedError('Not fully functional')
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_ida.bin_stream_ida.getbytes (   self,
  start,
  l = 1 
)

Definition at line 14 of file bin_stream_ida.py.

14 
15  def getbytes(self, start, l=1):
16  o = ""
17  for ad in xrange(l):
18  o += chr(Byte(ad + start - self.shift))
19  return o
def miasm2.core.bin_stream_ida.bin_stream_ida.getlen (   self)

Definition at line 33 of file bin_stream_ida.py.

33 
34  def getlen(self):
35  # Lazy version
36  if hasattr(self, "_getlen"):
37  return self._getlen
38  max_addr = SegEnd(list(Segments())[-1] - (self.offset + self.shift))
39  self._getlen = max_addr
40  return max_addr

+ 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_ida.bin_stream_ida.readbs (   self,
  l = 1 
)

Definition at line 20 of file bin_stream_ida.py.

20 
21  def readbs(self, l=1):
22  if self.offset + l > self.l:
23  raise IOError("not enough bytes")
24  o = self.getbytes(self.offset)
25  self.offset += l
26  return p

+ Here is the call graph for this function:

def miasm2.core.bin_stream_ida.bin_stream_ida.setoffset (   self,
  val 
)

Definition at line 30 of file bin_stream_ida.py.

30 
31  def setoffset(self, val):
32  self.offset = val

Member Data Documentation

miasm2.core.bin_stream_ida.bin_stream_ida._getlen
private

Definition at line 38 of file bin_stream_ida.py.

miasm2.core.bin_stream.bin_stream_str.bin
inherited

Definition at line 69 of file bin_stream.py.

miasm2.core.bin_stream.bin_stream_str.l
inherited

Definition at line 72 of file bin_stream.py.

miasm2.core.bin_stream_ida.bin_stream_ida.offset

Definition at line 31 of file bin_stream_ida.py.

miasm2.core.bin_stream.bin_stream_str.shift
inherited

Definition at line 71 of file bin_stream.py.


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