mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-06-02 18:26:53 +08:00
Merge remote-tracking branch
'origin/GP-4148-dragonmacher-global-data-type-edit-action' (Closes #5975, Closes #6576)
This commit is contained in:
+11
@@ -901,6 +901,17 @@
|
|||||||
"../DataTypeEditors/StructureEditor.htm"><FONT color="#0000ff">structure
|
"../DataTypeEditors/StructureEditor.htm"><FONT color="#0000ff">structure
|
||||||
editor</FONT></A> will appear, and for enums the <A href=
|
editor</FONT></A> will appear, and for enums the <A href=
|
||||||
"../DataTypeEditors/EnumEditor.htm">enum editor</A> will appear.</P>
|
"../DataTypeEditors/EnumEditor.htm">enum editor</A> will appear.</P>
|
||||||
|
|
||||||
|
|
||||||
|
<BLOCKQUOTE>
|
||||||
|
<P><IMG border="0" src="help/shared/tip.png" alt="">To edit a data type from anywhere
|
||||||
|
in the tool, you can activate the global <B>Edit Data Type</B> action from the
|
||||||
|
keyboard by pressing <B><I>Ctrl-Shift-D</I></B>. This will present you a
|
||||||
|
<A HREF="help/topics/DataTypeEditors/DataTypeSelectionDialog.htm">Data Type Chooser
|
||||||
|
Dialog</A> that you can use to choose a type to edit.
|
||||||
|
</P>
|
||||||
|
</BLOCKQUOTE>
|
||||||
|
|
||||||
</BLOCKQUOTE>
|
</BLOCKQUOTE>
|
||||||
|
|
||||||
<H3><A name="CreateEnumFromSelection"></A>Creating a new Enum from a Selection of
|
<H3><A name="CreateEnumFromSelection"></A>Creating a new Enum from a Selection of
|
||||||
|
|||||||
+1
-2
@@ -1,6 +1,5 @@
|
|||||||
/* ###
|
/* ###
|
||||||
* IP: GHIDRA
|
* IP: GHIDRA
|
||||||
* REVIEWED: YES
|
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package ghidra.app.plugin.core.compositeeditor;
|
package ghidra.app.plugin.core.compositeeditor;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Interface used for notification when an edit session is ending.
|
* Interface used for notification when an edit session is ending.
|
||||||
@@ -25,6 +23,7 @@ public interface EditorListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Notification that the editor is closed.
|
* Notification that the editor is closed.
|
||||||
|
* @param editor the editor
|
||||||
*/
|
*/
|
||||||
public void closed(EditorProvider editor);
|
public void closed(EditorProvider editor);
|
||||||
}
|
}
|
||||||
|
|||||||
+27
@@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||||||
import docking.ActionContext;
|
import docking.ActionContext;
|
||||||
import docking.Tool;
|
import docking.Tool;
|
||||||
import docking.action.*;
|
import docking.action.*;
|
||||||
|
import docking.action.builder.ActionBuilder;
|
||||||
import docking.actions.PopupActionProvider;
|
import docking.actions.PopupActionProvider;
|
||||||
import docking.widgets.tree.GTreeNode;
|
import docking.widgets.tree.GTreeNode;
|
||||||
import generic.jar.ResourceFile;
|
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.plugin.core.datamgr.util.DataTypeChooserDialog;
|
||||||
import ghidra.app.services.*;
|
import ghidra.app.services.*;
|
||||||
import ghidra.app.util.HelpTopics;
|
import ghidra.app.util.HelpTopics;
|
||||||
|
import ghidra.app.util.datatype.DataTypeSelectionDialog;
|
||||||
import ghidra.framework.Application;
|
import ghidra.framework.Application;
|
||||||
import ghidra.framework.main.OpenVersionedFileDialog;
|
import ghidra.framework.main.OpenVersionedFileDialog;
|
||||||
import ghidra.framework.model.*;
|
import ghidra.framework.model.*;
|
||||||
@@ -60,6 +62,7 @@ import ghidra.program.model.data.*;
|
|||||||
import ghidra.program.model.listing.DataTypeArchive;
|
import ghidra.program.model.listing.DataTypeArchive;
|
||||||
import ghidra.program.model.listing.Program;
|
import ghidra.program.model.listing.Program;
|
||||||
import ghidra.util.*;
|
import ghidra.util.*;
|
||||||
|
import ghidra.util.data.DataTypeParser.AllowedDataTypes;
|
||||||
import ghidra.util.datastruct.LRUMap;
|
import ghidra.util.datastruct.LRUMap;
|
||||||
import ghidra.util.exception.CancelledException;
|
import ghidra.util.exception.CancelledException;
|
||||||
import ghidra.util.exception.VersionException;
|
import ghidra.util.exception.VersionException;
|
||||||
@@ -443,12 +446,36 @@ public class DataTypeManagerPlugin extends ProgramPlugin
|
|||||||
*/
|
*/
|
||||||
private void createActions() {
|
private void createActions() {
|
||||||
createStandardArchivesMenu();
|
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) {
|
private void removeRecentAction(DockingAction action) {
|
||||||
tool.removeLocalAction(provider, 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
|
// DataTypeManagerService methods
|
||||||
//**********************************************************************************************
|
//**********************************************************************************************
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"
|
apply from: "$rootProject.projectDir/gradle/distributableGhidraModule.gradle"
|
||||||
apply from: "$rootProject.projectDir/gradle/javaProject.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/jacocoProject.gradle"
|
||||||
apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"
|
apply from: "$rootProject.projectDir/gradle/javaTestProject.gradle"
|
||||||
apply plugin: 'eclipse'
|
apply plugin: 'eclipse'
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
The default "handle" method takes anything returned by the "parse" method, creates key-value pairs
|
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 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.
|
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
|
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
|
are applied immediately to the current program. Items in the first category are added to the table
|
||||||
under column "xxx".</P>
|
under column "xxx".</P>
|
||||||
@@ -73,7 +73,7 @@
|
|||||||
|
|
||||||
<UL>
|
<UL>
|
||||||
<LI><A href="help/topics/ImporterPlugin/importer.htm">Importers</A></LI>
|
<LI><A href="help/topics/ImporterPlugin/importer.htm">Importers</A></LI>
|
||||||
<LI><A href="help/topics/ExporterPlugin/importer.htm">Exporters</A></LI>
|
<LI><A href="help/topics/ExporterPlugin/exporter.htm">Exporters</A></LI>
|
||||||
</UL>
|
</UL>
|
||||||
|
|
||||||
<P> </P>
|
<P> </P>
|
||||||
|
|||||||
@@ -17,9 +17,7 @@ package sarif;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.swing.Icon;
|
import javax.swing.Icon;
|
||||||
|
|
||||||
@@ -30,18 +28,11 @@ import docking.action.builder.ActionBuilder;
|
|||||||
import docking.tool.ToolConstants;
|
import docking.tool.ToolConstants;
|
||||||
import docking.widgets.filechooser.GhidraFileChooser;
|
import docking.widgets.filechooser.GhidraFileChooser;
|
||||||
import ghidra.MiscellaneousPluginPackage;
|
import ghidra.MiscellaneousPluginPackage;
|
||||||
import ghidra.app.events.ProgramActivatedPluginEvent;
|
import ghidra.app.events.*;
|
||||||
import ghidra.app.events.ProgramClosedPluginEvent;
|
|
||||||
import ghidra.app.events.ProgramOpenedPluginEvent;
|
|
||||||
import ghidra.app.events.ProgramVisibilityChangePluginEvent;
|
|
||||||
import ghidra.app.plugin.PluginCategoryNames;
|
import ghidra.app.plugin.PluginCategoryNames;
|
||||||
import ghidra.app.plugin.ProgramPlugin;
|
import ghidra.app.plugin.ProgramPlugin;
|
||||||
import ghidra.framework.options.Options;
|
import ghidra.framework.options.*;
|
||||||
import ghidra.framework.options.OptionsChangeListener;
|
import ghidra.framework.plugintool.*;
|
||||||
import ghidra.framework.options.ToolOptions;
|
|
||||||
import ghidra.framework.plugintool.PluginEvent;
|
|
||||||
import ghidra.framework.plugintool.PluginInfo;
|
|
||||||
import ghidra.framework.plugintool.PluginTool;
|
|
||||||
import ghidra.framework.plugintool.util.PluginStatus;
|
import ghidra.framework.plugintool.util.PluginStatus;
|
||||||
import ghidra.program.model.address.Address;
|
import ghidra.program.model.address.Address;
|
||||||
import ghidra.program.model.address.AddressSet;
|
import ghidra.program.model.address.AddressSet;
|
||||||
@@ -75,7 +66,7 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener
|
|||||||
|
|
||||||
public SarifPlugin(PluginTool tool) {
|
public SarifPlugin(PluginTool tool) {
|
||||||
super(tool);
|
super(tool);
|
||||||
this.sarifControllers = new HashMap<Program, SarifController>();
|
this.sarifControllers = new HashMap<>();
|
||||||
this.io = new SarifGsonIO();
|
this.io = new SarifGsonIO();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,8 +80,10 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener
|
|||||||
if (file != null) {
|
if (file != null) {
|
||||||
try {
|
try {
|
||||||
showSarif(file.getName(), io.readSarif(file));
|
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
|
* Ultimately both selections end up calling this to actually show something on
|
||||||
* the Ghidra gui
|
* the Ghidra gui
|
||||||
@@ -172,6 +164,7 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener
|
|||||||
new ActionBuilder("Read", getName())
|
new ActionBuilder("Read", getName())
|
||||||
.menuPath("Sarif", "Read File")
|
.menuPath("Sarif", "Read File")
|
||||||
.menuGroup("sarif", "1")
|
.menuGroup("sarif", "1")
|
||||||
|
.helpLocation(new HelpLocation("Sarif", "Using_SARIF_Files"))
|
||||||
.enabledWhen(ctx -> getCurrentProgram() != null)
|
.enabledWhen(ctx -> getCurrentProgram() != null)
|
||||||
.onAction(e -> {
|
.onAction(e -> {
|
||||||
GhidraFileChooser chooser = new GhidraFileChooser(tool.getActiveWindow());
|
GhidraFileChooser chooser = new GhidraFileChooser(tool.getActiveWindow());
|
||||||
@@ -205,16 +198,15 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener
|
|||||||
options.setOptionsHelpLocation(help);
|
options.setOptionsHelpLocation(help);
|
||||||
|
|
||||||
options.registerOption("Display Artifacts", displayArtifacts(), help,
|
options.registerOption("Display Artifacts", displayArtifacts(), help,
|
||||||
"Display artifacts by default");
|
"Display artifacts by default");
|
||||||
|
|
||||||
options.registerOption("Display Graphs", displayGraphs(), help,
|
options.registerOption("Display Graphs", displayGraphs(), help,
|
||||||
"Display graphs by default");
|
"Display graphs by default");
|
||||||
|
|
||||||
options.registerOption("Max Graph Size", getGraphSize(), help,
|
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,
|
options.registerOption("Append Graphs", appendToGraph(), help, "Append to existing graph");
|
||||||
"Append to existing graph");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,21 +220,25 @@ public class SarifPlugin extends ProgramPlugin implements OptionsChangeListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean displayGraphsByDefault = false;
|
private boolean displayGraphsByDefault = false;
|
||||||
|
|
||||||
public boolean displayGraphs() {
|
public boolean displayGraphs() {
|
||||||
return displayGraphsByDefault;
|
return displayGraphsByDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean displayArtifactsByDefault = false;
|
private boolean displayArtifactsByDefault = false;
|
||||||
|
|
||||||
public boolean displayArtifacts() {
|
public boolean displayArtifacts() {
|
||||||
return displayArtifactsByDefault;
|
return displayArtifactsByDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int maxGraphSize = 1000;
|
private int maxGraphSize = 1000;
|
||||||
|
|
||||||
public int getGraphSize() {
|
public int getGraphSize() {
|
||||||
return maxGraphSize;
|
return maxGraphSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean appendToCurrentGraph = false;
|
private boolean appendToCurrentGraph = false;
|
||||||
|
|
||||||
public boolean appendToGraph() {
|
public boolean appendToGraph() {
|
||||||
return appendToCurrentGraph;
|
return appendToCurrentGraph;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,7 +231,6 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dockingTool.toFront();
|
|
||||||
if (defaultFocusComponent != null) {
|
if (defaultFocusComponent != null) {
|
||||||
DockingWindowManager.requestFocus(defaultFocusComponent);
|
DockingWindowManager.requestFocus(defaultFocusComponent);
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user