Package ghidra.app.util.opinion

# Class GzfLoader

java.lang.Object
ghidra.app.util.opinion.GzfLoader

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

public class GzfLoader extends Object implements Loader
Loads a packed Ghidra program.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `GZF_NAME`

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

  `COMMAND_LINE_ARG_PREFIX, OPTIONS_PROJECT_SAVE_STATE_KEY`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GzfLoader()`

- ## 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)`
  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.
  `String`
  `getPreferredFileName(ByteProvider provider)`
  The preferred file name to use when loading.
  `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).
  `LoadResults<? extends DomainObject>`
  `load(ByteProvider provider, String programName, Project project, String projectFolderPath, LoadSpec loadSpec, List<Option> options, MessageLog messageLog, Object consumer, TaskMonitor monitor)`
  Loads bytes in a particular format as a new `Loaded` `DomainObject`.
  `void`
  `loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options, MessageLog messageLog, Program program, TaskMonitor monitor)`
  Loads bytes into the specified `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 java.lang.Object

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

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

  `compareTo, loadsIntoNewFolder, supportsLoadIntoProgram, supportsLoadIntoProgram`

- ## Field Details

  - ### GZF_NAME

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

- ## Constructor Details

  - ### GzfLoader

    public GzfLoader()

- ## Method Details

  - ### getTier

    public LoaderTier getTier()
    Description copied from interface: `Loader`
    For ordering purposes; lower tier numbers are more important (and listed first).
    Specified by:
      `getTier` in interface `Loader`
    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).
    Specified by:
      `getTierPriority` in interface `Loader`
    Returns:
      the ordering of the loader within its tier

  - ### 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`
    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.

  - ### getDefaultOptions

    public List<Option> getDefaultOptions(ByteProvider provider, LoadSpec loadSpec, DomainObject domainObject, boolean loadIntoProgram)
    Description copied from interface: `Loader`
    Gets the default `Loader` options.
    Specified by:
      `getDefaultOptions` in interface `Loader`
    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.
    Returns:
      A list of the `Loader`'s default options.

  - ### load

    public LoadResults<? extends DomainObject> load(ByteProvider provider, String programName, Project project, String projectFolderPath, LoadSpec loadSpec, List<Option> options, MessageLog messageLog, Object consumer, TaskMonitor monitor) throws IOException, CancelledException, VersionException
    Description copied from interface: `Loader`
    Loads bytes in a particular format as a new `Loaded` `DomainObject`. Multiple `DomainObject`s may end up getting created, depending on the nature of the format. The `Loaded` `DomainObject`s are bundled together in a `LoadResults` object which provides convenience methods to operate on the entire group of `Loaded` `DomainObject`s.

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

    It is also the responsibility of the caller to release the returned `Loaded` `DomainObject`s with `LoadResults.release(Object)` when they are no longer needed.

    Specified by:
      `load` in interface `Loader`
    Parameters:
      `provider` - The bytes to load.
      `programName` - A suggested name for the primary `Loaded` `DomainObject`. This is just a suggestion, and a `Loader` implementation reserves the right to change it. The `LoadResults` should be queried for their true names using `Loaded.getName()`.
      `project` - The `Project`. Loaders can use this to take advantage of existing `DomainFolder`s and `DomainFile`s to do custom behaviors such as loading libraries. Could be null if there is no project.
      `projectFolderPath` - A suggested project folder path for the `Loaded` `DomainObject`s. This is just a suggestion, and a `Loader` implementation reserves the right to change it for each `Loaded` result. The `LoadResults` should be queried for their true project folder paths using `Loaded.getProjectFolderPath()`.
      `loadSpec` - The `LoadSpec` to use during load.
      `options` - The load options.
      `messageLog` - The message log.
      `consumer` - A consumer object for generated `DomainObject`s.
      `monitor` - A task monitor.
    Returns:
      The `LoadResults` which contains one or more `Loaded` `DomainObject`s (created but not saved).
    Throws:
      `LoadException` - if the load failed in an expected way
      `IOException` - if there was an IO-related problem loading.
      `CancelledException` - if the user cancelled the load.
      `VersionException` - if the load process tried to open an existing `DomainFile` which was created with a newer or unsupported version of Ghidra

  - ### loadInto

    public void loadInto(ByteProvider provider, LoadSpec loadSpec, List<Option> options, MessageLog messageLog, Program program, TaskMonitor monitor) throws IOException, LoadException, CancelledException
    Description copied from interface: `Loader`
    Loads bytes into the specified `Program`. This method will not create any new `Program`s. It is only for adding to an existing `Program`.
    Specified by:
      `loadInto` in interface `Loader`
    Parameters:
      `provider` - The bytes to load into the `Program`.
      `loadSpec` - The `LoadSpec` to use during load.
      `options` - The load options.
      `messageLog` - The message log.
      `program` - The `Program` to load into.
      `monitor` - A cancelable task monitor.
    Throws:
      `LoadException` - if the load failed in an expected way.
      `IOException` - if there was an IO-related problem loading.
      `CancelledException` - if the user cancelled the load.

  - ### 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.
    Specified by:
      `findSupportedLoadSpecs` in interface `Loader`
    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.

  - ### getPreferredFileName

    public String getPreferredFileName(ByteProvider provider)
    Description copied from interface: `Loader`
    The preferred file name to use when loading.

    The default behavior of this method is to return the (cleaned up) name of the given `ByteProvider`.

    NOTE: This method may get called frequently, so only parse the given `ByteProvider` if absolutely necessary.

    Specified by:
      `getPreferredFileName` in interface `Loader`
    Parameters:
      `provider` - The bytes to load.
    Returns:
      The preferred file name to use when loading.

  - ### 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.
    Specified by:
      `getName` in interface `Loader`
    Returns:
      The `Loader`'s name.