Package ghidra.app.util.opinion
Class GdtLoader
java.lang.Object
ghidra.app.util.opinion.GdtLoader
- All Implemented Interfaces:
Loader,ExtensionPoint,Comparable<Loader>
Loads a packed Ghidra data type archive.
-
Nested Class Summary
Nested classes/interfaces inherited from interface ghidra.app.util.opinion.Loader
Loader.ImporterSettings -
Field Summary
Fields inherited from interface ghidra.app.util.opinion.Loader
COMMAND_LINE_ARG_PREFIX, loggingDisabled, OPTIONS_PROJECT_SAVE_STATE_KEY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindSupportedLoadSpecs(ByteProvider provider) If thisLoadersupports loading the givenByteProvider, this methods returns aCollectionof all supportedLoadSpecs that contain discovered load specification information that thisLoaderwill need to load.getDefaultOptions(ByteProvider provider, LoadSpec loadSpec, DomainObject domainObject, boolean loadIntoProgram, boolean mirrorFsLayout) Gets the defaultLoaderoptions.getName()getPreferredFileName(ByteProvider provider) The preferred file name to use when loading.getTier()For ordering purposes; lower tier numbers are more important (and listed first).intFor ordering purposes; lower numbers are more important (and listed first, within its tier).LoadResults<? extends DomainObject> load(Loader.ImporterSettings settings) Loads bytes in a particular format as a newLoadedDomainObject.voidloadInto(Program program, Loader.ImporterSettings settings) Loads bytes into the specifiedProgram.validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program program) Validates theLoader'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, waitMethods inherited from interface ghidra.app.util.opinion.Loader
compareTo, loadsIntoNewFolder, supportsLoadIntoProgram, supportsLoadIntoProgram
-
Constructor Details
-
GdtLoader
public GdtLoader()
-
-
Method Details
-
getDefaultOptions
public List<Option> getDefaultOptions(ByteProvider provider, LoadSpec loadSpec, DomainObject domainObject, boolean loadIntoProgram, boolean mirrorFsLayout) Description copied from interface:LoaderGets the defaultLoaderoptions.- Specified by:
getDefaultOptionsin interfaceLoader- Parameters:
provider- The bytes of the thing being loaded.loadSpec- TheLoadSpec.domainObject- TheDomainObjectbeing loaded.loadIntoProgram- True if the load is adding to an existingDomainObject; otherwise, false.mirrorFsLayout- True if the filesystem layout should be mirrored when loading; otherwise, false- Returns:
- A list of the
Loader's default options.
-
load
public LoadResults<? extends DomainObject> load(Loader.ImporterSettings settings) throws IOException, CancelledException, VersionException Description copied from interface:LoaderLoads bytes in a particular format as a newLoadedDomainObject. MultipleDomainObjects may end up getting created, depending on the nature of the format. TheLoadedDomainObjects are bundled together in aLoadResultsobject which provides convenience methods to operate on the entire group ofLoadedDomainObjects.Note that when the load completes, the returned
LoadedDomainObjects are not saved to a project. That is the responsibility of the caller (seeLoadResults.save(TaskMonitor)).It is also the responsibility of the caller to close the returned
LoadedDomainObjects withLoadResults.close()when they are no longer needed.- Specified by:
loadin interfaceLoader- Parameters:
settings- TheLoader.ImporterSettings.- Returns:
- The
LoadResultswhich contains one or moreLoadedDomainObjects (created but not saved). - Throws:
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 existingDomainFilewhich was created with a newer or unsupported version of Ghidra
-
loadInto
public void loadInto(Program program, Loader.ImporterSettings settings) throws IOException, LoadException, CancelledException Description copied from interface:LoaderLoads bytes into the specifiedProgram. This method will not create any newPrograms. It is only for adding to an existingProgram.- Specified by:
loadIntoin interfaceLoader- Parameters:
program- TheProgramto load into.settings- TheLoader.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.
-
validateOptions
public String validateOptions(ByteProvider provider, LoadSpec loadSpec, List<Option> options, Program program) Description copied from interface:LoaderValidates theLoader's options and returns null if all options are valid; otherwise, an error message describing the problem is returned.- Specified by:
validateOptionsin interfaceLoader- Parameters:
provider- The bytes of the thing being loaded.loadSpec- The proposedLoadSpec.options- The list ofOptions 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
Options are valid; otherwise, an error message describing the problem is returned.
-
findSupportedLoadSpecs
Description copied from interface:LoaderIf thisLoadersupports loading the givenByteProvider, this methods returns aCollectionof all supportedLoadSpecs that contain discovered load specification information that thisLoaderwill need to load. If thisLoadercannot support loading the givenByteProvider, an emptyCollectionis returned.- Specified by:
findSupportedLoadSpecsin interfaceLoader- Parameters:
provider- The bytes being loaded.- Returns:
- A
CollectionofLoadSpecs that thisLoadersupports loading, or an emptyCollectionif thisLoaderdoesn't support loading the givenByteProvider. - Throws:
IOException- if there was an IO-related issue finding theLoadSpecs.
-
getPreferredFileName
Description copied from interface:LoaderThe 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
ByteProviderif absolutely necessary.- Specified by:
getPreferredFileNamein interfaceLoader- Parameters:
provider- The bytes to load.- Returns:
- The preferred file name to use when loading, or
nullif a name could not be determined from the provider.
-
getName
Description copied from interface:Loader -
getTier
Description copied from interface:LoaderFor ordering purposes; lower tier numbers are more important (and listed first). -
getTierPriority
public int getTierPriority()Description copied from interface:LoaderFor ordering purposes; lower numbers are more important (and listed first, within its tier).- Specified by:
getTierPriorityin interfaceLoader- Returns:
- the ordering of the loader within its tier
-