Package ghidra.program.model.listing
Interface Program
- All Superinterfaces:
DataTypeManagerDomainObject
,DataTypeManagerOwner
,DomainObject
,Undoable
,UndoableDomainObject
- All Known Implementing Classes:
ProgramDB
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
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
Creation date to ask for analysisstatic final String
Format string of analysis datestatic final String
Name of boolean analyzed propertystatic final String
Name of ghidra version propertystatic final String
Name of date created propertystatic final String
static final Date
A date from January 1, 1970static final int
The maximum number of operands for any assembly languagestatic final String
Name of ghidra preferred root namespace category propertystatic final String
Name of program information property liststatic final String
Name of program settings property listFields 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
Modifier and TypeMethodDescriptionCreate a new AddressSetPropertyMap with the specified name.createIntRangeMap
(String name) Create a new IntRangeMap with the specified name.void
Remove the property map from the program.void
deleteIntRangeMap
(String name) Remove the property map from the program.Returns the AddressFactory for this program.Get the internal program address mapGet the property map with the given name.Get the bookmark manager.Get the program changes since the last save as a set of addresses.Gets the name of the compiler believed to have been used to create this program.Returns the CompilerSpec currently used by this program.Returns the creation date of this program.Returns the program's datatype manager.int
Gets the default pointer size in bytes as it may be stored within the program listing.Get the equate table object.Returns a value corresponding to the original file format.Returns a value corresponding to the original binary file MD5 hash.Gets the path to the program's executable file.Returns a value corresponding to the original binary file SHA256 hash.Returns the external manager.Returns the programs function manager.Returns the global namespace for this programReturns the current program image base addressgetIntRangeMap
(String name) Get the property map with the given name.Returns the language used by this program.Return the name of the language used by this program.Get the listing object.Get the programs maximum address.Get the memory object.get the program's minimum address.Gets the preferred root data type category path which corresponds to the global namespace of a namespace-based storage area.Returns the program context.Returns the user-specific data manager for this program.Get the reference manager.getRegister
(Address addr) Returns the largest register located at the specified addressgetRegister
(Address addr, int size) Returns a specific register based upon its address and sizegetRegister
(Varnode varnode) Returns the register which corresponds to the specified varnodegetRegister
(String name) Returns the register with the given name;Register[]
getRegisters
(Address addr) Returns all registers located at the specified addressGets the relocation table.Get the symbol table object.long
Returns an ID that is unique for this program.Get the user propertyMangager stored with this program.void
Invalidates any caching in a program.Address[]
parseAddress
(String addrStr) Return an array of Addresses that could represent the given string.Address[]
parseAddress
(String addrStr, boolean caseSensitive) Return an array of Addresses that could represent the given string.void
Restores the last committed image base.void
setCompiler
(String compiler) Sets the name of the compiler which created this program.void
setExecutableFormat
(String format) Sets the value corresponding to the original file format.void
setExecutableMD5
(String md5) Sets the value corresponding to the original binary file MD5 hash.void
setExecutablePath
(String path) Sets the path to the program's executable file.void
setExecutableSHA256
(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.void
setPreferredRootNamespaceCategoryPath
(String categoryPath) Sets the preferred data type category path which corresponds to the root of a namespace hierarchy storage area.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 Details
-
ANALYSIS_PROPERTIES
- See Also:
-
DISASSEMBLER_PROPERTIES
- See Also:
-
PROGRAM_INFO
Name of program information property list- See Also:
-
PROGRAM_SETTINGS
Name of program settings property list- See Also:
-
ANALYZED
Name of boolean analyzed property- See Also:
-
DATE_CREATED
Name of date created property- See Also:
-
CREATED_WITH_GHIDRA_VERSION
Name of ghidra version property- See Also:
-
PREFERRED_ROOT_NAMESPACE_CATEGORY_PROPERTY
Name of ghidra preferred root namespace category property- See Also:
-
ANALYSIS_START_DATE
Creation date to ask for analysis- See Also:
-
ANALYSIS_START_DATE_FORMAT
Format string of analysis date- See Also:
-
JANUARY_1_1970
A date from January 1, 1970 -
MAX_OPERANDS
static final int MAX_OPERANDSThe maximum number of operands for any assembly language- See Also:
-
-
Method Details
-
getListing
Listing getListing()Get the listing object.- Returns:
- the Listing interface to the listing object.
-
getAddressMap
AddressMap getAddressMap()Get the internal program address map- Returns:
- internal address map
-
getDataTypeManager
ProgramBasedDataTypeManager 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.- Returns:
- the function manager
-
getProgramUserData
ProgramUserData getProgramUserData()Returns the user-specific data manager for this program.- Returns:
- the program-specific user data manager
-
getSymbolTable
SymbolTable getSymbolTable()Get the symbol table object.- Returns:
- the symbol table object.
-
getExternalManager
ExternalManager getExternalManager()Returns the external manager.- 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.- Returns:
- the reference manager
-
getBookmarkManager
BookmarkManager getBookmarkManager()Get the bookmark manager.- Returns:
- 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:
-
getCompiler
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
Sets the name of the compiler which created this program.- Parameters:
compiler
- the name
-
getPreferredRootNamespaceCategoryPath
CategoryPath getPreferredRootNamespaceCategoryPath()Gets the preferred root data type category path which corresponds to the global namespace of a namespace-based storage area. Preference will be given to this category when searching for data types within a specific namespace. This setting corresponds to the Program Information option "Preferred Root Namespace Category. SeeDataTypeUtilities
and its various find methods for its usage details.- Returns:
- data type category path for root namespace or null if not set or is invalid.
-
setPreferredRootNamespaceCategoryPath
Sets the preferred data type category path which corresponds to the root of a namespace hierarchy storage area. Preference will be given to this category when searching for data types within a specific namespace. This setting corresponds to the Program Information option "Preferred Root Namespace Category. SeeDataTypeUtilities
and its various find methods for its usage details.- Parameters:
categoryPath
- data type category path for root namespace or null to clear option. The specified path must be absolute and start with "/" and must not end with one (e.g., /ClassDataTypes). An invalid path setting will be ignored.
-
getExecutablePath
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
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
String getExecutableFormat()Returns a value corresponding to the original file format.- Returns:
- original file format used to load program or null if unknown
-
setExecutableFormat
Sets the value corresponding to the original file format.- Parameters:
format
- the binary file format string to set.
-
getExecutableMD5
String getExecutableMD5()Returns a value corresponding to the original binary file MD5 hash.- Returns:
- original loaded file MD5 or null
-
setExecutableMD5
Sets the value corresponding to the original binary file MD5 hash.- Parameters:
md5
- MD5 binary file hash
-
setExecutableSHA256
Sets the value corresponding to the original binary file SHA256 hash.- Parameters:
sha256
- SHA256 binary file hash
-
getExecutableSHA256
String getExecutableSHA256()Returns a value corresponding to the original binary file SHA256 hash.- Returns:
- original loaded file SHA256 or null
-
getCreationDate
Date getCreationDate()Returns the creation date of this program. If the program was created before this property existed, then Jan 1, 1970 is returned.- Returns:
- the creation date of this program
-
getRelocationTable
RelocationTable getRelocationTable()Gets the relocation table.- Returns:
- relocation table object
-
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.- Returns:
- the program context object
-
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.- Returns:
- the program address factory
-
parseAddress
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
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
Returns the register with the given name;- Parameters:
name
- the name of the register to retrieve- Returns:
- register or null
-
getRegister
Returns the largest register located at the specified address- Parameters:
addr
- register minimum address- Returns:
- largest register at addr or null
-
getRegisters
Returns all registers located at the specified address- Parameters:
addr
- register minimum address- Returns:
- all registers at addr
-
getRegister
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
Returns the register which corresponds to the specified varnode- Parameters:
varnode
- the varnode- Returns:
- register or null
-
getImageBase
Address getImageBase()Returns the current program image base address- Returns:
- program image base address within default space
-
setImageBase
void setImageBase(Address base, boolean commit) throws AddressOverflowException, LockException, 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.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 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.compilerSpecID
- the new compiler specification IDforceRedisassembly
- if true a redisassembly will be forced. This should always be false.monitor
- the task monitor- Throws:
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- Returns:
- the global namespace
-
createAddressSetPropertyMap
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
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
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
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
Remove the property map from the program.- Parameters:
name
- name of the property map to remove
-
deleteIntRangeMap
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.- Returns:
- unique program ID
-