From ecfc518d025359e7d2cf7e5da30f856916bf48b4 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Fri, 12 Jan 2024 16:55:19 -0500 Subject: Add APIs for getting the the base Metadata object for BinaryViews and TypeLibraries --- python/typelibrary.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'python/typelibrary.py') diff --git a/python/typelibrary.py b/python/typelibrary.py index db22ee22..c9ddd37b 100644 --- a/python/typelibrary.py +++ b/python/typelibrary.py @@ -20,6 +20,7 @@ import ctypes from typing import Optional, List, Dict, Union +import uuid # Binary Ninja components import binaryninja @@ -282,6 +283,24 @@ class TypeLibrary: """ core.BNTypeLibraryRemoveMetadata(self.handle, key) + @property + def metadata(self) -> Dict[str, 'metadata.MetadataValueType']: + """ + `metadata` retrieves the metadata associated with the current type library. + + :rtype: Metadata object + :Example: + + >>> lib.store_metadata("integer", 1337) + >>> lib.metadata["integer"] + 1337 + """ + md_handle = core.BNTypeLibraryGetMetadata(self.handle) + assert md_handle is not None, "core.BNTypeLibraryGetMetadata returned None" + value = metadata.Metadata(handle=md_handle).value + assert isinstance(value, dict), "core.BNTypeLibraryGetMetadata returned non-dict" + return value + @property def type_container(self) -> 'typecontainer.TypeContainer': """ @@ -407,4 +426,3 @@ class TypeLibrary: return result finally: core.BNFreeQualifiedNameAndTypeArray(named_types, count.value) - -- cgit v1.3.1