From 3375478963786425457931027834955525009658 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 20 May 2024 20:18:52 -0400 Subject: Add TypeBuilder::SetWidth and TypeBuilder::SetAlignment --- binaryninjaapi.h | 2 ++ binaryninjacore.h | 2 ++ python/types.py | 8 ++++++++ type.cpp | 22 ++++++++++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/binaryninjaapi.h b/binaryninjaapi.h index d2cf74d2..d8db649b 100644 --- a/binaryninjaapi.h +++ b/binaryninjaapi.h @@ -8963,6 +8963,8 @@ namespace BinaryNinja { Ref GetEnumeration() const; Ref GetNamedTypeReference() const; Confidence GetScope() const; + TypeBuilder& SetWidth(size_t width); + TypeBuilder& SetAlignment(size_t alignment); TypeBuilder& SetNamedTypeReference(NamedTypeReference* ntr); TypeBuilder& SetScope(const Confidence& scope); TypeBuilder& SetConst(const Confidence& cnst); diff --git a/binaryninjacore.h b/binaryninjacore.h index 9e0b6986..b865fadc 100644 --- a/binaryninjacore.h +++ b/binaryninjacore.h @@ -5920,6 +5920,8 @@ extern "C" BINARYNINJACOREAPI void BNSetTypeBuilderPure(BNTypeBuilder* type, BNBoolWithConfidence* pure); BINARYNINJACOREAPI void BNSetFunctionTypeBuilderParameters( BNTypeBuilder* type, BNFunctionParameter* params, size_t paramCount); + BINARYNINJACOREAPI void BNTypeBuilderSetWidth(BNTypeBuilder* type, size_t width); + BINARYNINJACOREAPI void BNTypeBuilderSetAlignment(BNTypeBuilder* type, size_t alignment); BINARYNINJACOREAPI void BNTypeBuilderSetConst(BNTypeBuilder* type, BNBoolWithConfidence* cnst); BINARYNINJACOREAPI void BNTypeBuilderSetVolatile(BNTypeBuilder* type, BNBoolWithConfidence* vltl); BINARYNINJACOREAPI void BNTypeBuilderSetSigned(BNTypeBuilder* type, BNBoolWithConfidence* sign); diff --git a/python/types.py b/python/types.py index 945b88be..aea8f02c 100644 --- a/python/types.py +++ b/python/types.py @@ -749,6 +749,10 @@ class TypeBuilder: def width(self) -> _int: return core.BNGetTypeBuilderWidth(self._handle) + @width.setter + def width(self, value: _int): + core.BNTypeBuilderSetWidth(self._handle, value) + def __len__(self): return self.width @@ -788,6 +792,10 @@ class TypeBuilder: def alignment(self) -> _int: return core.BNGetTypeBuilderAlignment(self._handle) + @alignment.setter + def alignment(self, alignment: _int): + core.BNTypeBuilderSetAlignment(self._handle, alignment) + @property def child(self) -> 'Type': type_conf = core.BNGetTypeBuilderChildType(self._handle) diff --git a/type.cpp b/type.cpp index 6324238b..3cfa26f9 100644 --- a/type.cpp +++ b/type.cpp @@ -1349,12 +1349,34 @@ Confidence TypeBuilder::IsConst() const return Confidence(result.value, result.confidence); } + +Confidence TypeBuilder::IsVolatile() const +{ + BNBoolWithConfidence result = BNIsTypeBuilderVolatile(m_object); + return Confidence(result.value, result.confidence); +} + + void TypeBuilder::SetIntegerTypeDisplayType(BNIntegerDisplayType displayType) { BNSetIntegerTypeDisplayType(m_object, displayType); } +TypeBuilder& TypeBuilder::SetWidth(size_t width) +{ + BNTypeBuilderSetWidth(m_object, width); + return *this; +} + + +TypeBuilder& TypeBuilder::SetAlignment(size_t alignment) +{ + BNTypeBuilderSetAlignment(m_object, alignment); + return *this; +} + + TypeBuilder& TypeBuilder::SetConst(const Confidence& cnst) { BNBoolWithConfidence bc; -- cgit v1.3.1