Package ghidra.app.services
Interface ProgramManager
- All Known Implementing Classes:
ProgramMergeManagerPlugin
public interface ProgramManager
Service for managing programs. Multiple programs may be open in a tool, but only one is active at
any given time.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Program will be open as the currently active program within the tool.static final int
Program will be open in a Hidden state if not already open.static final int
Program will be open within the tool but no change will be made to the currently active program. -
Method Summary
Modifier and TypeMethodDescriptionboolean
closeAllPrograms
(boolean ignoreChanges) Closes all open programs in this tool.boolean
closeOtherPrograms
(boolean ignoreChanges) Closes all open programs in this tool except the current program.boolean
Closes the currently active programboolean
closeProgram
(Program program, boolean ignoreChanges) Closes the given program with the option of saving any changes.Program[]
Returns a list of all open program.Return the program that is currently active.getProgram
(Address addr) Returns the first program in the list of open programs that contains the given address.boolean
isLocked()
Deprecated.deprecated for 10.1; removal for 10.3 or laterboolean
Returns true if the specified program is open and considered visible to the user.void
lockDown
(boolean state) Deprecated.deprecated for 10.1; removal for 10.3 or lateropenProgram
(DomainFile domainFile) Open the program for the given domainFile.openProgram
(DomainFile df, int version) Opens the specified version of the program represented by the given DomainFile.openProgram
(DomainFile domainFile, int version, int state) Open the program for the given domainFileopenProgram
(DomainFile domainFile, Component dialogParent) Deprecated.deprecated for 10.1; removal for 10.3 or later; useopenProgram(DomainFile)
void
openProgram
(Program program) Opens the program to the tool.void
openProgram
(Program program, boolean current) Deprecated.use openProgram(Program program, int state) instead.void
openProgram
(Program program, int state) Open the specified program in the tool.openProgram
(URL ghidraURL, int state) Open the program corresponding to the given url.void
releaseProgram
(Program program, Object persistentOwner) Deprecated, for removal: This API element is subject to removal in a future version.this method is no longer used by the systemvoid
Saves the current program, possibly prompting the user for a new name.void
saveProgram
(Program program) Saves the specified program, possibly prompting the user for a new name.void
Prompts the user to save the current program to a selected file.void
saveProgramAs
(Program program) Prompts the user to save the specified program to a selected file.void
Sets the given program to be the current active program in the tool.boolean
setPersistentOwner
(Program program, Object owner) Deprecated, for removal: This API element is subject to removal in a future version.this method is no longer used by the system
-
Field Details
-
OPEN_HIDDEN
static final int OPEN_HIDDENProgram will be open in a Hidden state if not already open. This mode is generally used in conjunction with a persistent program owner.- See Also:
-
OPEN_CURRENT
static final int OPEN_CURRENTProgram will be open as the currently active program within the tool.- See Also:
-
OPEN_VISIBLE
static final int OPEN_VISIBLEProgram will be open within the tool but no change will be made to the currently active program. If this is the only program open, it will become the currently active program.- See Also:
-
-
Method Details
-
getCurrentProgram
Program getCurrentProgram()Return the program that is currently active.- Returns:
- may return null if no program is open
-
isVisible
Returns true if the specified program is open and considered visible to the user.- Parameters:
program
- the program- Returns:
- true if the specified program is open and considered visible to the user
-
closeProgram
boolean closeProgram()Closes the currently active program- Returns:
- true if the close is successful. false if the close fails or if there is no program currently active.
-
openProgram
Open the program corresponding to the given url.- Parameters:
ghidraURL
- valid server-based program URLstate
- initial open state (OPEN_HIDDEN, OPEN_CURRENT, OPEN_VISIBLE). The visibility states will be ignored if the program is already open.- Returns:
- null if the user canceled the "open" for the new program or an error occurred and was displayed.
- See Also:
-
openProgram
Open the program for the given domainFile. Once open it will become the active program.- Parameters:
domainFile
- domain file that has the program- Returns:
- null if the user canceled the "open" for the new program
-
openProgram
Deprecated.deprecated for 10.1; removal for 10.3 or later; useopenProgram(DomainFile)
Open the program for the given domainFile. Once open it will become the active program.Note: this method functions exactly as
openProgram(DomainFile)
- Parameters:
domainFile
- domain file that has the programdialogParent
- unused- Returns:
- the program
-
openProgram
Opens the specified version of the program represented by the given DomainFile. This method should be used for shared DomainFiles. The newly opened file will be made the active program.- Parameters:
df
- the DomainFile to openversion
- the version of the Program to open- Returns:
- the opened program or null if the given version does not exist.
-
openProgram
Open the program for the given domainFile- Parameters:
domainFile
- domain file that has the programversion
- the version of the Program to open. Specify DomainFile.DEFAULT_VERSION for file update mode.state
- initial open state (OPEN_HIDDEN, OPEN_CURRENT, OPEN_VISIBLE). The visibility states will be ignored if the program is already open.- Returns:
- null if the user canceled the "open" for the new program or an error occurred and was displayed.
-
openProgram
Opens the program to the tool. In this case the program is already open, but this tool may not have it registered as open. The program is made the active program.- Parameters:
program
- the program to register as open with the tool.
-
openProgram
Deprecated.use openProgram(Program program, int state) instead.Opens the program to the tool. In this case the program is already open, but this tool may not have it registered as open. The program is made the active program.- Parameters:
program
- the program to register as open with the tool.current
- if true, the program is made the current active program. If false, then the program is made active only if it the first open program in the tool.
-
openProgram
Open the specified program in the tool.- Parameters:
program
- the programstate
- initial open state (OPEN_HIDDEN, OPEN_CURRENT, OPEN_VISIBLE). The visibility states will be ignored if the program is already open.
-
saveProgram
void saveProgram()Saves the current program, possibly prompting the user for a new name. -
saveProgram
Saves the specified program, possibly prompting the user for a new name.- Parameters:
program
- the program
-
saveProgramAs
void saveProgramAs()Prompts the user to save the current program to a selected file. -
saveProgramAs
Prompts the user to save the specified program to a selected file.- Parameters:
program
- the program
-
setPersistentOwner
@Deprecated(forRemoval=true, since="10.2") boolean setPersistentOwner(Program program, Object owner) Deprecated, for removal: This API element is subject to removal in a future version.this method is no longer used by the systemEstablish a persistent owner on an open program. This will cause the program manager to imply make a program hidden if it is closed.- Parameters:
program
- the programowner
- the owner- Returns:
- true if program is open and another object is not already the owner, or the specified owner is already the owner.
- See Also:
-
releaseProgram
@Deprecated(forRemoval=true, since="10.2") void releaseProgram(Program program, Object persistentOwner) Deprecated, for removal: This API element is subject to removal in a future version.this method is no longer used by the systemRelease the persistent ownership of a program.The program will automatically be closed if it is hidden or was marked as temporary. If any of these closures corresponds to a program with changes the user will be given an opportunity to save or keep the program open.
If persistentOwner is not the correct owner, the method will have no affect.
- Parameters:
program
- the programpersistentOwner
- the owner defined bysetPersistentOwner(Program, Object)
-
closeProgram
Closes the given program with the option of saving any changes. The exact behavior of this method depends on several factors. First of all, if any other tool has this program open, then the program is closed for this tool only and the user is not prompted to save the program regardless of the ignoreChanges flag. Otherwise, if ignoreChanges is false and changes have been made, the user is prompted to save the program.- Parameters:
program
- the program to close.ignoreChanges
- if true, the program is closed without saving any changes.- Returns:
- true if the program was closed. Returns false if the user canceled the close while being prompted to save. Also returns false if the program passed in as a parameter is null.
-
closeOtherPrograms
boolean closeOtherPrograms(boolean ignoreChanges) Closes all open programs in this tool except the current program. If this tool is the only tool with a program open and that program has changes, then the user will be prompted to close each such file. (Providing the ignoreChanges flag is false)- Parameters:
ignoreChanges
- if true, the programs will be closed without saving changes.- Returns:
- true if all other programs were closed. Returns false if the user canceled the close while being prompted to save.
-
closeAllPrograms
boolean closeAllPrograms(boolean ignoreChanges) Closes all open programs in this tool. If this tool is the only tool with a program open and that program has changes, then the user will be prompted to close each such file. (Providing the ignoreChanges flag is false)- Parameters:
ignoreChanges
- if true, the programs will be closed without saving changes.- Returns:
- true if all programs were closed. Returns false if the user canceled the close while being prompted to save.
-
setCurrentProgram
Sets the given program to be the current active program in the tool.- Parameters:
p
- the program to make active.
-
getProgram
Returns the first program in the list of open programs that contains the given address. Programs are searched in the order they were opened within a given priority. Program are initially opened with the PRIORITY_NORMAL priority, but can be set to have PRIORITY_HIGH or PRIORITY_LOW.- Parameters:
addr
- the address for which to search.- Returns:
- the first program that can be found to contain the given address.
-
getAllOpenPrograms
Program[] getAllOpenPrograms()Returns a list of all open program.- Returns:
- the programs
-
lockDown
Deprecated.deprecated for 10.1; removal for 10.3 or laterAllows program manager state to be locked/unlocked. While locked, the program manager will not support opening additional programs.- Parameters:
state
- locked if true, unlocked if false
-
isLocked
Deprecated.deprecated for 10.1; removal for 10.3 or laterReturns true if program manager is in the locked state- Returns:
- true if program manager is in the locked state
-