diff options
| author | Peter LaFosse <peter@vector35.com> | 2021-09-03 15:54:45 -0400 |
|---|---|---|
| committer | Peter LaFosse <peter@vector35.com> | 2021-09-05 10:09:09 -0400 |
| commit | d376db916f5fc83f9e654edf23364d200839ac50 (patch) | |
| tree | 7f610b8e17ea0e11b342f85894d809d849cbf261 /python/highlevelil.py | |
| parent | bc5c0977dc5b4087e8f39cc67089bb5709aac04e (diff) | |
Commonize how BasicBlocks are constructed
Diffstat (limited to 'python/highlevelil.py')
| -rw-r--r-- | python/highlevelil.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/python/highlevelil.py b/python/highlevelil.py index 348468be..073fbfda 100644 --- a/python/highlevelil.py +++ b/python/highlevelil.py @@ -371,10 +371,11 @@ class HighLevelILInstruction: IL basic block object containing this expression (read-only) (only available on finalized functions). Returns None for HLIL_BLOCK expressions as these can contain multiple basic blocks. """ - block = core.BNGetHighLevelILBasicBlockForInstruction(self.function.handle, self.instr_index) - if not block or self.function.source_function is None: + core_block = core.BNGetHighLevelILBasicBlockForInstruction(self.function.handle, self.instr_index) + assert core_block is not None, "core.BNGetHighLevelILBasicBlockForInstruction returned None" + if self.function.source_function is None: return None - return HighLevelILBasicBlock(self.function.source_function.view, block, self.function) + return HighLevelILBasicBlock(core_block, self.function, self.function.source_function.view) @property def value(self) -> 'variable.RegisterValue': @@ -2175,8 +2176,8 @@ class HighLevelILFunction: try: for i in range(0, count.value): core_block = core.BNNewBasicBlockReference(blocks[i]) - assert core_block is not None - yield HighLevelILBasicBlock(view, core_block, self) + assert core_block is not None, "core.BNNewBasicBlockReference returned None" + yield HighLevelILBasicBlock(core_block, self, view) finally: core.BNFreeBasicBlockList(blocks, count.value) @@ -2223,8 +2224,8 @@ class HighLevelILFunction: try: for i in range(0, count.value): core_block = core.BNNewBasicBlockReference(blocks[i]) - assert core_block is not None - yield HighLevelILBasicBlock(view, core_block, self) + assert core_block is not None, "core.BNNewBasicBlockReference is None" + yield HighLevelILBasicBlock(core_block, self, view) finally: core.BNFreeBasicBlockList(blocks, count.value) @@ -2489,7 +2490,7 @@ class HighLevelILFunction: class HighLevelILBasicBlock(basicblock.BasicBlock): - def __init__(self, view:Optional['binaryview.BinaryView'], handle:core.BNBasicBlockHandle, owner:HighLevelILFunction): + def __init__(self, handle:core.BNBasicBlockHandle, owner:HighLevelILFunction, view:Optional['binaryview.BinaryView']): super(HighLevelILBasicBlock, self).__init__(handle, view) self._il_function = owner @@ -2510,7 +2511,7 @@ class HighLevelILBasicBlock(basicblock.BasicBlock): def _create_instance(self, handle:core.BNBasicBlockHandle, view:'binaryview.BinaryView'): """Internal method by super to instantiate child instances""" - return HighLevelILBasicBlock(view, handle, self.il_function) + return HighLevelILBasicBlock(handle, self.il_function, view) def __hash__(self): return hash((self.start, self.end, self.il_function)) |
