summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ui/stringsview.h48
-rw-r--r--ui/uitypes.h4
-rw-r--r--ui/viewframe.h10
3 files changed, 50 insertions, 12 deletions
diff --git a/ui/stringsview.h b/ui/stringsview.h
index 99c66b79..b8689a3a 100644
--- a/ui/stringsview.h
+++ b/ui/stringsview.h
@@ -18,6 +18,36 @@
\ingroup uiapi
*/
+class StringsListItem
+{
+ std::variant<BNStringReference, BinaryNinja::DerivedString> m_contents;
+
+public:
+ StringsListItem(const BNStringReference& ref): m_contents(ref) {}
+ StringsListItem(const BinaryNinja::DerivedString& str): m_contents(str) {}
+
+ bool IsStringReference() const { return std::holds_alternative<BNStringReference>(m_contents); }
+ bool IsDerivedString() const { return std::holds_alternative<BinaryNinja::DerivedString>(m_contents); }
+ std::optional<BNStringReference> GetStringReference() const;
+ std::optional<BinaryNinja::DerivedString> GetDerivedString() const;
+
+ std::optional<uint64_t> GetStartAddress() const;
+ BNDerivedStringLocationType GetLocationType() const;
+ uint64_t GetDataLength() const;
+ size_t GetCharacterLength() const;
+ std::optional<BNStringType> GetStringType() const;
+ QString GetStringTypeName() const;
+ std::optional<BinaryNinja::StringRef> GetStringRef() const;
+
+ QString GetString(BinaryViewRef data, bool simplified) const;
+
+ std::optional<uint64_t> GetReferenceCount(const std::map<uint64_t, uint64_t>& refs,
+ const std::map<BinaryNinja::DerivedString, uint64_t>& derivedRefs) const;
+
+ bool operator==(const StringsListItem& other) const;
+ bool operator!=(const StringsListItem& other) const;
+};
+
/*!
\ingroup stringsview
@@ -28,15 +58,16 @@ class BINARYNINJAUIAPI StringsListModel : public QAbstractItemModel, public Bina
struct StringUpdateEvent
{
- BNStringReference ref;
+ StringsListItem item;
bool added;
};
QWidget* m_stringsList;
BinaryViewRef m_data;
- std::vector<BNStringReference> m_allStrings;
- std::vector<BNStringReference> m_strings;
+ std::vector<StringsListItem> m_allStrings;
+ std::vector<StringsListItem> m_strings;
std::map<uint64_t, uint64_t> m_refCounts;
+ std::map<BinaryNinja::DerivedString, uint64_t> m_derivedRefCounts;
std::string m_filter;
size_t m_filteredByOptions;
@@ -48,8 +79,8 @@ class BINARYNINJAUIAPI StringsListModel : public QAbstractItemModel, public Bina
bool m_includeOnlyReferenced;
bool m_includeOnlyFromCurrentFunction;
- static bool stringComparison(const BNStringReference& a, const BNStringReference& b);
- bool matchString(const BNStringReference& stringRef);
+ static bool stringComparison(const StringsListItem& a, const StringsListItem& b);
+ bool matchString(const StringsListItem& item);
std::vector<StringUpdateEvent> getQueuedStringUpdates();
@@ -74,8 +105,8 @@ class BINARYNINJAUIAPI StringsListModel : public QAbstractItemModel, public Bina
virtual QVariant data(const QModelIndex& i, int role) const override;
virtual QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
- BNStringReference getStringAt(const QModelIndex& i);
- QModelIndex findString(const BNStringReference& ref);
+ StringsListItem getStringAt(const QModelIndex& i);
+ QModelIndex findString(const StringsListItem& item);
virtual void OnStringFound(BinaryNinja::BinaryView* data, BNStringType type, uint64_t offset, size_t len) override;
virtual void OnStringRemoved(BinaryNinja::BinaryView* data, BNStringType type, uint64_t offset, size_t len) override;
@@ -147,8 +178,10 @@ class BINARYNINJAUIAPI StringsView : public QTableView, public View, public Filt
StringsListModel* m_list;
StringItemDelegate* m_itemDelegate;
+ bool m_selectionAddrValid = false;
uint64_t m_selectionBegin, m_selectionEnd;
uint64_t m_currentlySelectedDataAddress;
+ std::optional<BinaryNinja::DerivedString> m_derivedString;
public:
StringsView(BinaryViewRef data, StringsContainer* container);
@@ -156,6 +189,7 @@ class BINARYNINJAUIAPI StringsView : public QTableView, public View, public Filt
virtual BinaryViewRef getData() override { return m_data; }
virtual uint64_t getCurrentOffset() override;
virtual BNAddressRange getSelectionOffsets() override;
+ virtual SelectionInfoForXref getSelectionForXref() override;
virtual void setSelectionOffsets(BNAddressRange range) override;
virtual bool navigate(uint64_t offset) override;
diff --git a/ui/uitypes.h b/ui/uitypes.h
index 89fa43e6..40b46570 100644
--- a/ui/uitypes.h
+++ b/ui/uitypes.h
@@ -6,14 +6,14 @@
// there are changes to the API that affect linking, including new functions,
// new types, modifications to existing functions or types, or new versions
// of the Qt libraries.
-#define BN_CURRENT_UI_ABI_VERSION 11
+#define BN_CURRENT_UI_ABI_VERSION 12
// 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
// will require rebuilding. The minimum version is increased when there are
// incompatible changes that break binary compatibility, such as changes to
// existing types or functions, or a new version of Qt.
-#define BN_MINIMUM_UI_ABI_VERSION 11
+#define BN_MINIMUM_UI_ABI_VERSION 12
#ifdef __GNUC__
#ifdef BINARYNINJAUI_LIBRARY
diff --git a/ui/viewframe.h b/ui/viewframe.h
index 69f7a198..055e27c0 100644
--- a/ui/viewframe.h
+++ b/ui/viewframe.h
@@ -32,7 +32,7 @@ struct BINARYNINJAUIAPI SelectionInfoForXref
// Check these booleans before accessing the address/type/variable info,
// since the invalid fields are not guaranteed to be initialized/zero-ed.
// At any given time, at most one of these four should be true.
- bool addrValid, typeValid, typeFieldValid, localVarValid;
+ bool addrValid, typeValid, typeFieldValid, localVarValid, derivedStringValid;
BNFunctionGraphType ilSource = InvalidILViewType;
@@ -48,7 +48,9 @@ struct BINARYNINJAUIAPI SelectionInfoForXref
FunctionRef func;
ArchitectureRef arch;
- SelectionInfoForXref() : addrValid(false), typeValid(false), typeFieldValid(false), localVarValid(false) { }
+ BinaryNinja::DerivedString derivedString;
+
+ SelectionInfoForXref() : addrValid(false), typeValid(false), typeFieldValid(false), localVarValid(false), derivedStringValid(false) { }
bool operator==(const SelectionInfoForXref& other) const
{
@@ -60,11 +62,13 @@ struct BINARYNINJAUIAPI SelectionInfoForXref
return (type == other.type) && (offset == other.offset);
else if (localVarValid && other.localVarValid)
return (var == other.var) && (ilSource == other.ilSource);
+ else if (derivedStringValid && other.derivedStringValid)
+ return derivedString == other.derivedString;
return false;
}
bool operator!=(const SelectionInfoForXref& other) const { return !(*this == other); }
- bool isValid() const { return addrValid || typeValid || typeFieldValid || localVarValid; }
+ bool isValid() const { return addrValid || typeValid || typeFieldValid || localVarValid || derivedStringValid; }
};
/*!