diff options
Diffstat (limited to 'plugins/python/androperms/reader.py')
-rw-r--r-- | plugins/python/androperms/reader.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/plugins/python/androperms/reader.py b/plugins/python/androperms/reader.py new file mode 100644 index 0000000..f126850 --- /dev/null +++ b/plugins/python/androperms/reader.py @@ -0,0 +1,41 @@ +#!/usr/bin/python -u +# -*- coding: utf-8 -*- + + +from struct import unpack + + +class AXMLReader(): + """Provide various read helpers.""" + + def __init__(self, data): + + self._data = data + + self._position = 0 + self._length = len(self._data) + + + def readInt(self): + """Read a 4-bytes value.""" + + self.skipInt() + + value = unpack('<L', self._data[self._position - 4 : self._position])[0] + + return value + + + def skipInt(self): + """Skip a 4-bytes value.""" + + self._position += 4 + + if self._position > self._length: + raise Exception("Reader out of bound (%d > %d)!" % (self._position, self._length)) + + + def readIntArray(self, length): + """Read an array composed of 4-bytes values.""" + + return [ self.readInt() for i in range(0, length) ] |