From d13130eb6da9cfce5f0d09f311394ba3d90a6e03 Mon Sep 17 00:00:00 2001 From: Jordan Wiens Date: Mon, 27 Jan 2020 00:01:55 -0500 Subject: add negative block indexing for fn, mlil, and llil --- python/lowlevelil.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'python/lowlevelil.py') diff --git a/python/lowlevelil.py b/python/lowlevelil.py index 4d4ca2ec..87400b4d 100644 --- a/python/lowlevelil.py +++ b/python/lowlevelil.py @@ -1304,8 +1304,10 @@ class LowLevelILFunction(object): # for backwards compatibility if isinstance(i, LowLevelILInstruction): return i - if (i < 0) or (i >= len(self)): + if i < -len(self) or i >= len(self): raise IndexError("index out of range") + if i < 0: + i = len(self) + i return LowLevelILInstruction(self, core.BNGetLowLevelILIndexForInstruction(self.handle, i), i) def __setitem__(self, i, j): -- cgit v1.3.1