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

The following examples show how to use ghidra.framework.plugintool.PluginTool#addPlugin() . 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: NextPrevCodeUnitPluginTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
// we know that bookmarks is of type String
private void setupTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());
	tool.addPlugin(NextPrevCodeUnitPlugin.class.getName());
	tool.addPlugin(BookmarkPlugin.class.getName());

	NextPrevCodeUnitPlugin p = getPlugin(tool, NextPrevCodeUnitPlugin.class);
	direction = getAction(p, "Toggle Search Direction");
	nextInst = getAction(p, "Next Instruction");
	nextData = getAction(p, "Next Data");
	nextUndef = getAction(p, "Next Undefined");
	nextLabel = getAction(p, "Next Label");
	nextFunc = getAction(p, "Next Function");
	nextNonFunc = getAction(p, "Next Non-Function");
	nextBookmark = (MultiStateDockingAction<String>) getAction(p, "Next Bookmark");
}
 
Example 2
Source File: GhidraScriptRealProgramTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
@Before
public void setUp() throws Exception {

	env = new TestEnv();

	ClassicSampleX86ProgramBuilder builder = new ClassicSampleX86ProgramBuilder();
	program = builder.getProgram();

	PluginTool tool = env.showTool(program);
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(GhidraScriptMgrPlugin.class.getName());
	tool.addPlugin(GoToAddressLabelPlugin.class.getName());

	builder.dispose();

	ProgramLocation loc = new ProgramLocation(program, program.getMinAddress());

	state = new GhidraState(env.getTool(), env.getProject(), program, loc, null, null);
	transactionID = program.startTransaction(testName.getMethodName());
}
 
Example 3
Source File: NextPrevSelectionHighlightTest.java    From ghidra with Apache License 2.0 6 votes vote down vote up
private void setupTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());
	tool.addPlugin(NextPrevSelectedRangePlugin.class.getName());
	tool.addPlugin(NextPrevHighlightRangePlugin.class.getName());
	tool.addPlugin(SetHighlightPlugin.class.getName());

	NextPrevSelectedRangePlugin p1 = getPlugin(tool, NextPrevSelectedRangePlugin.class);
	NextPrevHighlightRangePlugin p2 = getPlugin(tool, NextPrevHighlightRangePlugin.class);
	nextSelection = getAction(p1, "Next Selected Range");
	prevSelection = getAction(p1, "Previous Selected Range");
	nextHighlight = getAction(p2, "Next Highlighted Range");
	prevHighlight = getAction(p2, "Previous Highlighted Range");

	SetHighlightPlugin hp = getPlugin(tool, SetHighlightPlugin.class);
	createHighlight = getAction(hp, "Set Highlight From Selection");
}
 
Example 4
Source File: SelectRefereceActionsTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {

	ToyProgramBuilder builder = new ToyProgramBuilder("test", false);
	builder.createMemory("mem", "0000", 0x100);
	builder.addBytesBranchConditional("0x20", "0x10");
	builder.addBytesBranchConditional("0x30", "0x20");
	builder.addBytesBranchConditional("0x40", "0x20");
	builder.addBytesBranchConditional("0x44", "0x14");
	builder.disassemble("0x00", 0x100);

	program = builder.getProgram();
	program.addConsumer(this);
	builder.dispose();

	addrFactory = program.getAddressFactory();

	env = new TestEnv();
	PluginTool tool = env.showTool(program);
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(SelectRefsPlugin.class.getName());

	cb = env.getPlugin(CodeBrowserPlugin.class);
	SelectRefsPlugin plugin = env.getPlugin(SelectRefsPlugin.class);
	forwardAction = (SelectForwardRefsAction) getInstanceField("forwardAction", plugin);
	backwardAction = (SelectBackRefsAction) getInstanceField("backwardAction", plugin);

}
 
Example 5
Source File: CodeUnitIteratorTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * ** Diagnostic Aid ** Open program in tool
 * @throws Exception
 */
