summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRusty Wagner <rusty@vector35.com>2020-01-13 20:35:50 -0500
committerRusty Wagner <rusty@vector35.com>2020-02-04 13:59:10 -0500
commitc34ac521dd6022d522053712833943c699bedb3f (patch)
tree2a3e345b65ee506cb6380c317d427157f536d04a
parentbb1fe1d4b3956f92810c107a35355d2622209c99 (diff)
Add registered name to type objects
-rw-r--r--binaryninjaapi.h1
-rw-r--r--binaryninjacore.h1
-rw-r--r--python/types.py13
m---------suite/binaries0
-rw-r--r--type.cpp9
5 files changed, 24 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 469850fa..ba863efa 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -2481,6 +2481,7 @@ __attribute__ ((format (printf, 1, 2)))
Confidence<BNMemberAccess> GetAccess() const;
Confidence<int64_t> GetStackAdjustment() const;
QualifiedName GetStructureName() const;
+ Ref<NamedTypeReference> GetRegisteredName() const;
uint64_t GetElementCount() const;
uint64_t GetOffset() const;
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 2d531c33..04793b09 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -3587,6 +3587,7 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI BNMemberAccessWithConfidence BNTypeGetMemberAccess(BNType* type);
BINARYNINJACOREAPI BNOffsetWithConfidence BNGetTypeStackAdjustment(BNType* type);
BINARYNINJACOREAPI BNQualifiedName BNTypeGetStructureName(BNType* type);
+ BINARYNINJACOREAPI BNNamedTypeReference* BNGetRegisteredTypeName(BNType* type);
BINARYNINJACOREAPI char* BNGetTypeString(BNType* type, BNPlatform* platform);
BINARYNINJACOREAPI char* BNGetTypeStringBeforeName(BNType* type, BNPlatform* platform);
diff --git a/python/types.py b/python/types.py
index 68fc9a76..8b883e6b 100644
--- a/python/types.py
+++ b/python/types.py
@@ -573,6 +573,16 @@ class Type(object):
result = core.BNGetTypeStackAdjustment(self._handle)
return SizeWithConfidence(result.value, confidence = result.confidence)
+ @property
+ def registered_name(self):
+ """Name of type registered to binary view, if any (read-only)"""
+ if self._mutable:
+ return None
+ name = core.BNGetRegisteredTypeName(self._handle)
+ if not name:
+ return None
+ return NamedTypeReference(handle = name)
+
def __len__(self):
return self.width
@@ -582,6 +592,9 @@ class Type(object):
platform = self._platform.handle
if self._mutable:
return core.BNGetTypeBuilderString(self._handle, platform)
+ name = self.registered_name
+ if name is not None:
+ return self.get_string_before_name() + " " + str(name.name) + self.get_string_after_name()
return core.BNGetTypeString(self._handle, platform)
def __repr__(self):
diff --git a/suite/binaries b/suite/binaries
-Subproject 24abb8fd8fe00a7188b5255bdcf9df36edc5feb
+Subproject 4b3df332218479562ca54a8ecff9847d6f41641
diff --git a/type.cpp b/type.cpp
index f607f333..58d23767 100644
--- a/type.cpp
+++ b/type.cpp
@@ -913,6 +913,15 @@ QualifiedName Type::GetStructureName() const
}
+Ref<NamedTypeReference> Type::GetRegisteredName() const
+{
+ BNNamedTypeReference* name = BNGetRegisteredTypeName(m_object);
+ if (!name)
+ return nullptr;
+ return new NamedTypeReference(name);
+}
+
+
Ref<Type> Type::WithReplacedStructure(Structure* from, Structure* to)
{
BNType* result = BNTypeWithReplacedStructure(m_object, from->GetObject(), to->GetObject());