Package ghidra.program.model.listing
Interface Program
-
- All Superinterfaces:
DataTypeManagerDomainObject
,DataTypeManagerOwner
,DomainObject
,Undoable
,UndoableDomainObject
- All Known Implementing Classes:
ProgramDB
public interface Program extends DataTypeManagerDomainObject
This interface represents the main entry point into an object which stores all information relating to a single program. This program model divides a program into four major parts: the memory, the symbol table, the equate table, and the listing. Each of these parts has an extensive interface and can be retrieved via this program interface. Although the components are divided into separate objects, they are not independent. Any changes to one component may and probably will affect the other components. Also, the state of one component will restrict the actions of another component. For example, the createCodeUnit() method of listing will fail if memory is undefined at the address where the codeUnit is to be created.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ANALYSIS_PROPERTIES
static java.lang.String
ANALYSIS_START_DATE
Creation date to ask for analysisstatic java.lang.String
ANALYSIS_START_DATE_FORMAT
Format string of analysis datestatic java.lang.String
ANALYZED
Name of boolean analyzed propertystatic java.lang.String
CREATED_WITH_GHIDRA_VERSION
Name of ghidra version propertystatic java.lang.String
DATE_CREATED
Name of date created propertystatic java.lang.String
DISASSEMBLER_PROPERTIES
static java.util.Date
JANUARY_1_1970
A date from January 1, 1970static int
MAX_OPERANDS
The maximum number of operands for any assembly languagestatic java.lang.String
PROGRAM_INFO
Name of program information property liststatic java.lang.String
PROGRAM_SETTINGS
Name of program settings property list-
Fields inherited from interface ghidra.framework.model.DomainObject
DO_DOMAIN_FILE_CHANGED, DO_OBJECT_CLOSED, DO_OBJECT_ERROR, DO_OBJECT_RENAMED, DO_OBJECT_RESTORED, DO_OBJECT_SAVED, DO_PROPERTY_CHANGED, undoLock
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description AddressSetPropertyMap
createAddressSetPropertyMap(java.lang.String name)
Create a new AddressSetPropertyMap with the specified name.IntRangeMap
createIntRangeMap(java.lang.String name)
Create a new IntRangeMap with the specified name.void
deleteAddressSetPropertyMap(java.lang.String name)
Remove the property map from the program.void
deleteIntRangeMap(java.lang.String name)
Remove the property map from the program.AddressFactory
getAddressFactory()
Returns the AddressFactory for this program.AddressMap
getAddressMap()
AddressSetPropertyMap
getAddressSetPropertyMap(java.lang.String name)
Get the property map with the given name.BookmarkManager
getBookmarkManager()
Get the bookmark manager.ProgramChangeSet
getChanges()
Get the program changes since the last save as a set of addresses.java.lang.String
getCompiler()
Gets the name of the compiler believed to have been used to create this program.CompilerSpec
getCompilerSpec()
Returns the CompilerSpec currently used by this program.java.util.Date
getCreationDate()
Returns the creation date of this program.DataTypeManager
getDataTypeManager()
Returns the program's datatype manager.int
getDefaultPointerSize()
Gets the default pointer size in bytes as it may be stored within the program listing.EquateTable
getEquateTable()
Get the equate table object.java.lang.String
getExecutableFormat()
Returns a value corresponding to the original file format.java.lang.String
getExecutableMD5()
Returns a value corresponding to the original binary file MD5 hash.java.lang.String
getExecutablePath()
Gets the path to the program's executable file.java.lang.String
getExecutableSHA256()
Returns a value corresponding to the original binary file SHA256 hash.ExternalManager
getExternalManager()
Returns the external manager.FunctionManager
getFunctionManager()
Returns the programs function manager.Namespace
getGlobalNamespace()
Returns the global namespace for this programAddress
getImageBase()
Returns the current program image base address;IntRangeMap
getIntRangeMap(java.lang.String name)
Get the property map with the given name.Language
getLanguage()
Returns the language used by this program.LanguageID
getLanguageID()
Return the name of the language used by this program.Listing
getListing()
Get the listing object.Address
getMaxAddress()
Get the programs maximum address.Memory
getMemory()
Get the memory object.Address
getMinAddress()
get the program's minimum address.ProgramContext
getProgramContext()
Returns the program context.ProgramUserData
getProgramUserData()
Returns the user-specific data manager for this program.ReferenceManager
getReferenceManager()
Get the reference manager.Register
getRegister(Address addr)
Returns the largest register located at the specified addressRegister
getRegister(Address addr, int size)
Returns a specific register based upon its address and sizeRegister
getRegister(Varnode varnode)
Returns the register which corresponds to the specified varnodeRegister
getRegister(java.lang.String name)
Returns the register with the given name;Register[]
getRegisters(Address addr)
Returns all registers located at the specified addressRelocationTable
getRelocationTable()
Gets the relocation table.SymbolTable
getSymbolTable()
Get the symbol table object.long
getUniqueProgramID()
Returns an ID that is unique for this program.PropertyMapManager
getUsrPropertyManager()
Get the user propertyMangager stored with this program.void
invalidate()
Invalidates any caching in a program.Address[]
parseAddress(java.lang.String addrStr)
Return an array of Addresses that could represent the given string.Address[]
parseAddress(java.lang.String addrStr, boolean caseSensitive)
Return an array of Addresses that could represent the given string.void
restoreImageBase()
Restores the last committed image base.void
setCompiler(java.lang.String compiler)
Sets the name of the compiler which created this program.void
setExecutableFormat(java.lang.String format)
Sets the value corresponding to the original file format.void
setExecutableMD5(java.lang.String md5)
Sets the value corresponding to the original binary file MD5 hash.void
setExecutablePath(java.lang.String path)
Sets the path to the program's executable file.void
setExecutableSHA256(java.lang.String sha256)
Sets the value corresponding to the original binary file SHA256 hash.void
setImageBase(Address base, boolean commit)
Sets the program's image base address.void
setLanguage(Language language, CompilerSpecID compilerSpecID, boolean forceRedisassembly, TaskMonitor monitor)
Sets the language for the program.-
Methods inherited from interface ghidra.framework.model.DomainObject
addCloseListener, addConsumer, addListener, canLock, canSave, createPrivateEventQueue, flushEvents, flushPrivateEventQueue, forceLock, getConsumerList, getDescription, getDomainFile, getMetadata, getModificationNumber, getName, getOptions, getOptionsNames, hasExclusiveAccess, isChangeable, isChanged, isClosed, isLocked, isSendingEvents, isTemporary, isUsedBy, lock, release, removeCloseListener, removeListener, removePrivateEventQueue, save, saveToPackedFile, setEventsEnabled, setName, setTemporary, unlock
-
Methods inherited from interface ghidra.framework.model.Undoable
addTransactionListener, canRedo, canUndo, clearUndo, getRedoName, getUndoName, redo, removeTransactionListener, undo
-
Methods inherited from interface ghidra.framework.model.UndoableDomainObject
addSynchronizedDomainObject, endTransaction, getCurrentTransaction, getSynchronizedDomainObjects, hasTerminatedTransaction, releaseSynchronizedDomainObject, startTransaction, startTransaction
-
-
-
-
Field Detail
-
ANALYSIS_PROPERTIES
static final java.lang.String ANALYSIS_PROPERTIES
- See Also:
- Constant Field Values
-
DISASSEMBLER_PROPERTIES
static final java.lang.String DISASSEMBLER_PROPERTIES
- See Also:
- Constant Field Values
-
PROGRAM_INFO
static final java.lang.String PROGRAM_INFO
Name of program information property list- See Also:
- Constant Field Values
-
PROGRAM_SETTINGS
static final java.lang.String PROGRAM_SETTINGS
Name of program settings property list- See Also:
- Constant Field Values
-
ANALYZED
static final java.lang.String ANALYZED
Name of boolean analyzed property- See Also:
- Constant Field Values
-
DATE_CREATED
static final java.lang.String DATE_CREATED
Name of date created property- See Also:
- Constant Field Values
-
CREATED_WITH_GHIDRA_VERSION
static final java.lang.String CREATED_WITH_GHIDRA_VERSION
Name of ghidra version property- See Also:
- Constant Field Values
-
ANALYSIS_START_DATE
static final java.lang.String ANALYSIS_START_DATE
Creation date to ask for analysis- See Also:
- Constant Field Values
-
ANALYSIS_START_DATE_FORMAT
static final java.lang.String ANALYSIS_START_DATE_FORMAT
Format string of analysis date- See Also:
- Constant Field Values
-
JANUARY_1_1970
static final java.util.Date JANUARY_1_1970
A date from January 1, 1970
-
MAX_OPERANDS
static final int MAX_OPERANDS
The maximum number of operands for any assembly language- See Also:
- Constant Field Values
-
-
Method Detail
-
getListing
Listing getListing()
Get the listing object.- Returns:
- the Listing interface to the listing object.
-
getAddressMap
AddressMap getAddressMap()
-
getDataTypeManager
DataTypeManager getDataTypeManager()
Returns the program's datatype manager.- Specified by:
getDataTypeManager
in interfaceDataTypeManagerOwner
- Returns:
- the data type manager.
-
getFunctionManager
FunctionManager getFunctionManager()
Returns the programs function manager.
-
getProgramUserData
ProgramUserData getProgramUserData()
Returns the user-specific data manager for this program.
-
getSymbolTable
SymbolTable getSymbolTable()
Get the symbol table object.- Returns:
- the symbol table object.
-
getExternalManager
ExternalManager getExternalManager()
Returns the external manager.
-
getEquateTable
EquateTable getEquateTable()
Get the equate table object.- Returns:
- the equate table.
-
getMemory
Memory getMemory()
Get the memory object.- Returns:
- the memory object.
-
getReferenceManager
ReferenceManager getReferenceManager()
Get the reference manager.
-
getBookmarkManager
BookmarkManager getBookmarkManager()
Get the bookmark manager.
-
getDefaultPointerSize
int getDefaultPointerSize()
Gets the default pointer size in bytes as it may be stored within the program listing.- Returns:
- default pointer size.
- See Also:
DataOrganization.getPointerSize()
-
getCompiler
java.lang.String getCompiler()
Gets the name of the compiler believed to have been used to create this program. If the compiler hasn't been determined then "unknown" is returned.- Returns:
- name of the compiler or "unknown".
-
setCompiler
void setCompiler(java.lang.String compiler)
Sets the name of the compiler which created this program.- Parameters:
compiler
- the name
-
getExecutablePath
java.lang.String getExecutablePath()
Gets the path to the program's executable file. For example,C:\Temp\test.exe
. This will allow plugins to execute the program.- Returns:
- String path to program's exe file
-
setExecutablePath
void setExecutablePath(java.lang.String path)
Sets the path to the program's executable file. For example,C:\Temp\test.exe
.- Parameters:
path
- the path to the program's exe
-
getExecutableFormat
java.lang.String getExecutableFormat()
Returns a value corresponding to the original file format.
-
setExecutableFormat
void setExecutableFormat(java.lang.String format)
Sets the value corresponding to the original file format.- Parameters:
format
- the format string to set.
-
getExecutableMD5
java.lang.String getExecutableMD5()
Returns a value corresponding to the original binary file MD5 hash. May be null if program source did not correspond to a binary file.
-
setExecutableMD5
void setExecutableMD5(java.lang.String md5)
Sets the value corresponding to the original binary file MD5 hash.- Parameters:
md5
- MD5 binary file hash
-
setExecutableSHA256
void setExecutableSHA256(java.lang.String sha256)
Sets the value corresponding to the original binary file SHA256 hash.- Parameters:
sha256
- SHA256 binary file hash
-
getExecutableSHA256
java.lang.String getExecutableSHA256()
Returns a value corresponding to the original binary file SHA256 hash. May be null if program source did not correspond to a binary file.
-
getCreationDate
java.util.Date getCreationDate()
Returns the creation date of this program. If the program was created before this property existed, then Jan 1, 1970 is returned.- Parameters:
program
- the prorgam- Returns:
- the creation date of this program
-
getRelocationTable
RelocationTable getRelocationTable()
Gets the relocation table.
-
getLanguage
Language getLanguage()
Returns the language used by this program.- Returns:
- the language used by this program.
-
getCompilerSpec
CompilerSpec getCompilerSpec()
Returns the CompilerSpec currently used by this program.- Returns:
- the compilerSpec currently used by this program.
-
getLanguageID
LanguageID getLanguageID()
Return the name of the language used by this program.- Returns:
- the name of the language
-
getUsrPropertyManager
PropertyMapManager getUsrPropertyManager()
Get the user propertyMangager stored with this program. The user property manager is used to store arbitrary address indexed information associated with the program.- Returns:
- the user property manager.
-
getProgramContext
ProgramContext getProgramContext()
Returns the program context.
-
getMinAddress
Address getMinAddress()
get the program's minimum address.- Returns:
- the program's minimum address or null if no memory blocks have been defined in the program.
-
getMaxAddress
Address getMaxAddress()
Get the programs maximum address.- Returns:
- the program's maximum address or null if no memory blocks have been defined in the program.
-
getChanges
ProgramChangeSet getChanges()
Get the program changes since the last save as a set of addresses.- Returns:
- set of changed addresses within program.
-
getAddressFactory
AddressFactory getAddressFactory()
Returns the AddressFactory for this program.
-
parseAddress
Address[] parseAddress(java.lang.String addrStr)
Return an array of Addresses that could represent the given string.- Parameters:
addrStr
- the string to parse.- Returns:
- zero length array if addrStr is properly formatted but no matching addresses were found or if the address is improperly formatted.
-
parseAddress
Address[] parseAddress(java.lang.String addrStr, boolean caseSensitive)
Return an array of Addresses that could represent the given string.- Parameters:
addrStr
- the string to parse.caseSensitive
- whether or not to process any addressSpace names as case sensitive.- Returns:
- zero length array if addrStr is properly formatted but no matching addresses were found or if the address is improperly formatted.
-
invalidate
void invalidate()
Invalidates any caching in a program. NOTE: Over-using this method can adversely affect system performance.
-
getRegister
Register getRegister(java.lang.String name)
Returns the register with the given name;- Parameters:
name
- the name of the register to retrieve- Returns:
- register or null
-
getRegister
Register getRegister(Address addr)
Returns the largest register located at the specified address- Parameters:
addr
-- Returns:
- largest register or null
-
getRegisters
Register[] getRegisters(Address addr)
Returns all registers located at the specified address- Parameters:
addr
-- Returns:
- largest register
-
getRegister
Register getRegister(Address addr, int size)
Returns a specific register based upon its address and size- Parameters:
addr
- register addresssize
- the size of the register (in bytes);- Returns:
- register or null
-
getRegister
Register getRegister(Varnode varnode)
Returns the register which corresponds to the specified varnode- Parameters:
addr
- register addresssize
- the size of the register (in bytes);- Returns:
- register or null
-
getImageBase
Address getImageBase()
Returns the current program image base address;
-
setImageBase
void setImageBase(Address base, boolean commit) throws AddressOverflowException, LockException, java.lang.IllegalStateException
Sets the program's image base address.- Parameters:
base
- the new image base address;commit
- if false, then the image base change is temporary and does not really change the program and will be lost once the program is closed. If true, the change is permanent and marks the program as "changed" (needs saving).- Throws:
AddressOverflowException
- if the new image would cause a memory block to end past the the address space.LockException
- if the program is shared and the user does not have an exclusive checkout. This will never be thrown if commit is false.java.lang.IllegalStateException
- if the program state is not suitable for setting the image base.
-
restoreImageBase
void restoreImageBase()
Restores the last committed image base.
-
setLanguage
void setLanguage(Language language, CompilerSpecID compilerSpecID, boolean forceRedisassembly, TaskMonitor monitor) throws java.lang.IllegalStateException, IncompatibleLanguageException, LockException
Sets the language for the program. If the new language is "compatible" with the old language, the addressMap is adjusted then the program is "re-disassembled".- Parameters:
language
- the new language to use.forceRedisassembly
- if true a redisassembly will be forced. This should always be false.monitor
- the task monitor- Throws:
java.lang.IllegalStateException
- thrown if any error occurs, including a cancelled monitor, which leaves this program object in an unusable state. The current transaction should be aborted and the program instance discarded.IncompatibleLanguageException
- thrown if the new language is too different from the existing language.LockException
- if the program is shared and not checked out exclusively.
-
getGlobalNamespace
Namespace getGlobalNamespace()
Returns the global namespace for this program
-
createAddressSetPropertyMap
AddressSetPropertyMap createAddressSetPropertyMap(java.lang.String name) throws DuplicateNameException
Create a new AddressSetPropertyMap with the specified name.- Parameters:
name
- name of the property map.- Returns:
- the newly created property map.
- Throws:
DuplicateNameException
- if a property map already exists with the given name.
-
createIntRangeMap
IntRangeMap createIntRangeMap(java.lang.String name) throws DuplicateNameException
Create a new IntRangeMap with the specified name.- Parameters:
name
- name of the property map.- Returns:
- the newly created property map.
- Throws:
DuplicateNameException
- if a property map already exists with the given name.
-
getAddressSetPropertyMap
AddressSetPropertyMap getAddressSetPropertyMap(java.lang.String name)
Get the property map with the given name.- Parameters:
name
- name of the property map- Returns:
- null if no property map exist with the given name
-
getIntRangeMap
IntRangeMap getIntRangeMap(java.lang.String name)
Get the property map with the given name.- Parameters:
name
- name of the property map- Returns:
- null if no property map exist with the given name
-
deleteAddressSetPropertyMap
void deleteAddressSetPropertyMap(java.lang.String name)
Remove the property map from the program.- Parameters:
name
- name of the property map to remove
-
deleteIntRangeMap
void deleteIntRangeMap(java.lang.String name)
Remove the property map from the program.- Parameters:
name
- name of the property map to remove
-
getUniqueProgramID
long getUniqueProgramID()
Returns an ID that is unique for this program. This provides an easy way to store references to a program across client persistence.
-
-