summaryrefslogtreecommitdiff
path: root/python/binaryview.py
diff options
context:
space:
mode:
Diffstat (limited to 'python/binaryview.py')
-rw-r--r--python/binaryview.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 12f886fd..ef559d8b 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -978,6 +978,9 @@ class Segment:
def __hash__(self):
return hash(ctypes.addressof(self.handle.contents))
+ def __contains__(self, i:int):
+ return i >= self.start and i < self.end
+
@property
def start(self) -> int:
return core.BNSegmentGetStart(self.handle)
@@ -1073,6 +1076,9 @@ class Section:
def __hash__(self):
return hash(ctypes.addressof(self.handle.contents))
+ def __contains__(self, i:int):
+ return i >= self.start and i < self.end
+
@property
def name(self) -> str:
return core.BNSectionGetName(self.handle)
@@ -1493,6 +1499,12 @@ class BinaryView:
else:
raise IndexError("index out of range")
+ def __contains__(self, i:int):
+ for s in self.segments:
+ if i in s:
+ return True
+ return False
+
@classmethod
def register(cls) -> None:
binaryninja._init_plugins()