From d811fffd69ffba789b960edd4fa31cc3d3f5905e Mon Sep 17 00:00:00 2001 From: Rusty Wagner Date: Thu, 16 Mar 2023 19:54:07 -0400 Subject: Add support for deriving structures from other structures --- python/binaryview.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'python/binaryview.py') diff --git a/python/binaryview.py b/python/binaryview.py index 5c198986..3d2acbdb 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -4488,6 +4488,35 @@ class BinaryView: finally: core.BNFreeDataReferences(refs) + def get_data_refs_from_for_type_field(self, name: '_types.QualifiedNameType', offset: int) -> List[int]: + """ + ``get_data_refs_from_for_type_field`` returns a list of virtual addresses of data which are referenced by the type ``name``. + + Only data referenced by structures with the ``__data_var_refs`` attribute are included. + + :param QualifiedName name: name of type to query for references + :param int offset: offset of the field, relative to the type + :return: list of integers + :rtype: list(integer) + :Example: + + >>> bv.get_data_refs_from_for_type_field('A', 0x8) + [4203812] + >>> + """ + count = ctypes.c_ulonglong(0) + _name = _types.QualifiedName(name)._to_core_struct() + refs = core.BNGetDataReferencesFromForTypeField(self.handle, _name, offset, count) + assert refs is not None, "core.BNGetDataReferencesFromForTypeField returned None" + + result = [] + try: + for i in range(0, count.value): + result.append(refs[i]) + return result + finally: + core.BNFreeDataReferences(refs) + def get_type_refs_for_type(self, name: '_types.QualifiedNameType') -> List['_types.TypeReferenceSource']: """ ``get_type_refs_for_type`` returns a list of TypeReferenceSource objects (xrefs or cross-references) that reference the provided QualifiedName. -- cgit v1.3.1