Skip to content

Commit 0268348

Browse files
committed
DBO: Metadata api
1 parent 1108176 commit 0268348

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

binaryninjaapi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22407,6 +22407,7 @@ namespace BinaryNinja {
2240722407
int GetType() const;
2240822408
std::string GetId() const;
2240922409
std::string GetDescription() const;
22410+
Ref<Metadata> GetMetadata() const;
2241022411
Ref<DatabaseObject> GetParent() const;
2241122412
std::unordered_map<std::string, Ref<DatabaseObject>> GetChildren();
2241222413
std::vector<std::string> GetDependencies() const;

binaryninjacore.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9128,6 +9128,7 @@ extern "C"
91289128
BINARYNINJACOREAPI int BNGetDatabaseObjectType(BNDatabaseObject* object);
91299129
BINARYNINJACOREAPI char* BNGetDatabaseObjectId(BNDatabaseObject* object);
91309130
BINARYNINJACOREAPI char* BNGetDatabaseObjectDescription(BNDatabaseObject* object);
9131+
BINARYNINJACOREAPI BNMetadata* BNGetDatabaseObjectMetadata(BNDatabaseObject* object);
91319132
BINARYNINJACOREAPI BNDatabaseObject* BNGetDatabaseObjectParent(BNDatabaseObject* object);
91329133
BINARYNINJACOREAPI size_t BNGetDatabaseObjectChildren(BNDatabaseObject* object, char*** names, BNDatabaseObject*** objects);
91339134
BINARYNINJACOREAPI char** BNGetDatabaseObjectDependencies(BNDatabaseObject* object, size_t* count);

merge.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,15 @@ std::string DatabaseObject::GetDescription() const
6161
}
6262

6363

64+
Ref<Metadata> DatabaseObject::GetMetadata() const
65+
{
66+
BNMetadata* metadata = BNGetDatabaseObjectMetadata(m_object);
67+
if (!metadata)
68+
return nullptr;
69+
return new Metadata(metadata);
70+
}
71+
72+
6473
int DatabaseObject::GetType() const
6574
{
6675
return BNGetDatabaseObjectType(m_object);

python/database.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,14 @@ def description(self) -> str:
402402
"""Get the database object description (read-only)"""
403403
return core.BNGetDatabaseObjectDescription(self.handle)
404404

405+
@property
406+
def metadata(self) -> Optional['binaryninja.Metadata']:
407+
"""Get specific metadata about this object (read-only)"""
408+
handle = core.BNGetDatabaseObjectMetadata(self.handle)
409+
if handle is None:
410+
return None
411+
return binaryninja.Metadata(handle=handle)
412+
405413
@property
406414
def parent(self) -> Optional['DatabaseObject']:
407415
"""Get the parent database object (read-only)"""

0 commit comments

Comments
 (0)