Package ghidra.app.util.exporter
Class IntelHexExporter
java.lang.Object
ghidra.app.util.exporter.Exporter
ghidra.app.util.exporter.IntelHexExporter
- All Implemented Interfaces:
ExtensionPoint
Exports the current program (or program selection) as bytes in Intel Hex format.
The output defaults to lines of 16-bytes but this is configurable using the
recordSizeOption
attribute. This allows users to select any record size
up to the max of 0xFF. Users may also choose to Drop Extra Bytes
, which will
cause only lines that match the max record size to be printed; any other
bytes will be dropped. If this option is not set, every byte will be represented in the output.
-
Field Summary
Modifier and TypeFieldDescriptionprotected Option
Option allowing the user to select the address spaceprotected ghidra.app.util.exporter.IntelHexExporter.RecordSizeOption
Option allowing the user to select the number of bytes in each line of outputFields inherited from class ghidra.app.util.exporter.Exporter
EMPTY_OPTIONS, log, provider
-
Constructor Summary
ModifierConstructorDescriptionConstructs a new Intel Hex exporter.IntelHexExporter
(int recordSize, boolean dropBytes) Constructs a new Intel Hex exporter with a custom record size.protected
IntelHexExporter
(String name, String extension, HelpLocation help) Constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected List
<IntelHexRecord> dumpMemory
(Program program, Memory memory, AddressSetView addrSetView, TaskMonitor monitor) boolean
export
(File file, DomainObject domainObj, AddressSetView addrSet, TaskMonitor monitor) Actually does the work of exporting aDomainObject
.getOptions
(DomainObjectService domainObjectService) Returns the available options for this exporter.void
setOptions
(List<Option> options) Sets the options.Methods inherited from class ghidra.app.util.exporter.Exporter
canExportDomainFile, canExportDomainObject, canExportDomainObject, export, getDefaultFileExtension, getHelpLocation, getMessageLog, getName, setExporterServiceProvider, supportsAddressRestrictedExport, toString
-
Field Details
-
addressSpaceOption
Option allowing the user to select the address space -
recordSizeOption
protected ghidra.app.util.exporter.IntelHexExporter.RecordSizeOption recordSizeOptionOption allowing the user to select the number of bytes in each line of output
-
-
Constructor Details
-
IntelHexExporter
public IntelHexExporter()Constructs a new Intel Hex exporter. This will use a record size of 16 (the default) and will export ALL bytes in the program or selection (even if the total length is not a multiple of 16. -
IntelHexExporter
public IntelHexExporter(int recordSize, boolean dropBytes) Constructs a new Intel Hex exporter with a custom record size.- Parameters:
recordSize
- the record size to use when writing to the output filedropBytes
- if true, bytes at the end of the file that don't match the specified record size will be dropped
-
IntelHexExporter
Constructor- Parameters:
name
- the name of the exporterextension
- the extension to use for the output filehelp
- location of Ghidra help
-
-
Method Details
-
getOptions
Description copied from class:Exporter
Returns the available options for this exporter. The program is needed because some exporters may have options that vary depending on the specific program being exported.- Specified by:
getOptions
in classExporter
- Parameters:
domainObjectService
- a service for retrieving the applicable domainObject.- Returns:
- the available options for this exporter
-
setOptions
Description copied from class:Exporter
Sets the options. This method is not for defining the options, but rather it is for setting the values of options. If invalid options are passed in, then OptionException should be thrown.- Specified by:
setOptions
in classExporter
- Parameters:
options
- the option values for this exporter- Throws:
OptionException
- if invalid options are passed in
-
export
public boolean export(File file, DomainObject domainObj, AddressSetView addrSet, TaskMonitor monitor) throws IOException, ExporterException Description copied from class:Exporter
Actually does the work of exporting aDomainObject
. Export will include all saved and unsaved modifications which may have been made to the object.- Specified by:
export
in classExporter
- Parameters:
file
- the output file to write the exported infodomainObj
- the domain object to exportaddrSet
- the address set if only a portion of the program should be exported NOTE: seeExporter.supportsAddressRestrictedExport()
.monitor
- the task monitor- Returns:
- true if the program was successfully exported; otherwise, false. If the program was not successfully exported, the message log should be checked to find the source of the error.
- Throws:
IOException
- if an IO error occursExporterException
- if export error occurs
-
dumpMemory
protected List<IntelHexRecord> dumpMemory(Program program, Memory memory, AddressSetView addrSetView, TaskMonitor monitor) throws MemoryAccessException - Throws:
MemoryAccessException
-