diff options
| author | rollsafe <rollsafe@users.noreply.github.com> | 2019-06-11 15:29:57 -0400 |
|---|---|---|
| committer | rollsafe <rollsafe@users.noreply.github.com> | 2019-06-13 17:29:56 -0400 |
| commit | 1f885d1482d0d4e91f84c6d171672bf0d545923e (patch) | |
| tree | 9f4ff618f8f7a67a207cef5d8d3b18d32701dadd /python | |
| parent | 5502500f2a605af47523847db67b4c506d8f16e4 (diff) | |
Add comments map to binaryview
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index 04f0e2dc..9692689c 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -4373,6 +4373,51 @@ class BinaryView(object): core.BNFreeStringList(outgoing_names, len(name_list)) return result + @property + def address_comments(self): + """ + Returns a read-only dict of the address comments attached to this BinaryView + + Note that these are different from function-level comments which are specific to each function. + For annotating code, it is recommended to use comments attached to functions rather than address + comments attached to the BinaryView. On the other hand, BinaryView comments can be attached to data + whereas function comments cannot. + To create a function-level comment, use :func:`~binaryninja.function.Function.add_user_code_ref`. + """ + count = ctypes.c_ulonglong() + addrs = core.BNGetGlobalCommentedAddresses(self.handle, count) + result = {} + for i in range(0, count.value): + result[addrs[i]] = self.get_comment_at(addrs[i]) + core.BNFreeAddressList(addrs) + return result + + def get_comment_at(self, addr): + """ + ``get_comment_at`` returns the address-based comment attached to the given address in this BinaryView + Note that address-based comments are different from function-level comments which are specific to each function. + For more information, see :func:`address_comments`. + + """ + return core.BNGetGlobalCommentForAddress(self.handle, addr) + + def set_comment_at(self, addr, comment): + """ + ``set_comment_at`` sets a comment for the BinaryView at the address specified + + Note that these are different from function-level comments which are specific to each function. + For more information, see :func:`address_comments`. + + :param addr int: virtual address within the current BinaryView to apply the comment to + :param comment str: string comment to apply + :rtype: None + :Example: + + >>> bv.set_comment_at(here, "hi") + + """ + core.BNSetGlobalCommentForAddress(self.handle, addr, comment) + def query_metadata(self, key): """ `query_metadata` retrieves a metadata associated with the given key stored in the current BinaryView. |
