summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter LaFosse <peter@vector35.com>2021-09-03 11:11:49 -0400
committerPeter LaFosse <peter@vector35.com>2021-09-06 11:46:43 -0400
commitd28dc76f738c1b3c6469213c2582ca7680b8fefe (patch)
tree92274f9622c096baa42d4f78f4b048567e90b0ca
parentb7ef15830ab8652fd50f3289508ac006f756d6cc (diff)
Add BNTypeBuilderSetChildType
-rw-r--r--binaryninjaapi.h1
-rw-r--r--binaryninjacore.h1
-rw-r--r--python/types.py35
3 files changed, 24 insertions, 13 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 3584807b..bb104ef3 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -2913,6 +2913,7 @@ __attribute__ ((format (printf, 1, 2)))
TypeBuilder& SetScope(const Confidence<BNMemberScope>& scope);
TypeBuilder& SetConst(const Confidence<bool>& cnst);
TypeBuilder& SetVolatile(const Confidence<bool>& vltl);
+ TypeBuilder& SetChildType(const Confidence<Ref<Type>>& child);
TypeBuilder& SetSigned(const Confidence<bool>& vltl);
TypeBuilder& SetTypeName(const QualifiedName& name);
TypeBuilder& SetAlternateName(const std::string& name);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 59a7141e..68b2e2ee 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -4769,6 +4769,7 @@ __attribute__ ((format (printf, 1, 2)))
BINARYNINJACOREAPI void BNTypeBuilderSetConst(BNTypeBuilder* type, BNBoolWithConfidence* cnst);
BINARYNINJACOREAPI void BNTypeBuilderSetVolatile(BNTypeBuilder* type, BNBoolWithConfidence* vltl);
BINARYNINJACOREAPI void BNTypeBuilderSetSigned(BNTypeBuilder* type, BNBoolWithConfidence* sign);
+ BINARYNINJACOREAPI void BNTypeBuilderSetChildType(BNTypeBuilder* type, BNTypeWithConfidence* child);
BINARYNINJACOREAPI BNOffsetWithConfidence BNGetTypeBuilderStackAdjustment(BNTypeBuilder* type);
BINARYNINJACOREAPI BNQualifiedName BNTypeBuilderGetStructureName(BNTypeBuilder* type);
BINARYNINJACOREAPI BNReferenceType BNTypeBuilderGetReferenceType(BNTypeBuilder* type);
diff --git a/python/types.py b/python/types.py
index 965d5f8d..9f5f9f1d 100644
--- a/python/types.py
+++ b/python/types.py
@@ -609,15 +609,24 @@ class TypeBuilder:
return BoolWithConfidence(result.value, confidence = result.confidence)
@volatile.setter
- def volatile(self, value:BoolWithConfidence) -> None:
- core.BNTypeBuilderSetVolatile(self._handle, value.to_core_struct())
+ def volatile(self, value:BoolWithConfidenceType) -> None: # type: ignore We explicitly allow 'set' type to be different than 'get' type
+ core.BNTypeBuilderSetVolatile(self._handle, BoolWithConfidence.get_core_struct(value))
@property
def alignment(self) -> _int:
return core.BNGetTypeBuilderAlignment(self._handle)
- def _child(self, platform:'_platform.Platform'=None, confidence:_int=core.max_confidence) -> 'Type':
- return Type.create(core.BNNewTypeReference(core.BNGetTypeBuilderChildType(self._handle)), platform, confidence)
+ @property
+ def child(self) -> 'Type':
+ type_conf = core.BNGetTypeBuilderChildType(self._handle)
+ assert type_conf is not None, "core.BNGetTypeBuilderChildType returned None"
+ handle = core.BNNewTypeReference(type_conf.type)
+ assert handle is not None, "core.BNNewTypeReference returned None"
+ return Type.create(handle, self.platform, type_conf.confidence)
+
+ @child.setter
+ def child(self, value:'Type') -> None:
+ return core.BNTypeBuilderSetChildType(self._handle, value._to_core_struct())
@property
def alternate_name(self) -> str:
@@ -721,8 +730,8 @@ class Pointer(TypeBuilder):
return self.immutable_target.mutable_copy()
@property
- def immutable_target(self, platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'Type':
- return self._child(platform, confidence)
+ def immutable_target(self) -> 'Type':
+ return self.child
class Array(TypeBuilder):
@@ -738,8 +747,8 @@ class Array(TypeBuilder):
return core.BNGetTypeBuilderElementCount(self._handle)
@property
- def element_type(self, platform:'_platform.Platform'=None, confidence:int=core.max_confidence):
- return self._child(platform, confidence)
+ def element_type(self):
+ return self.child
class Function(TypeBuilder):
@@ -792,16 +801,16 @@ class Function(TypeBuilder):
return cls(handle, platform, confidence)
@property
- def immutable_return_value(self, platform:'_platform.Platform'=None, confidence:int=core.max_confidence) -> 'Type':
- return self._child(platform, confidence)
+ def immutable_return_value(self) -> 'Type':
+ return self.child
@property
def return_value(self) -> TypeBuilder:
- return self.immutable_return_value.mutable_copy()
+ return self.child.mutable_copy()
@return_value.setter
- def return_value(self, value:SomeType): # type: ignore
- self._return_type = value.mutable_copy() # TODO: Fix me
+ def return_value(self, value:SomeType) -> None: # type: ignore
+ self.child = value
def append(self, type:Union[SomeType, FunctionParameter], name:str=""):
params = self.parameters