From 06e37a041f7bcd640f4abc191166937148713df3 Mon Sep 17 00:00:00 2001 From: Ajax Date: Fri, 27 Feb 2015 12:25:54 +0100 Subject: BinStreamIDA: `getlen` is now lazy, and use the proper IDA API --- miasm2/core/bin_stream_ida.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'miasm2') 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 -- cgit 1.4.1