private void openProgramInTool() throws Exception {

	TestEnv env = new TestEnv();
	try {
		PluginTool tool = env.getTool();
		tool.addPlugin(CodeBrowserPlugin.class.getName());
		tool.addPlugin(NextPrevAddressPlugin.class.getName());
		tool.addPlugin(DisassemblerPlugin.class.getName());
		tool.addPlugin(ClearPlugin.class.getName());
		tool.addPlugin(GhidraScriptMgrPlugin.class.getName());
		tool.addPlugin(BookmarkPlugin.class.getName());
		tool.addPlugin(GoToAddressLabelPlugin.class.getName());

		ProgramManager pm = tool.getService(ProgramManager.class);
		pm.openProgram(program);

		showTool(tool);

		// Place breakpoint on next line when this method is used for diagnostic
		Msg.info(this, "Opened test program in tool");

		pm.closeAllPrograms(true);
	}
	finally {
		env.dispose();
	}
}
 
Example 6
Source File: CopyPasteFunctionInfoTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setupTool(PluginTool tool) throws Exception {
	tool.addPlugin(ClipboardPlugin.class.getName());
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());
	tool.addPlugin(GoToAddressLabelPlugin.class.getName());
	tool.addPlugin(FunctionPlugin.class.getName());
}
 
Example 7
Source File: ComputeChecksumsPluginTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void configureTool(PluginTool toolToConfigure) throws Exception {
	toolToConfigure.addPlugin(BlockModelServicePlugin.class.getName());
	toolToConfigure.addPlugin(NextPrevAddressPlugin.class.getName());
	toolToConfigure.addPlugin(CodeBrowserPlugin.class.getName());
	toolToConfigure.addPlugin(GoToAddressLabelPlugin.class.getName());
	toolToConfigure.addPlugin(ComputeChecksumsPlugin.class.getName());
}
 
Example 8
Source File: AutoTableDisassemblerTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setupTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());
	tool.addPlugin(AutoTableDisassemblerPlugin.class.getName());
	tool.addPlugin(GoToAddressLabelPlugin.class.getName());

	cb = getPlugin(tool, CodeBrowserPlugin.class);
	Plugin p = getPlugin(tool, AutoTableDisassemblerPlugin.class);
	searchAction = getAction(p, "Search for Address Tables");

	env.showTool();
	loadProgram();
}
 
Example 9
Source File: ToolPluginOptionsTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setUpSearchTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(ProgramManagerPlugin.class.getName());
	tool.addPlugin(GoToServicePlugin.class.getName());
	tool.addPlugin(SearchTextPlugin.class.getName());

	showTool(tool);
}
 
Example 10
Source File: SelectBlockPluginTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void configureTool(PluginTool toolToConfigure) throws Exception {
	toolToConfigure.addPlugin(BlockModelServicePlugin.class.getName());
	toolToConfigure.addPlugin(NextPrevAddressPlugin.class.getName());
	toolToConfigure.addPlugin(CodeBrowserPlugin.class.getName());
	toolToConfigure.addPlugin(GoToAddressLabelPlugin.class.getName());
	toolToConfigure.addPlugin(SelectBlockPlugin.class.getName());
}
 
Example 11
Source File: DiffTestAdapter.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void setUpCodeBrowserTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(ProgramDiffPlugin.class.getName());
	tool.addPlugin(GoToAddressLabelPlugin.class.getName());
	tool.addPlugin(MarkerManagerPlugin.class.getName());
	cb = getPlugin(tool, CodeBrowserPlugin.class);
	diffPlugin = getPlugin(tool, ProgramDiffPlugin.class);
}
 
Example 12
Source File: QualifiedSelectionPluginTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
protected void setUpQualifiedSelection(PluginTool tool) throws Exception {
	tool.addPlugin(QualifiedSelectionPlugin.class.getName());
	qSelectPlugin = getPlugin(tool, QualifiedSelectionPlugin.class);
	selectDataAction = getAction(qSelectPlugin, "Data");
	selectInstructionAction = getAction(qSelectPlugin, "Instructions");
	selectUndefinedAction = getAction(qSelectPlugin, "Undefined");
}
 
