diff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/data_type_manager_description.htm b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/data_type_manager_description.htm index f072007660..f37737d95d 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/data_type_manager_description.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/data_type_manager_description.htm @@ -901,6 +901,17 @@ "../DataTypeEditors/StructureEditor.htm">structure editor will appear, and for enums the enum editor will appear.

+ + +
+

To edit a data type from anywhere + in the tool, you can activate the global Edit Data Type action from the + keyboard by pressing Ctrl-Shift-D. This will present you a + Data Type Chooser + Dialog that you can use to choose a type to edit. +

+
+

Creating a new Enum from a Selection of diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditorListener.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditorListener.java index 253c530002..1ff3a98d1a 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditorListener.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditorListener.java @@ -1,6 +1,5 @@ /* ### * IP: GHIDRA - * REVIEWED: YES * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,15 +15,15 @@ */ package ghidra.app.plugin.core.compositeeditor; - /** * * Interface used for notification when an edit session is ending. */ public interface EditorListener { - + /** * Notification that the editor is closed. + * @param editor the editor */ public void closed(EditorProvider editor); } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java index d1ceb604e8..9823ebb551 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java @@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils; import docking.ActionContext; import docking.Tool; import docking.action.*; +import docking.action.builder.ActionBuilder; import docking.actions.PopupActionProvider; import docking.widgets.tree.GTreeNode; import generic.jar.ResourceFile; @@ -47,6 +48,7 @@ import ghidra.app.plugin.core.datamgr.util.DataDropOnBrowserHandler; import ghidra.app.plugin.core.datamgr.util.DataTypeChooserDialog; import ghidra.app.services.*; import ghidra.app.util.HelpTopics; +import ghidra.app.util.datatype.DataTypeSelectionDialog; import ghidra.framework.Application; import ghidra.framework.main.OpenVersionedFileDialog; import ghidra.framework.model.*; @@ -60,6 +62,7 @@ import ghidra.program.model.data.*; import ghidra.program.model.listing.DataTypeArchive; import ghidra.program.model.listing.Program; import ghidra.util.*; +import ghidra.util.data.DataTypeParser.AllowedDataTypes; import ghidra.util.datastruct.LRUMap; import ghidra.util.exception.CancelledException; import ghidra.util.exception.VersionException; @@ -443,12 +446,36 @@ public class DataTypeManagerPlugin extends ProgramPlugin */ private void createActions() { createStandardArchivesMenu(); + + //@formatter:off + new ActionBuilder("Edit Data Type", getName()) + .keyBinding("Control Shift D") + .onAction(this::edit) + .buildAndInstall(tool); + //@formatter:on } private void removeRecentAction(DockingAction action) { tool.removeLocalAction(provider, action); } + private void edit(ActionContext c) { + DataType dt = chooseType(); + if (dt != null) { + edit(dt); + } + } + + private DataType chooseType() { + + int noSizeRestriction = -1; + DataTypeSelectionDialog selectionDialog = + new DataTypeSelectionDialog(tool, null, noSizeRestriction, AllowedDataTypes.ALL); + + tool.showDialog(selectionDialog); + return selectionDialog.getUserChosenDataType(); + } + //********************************************************************************************** // DataTypeManagerService methods //********************************************************************************************** diff --git a/Ghidra/Features/Sarif/build.gradle b/Ghidra/Features/Sarif/build.gradle index bee4d880d4..3f62c3b2b6 100644 --- a/Ghidra/Features/Sarif/build.gradle +++ b/Ghidra/Features/Sarif/build.gradle @@ -15,6 +15,7 @@ */ apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle" apply from: "$rootProject.projectDir/gradle/javaProject.gradle" +apply from: "$rootProject.projectDir/gradle/helpProject.gradle" apply from: "$rootProject.projectDir/gradle/jacocoProject.gradle" apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle" apply plugin: 'eclipse' diff --git a/Ghidra/Features/Sarif/src/main/help/help/topics/Sarif/SARIF.htm b/Ghidra/Features/Sarif/src/main/help/help/topics/Sarif/SARIF.htm index da6bed2120..e263fe690c 100644 --- a/Ghidra/Features/Sarif/src/main/help/help/topics/Sarif/SARIF.htm +++ b/Ghidra/Features/Sarif/src/main/help/help/topics/Sarif/SARIF.htm @@ -51,7 +51,7 @@ The default "handle" method takes anything returned by the "parse" method, creates key-value pairs (stored as a map, but...) using "getKey" and the value returned, and adds them to a list of results stored in the data frame. These can be retrieved programmatically later or processed immediately. - For example, the SarifPropertyResultHandler looks for results with "AdditionalProperties" labelled + For example, the SarifPropertyResultHandler looks for results with "AdditionalProperties" labeled either "viewer/table/xxx" or "listing/[comment, highlight, bookmark]". Items in the second category are applied immediately to the current program. Items in the first category are added to the table under column "xxx".

@@ -73,7 +73,7 @@

 

diff --git a/Ghidra/Features/Sarif/src/main/java/sarif/SarifPlugin.java b/Ghidra/Features/Sarif/src/main/java/sarif/SarifPlugin.java index 6dadca0383..407a929ff5 100644 --- a/Ghidra/Features/Sarif/src/main/java/sarif/SarifPlugin.java +++ b/Ghidra/Features/Sarif/src/main/java/sarif/SarifPlugin.java @@ -17,9 +17,7 @@ package sarif; import java.io.File; import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.util.*; import javax.swing.Icon; @@ -30,18 +28,11 @@ import docking.action.builder.ActionBuilder; import docking.tool.ToolConstants; import docking.widgets.filechooser.GhidraFileChooser; import ghidra.MiscellaneousPluginPackage; -import ghidra.app.events.ProgramActivatedPluginEvent; -import ghidra.app.events.ProgramClosedPluginEvent; -import ghidra.app.events.ProgramOpenedPluginEvent; -import ghidra.app.events.ProgramVisibilityChangePluginEvent; +import ghidra.app.events.*; import ghidra.app.plugin.PluginCategoryNames; import ghidra.app.plugin.ProgramPlugin; -import ghidra.framework.options.Options; -import ghidra.framework.options.OptionsChangeListener; -import ghidra.framework.options.ToolOptions; -import ghidra.framework.plugintool.PluginEvent; -import ghidra.framework.plugintool.PluginInfo; -import ghidra.framework.plugintool.PluginTool; +import ghidra.framework.options.*; +import ghidra.framework.plugintool.*; import ghidra.framework.plugintool.util.PluginStatus; import ghidra.program.model.address.Address; import ghidra.program.model.address.AddressSet; @@ -75,7 +66,7 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener public SarifPlugin(PluginTool tool) { super(tool); - this.sarifControllers = new HashMap(); + this.sarifControllers = new HashMap<>(); this.io = new SarifGsonIO(); } @@ -84,13 +75,15 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener createActions(); initializeOptions(); } - + public void readFile(File file) { if (file != null) { try { showSarif(file.getName(), io.readSarif(file)); - } catch (JsonSyntaxException | IOException e) { - Msg.showError(this, tool.getActiveWindow(), "File parse error", "Invalid Sarif File"); + } + catch (JsonSyntaxException | IOException e) { + Msg.showError(this, tool.getActiveWindow(), "File parse error", + "Invalid Sarif File"); } } } @@ -135,7 +128,6 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener } } - /** * Ultimately both selections end up calling this to actually show something on * the Ghidra gui @@ -154,7 +146,7 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener if (currentController != null) { currentController.showTable(logName, sarif); return; - } + } } Msg.showError(this, tool.getActiveWindow(), "File parse error", "No current program"); } @@ -166,12 +158,13 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener } this.setSelection(selection); } - + private void createActions() { //@formatter:off new ActionBuilder("Read", getName()) .menuPath("Sarif", "Read File") .menuGroup("sarif", "1") + .helpLocation(new HelpLocation("Sarif", "Using_SARIF_Files")) .enabledWhen(ctx -> getCurrentProgram() != null) .onAction(e -> { GhidraFileChooser chooser = new GhidraFileChooser(tool.getActiveWindow()); @@ -180,7 +173,7 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener .buildAndInstall(tool); //@formatter:on } - + private void initializeOptions() { ToolOptions options = tool.getOptions(ToolConstants.GRAPH_OPTIONS); options.addOptionsChangeListener(this); @@ -199,22 +192,21 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener Options sarifOptions = options.getOptions(NAME); loadOptions(sarifOptions); } - + public void registerOptions(Options options, HelpLocation help) { options.setOptionsHelpLocation(help); options.registerOption("Display Artifacts", displayArtifacts(), help, - "Display artifacts by default"); + "Display artifacts by default"); options.registerOption("Display Graphs", displayGraphs(), help, - "Display graphs by default"); + "Display graphs by default"); options.registerOption("Max Graph Size", getGraphSize(), help, - "Maximum number of nodes per graph"); + "Maximum number of nodes per graph"); - options.registerOption("Append Graphs", appendToGraph(), help, - "Append to existing graph"); + options.registerOption("Append Graphs", appendToGraph(), help, "Append to existing graph"); } @@ -228,21 +220,25 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener } private boolean displayGraphsByDefault = false; + public boolean displayGraphs() { return displayGraphsByDefault; } private boolean displayArtifactsByDefault = false; + public boolean displayArtifacts() { return displayArtifactsByDefault; } private int maxGraphSize = 1000; + public int getGraphSize() { return maxGraphSize; } private boolean appendToCurrentGraph = false; + public boolean appendToGraph() { return appendToCurrentGraph; } diff --git a/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java b/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java index 324db9f96a..ced187402e 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/ComponentProvider.java @@ -231,7 +231,6 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext return; } - dockingTool.toFront(); if (defaultFocusComponent != null) { DockingWindowManager.requestFocus(defaultFocusComponent); return;