Class GhidraValuesMap

java.lang.Object
docking.widgets.values.GValuesMap
ghidra.features.base.values.GhidraValuesMap

public class GhidraValuesMap extends GValuesMap
Extends GValuesMap to add Ghidra specific types such as Address and Program
  • Constructor Details

    • GhidraValuesMap

      public GhidraValuesMap()
  • Method Details

    • setTaskMonitor

      public void setTaskMonitor(TaskMonitor monitor)
      Sets a task monitor to be used when opening programs. Otherwise, TaskMonitor.DUMMY is used.
      Parameters:
      monitor - the TaskMonitor to use for opening programs
    • defineAddress

      public AddressValue defineAddress(String name, Program program)
      Defines a value of type Address with no default value.
      Parameters:
      name - the name for this value
      program - the program used to get an AddressFactory for parsing addresses
      Returns:
      the new AddressValue that was defined.
    • defineAddress

      public AddressValue defineAddress(String name, Address defaultValue, Program program)
      Defines a value of type Address
      Parameters:
      name - the name for this value
      defaultValue - an option default value
      program - the program used to get an AddressFactory for parsing addresses
      Returns:
      the new AddressValue that was defined.
    • defineAddress

      public AddressValue defineAddress(String name, Address defaultValue, AddressFactory factory)
      Defines a value of type Address
      Parameters:
      name - the name for this value
      defaultValue - an option default value
      factory - the AddressFactory used to parse addresses
      Returns:
      the new AddressValue that was defined.
    • defineLanguage

      public LanguageValue defineLanguage(String name, LanguageCompilerSpecPair defaultValue)
      Defines a value of type LanguageCompilerSpecPair (folders in a Ghidra project).
      Parameters:
      name - the name for this value
      defaultValue - the initial value (can be null)
      Returns:
      the new ProjectFolderValue that was defined
    • defineProgram

      public ProgramFileValue defineProgram(String name)
      Defines a value of type Program file.
      Parameters:
      name - the name for this value
      Returns:
      the new ProgramFileValue defined
    • defineProgram

      public ProgramFileValue defineProgram(String name, String startPath)
      Defines a value of type Program file.
      Parameters:
      name - the name for this value
      startPath - the starting folder to display when picking programs from the chooser
      Returns:
      the new ProgramFileValue that was defined
    • defineProjectFile

      public ProjectFileValue defineProjectFile(String name)
      Defines a value of type DomainFile (files in a Ghidra project).
      Parameters:
      name - the name for this value
      Returns:
      the new ProjectFileValue that was defined
    • defineProjectFile

      public ProjectFileValue defineProjectFile(String name, String startingPath)
      Defines a value of type DomainFile (files in a Ghidra project).
      Parameters:
      name - the name for this value
      startingPath - the initial folder path for the chooser widget
      Returns:
      the new ProjectFileValue that was defined
    • defineProjectFolder

      public ProjectFolderValue defineProjectFolder(String name)
      Defines a value of type DomainFolder (folders in a Ghidra project).
      Parameters:
      name - the name for this value
      Returns:
      the new ProjectFolderValue that was defined
    • defineProjectFolder

      public ProjectFolderValue defineProjectFolder(String name, String defaultValuePath)
      Defines a value of type DomainFolder (files in a Ghidra project).
      Parameters:
      name - the name for this value
      defaultValuePath - the path for the initial value (can be null)
      Returns:
      the new ProjectFolderValue that was defined
    • getAddress

      public Address getAddress(String name)
      Gets the Address value for the given name.
      Parameters:
      name - the name of a previously defined Address value
      Returns:
      the Address
      Throws:
      IllegalArgumentException - if the name hasn't been defined as an Address type
    • getLanguage

      public LanguageCompilerSpecPair getLanguage(String name)
      Gets the Language (LanguageCompilerSpecPair) value for the given name.
      Parameters:
      name - the name of a previously defined language value
      Returns:
      the language value
      Throws:
      IllegalArgumentException - if the name hasn't been defined as a language type
    • getProgram

      public Program getProgram(String name, Object consumer, Tool tool, boolean upgradeIfNeeded) throws VersionException, IOException, CancelledException
      Gets (opens) the Program value for the given name. If the program is already open, then the consumer will be added to the program. The caller of this method is responsible for calling DomainObject.release(Object) with the same consumer when it is done using this program. Program are only closed after all consumers are released. If multiple calls are made to this method, then the consumer will be added multiple times and must be released multiple times.

      The consumer can be any object, but since the consumer's purpose is to keep the program open while some object is using it, the object itself is typically passed in as the consumer. For example, when used in a script, passing in the java keyword "this" as the consumer will make the script itself the consumer.

      Parameters:
      name - the name of a previously defined program value
      consumer - the consumer to be used to open the program
      tool - if non-null, the program will also be opened in the given tool. Note: the program will only be added to the tool once even if this method is called multiple times.
      upgradeIfNeeded - if true, program will be upgraded if needed and possible. If false, the program will only be upgraded after first prompting the user. In headless mode, it will attempt to upgrade only if the parameter is true.
      Returns:
      an opened program with the given consumer for the selected domain file or null if no program was selected.
      Throws:
      VersionException - if the Program is out-of-date from the version of GHIDRA and an upgrade was not been performed. In non-headless mode, the user will have already been notified via a popup dialog. current Ghidra Program version.
      IOException - if there is an error accessing the Program's DomainObject
      CancelledException - if the operation is cancelled
      IllegalArgumentException - if the name hasn't been defined as a project folder type
    • getProjectFile

      public DomainFile getProjectFile(String name)
      Gets the project file (DomainFile) value for the given name.
      Parameters:
      name - the name of a previously defined project file value
      Returns:
      the project file value
      Throws:
      IllegalArgumentException - if the name hasn't been defined as a project file type
    • getProjectFolder

      public DomainFolder getProjectFolder(String name)
      Gets the project folder (DomainFolder) value for the given name.
      Parameters:
      name - the name of a previously defined project folder value
      Returns:
      the project folder value
      Throws:
      IllegalArgumentException - if the name hasn't been defined as a project folder type
    • setAddress

      public void setAddress(String name, Address address)
      Sets the address value for the given name.
      Parameters:
      name - the name of the Address value that was previously defined
      address - the address to set as the value
      Throws:
      IllegalArgumentException - if the name hasn't been defined as an Address type
    • setLanguage

      public void setLanguage(String name, LanguageCompilerSpecPair value)
      Sets the Language (LanguageCompilerSpecPair) value for the given name.
      Parameters:
      name - the name of the Language value that was previously defined
      value - the Language to set as the value
      Throws:
      IllegalArgumentException - if the name hasn't been defined as a Language type
    • setProgram

      public void setProgram(String name, Program program)
      Sets the Program value for the given name.
      Parameters:
      name - the name of the Program value that was previously defined
      program - the Program to set as the value
      Throws:
      IllegalArgumentException - if the name hasn't been defined as a Program type
    • setProjectFile

      public void setProjectFile(String name, DomainFile file)
      Sets the project file DomainFile value for the given name.
      Parameters:
      name - the name of the project file value that was previously defined
      file - the project file to set as the value
      Throws:
      IllegalArgumentException - if the name hasn't been defined as a project file type
    • setProjectFolder

      public void setProjectFolder(String name, DomainFolder folder)
      Sets the project folder DomainFolder value for the given name.
      Parameters:
      name - the name of the project folder value that was previously defined
      folder - the project folder to set as the value
      Throws:
      IllegalArgumentException - if the name hasn't been defined as a project folder type