summaryrefslogtreecommitdiff
path: root/binaryninjaapi.h
diff options
context:
space:
mode:
authorXusheng <xusheng@vector35.com>2022-09-30 16:35:17 +0800
committerXusheng <xusheng@vector35.com>2022-10-05 11:35:20 +0800
commit4792eaf70e1ebe2c2f2a68c188a65a0a46e39acf (patch)
treeede7281639b235dbee57cd221d16d0da09d98a1f /binaryninjaapi.h
parent1268fa1d1d36d24d088982e61856d093a59611bd (diff)
Add SetExprType API to MLIL/HLIL
Add get/set_expr_type to MLIL/HLIL Python APi
Diffstat (limited to 'binaryninjaapi.h')
-rw-r--r--binaryninjaapi.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 46e3fedf..fa66a799 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -8866,6 +8866,19 @@ namespace BinaryNinja {
Confidence<Ref<Type>> GetExprType(size_t expr);
Confidence<Ref<Type>> GetExprType(const MediumLevelILInstruction& expr);
+ /*! SetExprType sets the type of a given expression.
+
+ \warning This method is only meant for workflows or for debugging purposes, since the changes they make
+ are not persistent and get lost after a database save and reload. To make persistent changes to the analysis,
+ one should use other APIs to, for example, change the type of variables. The analysis will then propagate the
+ type of the variable and update the type of related expressions.
+
+ \param expr index of the expression to set
+ \param type new type of the expression
+ */
+ void SetExprType(size_t expr, const Confidence<Ref<Type>>& type);
+ void SetExprType(const MediumLevelILInstruction& expr, const Confidence<Ref<Type>>& type);
+
static bool IsConstantType(BNMediumLevelILOperation op)
{
return op == MLIL_CONST || op == MLIL_CONST_PTR || op == MLIL_EXTERN_PTR;
@@ -9133,6 +9146,19 @@ namespace BinaryNinja {
Confidence<Ref<Type>> GetExprType(size_t expr);
Confidence<Ref<Type>> GetExprType(const HighLevelILInstruction& expr);
+ /*! SetExprType sets the type of a given expression.
+
+ \warning This method is only meant for workflows or for debugging purposes, since the changes they make
+ are not persistent and get lost after a database save and reload. To make persistent changes to the analysis,
+ one should use other APIs to, for example, change the type of variables. The analysis will then propagate the
+ type of the variable and update the type of related expressions.
+
+ \param expr index of the expression to set
+ \param type new type of the expression
+ */
+ void SetExprType(size_t expr, const Confidence<Ref<Type>>& type);
+ void SetExprType(const HighLevelILInstruction& expr, const Confidence<Ref<Type>>& type);
+
void VisitAllExprs(const std::function<bool(const HighLevelILInstruction& expr)>& func);
Ref<FlowGraph> CreateFunctionGraph(DisassemblySettings* settings = nullptr);