summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2023-03-21 16:56:09 -0400
committerKyleMiles <krm504@nyu.edu>2023-03-22 19:34:08 -0400
commit9d761a52c55a052c67d7e895dcf0a5852a35fdca (patch)
tree604c4107718df1b3970f24fefba07bd731cde22a /python
parent87b596717e0cf990e69f1badc079a0eca087bb4c (diff)
Tags refactor
Diffstat (limited to 'python')
-rw-r--r--python/binaryview.py392
-rw-r--r--python/function.py434
2 files changed, 360 insertions, 466 deletions
diff --git a/python/binaryview.py b/python/binaryview.py
index 2b202735..f2f08b3b 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -5252,8 +5252,7 @@ class BinaryView:
:rtype: TagType
:Example:
- >>> tt = bv.create_tag_type("Crabby Functions", "🦀")
- >>> bv.create_user_data_tag(here, tt, "Get Crabbed")
+ >>> bv.create_tag_type("Crabby Functions", "🦀")
>>>
"""
tag_handle = core.BNCreateTagType(self.handle)
@@ -5264,14 +5263,16 @@ class BinaryView:
core.BNAddTagType(self.handle, tag_type.handle)
return tag_type
- def remove_tag_type(self, tag_type: 'TagType') -> None:
+ def remove_tag_type(self, tag_type: str):
"""
``remove_tag_type`` removes a :py:class:`TagType` and all tags that use it
- :param TagType tag_type: The :py:class:`TagType` to remove
+ :param str tag_type: The name of the tag type to remove
:rtype: None
"""
- core.BNRemoveTagType(self.handle, tag_type.handle)
+ tag_type = self.get_tag_type(tag_type)
+ if tag_type is not None:
+ core.BNRemoveTagType(self.handle, tag_type.handle)
@property
def tag_types(self) -> Mapping[str, Union['TagType', List['TagType']]]:
@@ -5308,63 +5309,74 @@ class BinaryView:
def get_tag_type(self, name: str) -> Optional['TagType']:
"""
- Get a tag type by its name. Shorthand for get_tag_type_by_name()
+ Get a tag type by its name.
:param name: Name of the tag type
:return: The relevant tag type, if it exists
:rtype: TagType
"""
- return self.get_tag_type_by_name(name)
- def get_tag_type_by_name(self, name: str) -> Optional['TagType']:
+ if isinstance(name, TagType):
+ log_warn("Accessing tag types by type is deprecated. Please use the name instead.")
+ return name
+ else:
+ tag_type = core.BNGetTagType(self.handle, name)
+ if tag_type is not None:
+ return TagType(tag_type)
+ else:
+ log_error(f"Tag type `{name}` does not exist!")
+ return None
+
+ def add_tag(self, addr: int, tag_type_name: str, data: str, user: bool = True):
"""
- Get a tag type by its name
+ ``add_tag`` creates and adds a :py:class:`Tag` object at a data address.
- :param name: Name of the tag type
- :return: The relevant tag type, if it exists
- :rtype: TagType
+ This API is appropriate for generic data tags. For functions,
+ consider using :py:func:`~binaryninja.function.Function.add_tag`.
+
+ :param int addr: address at which to add the tag
+ :param str tag_type_name: The name of the tag type for this Tag
+ :param str data: additional data for the Tag
+ :param bool user: Whether or not a user tag
+ :Example:
+
+ >>> bv.add_tag(here, "Crashes", "Null pointer dereference")
+ >>>
"""
+ tag_type = self.get_tag_type(tag_type_name)
+ if tag_type is None:
+ return
+
+ tag_handle = core.BNCreateTag(tag_type.handle, data)
+ assert tag_handle is not None, "core.BNCreateTag returned None"
+ tag = Tag(tag_handle)
+ core.BNAddTag(self.handle, tag.handle, user)
+ core.BNAddUserDataTag(self.handle, addr, tag.handle)
+
+ @deprecation.deprecated(details='get_tag_type_by_name is deprecated; use get_tag_type instead')
+ def get_tag_type_by_name(self, name: str) -> Optional['TagType']:
tag_type = core.BNGetTagType(self.handle, name)
if tag_type is None:
return None
return TagType(tag_type)
+ @deprecation.deprecated(details='get_tag_type_by_id is deprecated; use get_tag_type instead')
def get_tag_type_by_id(self, id: str) -> Optional['TagType']:
- """
- Get a tag type by its id
-
- :param id: Id of the tag type
- :return: The relevant tag type, if it exists
- :rtype: TagType
- """
tag_type = core.BNGetTagTypeById(self.handle, id)
if tag_type is None:
return None
return TagType(tag_type)
+ @deprecation.deprecated(details='create_user_tag is deprecated; use add_tag instead')
def create_user_tag(self, type: 'TagType', data: str) -> 'Tag':
return self.create_tag(type, data, True)
+ @deprecation.deprecated(details='create_auto_tag is deprecated; use add_tag instead')
def create_auto_tag(self, type: 'TagType', data: str) -> 'Tag':
return self.create_tag(type, data, False)
+ @deprecation.deprecated(details='create_tag is deprecated; use add_tag instead')
def create_tag(self, tag_type: 'TagType', data: str, user: bool = True) -> 'Tag':
- """
- ``create_tag`` creates a new :py:class:`Tag` object but does not add it anywhere.
- Use :py:func:`create_user_data_tag` to create and add in one step.
-
- :param TagType tag_type: The :py:class:`TagType` for this Tag
- :param str data: additional data for the Tag
- :param bool user: Whether or not a user tag
- :return: The created Tag
- :rtype: Tag
- :Example:
-
- >>> tt = bv.tag_types["Crashes"]
- >>> tag = bv.create_tag(tt, "Null pointer dereference", True)
- >>> bv.add_user_data_tag(here, tag)
- >>>
- """
if not isinstance(tag_type, TagType):
raise ValueError(f"type is not a TagType instead got {type(tag_type)} : {repr(tag_type)}")
tag_handle = core.BNCreateTag(tag_type.handle, data)
@@ -5373,30 +5385,42 @@ class BinaryView:
core.BNAddTag(self.handle, tag.handle, user)
return tag
+ @deprecation.deprecated(details='get_tag is deprecated')
def get_tag(self, id: str) -> Optional['Tag']:
- """
- Get a tag by its id. Note this does not tell you anything about where it is used.
-
- :param id: tag id
- :return: the relevant tag, if it exists
- :rtype: Tag
- """
tag = core.BNGetTag(self.handle, id)
if tag is None:
return None
return Tag(tag)
@property
- def data_tags(self) -> List[Tuple[int, 'Tag']]:
+ def tags(self) -> List[Tuple[int, 'Tag']]:
+ """
+ ``tags`` gets a list of all data :py:class:`Tag` objects in the view.
+ Tags are returned as a list of (address, :py:class:`Tag`) pairs.
+
+ :type: list(int, Tag)
"""
- ``data_tags`` gets a list of all data :py:class:`Tag` objects in the view.
+ return self.get_tags()
+
+ def get_tags(self, auto: Optional[bool] = None) -> List[Tuple[int, 'Tag']]:
+ """
+ ``tags`` gets a list of all data :py:class:`Tag` objects in the view.
Tags are returned as a list of (address, :py:class:`Tag`) pairs.
:type: list(int, Tag)
"""
count = ctypes.c_ulonglong()
- tags = core.BNGetDataTagReferences(self.handle, count)
- assert tags is not None, "core.BNGetDataTagReferences returned None"
+
+ if auto is None:
+ tags = core.BNGetDataTagReferences(self.handle, count)
+ assert tags is not None, "core.BNGetDataTagReferences returned None"
+ elif auto:
+ tags = core.BNGetAutoDataTagReferences(self.handle, count)
+ assert tags is not None, "core.BNGetAutoDataTagReferences return None"
+ else:
+ tags = core.BNGetUserDataTagReferences(self.handle, count)
+ assert tags is not None, "core.BNGetUserDataTagReferences returned None"
+
result = []
try:
for i in range(0, count.value):
@@ -5408,38 +5432,33 @@ class BinaryView:
finally:
core.BNFreeTagReferences(tags, count.value)
+ @deprecation.deprecated(details='data_tags is deprecated; use tags instead')
@property
- def auto_data_tags(self) -> List[Tuple[int, 'Tag']]:
- """
- ``auto_data_tags`` gets a list of all auto-defined data :py:class:`Tag` objects in the view.
- Tags are returned as a list of (address, :py:class:`Tag`) pairs.
+ def data_tags(self) -> List[Tuple[int, 'Tag']]:
+ return self.tags
- :type: list(int, Tag)
- """
+ @deprecation.deprecated(details='auto_data_tags is deprecated; use get_tags instead')
+ @property
+ def auto_data_tags(self) -> List[Tuple[int, 'Tag']]:
count = ctypes.c_ulonglong()
- refs = core.BNGetAutoDataTagReferences(self.handle, count)
- assert refs is not None, "core.BNGetAutoDataTagReferences return None"
+ tags = core.BNGetAutoDataTagReferences(self.handle, count)
+ assert tags is not None, "core.BNGetAutoDataTagReferences return None"
result = []
try:
for i in range(0, count.value):
- handle = refs[i].tag
+ handle = tags[i].tag
assert handle is not None, "BNGetAutoDataTagReferences returned handle set to None"
tag_ref = core.BNNewTagReference(handle)
assert tag_ref is not None, "BNNewTagReference returned None"
tag = Tag(tag_ref)
- result.append((refs[i].addr, tag))
+ result.append((tags[i].addr, tag))
return result
finally:
- core.BNFreeTagReferences(refs, count.value)
+ core.BNFreeTagReferences(tags, count.value)
+ @deprecation.deprecated(details='user_data_tags is deprecated; use get_tags instead')
@property
def user_data_tags(self) -> List[Tuple[int, 'Tag']]:
- """
- ``user_data_tags`` gets a list of all user data :py:class:`Tag` objects in the view.
- Tags are returned as a list of (address, :py:class:`Tag`) pairs.
-
- :type: list(int, Tag)
- """
count = ctypes.c_ulonglong()
refs = core.BNGetUserDataTagReferences(self.handle, count)
assert refs is not None, "core.BNGetUserDataTagReferences returned None"
@@ -5456,17 +5475,26 @@ class BinaryView:
finally:
core.BNFreeTagReferences(refs, count.value)
- def get_data_tags_at(self, addr: int) -> List['Tag']:
+ def get_tags_at(self, addr: int, auto: Optional[bool] = None) -> List['Tag']:
"""
- ``get_data_tags_at`` gets a list of all :py:class:`Tag` objects for a data address.
+ ``get_data_tags_at`` gets a list of :py:class:`Tag` objects for a data address.
:param int addr: address to get tags at
+ :param bool auto: If None, gets all tags, if True, gets auto tags, if False, gets user tags
:return: A list of data :py:class:`Tag` objects
:rtype: list(Tag)
"""
count = ctypes.c_ulonglong()
- tags = core.BNGetDataTags(self.handle, addr, count)
- assert tags is not None, "core.BNGetDataTags returned None"
+ if auto is None:
+ tags = core.BNGetDataTags(self.handle, addr, count)
+ assert tags is not None, "core.BNGetDataTags returned None"
+ elif auto:
+ tags = core.BNGetAutoDataTags(self.handle, addr, count)
+ assert tags is not None, "core.BNGetAutoDataTags returned None"
+ else:
+ tags = core.BNGetUserDataTags(self.handle, addr, count)
+ assert tags is not None, "core.BNGetUserDataTags returned None"
+
result = []
try:
for i in range(0, count.value):
@@ -5477,60 +5505,36 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
- def get_auto_data_tags_at(self, addr: int) -> List['Tag']:
- """
- ``get_auto_data_tags_at`` gets a list of all auto-defined :py:class:`Tag` objects for a data address.
+ @deprecation.deprecated(details='get_data_tags_at is deprecated; use get_tags_at instead')
+ def get_data_tags_at(self, addr: int, auto: Optional[bool] = None) -> List['Tag']:
+ return self.get_tags_at(addr, auto)
- :param int addr: address to get tags at
- :return: A list of data :py:class:`Tag` objects
- :rtype: list(Tag)
- """
- count = ctypes.c_ulonglong()
- tags = core.BNGetAutoDataTags(self.handle, addr, count)
- assert tags is not None, "core.BNGetAutoDataTags returned None"
- result = []
- try:
- for i in range(0, count.value):
- tag_ref = core.BNNewTagReference(tags[i])
- assert tag_ref is not None, "BNNewTagReference returned None"
- result.append(Tag(tag_ref))
- return result
- finally:
- core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='get_auto_data_tags_at is deprecated; use get_tags_at instead')
+ def get_auto_data_tags_at(self, addr: int) -> List['Tag']:
+ return self.get_tags_at(addr, True)
+ @deprecation.deprecated(details='get_user_data_tags_at is deprecated; use get_tags_at instead')
def get_user_data_tags_at(self, addr: int) -> List['Tag']:
- """
- ``get_user_data_tags_at`` gets a list of all user :py:class:`Tag` objects for a data address.
+ return self.get_tags_at(addr, False)
- :param int addr: address to get tags at
- :return: A list of data :py:class:`Tag` objects
- :rtype: list(Tag)
- """
+ @deprecation.deprecated(details='get_data_tags_of_type is deprecated; use get_tags_at instead')
+ def get_data_tags_of_type(self, addr: int, tag_type: str, auto: Optional[bool] = None) -> List['Tag']:
count = ctypes.c_ulonglong()
- tags = core.BNGetUserDataTags(self.handle, addr, count)
- assert tags is not None, "core.BNGetUserDataTags returned None"
- result = []
- try:
- for i in range(0, count.value):
- tag_ref = core.BNNewTagReference(tags[i])
- assert tag_ref is not None, "BNNewTagReference returned None"
- result.append(Tag(tag_ref))
- return result
- finally:
- core.BNFreeTagList(tags, count.value)
- def get_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> List['Tag']:
- """
- ``get_data_tags_of_type`` gets a list of all :py:class:`Tag` objects for a data address of a given type.
+ tag_type = self.get_tag_type(tag_type)
+ if tag_type is None:
+ return []
+
+ if auto is None:
+ tags = core.BNGetDataTagsOfType(self.handle, addr, tag_type.handle, count)
+ assert tags is not None, "BNGetDataTagsOfType returned None"
+ elif auto:
+ tags = core.BNGetAutoDataTagsOfType(self.handle, addr, tag_type.handle, count)
+ assert tags is not None, "core.BNGetAutoDataTagsOfType returned None"
+ else:
+ tags = core.BNGetUserDataTagsOfType(self.handle, addr, tag_type.handle, count)
+ assert tags is not None, "core.BNGetUserDataTagsOfType returned None"
- :param int addr: address to get tags at
- :param TagType tag_type: :py:class:`TagType` object to match in searching
- :return: A list of data :py:class:`Tag` objects
- :rtype: list(Tag)
- """
- count = ctypes.c_ulonglong()
- tags = core.BNGetDataTagsOfType(self.handle, addr, tag_type.handle, count)
- assert tags is not None, "BNGetDataTagsOfType returned None"
result = []
try:
for i in range(0, count.value):
@@ -5541,15 +5545,8 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='get_auto_data_tags_of_type is deprecated; use get_tags_at instead')
def get_auto_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> List['Tag']:
- """
- ``get_auto_data_tags_of_type`` gets a list of all auto-defined :py:class:`Tag` objects for a data address of a given type.
-
- :param int addr: address to get tags at
- :param TagType tag_type: :py:class:`TagType` object to match in searching
- :return: A list of data :py:class:`Tag` objects
- :rtype: list(Tag)
- """
count = ctypes.c_ulonglong()
tags = core.BNGetAutoDataTagsOfType(self.handle, addr, tag_type.handle, count)
assert tags is not None, "core.BNGetAutoDataTagsOfType returned None"
@@ -5563,15 +5560,8 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='get_user_data_tags_of_type is deprecated; use get_tags_at instead')
def get_user_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> List['Tag']:
- """
- ``get_user_data_tags_of_type`` gets a list of all user :py:class:`Tag` objects for a data address of a given type.
-
- :param int addr: address to get tags at
- :param TagType tag_type: :py:class:`TagType` object to match in searching
- :return: A list of data :py:class:`Tag` objects
- :rtype: list(Tag)
- """
count = ctypes.c_ulonglong()
tags = core.BNGetUserDataTagsOfType(self.handle, addr, tag_type.handle, count)
assert tags is not None, "BNGetUserDataTagsOfType returned None"
@@ -5585,18 +5575,27 @@ class BinaryView:
finally:
core.BNFreeTagList(tags, count.value)
- def get_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
+ def get_tags_in_range(self, address_range: 'variable.AddressRange', auto: Optional[bool] = None) -> List[Tuple[int, 'Tag']]:
"""
``get_data_tags_in_range`` gets a list of all data :py:class:`Tag` objects in a given range.
Range is inclusive at the start, exclusive at the end.
:param AddressRange address_range: address range from which to get tags
+ :param bool auto: If None, gets all tags, if True, gets auto tags, if False, gets auto tags
:return: A list of (address, data tag) tuples
:rtype: list((int, Tag))
"""
count = ctypes.c_ulonglong()
- refs = core.BNGetDataTagsInRange(self.handle, address_range.start, address_range.end, count)
- assert refs is not None, "BNGetDataTagsInRange returned None"
+ if auto is None:
+ refs = core.BNGetDataTagsInRange(self.handle, address_range.start, address_range.end, count)
+ assert refs is not None, "BNGetDataTagsInRange returned None"
+ elif auto:
+ refs = core.BNGetAutoDataTagsInRange(self.handle, address_range.start, address_range.end, count)
+ assert refs is not None, "BNGetAutoDataTagsInRange returned None"
+ else:
+ refs = core.BNGetUserDataTagsInRange(self.handle, address_range.start, address_range.end, count)
+ assert refs is not None, "BNGetUserDataTagsInRange returned None"
+
result = []
try:
for i in range(0, count.value):
@@ -5608,86 +5607,24 @@ class BinaryView:
finally:
core.BNFreeTagReferences(refs, count.value)
- def get_auto_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
- """
- ``get_auto_data_tags_in_range`` gets a list of all auto-defined data :py:class:`Tag` objects in a given range.
- Range is inclusive at the start, exclusive at the end.
+ @deprecation.deprecated(details='get_data_tags_in_range is deprecated; use get_tags_in_range instead')
+ def get_data_tags_in_range(self, address_range: 'variable.AddressRange', user: Optional[bool] = None) -> List[Tuple[int, 'Tag']]:
+ return self.get_tags_in_range(address_range, user)
- :param AddressRange address_range: address range from which to get tags
- :return: A list of (address, data tag) tuples
- :rtype: list((int, Tag))
- """
- count = ctypes.c_ulonglong()
- refs = core.BNGetAutoDataTagsInRange(self.handle, address_range.start, address_range.end, count)
- assert refs is not None, "BNGetAutoDataTagsInRange returned None"
- result = []
- try:
- for i in range(count.value):
- tag_ref = core.BNNewTagReference(refs[i].tag)
- assert tag_ref is not None, "BNNewTagReference returned None"
- tag = Tag(tag_ref)
- result.append((refs[i].addr, tag))
- return result
- finally:
- core.BNFreeTagReferences(refs, count.value)
+ @deprecation.deprecated(details='get_auto_data_tags_in_range is deprecated; use get_tags_in_range instead')
+ def get_auto_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
+ return self.get_tags_in_range(address_range, True)
+ @deprecation.deprecated(details='get_user_data_tags_in_range is deprecated; use get_tags_in_range instead')
def get_user_data_tags_in_range(self, address_range: 'variable.AddressRange') -> List[Tuple[int, 'Tag']]:
- """
- ``get_user_data_tags_in_range`` gets a list of all user data :py:class:`Tag` objects in a given range.
- Range is inclusive at the start, exclusive at the end.
-
- :param AddressRange address_range: address range from which to get tags
- :return: A list of (address, data tag) tuples
- :rtype: list((int, Tag))
- """
- count = ctypes.c_ulonglong()
- refs = core.BNGetUserDataTagsInRange(self.handle, address_range.start, address_range.end, count)
- assert refs is not None, "BNGetUserDataTagsInRange returned None"
- result = []
- try:
- for i in range(count.value):
- tag_ref = core.BNNewTagReference(refs[i].tag)
- assert tag_ref is not None, "BNNewTagReference returned None"
- tag = Tag(tag_ref)
- result.append((refs[i].addr, tag))
- return result
- finally:
- core.BNFreeTagReferences(refs, count.value)
-
- def add_user_data_tag(self, addr: int, tag: 'Tag') -> None:
- """
- ``add_user_data_tag`` adds an already-created :py:class:`Tag` object at a data address.
- Since this adds a user tag, it will be added to the current undo buffer.
- If you want to create the tag as well, consider using
- :py:func:`create_user_data_tag`
+ return self.get_tags_in_range(address_range, False)
- :param int addr: address at which to add the tag
- :param Tag tag: :py:class:`Tag` object to be added
- :rtype: None
- """
+ @deprecation.deprecated(details='add_user_data_tag is deprecated; use add_tag instead')
+ def add_user_data_tag(self, addr: int, tag: 'Tag'):
core.BNAddUserDataTag(self.handle, addr, tag.handle)
+ @deprecation.deprecated(details='create_user_data_tag is deprecated; use add_tag instead')
def create_user_data_tag(self, addr: int, type: 'TagType', data: str, unique: bool = False) -> 'Tag':
- """
- ``create_user_data_tag`` creates and adds a :py:class:`Tag` object at a data
- address. Since this adds a user tag, it will be added to the current
- undo buffer.
-
- This API is appropriate for generic data tags, for functions,
- consider using :py:func:`~binaryninja.function.Function.create_user_function_tag` or for
- specific addresses inside of functions, use :py:func:`~binaryninja.function.Function.create_user_address_tag`.
-
- :param int addr: address at which to add the tag
- :param TagType type: :py:class:`TagType` for the :py:class:`Tag` that is created
- :param str data: additional data for the Tag
- :param bool unique: if a tag already exists at this location with this data, don't add another
- :return: The created :py:class:`Tag`
- :rtype: Tag
- :Example:
-
- >>> tt = bv.tag_types["Crashes"]
- >>> bv.create_user_data_tag(here, tt, "String data to associate with this tag")
- """
if unique:
tags = self.get_data_tags_at(addr)
for tag in tags:
@@ -5698,7 +5635,7 @@ class BinaryView:
core.BNAddUserDataTag(self.handle, addr, tag.handle)
return tag
- def remove_user_data_tag(self, addr: int, tag: Tag) -> None:
+ def remove_user_data_tag(self, addr: int, tag: Tag):
"""
``remove_user_data_tag`` removes a :py:class:`Tag` object at a data address.
Since this removes a user tag, it will be added to the current undo buffer.
@@ -5709,40 +5646,25 @@ class BinaryView:
"""
core.BNRemoveUserDataTag(self.handle, addr, tag.handle)
- def remove_user_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> None:
+ def remove_user_data_tags_of_type(self, addr: int, tag_type: 'str'):
"""
``remove_user_data_tags_of_type`` removes all data tags at the given address of the given type.
Since this removes user tags, it will be added to the current undo buffer.
:param int addr: address at which to add the tags
- :param TagType tag_type: :py:class:`TagType` object to match for removing
+ :param str tag_type: Tag type name to match for removing
:rtype: None
"""
- core.BNRemoveUserDataTagsOfType(self.handle, addr, tag_type.handle)
-
- def add_auto_data_tag(self, addr: int, tag: 'Tag') -> None:
- """
- ``add_auto_data_tag`` adds an already-created :py:class:`Tag` object at a data address.
- If you want to create the tag as well, consider using
- :py:func:`~create_auto_data_tag`
+ tag_type = self.get_tag_type(tag_type)
+ if tag_type is not None:
+ core.BNRemoveUserDataTagsOfType(self.handle, addr, tag_type.handle)
- :param int addr: address at which to add the tag
- :param Tag tag: :py:class:`Tag` object to be added
- :rtype: None
- """
+ @deprecation.deprecated(details='add_auto_data_tag is deprecated; use add_tag instead')
+ def add_auto_data_tag(self, addr: int, tag: 'Tag'):
core.BNAddAutoDataTag(self.handle, addr, tag.handle)
+ @deprecation.deprecated(details='create_auto_data_tag is deprecated; use add_tag instead')
def create_auto_data_tag(self, addr: int, type: 'TagType', data: str, unique: bool = False) -> 'Tag':
- """
- ``create_auto_data_tag`` creates and adds a :py:class:`Tag` object at a data address.
-
- :param int addr: address at which to add the tag
- :param TagType type: :py:class:`TagType` for the :py:class:`Tag` that is created
- :param str data: additional data for the :py:class:`Tag`
- :param bool unique: If a tag already exists at this location with this data, don't add another
- :return: The created :py:class:`Tag` object
- :rtype: Tag
- """
if unique:
tags = self.get_data_tags_at(addr)
for tag in tags:
@@ -5753,7 +5675,7 @@ class BinaryView:
core.BNAddAutoDataTag(self.handle, addr, tag.handle)
return tag
- def remove_auto_data_tag(self, addr: int, tag: 'Tag') -> None:
+ def remove_auto_data_tag(self, addr: int, tag: 'Tag'):
"""
``remove_auto_data_tag`` removes a Tag object at a data address.
@@ -5763,15 +5685,17 @@ class BinaryView:
"""
core.BNRemoveAutoDataTag(self.handle, addr, tag.handle)
- def remove_auto_data_tags_of_type(self, addr: int, tag_type: 'TagType') -> None:
+ def remove_auto_data_tags_of_type(self, addr: int, tag_type: 'str'):
"""
``remove_auto_data_tags_of_type`` removes all data tags at the given address of the given type.
:param int addr: address at which to add the tags
- :param TagType tag_type: :py:class:`TagType` object to match for removing
+ :param str tag_type: Tag type name to match for removing
:rtype: None
"""
- core.BNRemoveAutoDataTagsOfType(self.handle, addr, tag_type.handle)
+ tag_type = self.get_tag_type(tag_type)
+ if tag_type is not None:
+ core.BNRemoveAutoDataTagsOfType(self.handle, addr, tag_type.handle)
def can_assemble(self, arch: Optional['architecture.Architecture'] = None) -> bool:
"""
diff --git a/python/function.py b/python/function.py
index 9e3b5344..1a1685f6 100644
--- a/python/function.py
+++ b/python/function.py
@@ -597,53 +597,199 @@ class Function:
finally:
core.BNFreeAddressList(addrs)
- def create_user_tag(self, type: 'binaryview.TagType', data: str = "") -> 'binaryview.Tag':
- """Create a _user_ Tag object"""
- return self.create_tag(type, data, True)
+ @property
+ def tags(self) -> TagList:
+ """
+ ``tags`` gets a TagList of all Tags in the function (but not "function tags").
+ Tags are returned as an iterable indexable object TagList of (arch, address, Tag) tuples.
- def create_auto_tag(self, type: 'binaryview.TagType', data: str = "") -> 'binaryview.Tag':
- """Create an _auto_ Tag object"""
- return self.create_tag(type, data, False)
+ :rtype: TagList((Architecture, int, Tag))
+ """
+ return TagList(self)
- def create_tag(self, type: 'binaryview.TagType', data: str = "", user: bool = True) -> 'binaryview.Tag':
+ def get_tags_at(self, addr: int, arch: Optional['architecture.Architecture'] = None, auto: Optional[bool] = None) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]:
"""
- ``create_tag`` creates a new Tag object but does not add it anywhere.
- Use :py:meth:`create_user_address_tag` or
- :py:meth:`create_user_function_tag` to create and add in one step.
+ ``get_tags`` gets a list of Tags (but not function tags). You optionally get tags by address, range, or type, and filter by user tags.
+ Tags are returned as a list of (arch, address, Tag) tuples.
- :param TagType type: The Tag Type for this Tag
- :param str data: Additional data for the Tag
- :param bool user: Boolean indicating if this is a user tag or not
- :return: The created Tag
- :rtype: Tag
- :Example:
+ :param int addr: Address to get tags from.
+ :param bool auto: If None, gets all tags, if True, gets auto tags, if False, gets user tags
+ :rtype: list((Architecture, int, Tag))
+ """
+ if arch is None:
+ assert self.arch is not None, "Can't call get_tags_at for function with no architecture specified"
+ arch = self.arch
+ count = ctypes.c_ulonglong()
+
+ if auto is None:
+ tags = core.BNGetAddressTags(self.handle, arch.handle, addr, count)
+ assert tags is not None, "core.BNGetAddressTags returned None"
+ elif auto:
+ tags = core.BNGetAutoAddressTags(self.handle, arch.handle, addr, count)
+ assert tags is not None, "core.BNGetAutoAddressTags returned None"
+ else:
+ tags = core.BNGetUserAddressTags(self.handle, arch.handle, addr, count)
+ assert tags is not None, "core.BNGetUserAddressTags returned None"
+
+ result = []
+ try:
+ for i in range(0, count.value):
+ core_tag = core.BNNewTagReference(tags[i])
+ assert core_tag is not None, "core.BNNewTagReference returned None"
+ result.append(binaryview.Tag(core_tag))
+ return result
+ finally:
+ core.BNFreeTagList(tags, count.value)
- >>> tt = bv.tag_types["Crashes"]
- >>> tag = current_function.create_tag(tt, "Null pointer dereference", True)
- >>> current_function.add_user_address_tag(here, tag)
- >>>
+ def get_tags_in_range(
+ self, address_range: 'variable.AddressRange', arch: Optional['architecture.Architecture'] = None, auto: Optional[bool] = None
+ ) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]:
"""
- return self.view.create_tag(type, data, user)
+ ``get_address_tags_in_range`` gets a list of all Tags in the function at a given address.
+ Range is inclusive at the start, exclusive at the end.
- @property
- def address_tags(self) -> TagList:
+ :param AddressRange address_range: Address range from which to get tags
+ :param Architecture arch: Architecture for the block in which the Tag is located (optional)
+ :param bool auto: If None, gets all tags, if True, gets auto tags, if False, gets user tags
+ :return: A list of (arch, address, Tag) tuples
+ :rtype: list((Architecture, int, Tag))
"""
- ``address_tags`` gets a TagList of all address Tags in the function.
- Tags are returned as an iterable indexable object TagList of (arch, address, Tag) tuples.
+ if arch is None:
+ assert self.arch is not None, "Can't call get_address_tags_in_range for function with no architecture specified"
+ arch = self.arch
+ count = ctypes.c_ulonglong()
- :rtype: TagList((Architecture, int, Tag))
+ if auto is None:
+ refs = core.BNGetAddressTagsInRange(self.handle, arch.handle, address_range.start, address_range.end, count)
+ assert refs is not None, "core.BNGetAddressTagsInRange returned None"
+ elif auto:
+ refs = core.BNGetAutoAddressTagsInRange(self.handle, arch.handle, address_range.start, address_range.end, count)
+ assert refs is not None, "core.BNGetAutoAddressTagsInRange returned None"
+ else:
+ refs = core.BNGetUserAddressTagsInRange(self.handle, arch.handle, address_range.start, address_range.end, count)
+ assert refs is not None, "core.BNGetUserAddressTagsInRange returned None"
+
+ try:
+ result = []
+ for i in range(0, count.value):
+ tag_ref = core.BNNewTagReference(refs[i].tag)
+ assert tag_ref is not None, "core.BNNewTagReference returned None"
+ tag = binaryview.Tag(tag_ref)
+ result.append((arch, refs[i].addr, tag))
+ return result
+ finally:
+ core.BNFreeTagReferences(refs, count.value)
+
+ def get_function_tags(self, auto: Optional[bool] = None, tag_type: Optional[str] = None) -> List['binaryview.Tag']:
"""
- return TagList(self)
+ ``get_function_tags`` gets a list of function Tags for the function.
- def get_address_tags_at(self, addr: int,
- arch: Optional['architecture.Architecture'] = None) -> List['binaryview.Tag']:
+ :param bool auto: If None, gets all tags, if True, gets auto tags, if False, gets user tags
+ :param str tag_type: If None, gets all tags, otherwise only gets tags of the given type
+ :rtype: list(Tag)
+ """
+ count = ctypes.c_ulonglong()
+
+ tags = []
+ if tag_type is not None:
+ tag_type = self.view.get_tag_type(tag_type)
+ if tag_type is None:
+ return []
+
+ if auto is None:
+ tags = core.BNGetFunctionTagsOfType(self.handle, tag_type.handle, count)
+ assert tags is not None, "core.BNGetFunctionTagsOfType returned None"
+ elif auto:
+ tags = core.BNGetAutoFunctionTagsOfType(self.handle, tag_type.handle, count)
+ assert tags is not None, "core.BNGetAutoFunctionTagsOfType returned None"
+ else:
+ tags = core.BNGetUserFunctionTagsOfType(self.handle, tag_type.handle, count)
+ assert tags is not None, "core.BNGetUserFunctionTagsOfType returned None"
+ else:
+ if user is None:
+ tags = core.BNGetFunctionTags(self.handle, count)
+ assert tags is not None, "core.BNGetFunctionTags returned None"
+ elif user:
+ tags = core.BNGetUserFunctionTags(self.handle, count)
+ assert tags is not None, "core.BNGetUserFunctionTags returned None"
+ else:
+ tags = core.BNGetAutoFunctionTags(self.handle, count)
+ assert tags is not None, "core.BNGetAutoFunctionTags returned None"
+
+ try:
+ result = []
+ for i in range(count.value):
+ core_tag = core.BNNewTagReference(tags[i])
+ assert core_tag is not None, "core.BNNewTagReference returned None"
+ result.append(binaryview.Tag(core_tag))
+ return result
+ finally:
+ core.BNFreeTagList(tags, count.value)
+
+ def add_tag(
+ self, tag_type: str, data: str, addr: Optional[int] = None, auto: bool = False,
+ arch: Optional['architecture.Architecture'] = None
+ ):
"""
- ``get_address_tags_at`` gets a generator of all Tags in the function at a given address.
+ ``create_user_address_tag`` creates and adds a Tag object at a given
+ address. Since this adds a user tag, it will be added to the current
+ undo buffer. To create tags associated with an address that is not
+ inside of a function, use :py:meth:`add_tag <binaryview.BinaryView.add_tag>`.
- :param int addr: Address to get tags at
+ :param str tag_type: Tag Type name for the Tag that is created
+ :param str data: Additional data for the Tag
+ :param int addr: Address at which to add the tag. If no address is provided, this will create a function tag
+ :param bool auto: Whether to create the tag as a auto tag (True) or user tag (False)
:param Architecture arch: Architecture for the block in which the Tag is added (optional)
- :return: A Generator of Tags
+ :Example:
+
+ >>> current_function.add_tag("Crashes", "Might be a buffer overflow?", here)
+ >>>
+
"""
+ tag_type = self.view.get_tag_type(tag_type)
+ if tag_type is None:
+ return
+ if arch is None:
+ arch = self.arch
+
+ # Create tag
+ tag_handle = core.BNCreateTag(tag_type.handle, data)
+ assert tag_handle is not None, "core.BNCreateTag returned None"
+ tag = binaryview.Tag(tag_handle)
+ core.BNAddTag(self.view.handle, tag.handle, auto)
+
+ if auto:
+ if addr is None:
+ core.BNAddAutoFunctionTag(self.handle, tag.handle)
+ else:
+ core.BNAddAutoAddressTag(self.handle, arch.handle, addr, tag.handle)
+ else:
+ if addr is None:
+ core.BNAddUserFunctionTag(self.handle, tag.handle)
+ else:
+ core.BNAddUserAddressTag(self.handle, arch.handle, addr, tag.handle)
+
+ @deprecation.deprecated(details='create_user_tag is deprecated; use add_tag instead')
+ def create_user_tag(self, type: 'binaryview.TagType', data: str = "") -> 'binaryview.Tag':
+ return self.create_tag(type, data, True)
+
+ @deprecation.deprecated(details='create_auto_tag is deprecated; use add_tag instead')
+ def create_auto_tag(self, type: 'binaryview.TagType', data: str = "") -> 'binaryview.Tag':
+ return self.create_tag(type, data, False)
+
+ @deprecation.deprecated(details='create_tag is deprecated; use add_tag instead')
+ def create_tag(self, type: 'binaryview.TagType', data: str = "", auto: bool = False) -> 'binaryview.Tag':
+ return self.view.create_tag(type, data, auto)
+
+ @deprecation.deprecated(details='address_tags is deprecated; use tags instead')
+ @property
+ def address_tags(self) -> TagList:
+ return TagList(self)
+
+ @deprecation.deprecated(details='get_address_tags_at is deprecated; use get_tags_at instead')
+ def get_address_tags_at(self, addr: int,
+ arch: Optional['architecture.Architecture'] = None) -> List['binaryview.Tag']:
if arch is None:
arch = self.arch
count = ctypes.c_ulonglong()
@@ -659,42 +805,19 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='add_user_address_tag is deprecated; use add_tag instead')
def add_user_address_tag(
self, addr: int, tag: 'binaryview.Tag', arch: Optional['architecture.Architecture'] = None
) -> None:
- """
- ``add_user_address_tag`` adds an already-created Tag object at a given address.
- Since this adds a user tag, it will be added to the current undo buffer.
- If you want to create the tag as well, consider using
- :meth:`create_user_address_tag <function.Function.create_user_address_tag>`
-
- :param int addr: Address at which to add the tag
- :param Tag tag: Tag object to be added
- :param Architecture arch: Architecture for the block in which the Tag is added (optional)
- :rtype: None
- """
if arch is None:
arch = self.arch
core.BNAddUserAddressTag(self.handle, arch.handle, addr, tag.handle)
+ @deprecation.deprecated(details='create_user_address_tag is deprecated; use add_tag instead')
def create_user_address_tag(
self, addr: int, tag_type: 'binaryview.TagType', data: str, unique: bool = False,
arch: Optional['architecture.Architecture'] = None
) -> 'binaryview.Tag':
- """
- ``create_user_address_tag`` creates and adds a Tag object at a given
- address. Since this adds a user tag, it will be added to the current
- undo buffer. To create tags associated with an address that is not
- inside of a function, use :py:meth:`create_user_data_tag <binaryview.BinaryView.create_user_data_tag>`.
-
- :param int addr: Address at which to add the tag
- :param TagType tag_type: Tag Type for the Tag that is created
- :param str data: Additional data for the Tag
- :param bool unique: If a tag already exists at this location with this data, don't add another
- :param Architecture arch: Architecture for the block in which the Tag is added (optional)
- :return: The created Tag
- :rtype: Tag
- """
if not isinstance(tag_type, binaryview.TagType):
raise TypeError(f"type is not a TagType instead got {type(tag_type)} : {repr(tag_type)}")
if arch is None:
@@ -725,38 +848,19 @@ class Function:
arch = self.arch
core.BNRemoveUserAddressTag(self.handle, arch.handle, addr, tag.handle)
+ @deprecation.deprecated(details='add_auto_address_tag is deprecated; use add_tag instead')
def add_auto_address_tag(
self, addr: int, tag: 'binaryview.Tag', arch: Optional['architecture.Architecture'] = None
) -> None:
- """
- ``add_auto_address_tag`` adds an already-created Tag object at a given address.
- If you want to create the tag as well, consider using
- :meth:`create_auto_address_tag <function.Function.create_auto_address_tag>`
-
- :param int addr: Address at which to add the tag
- :param Tag tag: Tag object to be added
- :param Architecture arch: Architecture for the block in which the Tag is added (optional)
- :rtype: None
- """
if arch is None:
arch = self.arch
core.BNAddAutoAddressTag(self.handle, arch.handle, addr, tag.handle)
+ @deprecation.deprecated(details='create_auto_address_tag is deprecated; use add_tag instead')
def create_auto_address_tag(
self, addr: int, type: 'binaryview.TagType', data: str, unique: bool = False,
arch: Optional['architecture.Architecture'] = None
) -> 'binaryview.Tag':
- """
- ``create_auto_address_tag`` creates and adds a Tag object at a given address.
-
- :param int addr: Address at which to add the tag
- :param TagType type: Tag Type for the Tag that is created
- :param str data: Additional data for the Tag
- :param bool unique: If a tag already exists at this location with this data, don't add another
- :param Architecture arch: Architecture for the block in which the Tag is added (optional)
- :return: The created Tag
- :rtype: Tag
- """
if arch is None:
arch = self.arch
if unique:
@@ -769,13 +873,9 @@ class Function:
core.BNAddAutoAddressTag(self.handle, arch.handle, addr, tag.handle)
return tag
+ @deprecation.deprecated(details='function_tags is deprecated; use get_function_tags instead')
@property
def function_tags(self) -> List['binaryview.Tag']:
- """
- ``function_tags`` gets a list of all function Tags for the function.
-
- :rtype: List(Tag)
- """
count = ctypes.c_ulonglong()
tags = core.BNGetFunctionTags(self.handle, count)
assert tags is not None, "core.BNGetFunctionTags returned None"
@@ -789,29 +889,12 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='add_user_function_tag is deprecated; use add_tag instead')
def add_user_function_tag(self, tag: 'binaryview.Tag') -> None:
- """
- ``add_user_function_tag`` adds an already-created Tag object as a function tag.
- Since this adds a user tag, it will be added to the current undo buffer.
- If you want to create the tag as well, consider using
- :meth:`create_user_function_tag <function.Function.create_user_function_tag>`
-
- :param Tag tag: Tag object to be added
- :rtype: None
- """
core.BNAddUserFunctionTag(self.handle, tag.handle)
+ @deprecation.deprecated(details='create_user_function_tag is deprecated; use add_tag instead')
def create_user_function_tag(self, type: 'binaryview.TagType', data: str, unique: bool = False) -> 'binaryview.Tag':
- """
- ``add_user_function_tag`` creates and adds a Tag object as a function tag.
- Since this adds a user tag, it will be added to the current undo buffer.
-
- :param TagType type: Tag Type for the Tag that is created
- :param str data: Additional data for the Tag
- :param bool unique: If a tag already exists with this data, don't add another
- :return: The created Tag
- :rtype: Tag
- """
if unique:
for tag in self.function_tags:
if tag.type == type and tag.data == data:
@@ -831,27 +914,12 @@ class Function:
"""
core.BNRemoveUserFunctionTag(self.handle, tag.handle)
+ @deprecation.deprecated(details='add_auto_function_tag is deprecated; use add_tag instead')
def add_auto_function_tag(self, tag: 'binaryview.Tag') -> None:
- """
- ``add_auto_function_tag`` adds an already-created Tag object as a function tag.
- If you want to create the tag as well, consider using
- :meth:`create_auto_function_tag <function.Function.create_auto_function_tag>`
-
- :param Tag tag: Tag object to be added
- :rtype: None
- """
core.BNAddAutoFunctionTag(self.handle, tag.handle)
+ @deprecation.deprecated(details='create_auto_function_tag is deprecated; use add_tag instead')
def create_auto_function_tag(self, type: 'binaryview.TagType', data: str, unique: bool = False) -> 'binaryview.Tag':
- """
- ``create_auto_function_tag`` creates and adds a Tag object as a function tag.
-
- :param TagType type: Tag Type for the Tag that is created
- :param str data: Additional data for the Tag
- :param bool unique: If a tag already exists with this data, don't add another
- :return: The created Tag
- :rtype: Tag
- """
if unique:
for tag in self.function_tags:
if tag.type == type and tag.data == data:
@@ -861,14 +929,9 @@ class Function:
core.BNAddAutoFunctionTag(self.handle, tag.handle)
return tag
+ @deprecation.deprecated(details='auto_address_tags is deprecated; use tags instead')
@property
def auto_address_tags(self) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]:
- """
- ``auto_address_tags`` gets a list of all auto-defined address Tags in the function.
- Tags are returned as a list of (arch, address, Tag) tuples.
-
- :rtype: list((Architecture, int, Tag))
- """
count = ctypes.c_ulonglong()
tags = core.BNGetAutoAddressTagReferences(self.handle, count)
assert tags is not None, "core.BNGetAutoAddressTagReferences returned None"
@@ -884,14 +947,9 @@ class Function:
finally:
core.BNFreeTagReferences(tags, count.value)
+ @deprecation.deprecated(details='user_address_tags is deprecated; use tags instead')
@property
def user_address_tags(self):
- """
- ``user_address_tags`` gets a list of all user address Tags in the function.
- Tags are returned as a list of (arch, address, Tag) tuples.
-
- :rtype: list((Architecture, int, Tag))
- """
count = ctypes.c_ulonglong()
tags = core.BNGetUserAddressTagReferences(self.handle, count)
assert tags is not None, "core.BNGetUserAddressTagReferences returned"
@@ -907,15 +965,8 @@ class Function:
finally:
core.BNFreeTagReferences(tags, count.value)
+ @deprecation.deprecated(details='get_auto_address_tags_at is deprecated; use get_tags_at instead')
def get_auto_address_tags_at(self, addr, arch=None):
- """
- ``get_auto_address_tags_at`` gets a list of all auto-defined Tags in the function at a given address.
-
- :param int addr: Address to get tags at
- :param Architecture arch: Architecture for the block in which the Tag is located (optional)
- :return: A list of Tags
- :rtype: list(Tag)
- """
if arch is None:
assert self.arch is not None, "Can't call get_auto_address_tags_at for function with no architecture specified"
arch = self.arch
@@ -932,15 +983,8 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='get_user_address_tags_at is deprecated; use get_tags_at instead')
def get_user_address_tags_at(self, addr, arch=None):
- """
- ``get_user_address_tags_at`` gets a list of all user Tags in the function at a given address.
-
- :param int addr: Address to get tags at
- :param Architecture arch: Architecture for the block in which the Tag is located (optional)
- :return: A list of Tags
- :rtype: list(Tag)
- """
if arch is None:
assert self.arch is not None, "Can't call get_user_address_tags_at for function with no architecture specified"
arch = self.arch
@@ -957,16 +1001,8 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='get_address_tags_of_type is deprecated; use get_tags_at instead')
def get_address_tags_of_type(self, addr: int, tag_type: 'binaryview.TagType', arch=None):
- """
- ``get_address_tags_of_type`` gets a list of all Tags in the function at a given address with a given type.
-
- :param int addr: Address to get tags at
- :param TagType tag_type: TagType object to match in searching
- :param Architecture arch: Architecture for the block in which the Tags are located (optional)
- :return: A list of data Tags
- :rtype: list(Tag)
- """
if arch is None:
assert self.arch is not None, "Can't call get_address_tags_of_type for function with no architecture specified"
arch = self.arch
@@ -983,18 +1019,10 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='get_auto_address_tags_of_type is deprecated; use get_tags_at instead')
def get_auto_address_tags_of_type(
self, addr: int, tag_type: 'binaryview.TagType', arch: Optional['architecture.Architecture'] = None
):
- """
- ``get_auto_address_tags_of_type`` gets a list of all auto-defined Tags in the function at a given address with a given type.
-
- :param int addr: Address to get tags at
- :param TagType tag_type: TagType object to match in searching
- :param Architecture arch: Architecture for the block in which the Tags are located (optional)
- :return: A list of data Tags
- :rtype: list(Tag)
- """
if arch is None:
assert self.arch is not None, "Can't call get_auto_address_tags_of_type for function with no architecture specified"
arch = self.arch
@@ -1011,18 +1039,10 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='get_user_address_tags_of_type is deprecated; use get_tags_at instead')
def get_user_address_tags_of_type(
self, addr: int, tag_type: 'binaryview.TagType', arch: Optional['architecture.Architecture'] = None
):
- """
- ``get_user_address_tags_of_type`` gets a list of all user Tags in the function at a given address with a given type.
-
- :param int addr: Address to get tags at
- :param TagType tag_type: TagType object to match in searching
- :param Architecture arch: Architecture for the block in which the Tags are located (optional)
- :return: A list of data Tags
- :rtype: list(Tag)
- """
if arch is None:
assert self.arch is not None, "Can't get_user_address_tags_of_type for function with no architecture specified"
arch = self.arch
@@ -1039,18 +1059,10 @@ class Function:
finally:
core.BNFreeTagList(tags, count.value)
+ @deprecation.deprecated(details='get_address_tags_in_range is deprecated; use get_tags_in_range instead')
def get_address_tags_in_range(
self, address_range: 'variable.AddressRange', arch: Optional['architecture.Architecture'] = None
) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]:
- """
- ``get_address_tags_in_range`` gets a list of all Tags in the function at a given address.
- Range is inclusive at the start, exclusive at the end.
-
- :param AddressRange address_range: Address range from which to get tags
- :param Architecture arch: Architecture for the block in which the Tag is located (optional)
- :return: A list of (arch, address, Tag) tuples
- :rtype: list((Architecture, int, Tag))
- """
if arch is None:
assert self.arch is not None, "Can't call get_address_tags_in_range for function with no architecture specified"
arch = self.arch
@@ -1068,18 +1080,10 @@ class Function:
finally:
core.BNFreeTagReferences(refs, count.value)
+ @deprecation.deprecated(details='get_auto_address_tags_in_range is deprecated; use get_tags_in_range instead')
def get_auto_address_tags_in_range(
self, address_range: 'variable.AddressRange', arch: Optional['architecture.Architecture'] = None
) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]:
- """
- ``get_auto_address_tags_in_range`` gets a list of all auto-defined Tags in the function at a given address.
- Range is inclusive at the start, exclusive at the end.
-
- :param AddressRange address_range: Address range from which to get tags
- :param Architecture arch: Architecture for the block in which the Tag is located (optional)
- :return: A list of (arch, address, Tag) tuples
- :rtype: list((Architecture, int, Tag))
- """
if arch is None:
assert self.arch is not None, "Can't call get_auto_address_tags_in_range for function with no architecture specified"
arch = self.arch
@@ -1097,18 +1101,10 @@ class Function:
finally:
core.BNFreeTagReferences(refs, count.value)
+ @deprecation.deprecated(details='get_user_address_tags_in_range is deprecated; use get_tags_in_range instead')
def get_user_address_tags_in_range(
self, address_range: 'variable.AddressRange', arch: Optional['architecture.Architecture'] = None
) -> List[Tuple['architecture.Architecture', int, 'binaryview.Tag']]:
- """
- ``get_user_address_tags_in_range`` gets a list of all user Tags in the function at a given address.
- Range is inclusive at the start, exclusive at the end.
-
- :param AddressRange address_range: Address range from which to get tags
- :param Architecture arch: Architecture for the block in which the Tag is located (optional)
- :return: A list of (arch, address, Tag) tuples
- :rtype: list((Architecture, int, Tag))
- """
if arch is None:
assert self.arch is not None, "Can't call get_user_address_tags_in_range for function with no architecture specified"
arch = self.arch
@@ -1168,13 +1164,9 @@ class Function:
arch = self.arch
core.BNRemoveAutoAddressTagsOfType(self.handle, arch.handle, addr, tag_type.handle)
+ @deprecation.deprecated(details='auto_function_tags is deprecated; use get_function_tags instead')
@property
def auto_function_tags(self):
- """
- ``auto_function_tags`` gets a list of all auto-defined function Tags for the function.
-
- :rtype: list(Tag)
- """
count = ctypes.c_ulonglong()
tags = core.BNGetAutoFunctionTags(self.handle, count)
assert tags is not None, "core.BNGetAutoFunctionTags returned None"
@@ -1186,13 +1178,9 @@ class Function:
core.BNFreeTagList(tags, count.value)
return result
+ @deprecation.deprecated(details='user_function_tags is deprecated; use get_function_tags instead')
@property
def user_function_tags(self):
- """
- ``user_function_tags`` gets a list of all user function Tags for the function.
-
- :rtype: list(Tag)
- """
count = ctypes.c_ulonglong()
tags = core.BNGetUserFunctionTags(self.handle, count)
assert tags is not None, "core.BNGetUserFunctionTags returned None"
@@ -1204,14 +1192,8 @@ class Function:
core.BNFreeTagList(tags, count.value)
return result
+ @deprecation.deprecated(details='get_function_tags_of_type is deprecated; use get_function_tags instead')
def get_function_tags_of_type(self, tag_type):
- """
- ``get_function_tags_of_type`` gets a list of all function Tags with a given type.
-
- :param TagType tag_type: TagType object to match in searching
- :return: A list of data Tags
- :rtype: list(Tag)
- """
count = ctypes.c_ulonglong()
tags = core.BNGetFunctionTagsOfType(self.handle, tag_type.handle, count)
assert tags is not None, "core.BNGetFunctionTagsOfType returned None"
@@ -1223,14 +1205,8 @@ class Function:
core.BNFreeTagList(tags, count.value)
return result
+ @deprecation.deprecated(details='get_auto_function_tags_of_type is deprecated; use get_function_tags instead')
def get_auto_function_tags_of_type(self, tag_type):
- """
- ``get_auto_function_tags_of_type`` gets a list of all auto-defined function Tags with a given type.
-
- :param TagType tag_type: TagType object to match in searching
- :return: A list of data Tags
- :rtype: list(Tag)
- """
count = ctypes.c_ulonglong()
tags = core.BNGetAutoFunctionTagsOfType(self.handle, tag_type.handle, count)
assert tags is not None, "core.BNGetAutoFunctionTagsOfType returned None"
@@ -1242,14 +1218,8 @@ class Function:
core.BNFreeTagList(tags, count.value)
return result
+ @deprecation.deprecated(details='get_user_function_tags_of_type is deprecated; use get_function_tags instead')
def get_user_function_tags_of_type(self, tag_type):
- """
- ``get_user_function_tags_of_type`` gets a list of all user function Tags with a given type.
-
- :param TagType tag_type: TagType object to match in searching
- :return: A list of data Tags
- :rtype: list(Tag)
- """
count = ctypes.c_ulonglong()
tags = core.BNGetUserFunctionTagsOfType(self.handle, tag_type.handle, count)
assert tags is not None, "core.BNGetUserFunctionTagsOfType returned None"