summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Potchik <brian@vector35.com>2020-10-24 22:18:28 -0400
committerBrian Potchik <brian@vector35.com>2020-10-24 22:18:28 -0400
commit905382cc267cc1d0ee5e3c6e122819b869f46701 (patch)
tree1c8b911942d53c4c0a149f5a188874b7c158501e
parent798ff5b7e7b2de73d70017ddb0fc5e52150d9584 (diff)
PossibleValueSet dialog pulls existing values and miscellaneous cleanup.
-rw-r--r--binaryview.cpp2
-rw-r--r--function.cpp4
-rw-r--r--python/binaryview.py2
-rw-r--r--python/function.py22
-rw-r--r--ui/commands.h2
-rw-r--r--ui/possiblevaluesetdialog.h58
6 files changed, 33 insertions, 57 deletions
diff --git a/binaryview.cpp b/binaryview.cpp
index d355246d..2d6ecb4e 100644
--- a/binaryview.cpp
+++ b/binaryview.cpp
@@ -2454,7 +2454,7 @@ uint64_t BinaryView::GetPreviousDataVariableStartBeforeAddress(uint64_t addr)
bool BinaryView::ParsePossibleValueSet(const string& value, BNRegisterValueType state, PossibleValueSet& result, uint64_t here, string& errors)
{
BNPossibleValueSet res;
- char* errorStr;
+ char* errorStr = nullptr;
if (!BNParsePossibleValueSet(m_object, value.c_str(), state, &res, here, &errorStr))
{
diff --git a/function.cpp b/function.cpp
index 168decc2..2daf5522 100644
--- a/function.cpp
+++ b/function.cpp
@@ -1779,7 +1779,7 @@ void Function::SetUserVariableValue(const Variable& var, uint64_t defAddr, Possi
{
LogError("Could not get definition for Variable");
return;
- }
+ }
bool found = false;
for (auto& site : varDefs)
{
@@ -1817,7 +1817,7 @@ void Function::ClearUserVariableValue(const Variable& var, uint64_t defAddr)
{
LogError("Could not get definition for Variable");
return;
- }
+ }
bool found = false;
for (auto& site : varDefs)
{
diff --git a/python/binaryview.py b/python/binaryview.py
index e7c39641..a53cbf35 100644
--- a/python/binaryview.py
+++ b/python/binaryview.py
@@ -4738,6 +4738,8 @@ class BinaryView(object):
"""
result = core.BNPossibleValueSet()
errors = ctypes.c_char_p()
+ if value == None:
+ value = ''
if not core.BNParsePossibleValueSet(self.handle, value, state, result, here, errors):
if errors:
error_str = errors.value.decode("utf-8")
diff --git a/python/function.py b/python/function.py
index b3695949..35cad9b9 100644
--- a/python/function.py
+++ b/python/function.py
@@ -267,7 +267,7 @@ class ValueRange(object):
if not isinstance(other, self.__class__):
return NotImplemented
return self.start == other.start and self.end == other.end and self.step == other.step
-
+
@property
def start(self):
""" """
@@ -458,7 +458,7 @@ class PossibleValueSet(object):
result.valueSet = ctypes.cast(values, ctypes.POINTER(ctypes.c_longlong))
result.count = self.count
return result
-
+
@property
def type(self):
""" """
@@ -560,7 +560,7 @@ class PossibleValueSet(object):
@classmethod
def constant(self, value):
- """
+ """
Create a constant valued PossibleValueSet object.
:param int value: Integer value of the constant
@@ -573,7 +573,7 @@ class PossibleValueSet(object):
@classmethod
def constant_ptr(self, value):
- """
+ """
Create constant pointer valued PossibleValueSet object.
:param int value: Integer value of the constant pointer
@@ -586,7 +586,7 @@ class PossibleValueSet(object):
@classmethod
def stack_frame_offset(self, offset):
- """
+ """
Create a PossibleValueSet object for a stack frame offset.
:param int value: Integer value of the offset
@@ -605,7 +605,7 @@ class PossibleValueSet(object):
:param list(ValueRange) ranges: List of ValueRanges
:rtype: PossibleValueSet
:Example:
-
+
>>> v_1 = ValueRange(-5, -1, 1)
>>> v_2 = ValueRange(7, 10, 1)
>>> val = PossibleValueSet.signed_range_value([v_1, v_2])
@@ -653,7 +653,7 @@ class PossibleValueSet(object):
result.count = len(values)
return result
- @classmethod
+ @classmethod
def not_in_set_of_values(self, values):
"""
Create a PossibleValueSet object for a value NOT in a set of values.
@@ -670,7 +670,7 @@ class PossibleValueSet(object):
@classmethod
def lookup_table_value(self, lookup_table, mapping):
"""
- Create a PossibleValueSet object for a value which is a member of a
+ Create a PossibleValueSet object for a value which is a member of a
lookuptable.
:param list(LookupTableEntry) lookup_table: List of table entries
@@ -2669,7 +2669,7 @@ class Function(object):
def set_user_var_value(self, var, def_addr, value):
"""
`set_user_var_value` allows the user to specify a PossibleValueSet value for an MLIL variable at its
- definition site.
+ definition site.
.. warning:: Setting the variable value, triggers a reanalysis of the function and allows the dataflow
to compute and propagate values which depend on the current variable. This implies that branch conditions
@@ -2732,7 +2732,7 @@ class Function(object):
var_data = core.BNVariable()
var_data.type = var.source_type
- var_data.index = var.index
+ var_data.index = var.index
var_data.storage = var.storage
core.BNClearUserVariableValue(self.handle, var_data, def_site)
@@ -3249,7 +3249,7 @@ class InstructionTextToken(object):
``class InstructionTextToken`` is used to tell the core about the various components in the disassembly views.
The below table is provided for ducmentation purposes but the complete list of TokenTypes is available at: :class:`!enums.InstructionTextTokenType`. Note that types marked as `Not emitted by architectures` are not intended to be used by Architectures during lifting. Rather, they are added by the core during analysis or display. UI plugins, however, may make use of them as appropriate.
-
+
Uses of tokens include plugins that parse the output of an architecture (though parsing IL is recommended), or additionally, applying color schemes appropriately.
========================== ============================================
diff --git a/ui/commands.h b/ui/commands.h
index d033fd21..d0e8b981 100644
--- a/ui/commands.h
+++ b/ui/commands.h
@@ -23,7 +23,7 @@ bool BINARYNINJAUIAPI createInferredMember(QWidget* parent, BinaryViewRef data,
FunctionRef func, BNFunctionGraphType type);
bool BINARYNINJAUIAPI inputPossibleValueSet(QWidget* parent, BinaryViewRef data, FunctionRef currentFunction,
- HighlightTokenState& highlight, uint64_t defSiteAddress);
+ HighlightTokenState& highlight, uint64_t defSiteAddress, size_t ilInstructionIndex = BN_INVALID_EXPR);
bool BINARYNINJAUIAPI overwriteCode(BinaryViewRef data, ArchitectureRef arch,
uint64_t addr, size_t len, const BinaryNinja::DataBuffer& buffer);
diff --git a/ui/possiblevaluesetdialog.h b/ui/possiblevaluesetdialog.h
index 5b5550a3..d2229de7 100644
--- a/ui/possiblevaluesetdialog.h
+++ b/ui/possiblevaluesetdialog.h
@@ -2,59 +2,33 @@
#include <QtWidgets/QDialog>
#include <QtWidgets/QLabel>
-#include <QtCore/QStringListModel>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLineEdit>
-#include <QtCore/QTimer>
-#include <QtCore/QThread>
-#include <QToolTip>
-#include "binaryninjaapi.h"
-#include "dialogtextedit.h"
-#include "clickablelabel.h"
+
+#include "uitypes.h"
class BINARYNINJAUIAPI PossibleValueSetDialog: public QDialog
{
Q_OBJECT
- QComboBox* m_combo;
- QLineEdit* m_value;
- QStringListModel* m_model;
- QLabel* m_prompt;
- QString m_promptText;
- ClickableLabel* m_valueLabel;
BinaryViewRef m_view;
- bool m_resultValid;
- QStringList m_historyEntries;
- int m_historySize;
- QFont m_defaultFont;
- bool m_initialTextSelection;
- BinaryNinja::PossibleValueSet m_valueSet;
+ uint64_t m_addr;
+
+ QComboBox* m_combo;
+ QLineEdit* m_input;
QPushButton* m_acceptButton;
- QPalette m_defaultPalette;
- QString m_parseError;
- uint64_t m_here;
- QTimer* m_updateTimer;
+ QLabel* m_formatLabel;
-private Q_SLOTS:
- void accepted();
- void checkParse();
- void updateTimerEvent();
- void showHelp();
- void stateChanged(const QString&);
+ std::map<BNRegisterValueType, QString> m_typeText;
+ std::map<BNRegisterValueType, QString> m_formatText;
+ std::map<QString, BNRegisterValueType> m_regValueTypes;
+ BNRegisterValueType m_curRegValueType;
+
+ BinaryNinja::PossibleValueSet m_valueSet;
public:
- PossibleValueSetDialog(QWidget* parent, BinaryViewRef view, uint64_t here);
- BinaryNinja::PossibleValueSet getPossibleValueSet() const { return m_valueSet; }
- static BNRegisterValueType getRegisterValueTypeFromString(const std::string& stateStr);
-};
+ PossibleValueSetDialog(QWidget* parent, BinaryViewRef view, uint64_t addr, BinaryNinja::PossibleValueSet existingValue);
-static const QStringList valueSets = {
- "ConstantValue",
- "ConstantPointerValue",
- "StackFrameOffset",
- "SignedRangeValue",
- "UnsignedRangeValue",
- "InSetOfValues",
- "NotInSetOfValues",
- "UndeterminedValue",
+ BinaryNinja::PossibleValueSet getPossibleValueSet() const { return m_valueSet; }
+ void validate(const QString& input);
};