Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3730: Add To Program from File System Browser

Ryan Kurtz2644f5d70dcb
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/plugins/fsbrowser/FSBActionManager.java b/Ghidra/Features/Base/src/main/java/ghidra/plugins/fsbrowser/FSBActionManager.java
index 722c160ed0..eb5c16b79f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/plugins/fsbrowser/FSBActionManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/plugins/fsbrowser/FSBActionManager.java
@@ -82,6 +82,7 @@ class FSBActionManager {
DockingAction actionExpand;
DockingAction actionCollapse;
DockingAction actionImportBatch;
+ DockingAction actionAddToProgram;
DockingAction actionCloseFileSystem;
DockingAction actionClearCachedPasswords;
/* end package visibility */
@@ -116,6 +117,7 @@ class FSBActionManager {
actions.add((actionOpenPrograms = createOpenProgramsAction()));
actions.add((actionImport = createImportAction()));
actions.add((actionImportBatch = createBatchImportAction()));
+ actions.add((actionAddToProgram = createAddToProgramAction()));
actions.add((actionOpenFileSystemNewWindow = createOpenFileSystemNewWindowAction()));
actions.add((actionOpenFileSystemNested = createOpenFileSystemNestedAction()));
actions.add((actionOpenFileSystemChooser = createOpenNewFileSystemAction()));
@@ -342,7 +344,7 @@ class FSBActionManager {
.enabledWhen(ac -> ac.notBusy() && ac.getFileFSRL() != null)
.popupMenuIcon(ImageManager.EXTRACT)
.popupMenuPath("Export...")
- .popupMenuGroup("F", "B")
+ .popupMenuGroup("F", "C")
.onAction(
ac -> {
FSRL fsrl = ac.getFileFSRL();
@@ -707,6 +709,39 @@ class FSBActionManager {
.build();
}
+ private DockingAction createAddToProgramAction() {
+ return new ActionBuilder("FSB Add To Program", plugin.getName())
+ .withContext(FSBActionContext.class)
+ .enabledWhen(ac -> ac.notBusy() && ac.getLoadableFSRL() != null)
+ .popupMenuIcon(ImageManager.IMPORT)
+ .popupMenuPath("Add To Program")
+ .popupMenuGroup("F", "C")
+ .onAction(ac -> {
+ FSRL fsrl = ac.getLoadableFSRL();
+ if (fsrl == null) {
+ return;
+ }
+
+ gTree.runTask(monitor -> {
+ if (!ensureFileAccessable(fsrl, ac.getSelectedNode(), monitor)) {
+ return;
+ }
+
+ PluginTool tool = plugin.getTool();
+ ProgramManager pm = FSBUtils.getProgramManager(tool, false);
+ Program program = null;
+ if (pm == null || (program = pm.getCurrentProgram()) == null) {
+ Msg.showError(this, gTree, "Unable To Add To Program",
+ "No programs are open");
+ return;
+ }
+ ImporterUtilities.showAddToProgramDialog(fsrl, program, tool, monitor);
+ });
+
+ })
+ .build();
+ }
+
private DockingAction createClearCachedPasswordsAction() {
return new ActionBuilder("FSB Clear Cached Passwords", plugin.getName())
.withContext(FSBActionContext.class)