mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
fixing the graphing feature to initialize the graph with the current
selection and location
This commit is contained in:
parent
7ec583a4e8
commit
262b1c1d16
4 changed files with 28 additions and 11 deletions
|
@ -25,6 +25,7 @@ import ghidra.program.model.address.AddressSetView;
|
||||||
import ghidra.program.model.block.*;
|
import ghidra.program.model.block.*;
|
||||||
import ghidra.program.model.listing.*;
|
import ghidra.program.model.listing.*;
|
||||||
import ghidra.program.model.symbol.*;
|
import ghidra.program.model.symbol.*;
|
||||||
|
import ghidra.program.util.ProgramLocation;
|
||||||
import ghidra.program.util.ProgramSelection;
|
import ghidra.program.util.ProgramSelection;
|
||||||
import ghidra.service.graph.*;
|
import ghidra.service.graph.*;
|
||||||
import ghidra.util.HTMLUtilities;
|
import ghidra.util.HTMLUtilities;
|
||||||
|
@ -103,6 +104,7 @@ public class BlockGraphTask extends Task {
|
||||||
private final static String ENTRY_NEXUS_NAME = "Entry Points";
|
private final static String ENTRY_NEXUS_NAME = "Entry Points";
|
||||||
private CodeBlockModel blockModel;
|
private CodeBlockModel blockModel;
|
||||||
private AddressSetView selection;
|
private AddressSetView selection;
|
||||||
|
private ProgramLocation location;
|
||||||
private GraphDisplayProvider graphService;
|
private GraphDisplayProvider graphService;
|
||||||
private boolean reuseGraph;
|
private boolean reuseGraph;
|
||||||
private boolean appendGraph;
|
private boolean appendGraph;
|
||||||
|
@ -112,9 +114,10 @@ public class BlockGraphTask extends Task {
|
||||||
|
|
||||||
|
|
||||||
public BlockGraphTask(String actionName, boolean graphEntryPointNexus, boolean showCode,
|
public BlockGraphTask(String actionName, boolean graphEntryPointNexus, boolean showCode,
|
||||||
boolean reuseGraph,
|
boolean reuseGraph, boolean appendGraph, PluginTool tool, ProgramSelection selection,
|
||||||
boolean appendGraph, PluginTool tool, ProgramSelection selection,
|
ProgramLocation location, CodeBlockModel blockModel,
|
||||||
CodeBlockModel blockModel, GraphDisplayProvider graphService) {
|
GraphDisplayProvider graphService) {
|
||||||
|
|
||||||
super("Graph Program", true, false, true);
|
super("Graph Program", true, false, true);
|
||||||
this.actionName = actionName;
|
this.actionName = actionName;
|
||||||
|
|
||||||
|
@ -127,6 +130,7 @@ public class BlockGraphTask extends Task {
|
||||||
this.graphService = graphService;
|
this.graphService = graphService;
|
||||||
this.colorizingService = tool.getService(ColorizingService.class);
|
this.colorizingService = tool.getService(ColorizingService.class);
|
||||||
this.selection = selection;
|
this.selection = selection;
|
||||||
|
this.location = location;
|
||||||
this.program = blockModel.getProgram();
|
this.program = blockModel.getProgram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,8 +143,10 @@ public class BlockGraphTask extends Task {
|
||||||
monitor.setMessage("Generating Graph...");
|
monitor.setMessage("Generating Graph...");
|
||||||
try {
|
try {
|
||||||
GraphDisplay display = graphService.getGraphDisplay(reuseGraph, monitor);
|
GraphDisplay display = graphService.getGraphDisplay(reuseGraph, monitor);
|
||||||
display.setGraphDisplayListener(
|
BlockModelGraphDisplayListener listener =
|
||||||
new BlockModelGraphDisplayListener(tool, blockModel, display));
|
new BlockModelGraphDisplayListener(tool, blockModel, display);
|
||||||
|
display.setGraphDisplayListener(listener);
|
||||||
|
|
||||||
if (showCode) {
|
if (showCode) {
|
||||||
display.defineVertexAttribute(CODE_ATTRIBUTE);
|
display.defineVertexAttribute(CODE_ATTRIBUTE);
|
||||||
display.defineVertexAttribute(SYMBOLS_ATTRIBUTE);
|
display.defineVertexAttribute(SYMBOLS_ATTRIBUTE);
|
||||||
|
@ -148,6 +154,16 @@ public class BlockGraphTask extends Task {
|
||||||
codeLimitPerBlock + 1);
|
codeLimitPerBlock + 1);
|
||||||
}
|
}
|
||||||
display.setGraph(graph, actionName, appendGraph, monitor);
|
display.setGraph(graph, actionName, appendGraph, monitor);
|
||||||
|
|
||||||
|
if (location != null) {
|
||||||
|
display.setLocation(listener.getVertexIdForAddress(location.getAddress()));
|
||||||
|
}
|
||||||
|
if (selection != null && !selection.isEmpty()) {
|
||||||
|
List<String> selectedVertices = listener.getVertices(selection);
|
||||||
|
if (selectedVertices != null) {
|
||||||
|
display.selectVertices(selectedVertices);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (GraphException e) {
|
catch (GraphException e) {
|
||||||
if (!monitor.isCancelled()) {
|
if (!monitor.isCancelled()) {
|
||||||
|
|
|
@ -298,7 +298,8 @@ public class ProgramGraphPlugin extends ProgramPlugin
|
||||||
blockModelService.getNewModelByName(modelName, currentProgram, true);
|
blockModelService.getNewModelByName(modelName, currentProgram, true);
|
||||||
BlockGraphTask task =
|
BlockGraphTask task =
|
||||||
new BlockGraphTask(actionName, graphEntryPointNexus, showCode, reuseGraph,
|
new BlockGraphTask(actionName, graphEntryPointNexus, showCode, reuseGraph,
|
||||||
appendToGraph, tool, currentSelection, model, defaultGraphService);
|
appendToGraph, tool, currentSelection, currentLocation, model,
|
||||||
|
defaultGraphService);
|
||||||
task.setCodeLimitPerBlock(codeLimitPerBlock);
|
task.setCodeLimitPerBlock(codeLimitPerBlock);
|
||||||
new TaskLauncher(task, tool.getToolFrame());
|
new TaskLauncher(task, tool.getToolFrame());
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class BlockGraphEventTest extends AbstractBlockGraphTest {
|
||||||
TestGraphService graphService = new TestGraphService();
|
TestGraphService graphService = new TestGraphService();
|
||||||
BlockGraphTask task =
|
BlockGraphTask task =
|
||||||
new BlockGraphTask("test", false, false, false, false,
|
new BlockGraphTask("test", false, false, false, false,
|
||||||
tool, null, model, graphService);
|
tool, null, null, model, graphService);
|
||||||
|
|
||||||
task.monitoredRun(TaskMonitor.DUMMY);
|
task.monitoredRun(TaskMonitor.DUMMY);
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public class BlockGraphTaskTest extends AbstractBlockGraphTest {
|
||||||
TestGraphService graphService = new TestGraphService();
|
TestGraphService graphService = new TestGraphService();
|
||||||
BlockGraphTask task =
|
BlockGraphTask task =
|
||||||
new BlockGraphTask("test", false, DONT_SHOW_CODE, false, false,
|
new BlockGraphTask("test", false, DONT_SHOW_CODE, false, false,
|
||||||
tool, null, model, graphService);
|
tool, null, null, model, graphService);
|
||||||
|
|
||||||
task.monitoredRun(TaskMonitor.DUMMY);
|
task.monitoredRun(TaskMonitor.DUMMY);
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class BlockGraphTaskTest extends AbstractBlockGraphTest {
|
||||||
TestGraphService graphService = new TestGraphService();
|
TestGraphService graphService = new TestGraphService();
|
||||||
BlockGraphTask task =
|
BlockGraphTask task =
|
||||||
new BlockGraphTask("test", false, SHOW_CODE, false, false,
|
new BlockGraphTask("test", false, SHOW_CODE, false, false,
|
||||||
tool, null, model, graphService);
|
tool, null, null, model, graphService);
|
||||||
|
|
||||||
task.monitoredRun(TaskMonitor.DUMMY);
|
task.monitoredRun(TaskMonitor.DUMMY);
|
||||||
|
|
||||||
|
@ -152,7 +152,7 @@ public class BlockGraphTaskTest extends AbstractBlockGraphTest {
|
||||||
TestGraphService graphService = new TestGraphService();
|
TestGraphService graphService = new TestGraphService();
|
||||||
BlockGraphTask task =
|
BlockGraphTask task =
|
||||||
new BlockGraphTask("test", false, false, false, false,
|
new BlockGraphTask("test", false, false, false, false,
|
||||||
tool, null, model, graphService);
|
tool, null, null, model, graphService);
|
||||||
|
|
||||||
task.monitoredRun(TaskMonitor.DUMMY);
|
task.monitoredRun(TaskMonitor.DUMMY);
|
||||||
|
|
||||||
|
@ -199,7 +199,7 @@ public class BlockGraphTaskTest extends AbstractBlockGraphTest {
|
||||||
ProgramSelection sel = new ProgramSelection(addr(0x1002239), addr(0x1002247));
|
ProgramSelection sel = new ProgramSelection(addr(0x1002239), addr(0x1002247));
|
||||||
BlockGraphTask task =
|
BlockGraphTask task =
|
||||||
new BlockGraphTask("test", false, DONT_SHOW_CODE, false, false,
|
new BlockGraphTask("test", false, DONT_SHOW_CODE, false, false,
|
||||||
tool, sel, model, graphService);
|
tool, sel, null, model, graphService);
|
||||||
|
|
||||||
task.monitoredRun(TaskMonitor.DUMMY);
|
task.monitoredRun(TaskMonitor.DUMMY);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue