Java Code Examples for ghidra.framework.plugintool.PluginTool#getToolFrame()

The following examples show how to use ghidra.framework.plugintool.PluginTool#getToolFrame() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphASTControlFlowAction.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Override
protected void decompilerActionPerformed(DecompilerActionContext context) {
	PluginTool tool = context.getTool();
	GraphDisplayBroker service = tool.getService(GraphDisplayBroker.class);
	if (service == null) {
		Msg.showError(this, tool.getToolFrame(), "AST Graph Failed",
			"Graph consumer not found: Please add a graph consumer provider to your tool");
		return;
	}

	// TODO: Options should really be obtained from graph service
	Options options = tool.getOptions("Graph");
	boolean reuseGraph = options.getBoolean("Reuse Graph", false);
	int codeLimitPerBlock = options.getInt("Max Code Lines Displayed", 10);
	HighFunction highFunction = context.getHighFunction();
	Address locationAddr = context.getLocation().getAddress();
	ASTGraphTask task = new ASTGraphTask(service, !reuseGraph, codeLimitPerBlock, locationAddr,
		highFunction, CONTROL_FLOW_GRAPH, tool);
	new TaskLauncher(task, tool.getToolFrame());
}
 
Example 2
Source File: AutoAnalysisManager.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private static PluginTool getActiveTool(Program program) {
	WeakSet<PluginTool> toolSet = toolMap.get(program);
	if (toolSet.isEmpty()) {
		return null;
	}

	PluginTool anyTool = null;
	Iterator<PluginTool> iterator = toolSet.iterator();
	while (iterator.hasNext()) {
		PluginTool tool = iterator.next();

		anyTool = tool;
		JFrame toolFrame = tool.getToolFrame();
		if (toolFrame != null && toolFrame.isActive()) {
			return tool;
		}
	}

	return anyTool;
}
 
Example 3
Source File: AbstractToolSavingTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
protected void setToolPosition(final PluginTool tool, final Point point) {

		JFrame toolFrame = tool.getToolFrame();
		runSwing(() -> {
			Msg.debug(this, "setting tool location to: " + point + "\n\ton window: " +
				toolFrame.getTitle() + " (" + System.identityHashCode(toolFrame) + ")");
			toolFrame.setLocation(point);
		});
		waitForSwing();

		waitForCondition(() -> {

			Msg.debug(this,
				"\tattempt again - setting tool location to: " + point + "\n\ton window: " +
					toolFrame.getTitle() + " (" + System.identityHashCode(toolFrame) + ")");
			toolFrame.setLocation(point);

			Msg.debug(this, "checking " + point + " against " + toolFrame.getLocation());
			return point.equals(toolFrame.getLocation());
		});

		// debug
		runSwing(() -> {
			Msg.debug(this, "\ttool bounds now: " + toolFrame.getBounds());
		});
	}
 
Example 4
Source File: AbstractVTCorrelatorTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

	env = new VTTestEnv();
	PluginTool tool = env.showTool();

	plugin = env.getVersionTrackingPlugin();
	controller = env.getVTController();

	session = env.createSession(sourceProgLoc, destProgLoc);
	assertNotNull(session);

	srcProg = env.getSourceProgram();
	destProg = env.getDestinationProgram();

	JFrame toolFrame = tool.getToolFrame();
	toolFrame.setSize(800, 800);
}
 
Example 5
Source File: VTDuplicateSymbolMatchTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

	env = new VTTestEnv();
	PluginTool tool = env.showTool();
	session =
		env.createSession("VersionTracking/WallaceSrc.dupeStringTest.gzf",
			"VersionTracking/WallaceVersion2",
			new DuplicateSymbolNameProgramCorrelatorFactory());
	assertNotNull(session);

	srcProg = env.getSourceProgram();
	destProg = env.getDestinationProgram();
	JFrame toolFrame = tool.getToolFrame();
	toolFrame.setSize(800, 800);
}
 
Example 6
Source File: AutoAnalysisManager.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private static PluginTool getAnyTool() {
	PluginTool anyTool = null;
	Collection<WeakSet<PluginTool>> values = toolMap.values();
	for (WeakSet<PluginTool> weakSet : values) {
		for (PluginTool tool : weakSet) {
			JFrame toolFrame = tool.getToolFrame();
			if (toolFrame != null && toolFrame.isActive()) {
				return tool;
			}
		}
	}
	return anyTool;
}
 
Example 7
Source File: OpenVersionTrackingSessionAction.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionContext context) {
	PluginTool tool = controller.getTool();
	DataTreeDialog dialog =
		new DataTreeDialog(tool.getToolFrame(), "Open Version Tracking Session",
			DataTreeDialog.OPEN, new VTDomainFileFilter());

	tool.showDialog(dialog);
	if (!dialog.wasCancelled()) {
		DomainFile domainFile = dialog.getDomainFile();
		controller.openVersionTrackingSession(domainFile);
	}
}
 
Example 8
Source File: VTExactSymbolMatch1Test.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

	env = new VTTestEnv();
	PluginTool tool = env.showTool();
	session =
		env.createSession("VersionTracking/WallaceSrc.strDiffAddrTest.gzf",
			"VersionTracking/WallaceVersion2", new SymbolNameProgramCorrelatorFactory());
	assertNotNull(session);

	srcProg = env.getSourceProgram();
	destProg = env.getDestinationProgram();
	JFrame toolFrame = tool.getToolFrame();
	toolFrame.setSize(800, 800);
}
 
Example 9
Source File: VTMatchTableTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

	env = new VTTestEnv();
	PluginTool tool = env.showTool();
	session = env.createSession("VersionTracking/WallaceSrc", "VersionTracking/WallaceVersion2",
		new ExactMatchInstructionsProgramCorrelatorFactory());

	assertNotNull(session);

	JFrame toolFrame = tool.getToolFrame();
	toolFrame.setSize(800, 800);
}
 
Example 10
Source File: VersionControlAddAction.java    From ghidra with Apache License 2.0 4 votes vote down vote up
AddToVersionControlTask(List<DomainFile> list, PluginTool tool) {
	super("Add to Version Control", tool, list, tool.getToolFrame());
}
 
Example 11
Source File: AbstractToolSavingTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
protected Dimension getToolSize(PluginTool tool) {
	JFrame toolFrame = tool.getToolFrame();
	return toolFrame.getSize();
}
 
Example 12
Source File: AbstractToolSavingTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
protected void setToolSize(PluginTool tool, final Dimension dimension) {
	final JFrame toolFrame = tool.getToolFrame();

	runSwing(() -> toolFrame.setSize(dimension));
}
 
Example 13
Source File: OpenVersionedFileDialog.java    From ghidra with Apache License 2.0 2 votes vote down vote up
/**
 * Constructor
 * @param tool tool where the file is being opened.
 * @param title title to use
 * @param filter filter used to control what is displayed in data tree.
 */
public OpenVersionedFileDialog(PluginTool tool, String title, DomainFileFilter filter) {
	super(tool.getToolFrame(), title, DataTreeDialog.OPEN, filter);
	this.tool = tool;
	init();
}