summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorJordan Wiens <jordan@psifertex.com>2019-08-04 22:06:13 -0400
committerJordan Wiens <jordan@psifertex.com>2019-08-04 22:06:37 -0400
commitfaab567391ddee9951e85975e9621cc66c128dcb (patch)
tree5ea059a074e67b761dd0561b87003e1a4d58fb45 /python
parent4587d3ff3b9db208d98d6cff1dfc23fc61e0a015 (diff)
add total_bytes, highest_address, and lowest_address to native functions (in API only for now, will be moved into the core later)
Diffstat (limited to 'python')
-rw-r--r--python/function.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/python/function.py b/python/function.py
index 58565838..1ac95fb6 100644
--- a/python/function.py
+++ b/python/function.py
@@ -845,10 +845,30 @@ class Function(object):
@property
def start(self):
- """Function start (read-only)"""
+ """Function start address (read-only)"""
return core.BNGetFunctionStart(self.handle)
@property
+ def size(self):
+ """This property is not implemented as its implementation is not well defined. Use `.total_bytes` or `.highest_address-.lowest_address` instead"""
+ raise NotImplementedError("Intentionally unimplemented--use .total_bytes or .highest_address-.lowest_address.")
+
+ @property
+ def total_bytes(self):
+ """Total bytes of a function calculated by summing each basic_block. Because basic blocks can overlap and have gaps between them this may or may not be equivalent to a .size property."""
+ return sum(map(len, self))
+
+ @property
+ def highest_address(self):
+ "The highest virtual address in a function."""
+ return max(self, key=lambda block:block.end).end
+
+ @property
+ def lowest_address(self):
+ """The lowest virtual address in a function."""
+ return min(self, key=lambda block:block.start).start
+
+ @property
def symbol(self):
"""Function symbol(read-only)"""
sym = core.BNGetFunctionSymbol(self.handle)