mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-31 14:57:09 +08:00
Merge remote-tracking branch
'origin/GP-3913_ghidra1_DataStackPointersBug' (Closes #5754)
This commit is contained in:
@@ -15,7 +15,8 @@
|
|||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.data;
|
package ghidra.app.plugin.core.data;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
@@ -153,8 +154,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
tool.addAction(pointerAction);
|
tool.addAction(pointerAction);
|
||||||
|
|
||||||
// Data instance settings action based upon data selection in listing
|
// Data instance settings action based upon data selection in listing
|
||||||
new ActionBuilder("Data Settings", getName())
|
new ActionBuilder("Data Settings", getName()).sharedKeyBinding()
|
||||||
.sharedKeyBinding()
|
|
||||||
.popupMenuPath(DATA_SETTINGS_POPUP_PATH)
|
.popupMenuPath(DATA_SETTINGS_POPUP_PATH)
|
||||||
.popupMenuGroup("Settings")
|
.popupMenuGroup("Settings")
|
||||||
.withContext(ListingActionContext.class)
|
.withContext(ListingActionContext.class)
|
||||||
@@ -163,8 +163,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
.buildAndInstall(tool);
|
.buildAndInstall(tool);
|
||||||
|
|
||||||
// Default settings action based upon data selection in listing
|
// Default settings action based upon data selection in listing
|
||||||
new ActionBuilder("Default Settings", getName())
|
new ActionBuilder("Default Settings", getName()).sharedKeyBinding()
|
||||||
.sharedKeyBinding()
|
|
||||||
.popupMenuPath(DEFAULT_SETTINGS_POPUP_PATH)
|
.popupMenuPath(DEFAULT_SETTINGS_POPUP_PATH)
|
||||||
.popupMenuGroup("Settings")
|
.popupMenuGroup("Settings")
|
||||||
.withContext(ListingActionContext.class)
|
.withContext(ListingActionContext.class)
|
||||||
@@ -173,8 +172,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
.buildAndInstall(tool);
|
.buildAndInstall(tool);
|
||||||
|
|
||||||
// Default settings action for selected datatypes from datatype manager
|
// Default settings action for selected datatypes from datatype manager
|
||||||
new ActionBuilder("Default Settings", getName())
|
new ActionBuilder("Default Settings", getName()).sharedKeyBinding()
|
||||||
.sharedKeyBinding()
|
|
||||||
.popupMenuPath(DATATYPE_SETTINGS_POPUP_PATH)
|
.popupMenuPath(DATATYPE_SETTINGS_POPUP_PATH)
|
||||||
.popupMenuGroup("Settings")
|
.popupMenuGroup("Settings")
|
||||||
.withContext(DataTypesActionContext.class)
|
.withContext(DataTypesActionContext.class)
|
||||||
@@ -183,8 +181,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
.buildAndInstall(tool);
|
.buildAndInstall(tool);
|
||||||
|
|
||||||
// Default settings action for composite editor components (Program-based)
|
// Default settings action for composite editor components (Program-based)
|
||||||
new ActionBuilder("Default Settings", getName())
|
new ActionBuilder("Default Settings", getName()).sharedKeyBinding()
|
||||||
.sharedKeyBinding()
|
|
||||||
.popupMenuPath(DATATYPE_SETTINGS_POPUP_PATH)
|
.popupMenuPath(DATATYPE_SETTINGS_POPUP_PATH)
|
||||||
.popupMenuGroup("Settings")
|
.popupMenuGroup("Settings")
|
||||||
.withContext(ComponentProgramActionContext.class)
|
.withContext(ComponentProgramActionContext.class)
|
||||||
@@ -193,8 +190,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
.buildAndInstall(tool);
|
.buildAndInstall(tool);
|
||||||
|
|
||||||
// Default settings action for composite editor components (stand-alone archive)
|
// Default settings action for composite editor components (stand-alone archive)
|
||||||
new ActionBuilder("Default Settings", getName())
|
new ActionBuilder("Default Settings", getName()).sharedKeyBinding()
|
||||||
.sharedKeyBinding()
|
|
||||||
.popupMenuPath(DATATYPE_SETTINGS_POPUP_PATH)
|
.popupMenuPath(DATATYPE_SETTINGS_POPUP_PATH)
|
||||||
.popupMenuGroup("Settings")
|
.popupMenuGroup("Settings")
|
||||||
.withContext(ComponentStandAloneActionContext.class)
|
.withContext(ComponentStandAloneActionContext.class)
|
||||||
@@ -202,31 +198,31 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
.onAction(context -> editDefaultComponentSettings(context))
|
.onAction(context -> editDefaultComponentSettings(context))
|
||||||
.buildAndInstall(tool);
|
.buildAndInstall(tool);
|
||||||
|
|
||||||
editDataTypeAction = new ActionBuilder("Edit Data Type", getName())
|
editDataTypeAction =
|
||||||
.popupMenuPath(EDIT_DATA_TYPE_POPUP_PATH)
|
new ActionBuilder("Edit Data Type", getName()).popupMenuPath(EDIT_DATA_TYPE_POPUP_PATH)
|
||||||
.popupMenuGroup("BasicData")
|
.popupMenuGroup("BasicData")
|
||||||
.withContext(ListingActionContext.class)
|
.withContext(ListingActionContext.class)
|
||||||
.enabledWhen(c -> {
|
.enabledWhen(c -> {
|
||||||
DataType editableDt = getEditableDataTypeFromContext(c);
|
DataType editableDt = getEditableDataTypeFromContext(c);
|
||||||
if (editableDt != null) {
|
if (editableDt != null) {
|
||||||
editDataTypeAction.setHelpLocation(
|
editDataTypeAction
|
||||||
dtmService.getEditorHelpLocation(editableDt));
|
.setHelpLocation(dtmService.getEditorHelpLocation(editableDt));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
.onAction(c -> editDataTypeCallback(c))
|
.onAction(c -> editDataTypeCallback(c))
|
||||||
.helpLocation(new HelpLocation("DataTypeEditors", "Structure_Editor"))
|
.helpLocation(new HelpLocation("DataTypeEditors", "Structure_Editor"))
|
||||||
.buildAndInstall(tool);
|
.buildAndInstall(tool);
|
||||||
|
|
||||||
chooseDataTypeAction = new ChooseDataTypeAction(this);
|
chooseDataTypeAction = new ChooseDataTypeAction(this);
|
||||||
chooseDataTypeAction.setEnabled(false);
|
chooseDataTypeAction.setEnabled(false);
|
||||||
|
|
||||||
chooseDataTypeAction.setPopupMenuData(
|
chooseDataTypeAction
|
||||||
new MenuData(CHOOSE_DATA_TYPE_POPUP_PATH, BASIC_DATA_GROUP));
|
.setPopupMenuData(new MenuData(CHOOSE_DATA_TYPE_POPUP_PATH, BASIC_DATA_GROUP));
|
||||||
chooseDataTypeAction.setEnabled(true);
|
chooseDataTypeAction.setEnabled(true);
|
||||||
chooseDataTypeAction.setHelpLocation(
|
chooseDataTypeAction
|
||||||
new HelpLocation("DataTypeEditors", "DataTypeSelectionDialog"));
|
.setHelpLocation(new HelpLocation("DataTypeEditors", "DataTypeSelectionDialog"));
|
||||||
tool.addAction(chooseDataTypeAction);
|
tool.addAction(chooseDataTypeAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,8 +286,8 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean createData(DataType dt, ListingActionContext context,
|
public boolean createData(DataType dt, ListingActionContext context, boolean stackPointers,
|
||||||
boolean stackPointers, boolean enableConflictHandling) {
|
boolean enableConflictHandling) {
|
||||||
// TODO: conflict handler (i.e., removal of other conflicting data not yet supported)
|
// TODO: conflict handler (i.e., removal of other conflicting data not yet supported)
|
||||||
ProgramLocation location = context.getLocation();
|
ProgramLocation location = context.getLocation();
|
||||||
if (!(location instanceof CodeUnitLocation)) {
|
if (!(location instanceof CodeUnitLocation)) {
|
||||||
@@ -352,7 +348,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
new CreateDataInStructureBackgroundCmd(start, startPath, length, dt, stackPointers);
|
new CreateDataInStructureBackgroundCmd(start, startPath, length, dt, stackPointers);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
cmd = new CreateDataBackgroundCmd(selection, dt, true);
|
cmd = new CreateDataBackgroundCmd(selection, dt, stackPointers);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean didCreateData = false;
|
boolean didCreateData = false;
|
||||||
@@ -385,9 +381,8 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (newSize <= 0) {
|
if (newSize <= 0) {
|
||||||
tool.setStatusInfo(
|
tool.setStatusInfo("Invalid data location. Unable to resolve data length at " + start +
|
||||||
"Invalid data location. Unable to resolve data length at " + start + " for " +
|
" for " + dataType.getName());
|
||||||
dataType.getName());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,9 +511,7 @@ public class DataPlugin extends Plugin implements DataService {
|
|||||||
* Get rid of the dynamically created list of data types
|
* Get rid of the dynamically created list of data types
|
||||||
*/
|
*/
|
||||||
private void clearActions(List<DataAction> actions) {
|
private void clearActions(List<DataAction> actions) {
|
||||||
Iterator<DataAction> iter = actions.iterator();
|
for (DockingAction action : actions) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
DockingAction action = iter.next();
|
|
||||||
tool.removeAction(action);
|
tool.removeAction(action);
|
||||||
action.dispose();
|
action.dispose();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user