Package ghidra.app.util.opinion

# Class BinaryLoader

java.lang.Object
ghidra.app.util.opinion.AbstractProgramLoader
ghidra.app.util.opinion.BinaryLoader

All Implemented Interfaces:
  `Loader`, `ExtensionPoint`, `Comparable<Loader>`

public class BinaryLoader extends AbstractProgramLoader

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface ghidra.app.util.opinion.Loader

  `Loader.ImporterSettings`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `BINARY_NAME`
  `static final String`
  `OPTION_NAME_BASE_ADDR`
  `static final String`
  `OPTION_NAME_BLOCK_NAME`
  `static final String`
  `OPTION_NAME_FILE_OFFSET`
  `static final String`
  `OPTION_NAME_IS_OVERLAY`
  `static final String`
  `OPTION_NAME_LEN`

  ### Fields inherited from class ghidra.app.util.opinion.AbstractProgramLoader

  `ANCHOR_LABELS_OPTION_NAME, APPLY_LABELS_OPTION_NAME`

  ### Fields inherited from interface ghidra.app.util.opinion.Loader

  `COMMAND_LINE_ARG_PREFIX, loggingDisabled, OPTIONS_PROJECT_SAVE_STATE_KEY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BinaryLoader()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Collection<LoadSpec>`
  `findSupportedLoadSpecs(ByteProvider provider)`
  If this `Loader` supports loading the given `ByteProvider`, this methods returns a `Collection` of all supported `LoadSpec`s that contain discovered load specification information that this `Loader` will need to load.
  `List<Option>`
  `getDefaultOptions(ByteProvider provider, LoadSpec loadSpec, DomainObject domainObject, boolean loadIntoProgram, boolean mirrorFsLayout)`
  Gets the default `Loader` options.
  `String`
  `getName()`
  Gets the `Loader`'s name, which is used both for display purposes, and to identify the `Loader` in the opinion files.
  `LoaderTier`
  `getTier()`
  For ordering purposes; lower tier numbers are more important (and listed first).
  `int`
  `getTierPriority()`
  For ordering purposes; lower numbers are more important (and listed first, within its tier).
  `protected List<Loaded<Program>>`
  `loadProgram(Loader.ImporterSettings settings)`
  Loads bytes in a particular format as a new `Loaded` `Program`.
  `protected void`
  `loadProgramInto(Program prog, Loader.ImporterSettings settings)`
  Loads program bytes into the specified `Program`.
  `boolean`
  `shouldApplyProcessorLabelsByDefault()`
  Returns whether or not processor labels should be applied by default.
  `boolean`
  `supportsLoadIntoProgram()`
  Checks to see if this `Loader` supports loading into an existing `Program`.
  `String`
  `validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program program)`
  Validates the `Loader`'s options and returns null if all options are valid; otherwise, an error message describing the problem is returned.

  ### Methods inherited from class ghidra.app.util.opinion.AbstractProgramLoader

  `addExternalBlock, createDefaultMemoryBlocks, createProgram, createProgram, generateBlockName, getLanguageService, load, loadInto, markAsFunction, postLoadCleanup, postLoadProgramFixups, setProgramProperties`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface ghidra.app.util.opinion.Loader

  `compareTo, getPreferredFileName, loadsIntoNewFolder, supportsLoadIntoProgram`

- ## Field Details

  - ### BINARY_NAME

    public static final String BINARY_NAME
    See Also:
      - Constant Field Values

  - ### OPTION_NAME_LEN

    public static final String OPTION_NAME_LEN
    See Also:
      - Constant Field Values

  - ### OPTION_NAME_FILE_OFFSET

    public static final String OPTION_NAME_FILE_OFFSET
    See Also:
      - Constant Field Values

  - ### OPTION_NAME_BASE_ADDR

    public static final String OPTION_NAME_BASE_ADDR
    See Also:
      - Constant Field Values

  - ### OPTION_NAME_BLOCK_NAME

    public static final String OPTION_NAME_BLOCK_NAME
    See Also:
      - Constant Field Values

  - ### OPTION_NAME_IS_OVERLAY

    public static final String OPTION_NAME_IS_OVERLAY
    See Also:
      - Constant Field Values

- ## Constructor Details

  - ### BinaryLoader

    public BinaryLoader()

