mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 15:13:09 +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
|
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">
|
same as using the <b>Translate <IMG src="help/shared/arrow.gif" alt="->" border="0">
|
||||||
Manual</b> menu item.</li>
|
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>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>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.
|
<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,
|
CHARSET_COL,
|
||||||
HAS_ENCODING_ERROR,
|
HAS_ENCODING_ERROR,
|
||||||
UNICODE_SCRIPT,
|
UNICODE_SCRIPT,
|
||||||
TRANSLATED_VALUE
|
TRANSLATED_VALUE,
|
||||||
|
LENGTH_COL
|
||||||
}
|
}
|
||||||
|
|
||||||
DefinedStringsTableModel(PluginTool tool) {
|
DefinedStringsTableModel(PluginTool tool) {
|
||||||
@@ -103,6 +104,7 @@ class DefinedStringsTableModel extends AddressBasedTableModel<ProgramLocation> {
|
|||||||
descriptor.addHiddenColumn(new HasEncodingErrorColumn());
|
descriptor.addHiddenColumn(new HasEncodingErrorColumn());
|
||||||
descriptor.addHiddenColumn(new UnicodeScriptColumn());
|
descriptor.addHiddenColumn(new UnicodeScriptColumn());
|
||||||
descriptor.addHiddenColumn(new TranslatedValueColumn());
|
descriptor.addHiddenColumn(new TranslatedValueColumn());
|
||||||
|
descriptor.addHiddenColumn(new StringLengthColumn());
|
||||||
|
|
||||||
return descriptor;
|
return descriptor;
|
||||||
}
|
}
|
||||||
@@ -220,8 +222,8 @@ class DefinedStringsTableModel extends AddressBasedTableModel<ProgramLocation> {
|
|||||||
@Override
|
@Override
|
||||||
public StringDataInstance getValue(ProgramLocation rowObject, Settings settings,
|
public StringDataInstance getValue(ProgramLocation rowObject, Settings settings,
|
||||||
Program program, ServiceProvider serviceProvider) throws IllegalArgumentException {
|
Program program, ServiceProvider serviceProvider) throws IllegalArgumentException {
|
||||||
return StringDataInstance.getStringDataInstance(
|
return StringDataInstance
|
||||||
DataUtilities.getDataAtLocation(rowObject));
|
.getStringDataInstance(DataUtilities.getDataAtLocation(rowObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -269,8 +271,8 @@ class DefinedStringsTableModel extends AddressBasedTableModel<ProgramLocation> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getValue(ProgramLocation rowObject, Settings settings,
|
public String getValue(ProgramLocation rowObject, Settings settings, Program program,
|
||||||
Program program, ServiceProvider serviceProvider) throws IllegalArgumentException {
|
ServiceProvider serviceProvider) throws IllegalArgumentException {
|
||||||
Data data = DataUtilities.getDataAtLocation(rowObject);
|
Data data = DataUtilities.getDataAtLocation(rowObject);
|
||||||
if (StringDataInstance.isString(data)) {
|
if (StringDataInstance.isString(data)) {
|
||||||
StringDataInstance sdi = StringDataInstance.getStringDataInstance(data);
|
StringDataInstance sdi = StringDataInstance.getStringDataInstance(data);
|
||||||
@@ -358,8 +360,7 @@ class DefinedStringsTableModel extends AddressBasedTableModel<ProgramLocation> {
|
|||||||
String s = StringDataInstance.getStringDataInstance(data).getStringValue();
|
String s = StringDataInstance.getStringDataInstance(data).getStringValue();
|
||||||
|
|
||||||
return (s != null) && s.codePoints()
|
return (s != null) && s.codePoints()
|
||||||
.anyMatch(
|
.anyMatch(codePoint -> codePoint == StringUtilities.UNICODE_REPLACEMENT);
|
||||||
codePoint -> codePoint == StringUtilities.UNICODE_REPLACEMENT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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