From 769ef9ec0a2aef49039689e09680fa48c6dddf9d Mon Sep 17 00:00:00 2001 From: ghidra1 Date: Mon, 6 Feb 2023 09:48:54 -0500 Subject: [PATCH] GP-3034 GZF/GDT Import/Export improvements --- .../help/topics/ExporterPlugin/exporter.htm | 36 ++- .../help/topics/ImporterPlugin/importer.htm | 34 ++- .../help/topics/OverviewPlugin/Overview.htm | 10 +- .../core/datamgr/DataTypeManagerPlugin.java | 2 +- .../plugin/core/exporter/ExporterDialog.java | 218 +++++++++++------- .../plugin/core/exporter/ExporterPlugin.java | 18 +- .../app/services/FileImporterService.java | 2 + .../ghidra/app/util/DomainObjectService.java | 5 + ...hidraFileOpenDataFlavorHandlerService.java | 6 +- .../java/ghidra/app/util/OptionsDialog.java | 2 +- .../ghidra/app/util/OptionsEditorPanel.java | 26 ++- .../ghidra/app/util/exporter/Exporter.java | 81 ++++++- ...tArchiveExporter.java => GdtExporter.java} | 61 ++++- .../ghidra/app/util/exporter/GzfExporter.java | 33 ++- .../util/exporter/OriginalFileExporter.java | 2 +- .../AbstractFileListFlavorHandler.java | 75 ++++++ .../GhidraDataFlavorHandlerService.java | 5 +- .../main/datatree/JavaFileListHandler.java | 59 +---- .../main/datatree/LinuxFileUrlHandler.java | 78 ++----- .../plugin/importer/ImporterPlugin.java | 143 +++++++++++- .../main/java/docking/tool/ToolConstants.java | 5 + .../main/java/skeleton/SkeletonExporter.java | 8 + 22 files changed, 655 insertions(+), 254 deletions(-) rename Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/{ProjectArchiveExporter.java => GdtExporter.java} (54%) create mode 100644 Ghidra/Features/Base/src/main/java/ghidra/framework/main/datatree/AbstractFileListFlavorHandler.java diff --git a/Ghidra/Features/Base/src/main/help/help/topics/ExporterPlugin/exporter.htm b/Ghidra/Features/Base/src/main/help/help/topics/ExporterPlugin/exporter.htm index fd5950f946..f6bbdec7bd 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/ExporterPlugin/exporter.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/ExporterPlugin/exporter.htm @@ -24,7 +24,9 @@
  • C/C++
  • -
  • Ghidra Zip File (.gzf)
  • +
  • Ghidra Zip File (GZF)
  • + +
  • Ghidra Data Type Archive File (GDT)
  • HTML
  • @@ -58,6 +60,16 @@
  • Press the OK button to perform the export.
  • + +

    In preparation for a file export, a selected project + file may be opened in an attempt to support export formats that require an open + file. If the selected file requires an upgrade a warning dialog + will be displayed and the affected export formats will not be available until an upgrade + is perfored, however a direct packed format of the project file may still be chosen + without performing the upgrade first (e.g., Ghidra Zip File (GZF), + Ghidra Zip File (GZF)). +

    +

    To export from the CodeBrowser tool:

    @@ -276,12 +288,28 @@ -

    Ghidra Zip File (.gzf)

    +

    Ghidra Zip File (GZF)

    -

    Creates a zip file from a program in your project. You may want to create a zip file +

    Creates a GZF file from a Program in your project. You may want to create a GZF file so that you can give it to another user who can then import into their project.

    + "help/topics/ImporterPlugin/importer.htm">import into their project. A program + export of this format from the Project Window will be based on the current saved file + content and bypass any potential upgrade that may be required by other formats. +

    +
    + +

    Ghidra Data Type Archive File (GDT)

    + +
    +

    Creates a GDT file from a Data Type Archive in your project. You may want to create a GDT file + so that you can give it to another user who can then import into their project or open directly + via the Data Type Manager as a + File Data Type Archive. + A project Data Type Archive export of this format from the Project Window will be based on + the current saved file content and bypass any potential upgrade that may be required by other formats. +

    HTML

    diff --git a/Ghidra/Features/Base/src/main/help/help/topics/ImporterPlugin/importer.htm b/Ghidra/Features/Base/src/main/help/help/topics/ImporterPlugin/importer.htm index b54c4b83e6..20f9a560bf 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/ImporterPlugin/importer.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/ImporterPlugin/importer.htm @@ -36,8 +36,8 @@
  • Dump File Loader
  • DYLD Shared Cache
  • Executable and Linking Format (ELF)
  • -
  • Ghidra Data Type Archive Format
  • -
  • GZF Input Format
  • +
  • Ghidra Data Type Archive File (GDT)
  • +
  • Ghidra Zip File (GZF)
  • Intel Hex
  • Java Class File
  • Mac OS X Mach-O
  • @@ -81,14 +81,40 @@
  • Use the Importer Dialog (or the Batch Importer Dialog if it is an archive) that pops up to - configure the import.
  • + perform the import. -
  • Press OK to initiate the import.
  • +
  • Press OK from the Importer Dialog to perform the import.
  • A results summary dialog will appear and, if successful, the new program will appear in the project window and if initiated from a CodeBrowser tool, it will be opened in the tool.
  • + +

    Alternative Steps (drag-and-drop):

    + + +

    Batch Import

    diff --git a/Ghidra/Features/Base/src/main/help/help/topics/OverviewPlugin/Overview.htm b/Ghidra/Features/Base/src/main/help/help/topics/OverviewPlugin/Overview.htm index fe99903c45..7e9cf8e898 100644 --- a/Ghidra/Features/Base/src/main/help/help/topics/OverviewPlugin/Overview.htm +++ b/Ghidra/Features/Base/src/main/help/help/topics/OverviewPlugin/Overview.htm @@ -81,10 +81,8 @@

    The legend indicates the colors that correspond to each type of program element shown in - the overview display. The colors are specified as options and can be changed from the default - values. To change the colors, click on the color, or edit the options through the Edit - Options... dialog. You can choose the color from a - color chooser dialog.

    + the overview display. The colors used may be changed via the associated + Options (see below).

    Options

    @@ -107,8 +105,8 @@
  • Uninitialized Color - color for memory that is not initialized
  • -

    To view the options, select Edit Options... on - the tool, then choose the Overview node in the options tree. To change a color, double +

    To view the options, select Edit Tool Options... on + the tool, then choose the Overview node in the options tree. To change a color, double click on the color bar in the Overview Options panel. Choose the color from the color chooser dialog.

    diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java index f2727b03f8..7ea2f00b61 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java @@ -244,7 +244,7 @@ public class DataTypeManagerPlugin extends ProgramPlugin Project project = tool.getProjectManager().getActiveProject(); if (project != null && project.getName().equals(projectName)) { DomainFile df = project.getProjectData().getFile(pathname); - if (DataTypeArchive.class.isAssignableFrom(df.getDomainObjectClass())) { + if (df != null && DataTypeArchive.class.isAssignableFrom(df.getDomainObjectClass())) { return df; } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/exporter/ExporterDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/exporter/ExporterDialog.java index 5bfb13dfbb..9c437dfa20 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/exporter/ExporterDialog.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/exporter/ExporterDialog.java @@ -36,7 +36,9 @@ import docking.widgets.label.GLabel; import ghidra.app.plugin.core.help.AboutDomainObjectUtils; import ghidra.app.util.*; import ghidra.app.util.exporter.Exporter; +import ghidra.app.util.exporter.GzfExporter; import ghidra.app.util.importer.MessageLog; +import ghidra.framework.main.FrontEndService; import ghidra.framework.model.DomainFile; import ghidra.framework.model.DomainObject; import ghidra.framework.plugintool.PluginTool; @@ -62,17 +64,19 @@ import ghidra.util.task.*; public class ExporterDialog extends DialogComponentProvider implements AddressFactoryService { private static final String XML_WARNING = - " Warning: XML is lossy and intended only for transfering data to external tools. GZF is the recommended format for saving and sharing program data."; + " Warning: XML is lossy and intended only for transfering data to external tools. " + + "GZF is the recommended format for saving and sharing program data."; - private static String lastUsedExporterName = "Ghidra Zip File"; // default to GZF first time + private static String lastUsedExporterName = GzfExporter.NAME; // default to GZF first time private JButton optionsButton; private ProgramSelection currentSelection; - private JCheckBox selectionCheckBox; + private JCheckBox selectionCheckBox; // null for FrontEnd Tool use private JTextField filePathTextField; private JButton fileChooserButton; private GhidraComboBox comboBox; private final DomainFile domainFile; + private boolean domainObjectWasSupplied; private DomainObject domainObject; private List