mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-5634 - Fixed 'Find Structures by Size...' to find zero-length
structures
This commit is contained in:
parent
939a8f979c
commit
17d0a83d51
3 changed files with 31 additions and 4 deletions
|
@ -92,6 +92,10 @@ public class FindDataTypesBySizeAction extends DockingAction {
|
||||||
DataTypeNode dataTypeNode = (DataTypeNode) node;
|
DataTypeNode dataTypeNode = (DataTypeNode) node;
|
||||||
DataType dt = dataTypeNode.getDataType();
|
DataType dt = dataTypeNode.getDataType();
|
||||||
int length = dt.getLength();
|
int length = dt.getLength();
|
||||||
|
if (dt.isZeroLength()) {
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (Range range : sizes) {
|
for (Range range : sizes) {
|
||||||
if (range.contains(length)) {
|
if (range.contains(length)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -70,6 +70,10 @@ public class FindStructuresBySizeAction extends FindDataTypesBySizeAction {
|
||||||
|
|
||||||
Structure structure = (Structure) dataType;
|
Structure structure = (Structure) dataType;
|
||||||
int length = structure.getLength();
|
int length = structure.getLength();
|
||||||
|
if (structure.isZeroLength()) {
|
||||||
|
length = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (Range range : sizes) {
|
for (Range range : sizes) {
|
||||||
if (range.contains(length)) {
|
if (range.contains(length)) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -852,6 +852,25 @@ public class DataTypeManagerPluginTest extends AbstractGhidraHeadedIntegrationTe
|
||||||
assertMatchingStructures(resultsProvider, "Structure_0x8");
|
assertMatchingStructures(resultsProvider, "Structure_0x8");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testAction_FindStructureBySize_Empty() {
|
||||||
|
|
||||||
|
StructureDataType stuct = new StructureDataType("Structure_Empty", 0);
|
||||||
|
builder.addDataType(stuct);
|
||||||
|
|
||||||
|
DockingActionIf action = getAction(plugin, FindStructuresBySizeAction.NAME);
|
||||||
|
performAction(action, false);
|
||||||
|
|
||||||
|
NumberRangeInputDialog dialog = waitForDialogComponent(NumberRangeInputDialog.class);
|
||||||
|
setText(dialog, "0");
|
||||||
|
|
||||||
|
pressButtonByText(dialog, "OK");
|
||||||
|
|
||||||
|
DataTypesProvider resultsProvider =
|
||||||
|
waitForComponentProvider(DataTypesProvider.class, FindStructuresBySizeAction.NAME);
|
||||||
|
assertMatchingStructures(resultsProvider, "Structure_Empty");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAction_FindStructureBySize_Ranage() {
|
public void testAction_FindStructureBySize_Ranage() {
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue