Class IntelHexExporter

  • All Implemented Interfaces:
    ExtensionPoint

    public class IntelHexExporter
    extends Exporter
    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 Detail

      • addressSpaceOption

        protected Option addressSpaceOption
        Option allowing the user to select the address space
      • recordSizeOption

        protected ghidra.app.util.exporter.IntelHexExporter.RecordSizeOption recordSizeOption
        Option allowing the user to select the number of bytes in each line of output
    • Constructor Detail

      • 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 file
        dropBytes - if true, bytes at the end of the file that don't match the specified record size will be dropped
      • IntelHexExporter

        protected IntelHexExporter​(java.lang.String name,
                                   java.lang.String extension,
                                   HelpLocation help)
        Constructor
        Parameters:
        name - the name of the exporter
        extension - the extension to use for the output file
        help - location of Ghidra help
    • Method Detail

      • getOptions

        public java.util.List<Option> getOptions​(DomainObjectService domainObjectService)
        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 class Exporter
        Parameters:
        domainObjectService - a service for retrieving the applicable domainObject.
        Returns:
        the available options for this exporter
      • setOptions

        public void setOptions​(java.util.List<Option> options)
                        throws OptionException
        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 class Exporter
        Parameters:
        options - the option values for this exporter
        Throws:
        OptionException - if invalid options are passed in
      • export

        public boolean export​(java.io.File file,
                              DomainObject domainObj,
                              AddressSetView addrSet,
                              TaskMonitor monitor)
                       throws java.io.IOException,
                              ExporterException
        Description copied from class: Exporter
        Actually does the work of exporting the program.
        Specified by:
        export in class Exporter
        Parameters:
        file - the output file to write the exported info
        domainObj - the domain object to export
        addrSet - the address set if only a portion of the program should be exported
        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:
        java.io.IOException
        ExporterException