diff options
| author | Camille Mougey <commial@gmail.com> | 2014-12-03 11:07:48 +0100 |
|---|---|---|
| committer | Camille Mougey <commial@gmail.com> | 2014-12-03 11:07:48 +0100 |
| commit | d68ce6faeaedb4081b4f7dc6a32131c843e411de (patch) | |
| tree | d9ff50dd48c3c30d5036574edcf80c59dd7cb987 /miasm2/core/bin_stream_ida.py | |
| parent | a5397cee9bacc81224f786f9a62adf3de5c99c87 (diff) | |
| parent | 454f472a54f1c57a15fe22ccfad5ce22b4bd1a2d (diff) | |
| download | miasm-d68ce6faeaedb4081b4f7dc6a32131c843e411de.tar.gz miasm-d68ce6faeaedb4081b4f7dc6a32131c843e411de.zip | |
Merge pull request #7 from serpilliere/bin_stream_ida
Merge "Bin stream IDA" refactoring
Diffstat (limited to 'miasm2/core/bin_stream_ida.py')
| -rw-r--r-- | miasm2/core/bin_stream_ida.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/miasm2/core/bin_stream_ida.py b/miasm2/core/bin_stream_ida.py new file mode 100644 index 00000000..ff88f03e --- /dev/null +++ b/miasm2/core/bin_stream_ida.py @@ -0,0 +1,41 @@ +from idc import Byte + +from miasm2.core.bin_stream import bin_stream_str + + +class bin_stream_ida(bin_stream_str): + """ + bin_stream implementation for IDA + + IDA should provide Byte function + + Don't generate xrange using address computation: + It can raise error on overflow 7FFFFFFF with 32 bit python + """ + def getbytes(self, start, l=1): + o = "" + for ad in xrange(l): + o += chr(Byte(ad + start - self.shift)) + return o + + def readbs(self, l=1): + if self.offset + l > self.l: + raise IOError + o = self.getbytes(self.offset) + self.offset += l + return p + + def writebs(self, l=1): + raise ValueError('writebs unsupported') + + def __str__(self): + raise NotImplementedError('Not fully functional') + + def setoffset(self, val): + self.offset = val + + def __len__(self): + return 0x7FFFFFFF + + def getlen(self): + return 0x7FFFFFFF - self.offset - self.shift |