diff --git a/Ghidra/Features/Base/src/main/help/help/topics/DefinedStringsPlugin/DefinedStringsPlugin.htm b/Ghidra/Features/Base/src/main/help/help/topics/DefinedStringsPlugin/DefinedStringsPlugin.htm
index c9c99ab83e..71bc8685d9 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/DefinedStringsPlugin/DefinedStringsPlugin.htm
+++ b/Ghidra/Features/Base/src/main/help/help/topics/DefinedStringsPlugin/DefinedStringsPlugin.htm
@@ -39,6 +39,7 @@
representation into a value of your choice. This is the
same as using the Translate
Manual menu item.
+
String Length - the number of characters in the string.
Data Type - mnemonic or data type for the string type.
Is Ascii - boolean flag that indicates the string has non-ASCII characters.
Has Encoding Error - boolean flag that indicates the string had byte(s) that could not be converted by the character set.
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/DefinedStringsTableModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/DefinedStringsTableModel.java
index 9627364b07..b65b8b2987 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/DefinedStringsTableModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/strings/DefinedStringsTableModel.java
@@ -63,7 +63,8 @@ class DefinedStringsTableModel extends AddressBasedTableModel {
CHARSET_COL,
HAS_ENCODING_ERROR,
UNICODE_SCRIPT,
- TRANSLATED_VALUE
+ TRANSLATED_VALUE,
+ LENGTH_COL
}
DefinedStringsTableModel(PluginTool tool) {
@@ -103,6 +104,7 @@ class DefinedStringsTableModel extends AddressBasedTableModel {
descriptor.addHiddenColumn(new HasEncodingErrorColumn());
descriptor.addHiddenColumn(new UnicodeScriptColumn());
descriptor.addHiddenColumn(new TranslatedValueColumn());
+ descriptor.addHiddenColumn(new StringLengthColumn());
return descriptor;
}
@@ -220,8 +222,8 @@ class DefinedStringsTableModel extends AddressBasedTableModel {
@Override
public StringDataInstance getValue(ProgramLocation rowObject, Settings settings,
Program program, ServiceProvider serviceProvider) throws IllegalArgumentException {
- return StringDataInstance.getStringDataInstance(
- DataUtilities.getDataAtLocation(rowObject));
+ return StringDataInstance
+ .getStringDataInstance(DataUtilities.getDataAtLocation(rowObject));
}
@Override
@@ -269,8 +271,8 @@ class DefinedStringsTableModel extends AddressBasedTableModel {
}
@Override
- public String getValue(ProgramLocation rowObject, Settings settings,
- Program program, ServiceProvider serviceProvider) throws IllegalArgumentException {
+ public String getValue(ProgramLocation rowObject, Settings settings, Program program,
+ ServiceProvider serviceProvider) throws IllegalArgumentException {
Data data = DataUtilities.getDataAtLocation(rowObject);
if (StringDataInstance.isString(data)) {
StringDataInstance sdi = StringDataInstance.getStringDataInstance(data);
@@ -358,8 +360,7 @@ class DefinedStringsTableModel extends AddressBasedTableModel {
String s = StringDataInstance.getStringDataInstance(data).getStringValue();
return (s != null) && s.codePoints()
- .anyMatch(
- codePoint -> codePoint == StringUtilities.UNICODE_REPLACEMENT);
+ .anyMatch(codePoint -> codePoint == StringUtilities.UNICODE_REPLACEMENT);
}
@Override
@@ -450,4 +451,30 @@ class DefinedStringsTableModel extends AddressBasedTableModel {
}
}
+
+ private static class StringLengthColumn
+ extends AbstractProgramLocationTableColumn {
+
+ @Override
+ public String getColumnName() {
+ return "String Length";
+ }
+
+ @Override
+ public Integer getValue(ProgramLocation rowObject, Settings settings, Program program,
+ ServiceProvider serviceProvider) throws IllegalArgumentException {
+
+ Data data = DataUtilities.getDataAtLocation(rowObject);
+ String s = StringDataInstance.getStringDataInstance(data).getStringValue();
+
+ return s != null ? s.length() : 0;
+ }
+
+ @Override
+ public ProgramLocation getProgramLocation(ProgramLocation rowObject, Settings settings,
+ Program program, ServiceProvider serviceProvider) {
+ return rowObject;
+ }
+
+ }
}