- ## Method Details

  - ### getTier

    public LoaderTier getTier()
    Description copied from interface: `Loader`
    For ordering purposes; lower tier numbers are more important (and listed first).
    Returns:
      the tier of the loader

  - ### getTierPriority

    public int getTierPriority()
    Description copied from interface: `Loader`
    For ordering purposes; lower numbers are more important (and listed first, within its tier).
    Returns:
      the ordering of the loader within its tier

  - ### supportsLoadIntoProgram

    public boolean supportsLoadIntoProgram()
    Description copied from interface: `Loader`
    Checks to see if this `Loader` supports loading into an existing `Program`.

    The default behavior of this method is to return false.

    Returns:
      True if this `Loader` supports loading into an existing `Program`; otherwise, false.

  - ### findSupportedLoadSpecs

    public Collection<LoadSpec> findSupportedLoadSpecs(ByteProvider provider) throws IOException
    Description copied from interface: `Loader`
    If this `Loader` supports loading the given `ByteProvider`, this methods returns a `Collection` of all supported `LoadSpec`s that contain discovered load specification information that this `Loader` will need to load. If this `Loader` cannot support loading the given `ByteProvider`, an empty `Collection` is returned.
    Parameters:
      `provider` - The bytes being loaded.
    Returns:
      A `Collection` of `LoadSpec`s that this `Loader` supports loading, or an empty `Collection` if this `Loader` doesn't support loading the given `ByteProvider`.
    Throws:
      `IOException` - if there was an IO-related issue finding the `LoadSpec`s.

  - ### validateOptions

    public String validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program program)
    Description copied from interface: `Loader`
    Validates the `Loader`'s options and returns null if all options are valid; otherwise, an error message describing the problem is returned.
    Specified by:
      `validateOptions` in interface `Loader`
    Overrides:
      `validateOptions` in class `AbstractProgramLoader`
    Parameters:
      `provider` - The bytes of the thing being loaded.
      `loadSpec` - The proposed `LoadSpec`.
      `options` - The list of `Option`s to validate.
      `program` - existing program if the loader is adding to an existing program. If it is a fresh import, then this will be null.
    Returns:
      null if all `Option`s are valid; otherwise, an error message describing the problem is returned.

  - ### loadProgram

    protected List<Loaded<Program>> loadProgram(Loader.ImporterSettings settings) throws IOException, CancelledException
    Description copied from class: `AbstractProgramLoader`
    Loads bytes in a particular format as a new `Loaded` `Program`. Multiple `Program`s may end up getting created, depending on the nature of the format.

    Note that when the load completes, the returned `Loaded` `Program`s are not saved to a project. That is the responsibility of the caller (see `Loaded.save(TaskMonitor)`).

    It is also the responsibility of the caller to close the returned `Loaded` `Program`s with `Loaded.close()` when they are no longer needed.

    Specified by:
      `loadProgram` in class `AbstractProgramLoader`
    Parameters:
      `settings` - The `Loader.ImporterSettings`.
    Returns:
      A `List` of one or more `Loaded` `Program`s (created but not saved).
    Throws:
      `IOException` - if there was an IO-related problem loading.
      `CancelledException` - if the user cancelled the load.

  - ### loadProgramInto

    protected void loadProgramInto(Program prog, Loader.ImporterSettings settings) throws IOException, LoadException, CancelledException
    Description copied from class: `AbstractProgramLoader`
    Loads program bytes into the specified `Program`. This method will not create any new `Program`s. It is only for adding to an existing `Program`.

    NOTE: The loading that occurs in this method will automatically be done in a transaction.

    Specified by:
      `loadProgramInto` in class `AbstractProgramLoader`
    Parameters:
      `prog` - The `Program` to load into.
      `settings` - The `Loader.ImporterSettings`.
    Throws:
      `IOException` - if there was an IO-related problem loading.
      `LoadException` - if the load failed in an expected way.
      `CancelledException` - if the user cancelled the load.

  - ### getDefaultOptions

    public List<Option> getDefaultOptions(ByteProvider provider, LoadSpec loadSpec, DomainObject domainObject, boolean loadIntoProgram, boolean mirrorFsLayout)
    Description copied from interface: `Loader`
    Gets the default `Loader` options.
    Specified by:
      `getDefaultOptions` in interface `Loader`
    Overrides:
      `getDefaultOptions` in class `AbstractProgramLoader`
    Parameters:
      `provider` - The bytes of the thing being loaded.
      `loadSpec` - The `LoadSpec`.
      `domainObject` - The `DomainObject` being loaded.
      `loadIntoProgram` - True if the load is adding to an existing `DomainObject`; otherwise, false.
      `mirrorFsLayout` - True if the filesystem layout should be mirrored when loading; otherwise, false
    Returns:
      A list of the `Loader`'s default options.

  - ### getName

    public String getName()
    Description copied from interface: `Loader`
    Gets the `Loader`'s name, which is used both for display purposes, and to identify the `Loader` in the opinion files.
    Returns:
      The `Loader`'s name.

  - ### shouldApplyProcessorLabelsByDefault

    public boolean shouldApplyProcessorLabelsByDefault()
    Description copied from class: `AbstractProgramLoader`
    Returns whether or not processor labels should be applied by default. Most loaders will not need to override this method because they will not want the labels applied by default.
    Overrides:
      `shouldApplyProcessorLabelsByDefault` in class `AbstractProgramLoader`
    Returns:
      Whether or not processor labels should be applied by default.