about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAjax <commial@gmail.com>2015-02-27 12:25:54 +0100
committerYour Name <you@example.com>2015-02-27 14:13:41 +0100
commit06e37a041f7bcd640f4abc191166937148713df3 (patch)
tree3771098139b85b9422b122e81c0c883262325b81
parent2a14327dfb9df55f67f9abc818c461aebe6d7918 (diff)
downloadmiasm-06e37a041f7bcd640f4abc191166937148713df3.tar.gz
miasm-06e37a041f7bcd640f4abc191166937148713df3.zip
BinStreamIDA: `getlen` is now lazy, and use the proper IDA API
-rw-r--r--miasm2/core/bin_stream_ida.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/miasm2/core/bin_stream_ida.py b/miasm2/core/bin_stream_ida.py
index 62c06c9e..1610f8ca 100644
--- a/miasm2/core/bin_stream_ida.py
+++ b/miasm2/core/bin_stream_ida.py
@@ -1,4 +1,5 @@
 from idc import Byte, SegEnd
+from idautils import Segments
 
 from miasm2.core.bin_stream import bin_stream_str
 
@@ -30,4 +31,9 @@ class bin_stream_ida(bin_stream_str):
         self.offset = val
 
     def getlen(self):
-        return SegEnd(0) - (self.offset + self.shift)
+        # Lazy version
+        if hasattr(self, "_getlen"):
+            return self._getlen
+        max_addr = SegEnd(list(Segments())[-1]  - (self.offset + self.shift))
+        self._getlen = max_addr
+        return max_addr