``get_code_refs`` returns a generator of :py:class:`~binaryninja.binaryview.ReferenceSource` objects (xrefs or cross-references) that point to the provided virtual address. This function returns both autoanalysis ("auto") and user-specified ("user") xrefs. To add a user-specified reference, s
(self, addr: int, length: Optional[int] = None)
| 5243 | return basicblock.BasicBlock(block, self) |
| 5244 | |
| 5245 | def get_code_refs(self, addr: int, length: Optional[int] = None) -> Generator['ReferenceSource', None, None]: |
| 5246 | """ |
| 5247 | ``get_code_refs`` returns a generator of :py:class:`~binaryninja.binaryview.ReferenceSource` objects (xrefs or cross-references) that point to the provided virtual address. |
| 5248 | This function returns both autoanalysis ("auto") and user-specified ("user") xrefs. |
| 5249 | To add a user-specified reference, see :py:func:`~binaryninja.function.Function.add_user_code_ref`. |
| 5250 | |
| 5251 | The related :py:func:`get_data_refs` is used to find data references to an address unlike this API which returns references that exist in code. |
| 5252 | |
| 5253 | .. note:: Note that `get_code_refs` returns xrefs to code that references the address being queried. \ |
| 5254 | `get_data_refs` on the other hand returns references that exist in data (pointers in global variables for example). \ |
| 5255 | The related :py:func:`get_code_refs_from` looks for references that are outgoing from the queried address to other locations. |
| 5256 | |
| 5257 | :param int addr: virtual address to query for references |
| 5258 | :param int length: optional length of query |
| 5259 | :return: A generator of References for the given virtual address |
| 5260 | :rtype: Generator[ReferenceSource, None, None] |
| 5261 | :Example: |
| 5262 | |
| 5263 | >>> bv.get_code_refs(here) |
| 5264 | [<ref: x86@0x4165ff>] |
| 5265 | >>> |
| 5266 | |
| 5267 | """ |
| 5268 | count = ctypes.c_ulonglong(0) |
| 5269 | if length is None: |
| 5270 | refs = core.BNGetCodeReferences(self.handle, addr, count) |
| 5271 | assert refs is not None, "core.BNGetCodeReferences returned None" |
| 5272 | else: |
| 5273 | refs = core.BNGetCodeReferencesInRange(self.handle, addr, length, count) |
| 5274 | assert refs is not None, "core.BNGetCodeReferencesInRange returned None" |
| 5275 | |
| 5276 | try: |
| 5277 | for i in range(0, count.value): |
| 5278 | yield ReferenceSource._from_core_struct(self, refs[i]) |
| 5279 | finally: |
| 5280 | core.BNFreeCodeReferences(refs, count.value) |
| 5281 | |
| 5282 | def get_code_refs_from( |
| 5283 | self, addr: int, func: Optional['_function.Function'] = None, |
no test coverage detected