diff options
| author | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2015-02-11 10:44:24 +0100 |
|---|---|---|
| committer | Fabrice Desclaux <fabrice.desclaux@cea.fr> | 2015-02-11 13:27:14 +0100 |
| commit | 74cc70d786c73dcf7369349976761276f6940a58 (patch) | |
| tree | 32ff9a521480739dc83a511e8398a92850226b0f /miasm2/core/bin_stream_ida.py | |
| parent | dc916d52815feee22cc81a29fe1272278d4caefc (diff) | |
| download | miasm-74cc70d786c73dcf7369349976761276f6940a58.tar.gz miasm-74cc70d786c73dcf7369349976761276f6940a58.zip | |
bin_stream: clean code and update API
The __len__ cannot be used any more in bin_stream: Python returns an int object, which will cap values to 0x7FFFFFFF on 32 bit systems. A binary can have a base address higher than this, making it impossible to handle such programs. The __len__ is replaced by a call to getlen. Elfesteem needs an update to support 'max_addr' API in order to retrieve the elf/pe max virtual address.
Diffstat (limited to 'miasm2/core/bin_stream_ida.py')
| -rw-r--r-- | miasm2/core/bin_stream_ida.py | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/miasm2/core/bin_stream_ida.py b/miasm2/core/bin_stream_ida.py index ff88f03e..62c06c9e 100644 --- a/miasm2/core/bin_stream_ida.py +++ b/miasm2/core/bin_stream_ida.py @@ -1,4 +1,4 @@ -from idc import Byte +from idc import Byte, SegEnd from miasm2.core.bin_stream import bin_stream_str @@ -7,8 +7,6 @@ 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 """ @@ -20,22 +18,16 @@ class bin_stream_ida(bin_stream_str): def readbs(self, l=1): if self.offset + l > self.l: - raise IOError + raise IOError("not enough bytes") 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 + return SegEnd(0) - (self.offset + self.shift) |