mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-20 23:08:31 +08:00
Merge remote-tracking branch 'origin/GP-6437_dev747368_stringlen_column'
This commit is contained in:
+1
@@ -39,6 +39,7 @@
|
||||
representation into a value of your choice. This is the
|
||||
same as using the <b>Translate <IMG src="help/shared/arrow.gif" alt="->" border="0">
|
||||
Manual</b> menu item.</li>
|
||||
<li>String Length - the number of characters in the string.</li>
|
||||
<li>Data Type - mnemonic or data type for the string type.</li>
|
||||
<li>Is Ascii - boolean flag that indicates the string has non-ASCII characters.</li>
|
||||
<li>Has Encoding Error - boolean flag that indicates the string had byte(s) that could not be converted by the character set.
|
||||
|
||||
+34
-7
@@ -63,7 +63,8 @@ class DefinedStringsTableModel extends AddressBasedTableModel<ProgramLocation> {
|
||||
CHARSET_COL,
|
||||
HAS_ENCODING_ERROR,
|
||||
UNICODE_SCRIPT,
|
||||
TRANSLATED_VALUE
|
||||
TRANSLATED_VALUE,
|
||||
LENGTH_COL
|
||||
}
|
||||
|
||||
DefinedStringsTableModel(PluginTool tool) {
|
||||
@@ -103,6 +104,7 @@ class DefinedStringsTableModel extends AddressBasedTableModel<ProgramLocation> {
|
||||
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<ProgramLocation> {
|
||||
@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<ProgramLocation> {
|
||||
}
|
||||
|
||||
@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<ProgramLocation> {
|
||||
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<ProgramLocation> {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class StringLengthColumn
|
||||
extends AbstractProgramLocationTableColumn<ProgramLocation, Integer> {
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user