diff options
| author | Glenn Smith <glenn@vector35.com> | 2023-03-15 20:51:48 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2023-03-29 20:34:14 -0400 |
| commit | 7977801957364139464406602038722124434273 (patch) | |
| tree | 6ddcaba6992061f10932688a0dddafb8020953d4 /python | |
| parent | 3911076326059945990138870942693848884934 (diff) | |
BinaryView::LookupImportedType*
Diffstat (limited to 'python')
| -rw-r--r-- | python/binaryview.py | 44 |
1 files changed, 43 insertions, 1 deletions
diff --git a/python/binaryview.py b/python/binaryview.py index ba007e9c..d25f8e9e 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -7176,7 +7176,7 @@ class BinaryView: def lookup_imported_object_library( self, addr: int, platform: Optional['_platform.Platform'] = None - ) -> Optional[Tuple[typelibrary.TypeLibrary, '_types.QualifiedNameType']]: + ) -> Optional[Tuple[typelibrary.TypeLibrary, '_types.QualifiedName']]: """ ``lookup_imported_object_library`` gives you details of which type library and name was used to determine the type of a symbol at a given address @@ -7199,6 +7199,27 @@ class BinaryView: core.BNFreeQualifiedName(result_name) return lib, name + def lookup_imported_type_library( + self, name: '_types.QualifiedNameType' + ) -> Optional[Tuple[typelibrary.TypeLibrary, '_types.QualifiedName']]: + """ + ``lookup_imported_type_library`` gives you details of from which type library and name + a given type in the analysis was imported. + + :param name: Name of type in analysis + :return: A tuple of [TypeLibrary, QualifiedName] with the library and name used, or None if it was not imported + :rtype: Optional[Tuple[TypeLibrary, QualifiedName]] + """ + name = _types.QualifiedName(name) + result_lib = (ctypes.POINTER(core.BNTypeLibrary) * 1)() + result_name = (core.BNQualifiedName * 1)() + if not core.BNBinaryViewLookupImportedTypeLibrary(self.handle, name._to_core_struct(), result_lib, result_name): + return None + lib = typelibrary.TypeLibrary(result_lib[0]) + name = _types.QualifiedName._from_core_struct(result_name[0]) + core.BNFreeQualifiedName(result_name) + return lib, name + def register_platform_types(self, platform: '_platform.Platform') -> None: """ ``register_platform_types`` ensures that the platform-specific types for a :py:class:`Platform` are available @@ -7215,6 +7236,27 @@ class BinaryView: """ core.BNRegisterPlatformTypes(self.handle, platform.handle) + def lookup_imported_type_platform( + self, name: '_types.QualifiedNameType' + ) -> Optional[Tuple['_platform.Platform', '_types.QualifiedName']]: + """ + ``lookup_imported_type_platform`` gives you details of from which platform and name + a given type in the analysis was imported. + + :param name: Name of type in analysis + :return: A tuple of [Platform, QualifiedName] with the platform and name used, or None if it was not imported + :rtype: Optional[Tuple[Platform, QualifiedName]] + """ + name = _types.QualifiedName(name) + result_platform = (ctypes.POINTER(core.BNPlatform) * 1)() + result_name = (core.BNQualifiedName * 1)() + if not core.BNLookupImportedTypePlatform(self.handle, name._to_core_struct(), result_platform, result_name): + return None + platform = _platform.Platform(arch=self.arch, handle=result_platform[0]) + name = _types.QualifiedName._from_core_struct(result_name[0]) + core.BNFreeQualifiedName(result_name) + return platform, name + def find_next_data(self, start: int, data: bytes, flags: FindFlag = FindFlag.FindCaseSensitive) -> Optional[int]: """ ``find_next_data`` searches for the bytes ``data`` starting at the virtual address ``start`` until the end of the BinaryView. |
