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 4a8ff89bdd..78f8e89da5 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 @@ -22,15 +22,17 @@
--Creates a binary file containing only the bytes from each memory block in the program. - If the program was originally created using the Binary Importer, then this - exporter allows recreation of the original file.
- --
Only initialized memory blocks - are included in the output file.
@@ -284,22 +275,8 @@- -
-- -Writes an ELF program that was imported with the ELF loader back to its original file - layout. Any file-backed bytes that were modified by the user in the program database will - be reflected in the new file.
- -- -
Writing back a modified Memory - Map is not supported.
-
Relocation bytes are always - restored to their original values, even if the user modifies them.
-Creates a zip file from a program in your project. You may want to create a zip file @@ -321,7 +298,7 @@ the ASCII Options.
-The Intel Hex format, a printable file representing memory images, was originally @@ -345,18 +322,57 @@
-+ +Writes a PE program that was imported with the PE loader back to its original file - layout. Any file-backed bytes that were modified by the user in the program database will - be reflected in the new file.
+Writes a program back to its original file layout. By default, any file-backed bytes + that were modified by the user in the program database will be reflected in the new file. + Optionally, the program can be written back to its unmodified file bytes, discarding all + user modifications. +
+ +Original File Options
+ ++
+- Export User Byte Modifications - If checked, user byte modifications are + preserved in the exported file. If unchecked, no user byte modifications are preserved + and the exported file will exactly match the file that was originally imported.
++
+ +- Save Multiple File Sources To Directory - If checked, the destination file + will be treated as a directory. Each file source from the program will be saved to this + newly created directory with names of the form <directory>.0, <directory>.1, + etc. If the program contains multiple file sources and this option is not checked, only + the primary (first) file source will saved to the specified destination file.
+
This exporter is only + operational when the program has at least one file-backed byte source. This will be + reflected in the Memory Map's + Byte Source column, which entries that begin with File:
Writing back a modified Memory Map is not supported.
+ +
Relocation bytes are always restored to their original values, even if the user modifies them.
+
Programs written to disk with + this exporter may be runnable on your native platform. Use caution when exporting + potentially malicious programs.
+Creates a binary file containing only the raw bytes from each memory block in the + program. If there are multiple memory blocks, their bytes will be concatenated in the + exported binary file. If the program was originally created using the Binary + Importer and there is only one memory block, then this exporter allows recreation of + the original file.
+ +
Only initialized memory blocks + are included in the output file.
Source - Description of block origination.
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/AbstractLoaderExporter.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/AbstractLoaderExporter.java deleted file mode 100644 index 3bb1c77102..0000000000 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/exporter/AbstractLoaderExporter.java +++ /dev/null @@ -1,169 +0,0 @@ -/* ### - * IP: GHIDRA - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package ghidra.app.util.exporter; - -import java.io.*; -import java.nio.file.*; -import java.util.List; - -import ghidra.app.util.DomainObjectService; -import ghidra.app.util.Option; -import ghidra.app.util.opinion.Loader; -import ghidra.framework.model.DomainObject; -import ghidra.program.database.mem.AddressSourceInfo; -import ghidra.program.database.mem.FileBytes; -import ghidra.program.model.address.Address; -import ghidra.program.model.address.AddressSetView; -import ghidra.program.model.listing.Program; -import ghidra.program.model.mem.Memory; -import ghidra.program.model.mem.MemoryBlockSourceInfo; -import ghidra.program.model.reloc.Relocation; -import ghidra.util.Conv; -import ghidra.util.HelpLocation; -import ghidra.util.task.TaskMonitor; -import utilities.util.FileUtilities; - -/** - * An {@link Exporter} that can export programs imported with a particular {@link Loader} - */ -public abstract class AbstractLoaderExporter extends Exporter { - - /** - * Creates a new {@link AbstractLoaderExporter} - * - * @param name The display name of this exporter - * @param help The {@link HelpLocation} for this exporter - */ - protected AbstractLoaderExporter(String name, HelpLocation help) { - super(name, "", help); - } - - /** - * Checks to see if the given file format is supported by this exporter - * - * @param fileFormat The file format (loader name) of the program to export - * @return True if the given file format is supported by this exporter; otherwise, false - */ - protected abstract boolean supportsFileFormat(String fileFormat); - - @Override - public boolean export(File file, DomainObject domainObj, AddressSetView addrSet, - TaskMonitor monitor) throws IOException, ExporterException { - - if (!(domainObj instanceof Program)) { - log.appendMsg("Unsupported type: " + domainObj.getClass().getSimpleName()); - return false; - } - - Program program = (Program) domainObj; - Memory memory = program.getMemory(); - - String fileFormat = program.getExecutableFormat(); - if (!supportsFileFormat(fileFormat)) { - log.appendMsg("Unsupported file format: " + fileFormat); - return false; - } - - List