Package ghidra.program.util
Class ProgramUtilities
java.lang.Object
ghidra.program.util.ProgramUtilities
General utility class that provides convenience methods
to deal with Program objects.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddTrackedProgram(Program program) Programs will only be stored during testing and are maintained as weak references.static voidconvertFunctionWrappedExternalPointer(Symbol functionSymbol) Convert old function wrapped external pointers.static StringGet the bytes associated with the specified code unit cu formatted as a string.static DataConvertergetDataConverter(Program program) Returns an iterator for all of theProgramobjects in the system, which is all created programs in any state that have not been garbage collected.static booleanisChangedWithUpgradeOnly(Program program) Determine if a program has a single unsaved change which corresponds to an upgrade which occured during instantiation.static AddressparseAddress(Program program, String addressString) Parse anAddressstring which corresponds to the specified program.
-
Method Details
-
getDataConverter
-
addTrackedProgram
Programs will only be stored during testing and are maintained as weak references.- Parameters:
program- The program that is being tracked (all programs during testing.
-
getSystemPrograms
Returns an iterator for all of theProgramobjects in the system, which is all created programs in any state that have not been garbage collected.Note:The Iterator is backed by an unmodifiable set, so any attempts to modify the Iterator will throw an
UnsupportedOperationException.- Returns:
- an iterator for all of the programs in the system
-
parseAddress
Parse anAddressstring which corresponds to the specified program. Supported addresses include (order also indicates precedence):- Default loaded memory space (hex-offset only or with space-name, e.g., 'abcd', '0xabcd')
- Memory space-name based address (with hex-offset, e.g., 'ram:abc', see Note-1)
- External address (e.g., EXTERNAL:00001234, see Note-2)
- Stack address (e.g., Stack[0xa], Stack[-0xa], Stack[10], Stack[-10])
NOTES:
- Specifying only a hex offset should be restricted to a valid default address space offset to avoid having an arbitrary address space address returned. A non-default space address should include the appropriate address space name prefix.
- If an external address is returned it does not indicate that it is defined by the program.
- Parameters:
program- program whose memory spaces should be consideredaddressString- address string to be parsed (use of address space name prefix is case-sensitive).- Returns:
- parsed address or null if parse failed
-
getByteCodeString
Get the bytes associated with the specified code unit cu formatted as a string. Bytes will be returned as 2-digit hex separated with a space. Any undefined bytes will be represented by "??".- Parameters:
cu- code unit- Returns:
- formatted byte string
-
convertFunctionWrappedExternalPointer
Convert old function wrapped external pointers. Migrate function to external function.- Parameters:
functionSymbol- old fake IAT function to be migrated
-
isChangedWithUpgradeOnly
Determine if a program has a single unsaved change which corresponds to an upgrade which occured during instantiation.- Parameters:
program- the program to be checked for an unsaved upgrade condition.- Returns:
- true if program upgraded and has not been saved, else false
-