summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h6
-rw-r--r--binaryninjacore.h2
-rw-r--r--python/typecontainer.py10
-rw-r--r--rust/src/type_container.rs6
-rw-r--r--typecontainer.cpp7
5 files changed, 31 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 089b3693..520c038d 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -18573,6 +18573,12 @@ namespace BinaryNinja {
BNTypeContainer* GetObject() const { return m_object; }
+ /*! Get an empty type container which contains no types (immutable)
+
+ \return Empty type container
+ */
+ static TypeContainer GetEmptyTypeContainer();
+
/*! Get an id string for the Type Container. This will be unique within a given
analysis session, but may not be globally unique.
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 40959041..20bc8028 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -3280,6 +3280,7 @@ extern "C"
TypeArchiveTypeContainerType,
DebugInfoTypeContainerType,
PlatformTypeContainerType,
+ EmptyTypeContainerType,
OtherTypeContainerType
} BNTypeContainerType;
@@ -5305,6 +5306,7 @@ extern "C"
const char* autoTypeSource, bool importDepencencies, BNTypeParserResult* result,
BNTypeParserError** errors, size_t* errorCount
);
+ BINARYNINJACOREAPI BNTypeContainer* BNGetEmptyTypeContainer();
BINARYNINJACOREAPI BNTagType* BNCreateTagType(BNBinaryView* view);
BINARYNINJACOREAPI BNTagType* BNNewTagTypeReference(BNTagType* tagType);
diff --git a/python/typecontainer.py b/python/typecontainer.py
index 1a62dbe7..b4a9e794 100644
--- a/python/typecontainer.py
+++ b/python/typecontainer.py
@@ -66,6 +66,16 @@ class TypeContainer:
def __repr__(self):
return f"<type container {self.name}>"
+ @classmethod
+ def empty(cls):
+ """
+ Get an empty Type Container which contains no types (immutable)
+ Useful when a function requires a Type Container but you don't have one.
+ :return: Empty type container
+ """
+ handle = core.BNGetEmptyTypeContainer()
+ return TypeContainer(handle=handle)
+
@property
def id(self) -> str:
"""
diff --git a/rust/src/type_container.rs b/rust/src/type_container.rs
index d68fc9c0..e8c915df 100644
--- a/rust/src/type_container.rs
+++ b/rust/src/type_container.rs
@@ -42,6 +42,12 @@ impl TypeContainer {
}
}
+ /// Get an empty type container that contains no types (immutable)
+ pub fn empty() -> TypeContainer {
+ let result = unsafe { BNGetEmptyTypeContainer() };
+ unsafe { Self::from_raw(NonNull::new(result).unwrap()) }
+ }
+
/// Get an id string for the Type Container. This will be unique within a given
/// analysis session, but may not be globally unique.
pub fn id(&self) -> String {
diff --git a/typecontainer.cpp b/typecontainer.cpp
index 5d706fbf..244c7a27 100644
--- a/typecontainer.cpp
+++ b/typecontainer.cpp
@@ -93,6 +93,13 @@ TypeContainer& TypeContainer::operator=(TypeContainer&& other)
}
+TypeContainer TypeContainer::GetEmptyTypeContainer()
+{
+ auto* container = BNGetEmptyTypeContainer();
+ return TypeContainer(container);
+}
+
+
std::string TypeContainer::GetId() const
{
char* id = BNTypeContainerGetId(m_object);