summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Palmisciano <jp@jonpalmisc.com>2021-10-07 12:27:07 -0400
committerJon Palmisciano <jp@jonpalmisc.com>2021-10-07 14:44:17 -0400
commitb84383bfe8662e00d5699241097758b6a6e9d421 (patch)
treee2b94a0809f8fc90a970be14cb8e3adda25c1009
parent22b182fe9b91a8df273ab67d4d65270607595ffa (diff)
Add infrastructure for UTF-{16,32} string creation actions
LinearView: Update string methods for UTF-{16,32} string quick-creation - Update `makeString` to accept a character size for wide strings - Update `getStringLength` to handle wide strings, add doc comment TypeView, TypeView: Add `charSize` parameter to `makeString`
-rw-r--r--ui/flowgraphwidget.h2
-rw-r--r--ui/linearview.h10
-rw-r--r--ui/tokenizedtextview.h11
-rw-r--r--ui/typeview.h2
4 files changed, 19 insertions, 6 deletions
diff --git a/ui/flowgraphwidget.h b/ui/flowgraphwidget.h
index 6a77b829..2064e99b 100644
--- a/ui/flowgraphwidget.h
+++ b/ui/flowgraphwidget.h
@@ -344,7 +344,7 @@ private Q_SLOTS:
void skipAndReturnValue();
void makePtr();
- void makeString();
+ void makeString(size_t charSize = 1);
void reanalyze();
diff --git a/ui/linearview.h b/ui/linearview.h
index d7a4983e..7edf8097 100644
--- a/ui/linearview.h
+++ b/ui/linearview.h
@@ -264,7 +264,7 @@ private Q_SLOTS:
void makeFloat64();
void toggleFloatSize();
void makePtr();
- void makeString();
+ void makeString(size_t charSize = 1);
void changeType(const UIActionContext& context);
void undefineVariable();
void displayAs(const UIActionContext& context, BNIntegerDisplayType displayType) override;
@@ -274,7 +274,13 @@ private Q_SLOTS:
void createNewTypes();
void autoCreateMembers();
- size_t getStringLength(uint64_t startAddr);
+ //! Get the length of of the string (if there is one) starting at the
+ //! given address. String type is assumed to be UTF-8 by default, but the
+ //! `charSize` parameter can be set to 2 or 4 to look for UTF-16 or
+ //! UTF-32 string, respectively.
+ //!
+ //! Returns the length of the string in bytes, NOT the number of characters.
+ size_t getStringLength(uint64_t startAddr, size_t charSize = 1);
void setInstructionHighlight(BNHighlightColor color);
void setBlockHighlight(BNHighlightColor color);
diff --git a/ui/tokenizedtextview.h b/ui/tokenizedtextview.h
index 699c6caa..6424e6e4 100644
--- a/ui/tokenizedtextview.h
+++ b/ui/tokenizedtextview.h
@@ -94,11 +94,18 @@ class BINARYNINJAUIAPI TokenizedTextView: public QAbstractScrollArea, public Vie
void makeFloat64();
void toggleFloatSize();
void makePtr();
- void makeString();
+ void makeString(size_t charSize = 1);
void changeType();
void inferStructureType();
void autoCreateMembers();
- size_t getStringLength(uint64_t startAddr);
+
+ //! Get the length of of the string (if there is one) starting at the
+ //! given address. String type is assumed to be UTF-8 by default, but the
+ //! `charSize` parameter can be set to 2 or 4 to look for UTF-16 or
+ //! UTF-32 string, respectively.
+ //!
+ //! Returns the length of the string in bytes, NOT the number of characters.
+ size_t getStringLength(uint64_t startAddr, size_t charSize = 1);
void setInstructionHighlight(BNHighlightColor color);
void setBlockHighlight(BNHighlightColor color);
diff --git a/ui/typeview.h b/ui/typeview.h
index 512e2635..c5631a23 100644
--- a/ui/typeview.h
+++ b/ui/typeview.h
@@ -263,7 +263,7 @@ private Q_SLOTS:
void makeInt32();
void makeInt64();
void makePtr();
- void makeString();
+ void makeString(size_t charSize = 1);
void makeArray();
void newTypes();
void createStructure();