ghidra.framework.plugintool.PluginTool Java Examples
The following examples show how to use
ghidra.framework.plugintool.PluginTool.
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: OptionsDialogTest.java From ghidra with Apache License 2.0 | 6 votes |
private void showOptionsDialog(PluginTool pluginTool) throws Exception { // TODO change to getAction("Edit Options") Set<DockingActionIf> list = pluginTool.getAllActions(); for (DockingActionIf action : list) { if (action.getName().equals("Edit Options")) { performAction(action, false); break; } } waitForSwing(); dialog = waitForDialogComponent(OptionsDialog.class); optionsPanel = (OptionsPanel) getInstanceField("panel", dialog); Container pane = dialog.getComponent(); tree = findComponent(pane, JTree.class); treeModel = tree.getModel(); selectNode(treeModel.getRoot()); defaultPanel = (JPanel) findComponentByName(pane, "Default"); viewPanel = (JPanel) findComponentByName(pane, "View"); waitForThreadedModel(); assertTrue(defaultPanel.isShowing()); }
Example #2
Source File: NextPrevCodeUnitPluginTest.java From ghidra with Apache License 2.0 | 6 votes |
@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 #3
Source File: SaveToolConfigDialog.java From ghidra with Apache License 2.0 | 6 votes |
public SaveToolConfigDialog(PluginTool tool, ToolServices toolServices) { super("Save Tool to Tool Chest", true); this.tool = tool; this.toolServices = toolServices; addWorkPanel(buildMainPanel()); saveButton = new JButton("Save"); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ev) { save(); } }); addButton(saveButton); addCancelButton(); toolChest = toolServices.getToolChest(); addListeners(); setHelpLocation(new HelpLocation("FrontEndPlugin", "Save Tool")); }
Example #4
Source File: ToolManagerImpl.java From ghidra with Apache License 2.0 | 6 votes |
private void updateConnectMap(PluginTool tool) { Iterator<String> keys = connectMap.keySet().iterator(); Map<String, ToolConnectionImpl> map = new HashMap<>(); while (keys.hasNext()) { String key = keys.next(); ToolConnectionImpl tc = connectMap.get(key); PluginTool producer = tc.getProducer(); PluginTool consumer = tc.getConsumer(); if (producer == tool || consumer == tool) { String newkey = getKey(producer, consumer); tc.updateEventList(); map.put(newkey, tc); } else { map.put(key, tc); } } connectMap = map; }
Example #5
Source File: AbstractToolSavingTest.java From ghidra with Apache License 2.0 | 6 votes |
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 #6
Source File: ProjectDataTreePanel.java From ghidra with Apache License 2.0 | 6 votes |
private void create(String projectName) { root = createRootNode(projectName); tree = new DataTree(tool, root); if (plugin != null) { tree.addGTreeSelectionListener(e -> { PluginTool pluginTool = plugin.getTool(); pluginTool.contextChanged(null); }); } add(tree, BorderLayout.CENTER); tree.setProjectActive(isActiveProject); }
Example #7
Source File: ToolSaving1Test.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testAutoSaveOptionFromExitGhidra_WithToolConfigChange() { PluginTool tool = launchTool(DEFAULT_TEST_TOOL_NAME); // sanity check assertTrue("Test tool did not start out in expected state", !getBooleanFooOptions(tool)); // turn off auto save setAutoSaveEnabled(false); setBooleanFooOptions(tool, true); // exit closeAndReopenGhidra_WithGUI(tool, true, false); // re-launch tool to see if the option was saved tool = launchTool(DEFAULT_TEST_TOOL_NAME); assertEquals("Tool options saved when auto-save is disabled", false, getBooleanFooOptions(tool)); }
Example #8
Source File: AddBlockDialog.java From ghidra with Apache License 2.0 | 6 votes |
/** * Display the dialog filled with default values. * Used to enter a new MemoryBlock. * @param tool the tool that owns this dialog */ void showDialog(PluginTool tool) { nameField.setText(""); addrField.setAddress(model.getStartAddress()); lengthField.setValue(Long.valueOf(0)); model.setLength(0); commentField.setText(""); initialValueField.setValue(Long.valueOf(0)); model.setBlockType(MemoryBlockType.DEFAULT); model.setInitializedType(AddBlockModel.InitializedType.UNITIALIZED); model.setInitialValue(0); readCB.setSelected(model.isRead()); writeCB.setSelected(model.isWrite()); executeCB.setSelected(model.isExecute()); volatileCB.setSelected(model.isVolatile()); overlayCB.setSelected(model.isOverlay()); setOkEnabled(false); tool.showDialog(this, tool.getComponentProvider(PluginConstants.MEMORY_MAP)); }
Example #9
Source File: BatchImportDialog.java From ghidra with Apache License 2.0 | 6 votes |
/** * Shows the batch import dialog (via runSwingLater) and prompts the user to select * a file if the supplied {@code batchInfo} is empty. * <p> * The dialog will chain to the {@link ImportBatchTask} when the user clicks the * OK button. * <p> * @param tool {@link PluginTool} that will be the parent of the dialog * @param batchInfo optional {@link BatchInfo} instance with already discovered applications, or null. * @param initialFiles optional {@link List} of {@link FSRL files} to add to the batch import dialog, or null. * @param defaultFolder optional default destination folder for imported files or null for root folder. * @param programManager optional {@link ProgramManager} that will be used to open the newly imported * binaries. */ public static void showAndImport(PluginTool tool, BatchInfo batchInfo, List<FSRL> initialFiles, DomainFolder defaultFolder, ProgramManager programManager) { BatchImportDialog dialog = new BatchImportDialog(batchInfo, defaultFolder); dialog.setProgramManager(programManager); SystemUtilities.runSwingLater(() -> { dialog.build(); if (initialFiles != null && !initialFiles.isEmpty()) { dialog.addSources(initialFiles); } if (!dialog.setupInitialDefaults()) { return; } tool.showDialog(dialog); }); }
Example #10
Source File: EditFunctionSignatureDialog.java From ghidra with Apache License 2.0 | 6 votes |
/** * This class is not meant to be instantiated directly, but rather by * subclasses. * * @param plugin A reference to the FunctionPlugin. * @param title The title of the dialog. * @param function the function which is having its signature edited. */ public EditFunctionSignatureDialog(PluginTool tool, String title, final Function function) { super(title, true, true, true, false); this.tool = tool; this.function = function; this.oldFunctionName = function.getName(); this.oldFunctionSignature = function.getSignature().getPrototypeString(); addWorkPanel(buildMainPanel()); addOKButton(); addCancelButton(); setDefaultButton(okButton); setFunctionInfo(); setRememberSize(true); }
Example #11
Source File: CodeBrowserScreenMovementTest.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testConnectedBrowsers() throws Exception { PluginTool tool2 = showSecondTool(); CodeBrowserPlugin cb2 = getPlugin(tool2, CodeBrowserPlugin.class); env.connectTools(tool, tool2); codeBrowser.goToField(addr("0x1006420"), "Address", 0, 0); assertEquals("01006420", cb2.getCurrentFieldText()); for (int i = 0; i < 1000; i++) { cursorRight(fp); assertEquals("i = " + i, codeBrowser.getCurrentFieldText(), cb2.getCurrentFieldText()); assertEquals("i = " + i, codeBrowser.getCurrentFieldLoction(), cb2.getCurrentFieldLoction()); } }
Example #12
Source File: WorkspaceImpl.java From ghidra with Apache License 2.0 | 6 votes |
@Override public PluginTool runTool(ToolTemplate template) { PluginTool tool = toolManager.getTool(this, template); if (tool != null) { tool.setVisible(true); if (tool instanceof GhidraTool) { GhidraTool gTool = (GhidraTool) tool; gTool.checkForNewExtensions(); } runningTools.add(tool); // alert the tool manager that we changed toolManager.setWorkspaceChanged(this); toolManager.fireToolAddedEvent(this, tool); } return tool; }
Example #13
Source File: ToolConnectionPanel.java From ghidra with Apache License 2.0 | 6 votes |
private void doConnect(PluginTool producer, PluginTool consumer, String eventName, boolean connect) { ToolConnection tc = toolManager.getConnection(producer, consumer); if (tc.isConnected(eventName) == connect) { // if already connected return; } if (connect) { tc.connect(eventName); Msg.info(this, msgSource + ": Connected consumer " + consumer.getName() + " to producer " + producer.getName() + " for event " + eventName); } else { tc.disconnect(eventName); Msg.info(this, msgSource + ": Disconnected consumer " + consumer.getName() + " from producer " + producer.getName() + " for event " + eventName); } }
Example #14
Source File: SelectBlockDialog.java From ghidra with Apache License 2.0 | 6 votes |
SelectBlockDialog(PluginTool tool, Navigatable navigatable) { super("Select Bytes", false); this.tool = tool; this.navigatable = navigatable; // navigatable.addNavigatableListener(this); addWorkPanel(buildPanel()); addOKButton(); setOkButtonText("Select Bytes"); addDismissButton(); setHelpLocation(new HelpLocation("SelectBlockPlugin", "Select_Block_Help")); // make sure the state of the widgets is correct setItemsEnabled(false); forwardButton.doClick(); }
Example #15
Source File: ConsoleComponentProvider.java From ghidra with Apache License 2.0 | 6 votes |
public ConsoleComponentProvider(PluginTool tool, String owner) { super(tool, "Console", owner); // note: the owner has not changed, just the name; remove sometime after version 10 ComponentProvider.registerProviderNameOwnerChange(OLD_NAME, owner, NAME, owner); setDefaultWindowPosition(WindowPosition.BOTTOM); setHelpLocation(new HelpLocation(owner, owner)); setIcon(ResourceManager.loadImage(CONSOLE_GIF)); setWindowMenuGroup("Console"); setSubTitle("Scripting"); setTitle("Console"); createOptions(); build(); createActions(); }
Example #16
Source File: ToolSaving2Test.java From ghidra with Apache License 2.0 | 6 votes |
@Test public void testTwoToolsBothChanged_saveBoth_changeOneAgain_closeBoth() { PluginTool tool1 = launchTool(DEFAULT_TEST_TOOL_NAME); PluginTool tool2 = launchTool(DEFAULT_TEST_TOOL_NAME); boolean isSet = getBooleanFooOptions(tool1); setBooleanFooOptions(tool1, !isSet); setBooleanFooOptions(tool2, !isSet); saveTool(tool1); saveTool(tool2); isSet = getBooleanFooOptions(tool1); setBooleanFooOptions(tool1, !isSet); closeToolWithNoSaveDialog(tool2); closeToolAndManuallySave(tool1); PluginTool newTool = launchTool(DEFAULT_TEST_TOOL_NAME); assertEquals("Changed tool was not saved", !isSet, getBooleanFooOptions(newTool)); }
Example #17
Source File: ComputeChecksumsPlugin.java From ghidra with Apache License 2.0 | 5 votes |
/** * Constructor for the ComputeChecksumsPlugin. * @param tool */ public ComputeChecksumsPlugin(PluginTool tool) { super(tool, true, true); createActions(); provider = new ComputeChecksumsProvider(this); }
Example #18
Source File: AddEditDialog.java From ghidra with Apache License 2.0 | 5 votes |
public AddEditDialog(String title, PluginTool tool) { super(title, true, true, true, false); this.tool = tool; setHelpLocation(new HelpLocation(HelpTopics.LABEL, "AddEditDialog")); addWorkPanel(create()); setFocusComponent(labelNameChoices); addOKButton(); addCancelButton(); setDefaultButton(okButton); }
Example #19
Source File: AutoAnalysisManager.java From ghidra with Apache License 2.0 | 5 votes |
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 #20
Source File: WorkspaceImpl.java From ghidra with Apache License 2.0 | 5 votes |
void closeRunningTool(PluginTool tool) { // tool is already closed via the call that got us here, so just clean up runningTools.remove(tool); // alert the tool manager that we changed toolManager.setWorkspaceChanged(this); toolManager.toolRemoved(this, tool); }
Example #21
Source File: CommentDialog.java From ghidra with Apache License 2.0 | 5 votes |
void showDialog(String comment) { applyWasDone = true; origComments = comment; commentsField.setText(origComments); if (origComments != null && origComments.length() > 0) { commentsField.selectAll(); } PluginTool tool = plugin.getTool(); tool.showDialog( this, tool.getComponentProvider( PluginConstants.CODE_BROWSER )); }
Example #22
Source File: ExtensionTablePanel.java From ghidra with Apache License 2.0 | 5 votes |
/** * Constructor; builds the panel and sets table attributes. * * @param tool the tool showing the extension dialog */ public ExtensionTablePanel(PluginTool tool) { super(new BorderLayout()); tableModel = new ExtensionTableModel(tool); tableModel.setTableSortState( TableSortState.createDefaultSortState(ExtensionTableModel.NAME_COL)); table = new GTable(tableModel); table.setPreferredScrollableViewportSize(new Dimension(500, 300)); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane sp = new JScrollPane(table); sp.getViewport().setBackground(table.getBackground()); add(sp, BorderLayout.CENTER); tableFilterPanel = new GTableFilterPanel<>(table, tableModel); add(tableFilterPanel, BorderLayout.SOUTH); HelpService help = Help.getHelpService(); help.registerHelp(table, new HelpLocation(GenericHelpTopics.FRONT_END, "Extensions")); // Restrict the checkbox col to only be 25 pixels wide - the default size is // way too large. This is annoying but our table column classes don't have a nice // way to restrict column width. TableColumn col = table.getColumnModel().getColumn(ExtensionTableModel.INSTALLED_COL); col.setMaxWidth(25); // Finally, load the table with some data. refreshTable(); }
Example #23
Source File: ToolServicesImpl.java From ghidra with Apache License 2.0 | 5 votes |
@Override public PluginTool launchTool(String toolName, DomainFile domainFile) { ToolTemplate template = findToolChestToolTemplate(toolName); if (template != null) { Workspace workspace = toolManager.getActiveWorkspace(); PluginTool tool = workspace.runTool(template); tool.setVisible(true); if (domainFile != null) { tool.acceptDomainFiles(new DomainFile[] { domainFile }); } return tool; } return null; }
Example #24
Source File: ToolServicesImpl.java From ghidra with Apache License 2.0 | 5 votes |
@Override public PluginTool launchDefaultTool(DomainFile domainFile) { ToolTemplate template = getDefaultToolTemplate(domainFile); if (template != null) { Workspace workspace = toolManager.getActiveWorkspace(); PluginTool tool = workspace.runTool(template); tool.setVisible(true); if (domainFile != null) { tool.acceptDomainFiles(new DomainFile[] { domainFile }); } return tool; } return null; }
Example #25
Source File: ProjectAccessPanel.java From ghidra with Apache License 2.0 | 5 votes |
/** * Constructs a new panel from the given arguments. * * @param knownUsers names of the users that are known to the remote server * @param currentUser the current user * @param allUsers all users known to the repository * @param repositoryName the name of the repository * @param anonymousServerAccessAllowed true if the server allows anonymous access * @param anonymousAccessEnabled true if the repository allows anonymous access * (ignored if anonymousServerAccessAllowed is false) * @param tool the current tool */ public ProjectAccessPanel(String[] knownUsers, String currentUser, List<User> allUsers, String repositoryName, boolean anonymousServerAccessAllowed, boolean anonymousAccessEnabled, PluginTool tool) { super(new BorderLayout()); this.currentUser = currentUser; this.origProjectUserList = allUsers; this.origAnonymousAccessEnabled = anonymousAccessEnabled; this.repositoryName = repositoryName; this.tool = tool; createMainPanel(knownUsers, anonymousServerAccessAllowed); }
Example #26
Source File: CodeBrowserScreenMovementTest.java From ghidra with Apache License 2.0 | 5 votes |
private PluginTool showSecondTool() throws Exception { PluginTool tool2 = env.launchAnotherDefaultTool(); setUpCodeBrowserTool(tool2); ProgramManager pm = tool2.getService(ProgramManager.class); pm.openProgram(program.getDomainFile()); showTool(tool2); return tool2; }
Example #27
Source File: CopyPasteFunctionInfoTest.java From ghidra with Apache License 2.0 | 5 votes |
private void goToAddr(PluginTool tool, long offset) { Program p = programOne; if (tool == toolTwo) { p = programTwo; } goToAddr(tool, getAddr(p, offset)); }
Example #28
Source File: ToolManagerImpl.java From ghidra with Apache License 2.0 | 5 votes |
/** * Called by WorkspaceImpl when it is restoring its state. * @param toolName the name of the tool * @return the tool */ public PluginTool getTool(String toolName) { ToolTemplate template = toolServices.getToolChest().getToolTemplate(toolName); if (template == null) { return null; } PluginTool tool = template.createTool(project); if (tool != null) { registerTool(toolName, tool); } return tool; }
Example #29
Source File: AbstractToolSavingTest.java From ghidra with Apache License 2.0 | 5 votes |
protected void setBookmarkProviderShowing(final PluginTool tool, final boolean visible) { BookmarkPlugin plugin = getPlugin(tool, BookmarkPlugin.class); final ComponentProvider provider = (ComponentProvider) getInstanceField("provider", plugin); runSwing(() -> tool.showComponentProvider(provider, visible)); boolean newVisibleState = tool.isVisible(provider); assertEquals(visible, newVisibleState); }
Example #30
Source File: UndoAction.java From ghidra with Apache License 2.0 | 5 votes |
public UndoAction(PluginTool tool, String owner) { super("Undo", owner); this.tool = tool; setHelpLocation(new HelpLocation(ToolConstants.TOOL_HELP_TOPIC, "Undo")); String[] menuPath = { ToolConstants.MENU_EDIT, "&Undo" }; Icon icon = ResourceManager.loadImage("images/undo.png"); MenuData menuData = new MenuData(menuPath, icon, "Undo"); menuData.setMenuSubGroup("1Undo"); // make this appear above the redo menu item setMenuBarData(menuData); setToolBarData(new ToolBarData(icon, "Undo")); setDescription("Undo"); setKeyBindingData(new KeyBindingData("ctrl Z")); }