Example 13
Source File: Function1Test.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setupTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());
	tool.addPlugin(NextPrevSelectedRangePlugin.class.getName());
	tool.addPlugin(NextPrevHighlightRangePlugin.class.getName());
	tool.addPlugin(SetHighlightPlugin.class.getName());
	tool.addPlugin(FunctionPlugin.class.getName());
	tool.addPlugin(AutoAnalysisPlugin.class.getName());
	tool.addPlugin(DisassemblerPlugin.class.getName());
	tool.addPlugin(GoToAddressLabelPlugin.class.getName());

	cb = env.getPlugin(CodeBrowserPlugin.class);
	dp = getPlugin(tool, DisassemblerPlugin.class);

	fp = getPlugin(tool, FunctionPlugin.class);
	createFunction = getAction(fp, "Create Function");
	createThunk = getAction(fp, "Create Thunk Function");
	editThunk = getAction(fp, "Set Thunked Function");
	revertThunk = getAction(fp, "Revert Thunk Function");
	deleteFunction = getAction(fp, "Delete Function");
	editComment = getAction(fp, "Edit Variable Comment");
	deleteComment = getAction(fp, "Delete Function Variable Comment");
	byteCycleAction = getAction(fp, "Cycle: byte,word,dword,qword");
	floatCycleAction = getAction(fp, "Cycle: float,double");
	createArray = getAction(fp, "Define Array");
	createPointer = getAction(fp, "Define pointer");
	clearFunctionReturnTypeAction = getAction(fp, "Clear Function Return Type");
	deleteFunctionVar = getAction(fp, "Delete Function Variable");
	chooseDataType = getAction(fp, "Choose Data Type");
}
 
Example 14
Source File: FunctionEditorDialogTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
private void setupTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(FunctionPlugin.class.getName());
	tool.addPlugin(GoToAddressLabelPlugin.class.getName());

	cb = env.getPlugin(CodeBrowserPlugin.class);
	fp = getPlugin(tool, FunctionPlugin.class);
	editFunction = getAction(fp, "Edit Function");
	createFunction = getAction(fp, "Create Function");
}
 
Example 15
Source File: StringTableProviderTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void setUpCodeBrowserTool(PluginTool tool) throws Exception {
	tool.addPlugin(ProgramManagerPlugin.class.getName());
	tool.addPlugin(StringTablePlugin.class.getName());
	tool.addPlugin(CodeBrowserPlugin.class.getName());
}
 
Example 16
Source File: HeaderActionsTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void setUpCodeBrowserTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());
	cb = env.getPlugin(CodeBrowserPlugin.class);
}
 
Example 17
Source File: HeaderTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void setUpCodeBrowserTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());

	cb = env.getPlugin(CodeBrowserPlugin.class);
}
 
Example 18
Source File: SymbolTablePluginTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void configureTool(PluginTool tool1) throws Exception {
	tool1.addPlugin(CodeBrowserPlugin.class.getName());
	tool1.addPlugin(GoToAddressLabelPlugin.class.getName());
	tool1.addPlugin(SymbolTablePlugin.class.getName());
}
 
Example 19
Source File: CodeBrowserTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void setUpCodeBrowserTool(PluginTool tool) throws Exception {
	tool.addPlugin(CodeBrowserPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());
	addPlugin(tool, SymbolTablePlugin.class);
}
 
Example 20
Source File: ByteViewerConnectedToolBehaviorTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
private void setUpTool(PluginTool tool) throws Exception {
	tool.addPlugin(NavigationHistoryPlugin.class.getName());
	tool.addPlugin(NextPrevAddressPlugin.class.getName());
	tool.addPlugin(ByteViewerPlugin.class.getName());
}