diff options
| author | Rusty Wagner <rusty@vector35.com> | 2016-05-25 19:29:10 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2016-05-25 19:29:10 -0400 |
| commit | 0c3c4285a38d70bafb089b85e6764d0f4153ff9c (patch) | |
| tree | 8e0025d90a2938d46596cbd62e691150dc6650bf /python/__init__.py | |
| parent | ebb6efaf92d36c0284bd8a5450cf2c051446f23a (diff) | |
Adding API to retrieve basic block annotations
Diffstat (limited to 'python/__init__.py')
| -rw-r--r-- | python/__init__.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/python/__init__.py b/python/__init__.py index 8ddb6262..821e3f41 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -2408,6 +2408,21 @@ class Function(object): core.BNFreeIndirectBranchList(branches) return result + def get_block_annotations(self, arch, addr): + count = ctypes.c_ulonglong(0) + lines = core.BNGetFunctionBlockAnnotations(self.handle, arch.handle, addr, count) + result = [] + for i in xrange(0, count.value): + tokens = [] + for j in xrange(0, lines[i].count): + token_type = core.BNInstructionTextTokenType_names[lines[i].tokens[j].type] + text = lines[i].tokens[j].text + value = lines[i].tokens[j].value + tokens.append(InstructionTextToken(token_type, text, value)) + result.append(tokens) + core.BNFreeInstructionTextLines(lines, count.value) + return result + class BasicBlockEdge: def __init__(self, branch_type, target, arch): self.type = core.BNBranchType_names[branch_type] @@ -2484,6 +2499,11 @@ class BasicBlock(object): """Whether basic block has undetermined outgoing edges (read-only)""" return core.BNBasicBlockHasUndeterminedOutgoingEdges(self.handle) + @property + def annotations(self): + """List of automatic annotations for the start of this block (read-only)""" + return self.function.get_block_annotations(self.arch, self.start) + def __setattr__(self, name, value): try: object.__setattr__(self,name,value) |
