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_str Class Reference
+ Inheritance diagram for miasm2.core.bin_stream.bin_stream_str:
+ Collaboration diagram for miasm2.core.bin_stream.bin_stream_str:

Public Member Functions

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

Public Attributes

 bin
 
 offset
 
 shift
 
 l
 

Detailed Description

Definition at line 65 of file bin_stream.py.

Constructor & Destructor Documentation

def miasm2.core.bin_stream.bin_stream_str.__init__ (   self,
  input_str = "",
  offset = 0L,
  shift = 0 
)

Definition at line 67 of file bin_stream.py.

67 
68  def __init__(self, input_str="", offset=0L, shift=0):
69  bin_stream.__init__(self)
70  self.bin = input_str
71  self.offset = offset
72  self.shift = shift
73  self.l = len(input_str)

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

Definition at line 86 of file bin_stream.py.

86 
87  def __str__(self):
88  out = self.bin[self.offset + self.shift:]
89  return out
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_str.getbytes (   self,
  start,
  l = 1 
)

Definition at line 74 of file bin_stream.py.

74 
75  def getbytes(self, start, l=1):
76  if start + l + self.shift > self.l:
77  raise IOError("not enough bytes in str")
78 
79  return super(bin_stream_str, self).getbytes(start + self.shift, l)
def miasm2.core.bin_stream.bin_stream_str.getlen (   self)

Definition at line 93 of file bin_stream.py.

93 
94  def getlen(self):
95  return self.l - (self.offset + self.shift)
96 

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

Definition at line 80 of file bin_stream.py.

80 
81  def readbs(self, l=1):
82  if self.offset + l + self.shift > self.l:
83  raise IOError("not enough bytes in str")
84  self.offset += l
85  return self.bin[self.offset - l + self.shift:self.offset + self.shift]
def miasm2.core.bin_stream.bin_stream_str.setoffset (   self,
  val 
)

Definition at line 90 of file bin_stream.py.

90 
91  def setoffset(self, val):
92  self.offset = val

Member Data Documentation

miasm2.core.bin_stream.bin_stream_str.bin

Definition at line 69 of file bin_stream.py.

miasm2.core.bin_stream.bin_stream_str.l

Definition at line 72 of file bin_stream.py.

miasm2.core.bin_stream.bin_stream_str.offset

Definition at line 70 of file bin_stream.py.

miasm2.core.bin_stream.bin_stream_str.shift

Definition at line 71 of file bin_stream.py.


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