summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--binaryninjaapi.h3
-rw-r--r--binaryninjacore.h7
-rw-r--r--function.cpp12
-rw-r--r--python/function.py10
-rw-r--r--ui/commands.h1
-rw-r--r--ui/flowgraphwidget.h3
-rw-r--r--ui/linearview.h3
7 files changed, 38 insertions, 1 deletions
diff --git a/binaryninjaapi.h b/binaryninjaapi.h
index 6d5c144c..0d4533b5 100644
--- a/binaryninjaapi.h
+++ b/binaryninjaapi.h
@@ -11430,6 +11430,9 @@ namespace BinaryNinja {
BNExprFolding GetExprFolding(uint64_t addr);
void SetExprFolding(uint64_t addr, BNExprFolding mode);
+ bool IsConditionInverted(uint64_t addr);
+ void SetConditionInverted(uint64_t addr, bool invert);
+
std::map<Variable, std::set<Variable>> GetMergedVariables();
void MergeVariables(const Variable& target, const std::set<Variable>& sources);
void UnmergeVariables(const Variable& target, const std::set<Variable>& sources);
diff --git a/binaryninjacore.h b/binaryninjacore.h
index 505e10e2..9daf70e4 100644
--- a/binaryninjacore.h
+++ b/binaryninjacore.h
@@ -37,7 +37,7 @@
// Current ABI version for linking to the core. This is incremented any time
// there are changes to the API that affect linking, including new functions,
// new types, or modifications to existing functions or types.
-#define BN_CURRENT_CORE_ABI_VERSION 108
+#define BN_CURRENT_CORE_ABI_VERSION 109
// Minimum ABI version that is supported for loading of plugins. Plugins that
// are linked to an ABI version less than this will not be able to load and
@@ -1024,6 +1024,9 @@ extern "C"
// HLIL expression can be folded into other expressions or has been folded
HLILFoldableExpr = 0x100,
+
+ // HLIL condition can be displayed as the inverse
+ HLILInvertableCondition = 0x200,
} BNILInstructionAttribute;
typedef enum BNIntrinsicClass
@@ -4993,6 +4996,8 @@ extern "C"
BNFunction* func, const BNVariable* var, BNDeadStoreElimination mode);
BINARYNINJACOREAPI BNExprFolding BNGetExprFolding(BNFunction* func, uint64_t addr);
BINARYNINJACOREAPI void BNSetExprFolding(BNFunction* func, uint64_t addr, BNExprFolding mode);
+ BINARYNINJACOREAPI bool BNIsConditionInverted(BNFunction* func, uint64_t addr);
+ BINARYNINJACOREAPI void BNSetConditionInverted(BNFunction* func, uint64_t addr, bool invert);
BINARYNINJACOREAPI BNMergedVariable* BNGetMergedVariables(BNFunction* func, size_t* count);
BINARYNINJACOREAPI void BNFreeMergedVariableList(BNMergedVariable* vars, size_t count);
BINARYNINJACOREAPI void BNMergeVariables(BNFunction* func, const BNVariable* target, const BNVariable* sources,
diff --git a/function.cpp b/function.cpp
index 756c9629..fec9e108 100644
--- a/function.cpp
+++ b/function.cpp
@@ -2825,6 +2825,18 @@ void Function::SetExprFolding(uint64_t addr, BNExprFolding mode)
}
+bool Function::IsConditionInverted(uint64_t addr)
+{
+ return BNIsConditionInverted(m_object, addr);
+}
+
+
+void Function::SetConditionInverted(uint64_t addr, bool invert)
+{
+ BNSetConditionInverted(m_object, addr, invert);
+}
+
+
std::map<Variable, std::set<Variable>> Function::GetMergedVariables()
{
size_t count;
diff --git a/python/function.py b/python/function.py
index dc7add3a..ae3af65b 100644
--- a/python/function.py
+++ b/python/function.py
@@ -3466,6 +3466,16 @@ class Function:
addr = addr.address
core.BNSetExprFolding(self.handle, addr, value)
+ def is_condition_inverted(self, addr: Union[int, highlevelil.HighLevelILInstruction]) -> bool:
+ if isinstance(addr, highlevelil.HighLevelILInstruction):
+ addr = addr.address
+ return core.BNIsConditionInverted(self.handle, addr)
+
+ def set_condition_inverted(self, addr: Union[int, highlevelil.HighLevelILInstruction], invert: bool):
+ if isinstance(addr, highlevelil.HighLevelILInstruction):
+ addr = addr.address
+ core.BNSetConditionInverted(self.handle, addr, invert)
+
class AdvancedFunctionAnalysisDataRequestor:
def __init__(self, func: Optional['Function'] = None):
diff --git a/ui/commands.h b/ui/commands.h
index 7fb3f539..aed0fbf6 100644
--- a/ui/commands.h
+++ b/ui/commands.h
@@ -97,6 +97,7 @@ TypeRef GetFunctionType(BinaryViewRef data, TypeRef type);
std::optional<uint64_t> getFoldableExprAddress(
BinaryNinja::HighLevelILFunction* hlil, const HighlightTokenState& highlight);
+std::optional<uint64_t> getInvertableConditionAddress(BinaryNinja::HighLevelILFunction* hlil, size_t instrIndex);
/*!
@}
diff --git a/ui/flowgraphwidget.h b/ui/flowgraphwidget.h
index c7af8aa9..b69ec38b 100644
--- a/ui/flowgraphwidget.h
+++ b/ui/flowgraphwidget.h
@@ -168,6 +168,8 @@ class BINARYNINJAUIAPI FlowGraphWidget :
BNDeadStoreElimination getCurrentVariableDeadStoreElimination();
std::optional<uint64_t> getCurrentFoldableExprAddress();
BNExprFolding getCurrentExprFolding();
+ std::optional<uint64_t> getCurrentInvertableConditionAddress();
+ bool getCurrentConditionInverted();
std::optional<std::pair<BinaryNinja::Variable, BinaryNinja::Variable>> getMergeVariablesAtCurrentLocation();
protected:
@@ -398,6 +400,7 @@ class BINARYNINJAUIAPI FlowGraphWidget :
void setCurrentVariableDeadStoreElimination(BNDeadStoreElimination elimination);
void setCurrentExprFolding(BNExprFolding folding);
+ void toggleConditionInverted();
void splitToNewTabAndNavigateFromCursorPosition();
void splitToNewWindowAndNavigateFromCursorPosition();
void splitToNewPaneAndNavigateFromCursorPosition();
diff --git a/ui/linearview.h b/ui/linearview.h
index e5305aa8..2ea8e37f 100644
--- a/ui/linearview.h
+++ b/ui/linearview.h
@@ -318,6 +318,8 @@ class BINARYNINJAUIAPI LinearView : public QAbstractScrollArea, public View, pub
BNDeadStoreElimination getCurrentVariableDeadStoreElimination();
std::optional<uint64_t> getCurrentFoldableExprAddress();
BNExprFolding getCurrentExprFolding();
+ std::optional<uint64_t> getCurrentInvertableConditionAddress();
+ bool getCurrentConditionInverted();
void setDataButtonVisible(bool visible);
std::optional<std::pair<BinaryNinja::Variable, BinaryNinja::Variable>> getMergeVariablesAtCurrentLocation();
@@ -409,6 +411,7 @@ private Q_SLOTS:
void setCurrentVariableDeadStoreElimination(BNDeadStoreElimination elimination);
void setCurrentExprFolding(BNExprFolding folding);
+ void toggleConditionInverted();
Q_SIGNALS:
void notifyResizeEvent(int width, int height);