Class FlatProgramAPI
- Direct Known Subclasses:
AppleSingleDoubleBinaryAnalysisCommand
,CoffArchiveBinaryAnalysisCommand
,CoffBinaryAnalysisCommand
,ElfBinaryAnalysisCommand
,GhidraScript
,MachoBinaryAnalysisCommand
,PefBinaryAnalysisCommand
,PortableExecutableBinaryAnalysisCommand
NOTE:
- NO METHODS *SHOULD* EVER BE REMOVED FROM THIS CLASS.
- NO METHOD SIGNATURES *SHOULD* EVER BE CHANGED IN THIS CLASS.
This class is used by GhidraScript.
Changing this class will break user scripts.
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
Constructs a new flat program API.FlatProgramAPI
(Program program) Constructs a new flat program API.FlatProgramAPI
(Program program, TaskMonitor monitor) Constructs a new flat program API. -
Method Summary
Modifier and TypeMethodDescriptionfinal void
addEntryPoint
(Address address) Adds an entry point at the specified address.final Reference
addInstructionXref
(Address from, Address to, int opIndex, FlowType type) Adds a cross reference (XREF).void
Deprecated, for removal: This API element is subject to removal in a future version.void
analyzeAll
(Program program) Starts auto-analysis on the specified program and performs complete analysis of the entire program.void
analyzeChanges
(Program program) Starts auto-analysis if not started and waits for pending analysis to complete.final void
clearListing
(Address address) Clears the code unit (instruction or data) defined at the address.final void
clearListing
(Address start, Address end) Clears the code units (instructions or data) in the specified range.final void
Clears the code units (instructions or data) in the specified setfinal boolean
clearListing
(AddressSetView set, boolean code, boolean symbols, boolean comments, boolean properties, boolean functions, boolean registers, boolean equates, boolean userReferences, boolean analysisReferences, boolean importReferences, boolean defaultReferences, boolean bookmarks) Clears the listing in the specified address set.final AddressSet
Creates a new mutable address set.final Data
createAsciiString
(Address address) Creates a null terminated ascii string starting at the specified address.final Data
createAsciiString
(Address address, int length) Create an ASCII string at the specified address.final Bookmark
createBookmark
(Address address, String category, String note) Creates aNOTE
bookmark at the specified address
NOTE: if aNOTE
bookmark already exists at the address, it will be replaced.final Data
createByte
(Address address) Creates a byte datatype at the given address.final Data
createChar
(Address address) Creates a char datatype at the given address.final GhidraClass
createClass
(Namespace parent, String className) Creates a newGhidraClass
with the given name contained inside the specified parent namespace.final Data
createData
(Address address, DataType datatype) Creates a new defined Data object at the given address.final Data
createDouble
(Address address) Creates a double datatype at the given address.final Data
createDWord
(Address address) Creates a dword datatype at the given address.final void
createDwords
(Address start, int count) Creates a list of dword datatypes starting at the given address.final Equate
createEquate
(Data data, String equateName) Creates a new equate on the scalar value at the value of the data.final Equate
createEquate
(Instruction instruction, int operandIndex, String equateName) Creates a new equate on the scalar value at the operand index of the instruction.final Reference
createExternalReference
(Data data, String libraryName, String externalLabel, Address externalAddr) Creates an external reference from the given data.final Reference
createExternalReference
(Instruction instruction, int operandIndex, String libraryName, String externalLabel, Address externalAddr) Creates an external reference from the given instruction.final Reference
createExternalReference
(Instruction instruction, int operandIndex, String libraryName, String externalLabel, Address externalAddr, RefType refType) Creates an external reference from the given instruction.final Data
createFloat
(Address address) Creates a float datatype at the given address.final ProgramFragment
createFragment
(ProgramModule module, String fragmentName, Address start, long length) Creates a fragment in the given folder of the default program tree.final ProgramFragment
createFragment
(ProgramModule module, String fragmentName, Address start, Address end) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated because it did not allow you to include the largest possible address.final ProgramFragment
createFragment
(String fragmentName, Address start, long length) Creates a fragment in the root folder of the default program tree.final ProgramFragment
createFragment
(String fragmentName, Address start, Address end) Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated because it did not allow you to include the largest possible address.final Function
createFunction
(Address entryPoint, String name) Creates a function at entry point with the specified namefinal Symbol
createLabel
(Address address, String name, boolean makePrimary) Creates a label at the specified address in the global namespace.final Symbol
createLabel
(Address address, String name, boolean makePrimary, SourceType sourceType) Creates a label at the specified address in the global namespace.final Symbol
createLabel
(Address address, String name, Namespace namespace, boolean makePrimary, SourceType sourceType) Creates a label at the specified address in the specified namespace.final MemoryBlock
createMemoryBlock
(String name, Address start, byte[] bytes, boolean overlay) Create a new memory block.final MemoryBlock
createMemoryBlock
(String name, Address start, InputStream input, long length, boolean overlay) Create a new memory block.final Reference
createMemoryReference
(Data data, Address toAddress, RefType dataRefType) Creates a memory reference from the given data.final Reference
createMemoryReference
(Instruction instruction, int operandIndex, Address toAddress, RefType flowType) Creates a memory reference from the given instruction.final Namespace
createNamespace
(Namespace parent, String namespaceName) Creates a newNamespace
with the given name contained inside the specified parent namespace.final Data
createQWord
(Address address) Creates a qword datatype at the given address.final Reference
createStackReference
(Instruction instruction, int operandIndex, int stackOffset, boolean isWrite) Create a stack reference from the given instructionfinal Symbol
createSymbol
(Address address, String name, boolean makePrimary) Deprecated, for removal: This API element is subject to removal in a future version.usecreateLabel(Address, String, boolean)
instead.final Symbol
createSymbol
(Address address, String name, boolean makePrimary, boolean makeUnique, SourceType sourceType) Deprecated, for removal: This API element is subject to removal in a future version.usecreateLabel(Address, String, boolean, SourceType)
instead.final Data
createUnicodeString
(Address address) Creates a null terminated unicode string starting at the specified address.final Data
createWord
(Address address) Creates a word datatype at the given address.final boolean
disassemble
(Address address) Start disassembling at the specified address.final void
end
(boolean commit) Ends the transactions on the current program.final Address
Finds the first occurrence of the byte starting from the address.final Address
Finds the first occurrence of the byte array sequence starting from the address.final Address
Finds the first occurrence of 'text' in the program listing.final Address
Finds the first occurrence of the byte array sequence that matches the given byte string, starting from the address.final Address[]
Finds the first<matchLimit>
occurrences of the byte array sequence that matches the given byte string, starting from the address.final Address[]
Finds the first<matchLimit>
occurrences of the byte array sequence that matches the given byte string, starting from the address.final Address[]
findBytes
(AddressSetView set, String byteString, int matchLimit, int alignment) Finds a byte pattern within an addressSet.final Address[]
findBytes
(AddressSetView set, String byteString, int matchLimit, int alignment, boolean searchAcrossAddressGaps) Finds a byte pattern within an addressSet.findPascalStrings
(AddressSetView addressSet, int minimumStringLength, int alignment, boolean includePascalUnicode) Search for sequences of Pascal Ascii strings in program memory.findStrings
(AddressSetView addressSet, int minimumStringLength, int alignment, boolean requireNullTermination, boolean includeAllCharWidths) Search for sequences of Ascii strings in program memory.final AddressFactory
final Bookmark[]
getBookmarks
(Address address) Returns all of the NOTE bookmarks defined at the specified addressfinal byte
Returns the signed 'byte' value at the specified address in memory.final byte[]
Reads length number of signed bytes starting at the specified address.Gets the current program.final Data
getDataAfter
(Address address) Returns the defined data after the specified address or null if no data exists.final Data
getDataAfter
(Data data) Returns the defined data after the specified data or null if no data exists.final Data
Returns the defined data at the specified address or null if no data exists.final Data
getDataBefore
(Address address) Returns the defined data before the specified address or null if no data exists.final Data
getDataBefore
(Data data) Returns the defined data before the specified data or null if no data exists.final Data
getDataContaining
(Address address) Returns the defined data containing the specified address or null if no data exists.final DataType[]
getDataTypes
(String name) Searches through the datatype manager of the current program and returns an array of datatypes that match the specified name.final double
Returns the 'double' value at the specified address in memory.final String
getEOLComment
(Address address) Returns the EOL comment at the specified address.final Equate
Returns the equate defined on the data.final Equate
getEquate
(Instruction instruction, int operandIndex, long value) Returns the equate defined at the operand index of the instruction with the given value.getEquates
(Instruction instruction, int operandIndex) Returns the equates defined at the operand index of the instruction.final Data
Returns the first defined data in the current program.final Function
Returns the first function in the current program.final Instruction
Returns the first instruction in the current program.final Instruction
getFirstInstruction
(Function function) Returns the first instruction in the function.final float
Returns the 'float' value at the specified address in memory.final ProgramFragment
getFragment
(ProgramModule module, String fragmentName) Returns the fragment with the specified name defined in the given module.final Function
getFunction
(String name) Deprecated, for removal: This API element is subject to removal in a future version.this method makes no sense in the new world order where function names no longer have to be unique.final Function
getFunctionAfter
(Address address) Returns the function defined after the specified address.final Function
getFunctionAfter
(Function function) Returns the function defined after the specified function in address order.final Function
getFunctionAt
(Address entryPoint) Returns the function with the specified entry point, or null if no function exists.final Function
getFunctionBefore
(Address address) Returns the function defined before the specified address.final Function
getFunctionBefore
(Function function) Returns the function defined before the specified function in address order.final Function
getFunctionContaining
(Address address) Returns the function containing the specified address.getGlobalFunctions
(String name) Returns a list of all functions in the global namespace with the given name.final Instruction
getInstructionAfter
(Address address) Returns the instruction defined after the specified address or null if no instruction exists.final Instruction
getInstructionAfter
(Instruction instruction) Returns the instruction defined after the specified instruction or null if no instruction exists.final Instruction
getInstructionAt
(Address address) Returns the instruction at the specified address or null if no instruction exists.final Instruction
getInstructionBefore
(Address address) Returns the instruction defined before the specified address or null if no instruction exists.final Instruction
getInstructionBefore
(Instruction instruction) Returns the instruction defined before the specified instruction or null if no instruction exists.final Instruction
getInstructionContaining
(Address address) Returns the instruction containing the specified address or null if no instruction exists.final int
Returns the 'integer' value at the specified address in memory.final Data
Returns the last defined data in the current program.final Function
Returns the last function in the current program.final Instruction
Returns the last instruction in the current program.final long
Returns the 'long' value at the specified address in memory.final MemoryBlock
getMemoryBlock
(Address address) Returns the memory block containing the specified address, or null if no memory block contains the address.final MemoryBlock
getMemoryBlock
(String name) Returns the first memory block with the specified name.final MemoryBlock[]
Returns an array containing all the memory blocks in the current program.Gets the current task monitor.final Namespace
getNamespace
(Namespace parent, String namespaceName) Returns the non-function namespace with the given name contained inside the specified parent namespace.final String
getPlateComment
(Address address) Returns the PLATE comment at the specified address.final String
getPostComment
(Address address) Returns the POST comment at the specified address.final String
getPreComment
(Address address) Returns the PRE comment at the specified address.final File
Returns theFile
that the program was originally imported from.This method looks up the current project and returns the root domain folder.final Reference
getReference
(Data data, Address toAddress) Returns the reference from the data to the given address.final Reference
getReference
(Instruction instruction, Address toAddress) Returns the reference from the instruction to the given address.final Reference[]
getReferencesFrom
(Address address) Returns an array of the references FROM the given address.final Reference[]
getReferencesTo
(Address address) Returns an array of the references TO the given address.final String
getRepeatableComment
(Address address) Returns the repeatable comment at the specified address.final short
Returns the 'short' value at the specified address in memory.final Symbol
Deprecated, for removal: This API element is subject to removal in a future version.final Symbol
getSymbolAfter
(Address address) Returns the next non-default primary symbol defined after the given address.final Symbol
getSymbolAfter
(Symbol symbol) Returns the next non-default primary symbol defined after the given symbol.final Symbol
getSymbolAt
(Address address) Returns the PRIMARY symbol at the specified address, or null if no symbol exists.final Symbol
getSymbolAt
(Address address, String name) Deprecated, for removal: This API element is subject to removal in a future version.Since the same label name can be at the same address if in a different namespace, this method is ambiguous.final Symbol
getSymbolAt
(Address address, String name, Namespace namespace) Returns the symbol with the specified address, name, and namespacefinal Symbol
getSymbolBefore
(Address address) Returns the previous non-default primary symbol defined after the previous address.final Symbol
getSymbolBefore
(Symbol symbol) Returns the previous non-default primary symbol defined before the given symbol.getSymbols
(String name, Namespace namespace) Returns a list of all the symbols with the given name in the given namespace.final Data
getUndefinedDataAfter
(Address address) Returns the undefined data after the specified address or null if no undefined data exists.final Data
getUndefinedDataAt
(Address address) Returns the undefined data at the specified address or null if no undefined data exists.final Data
getUndefinedDataBefore
(Address address) Returns the undefined data before the specified address or null if no undefined data exists.final FileDataTypeManager
openDataTypeArchive
(File archiveFile, boolean readOnly) Opens an existing File Data Type Archive.final void
removeBookmark
(Bookmark bookmark) Removes the specified bookmark.final void
removeData
(Data data) Removes the given data from the current program.final void
removeDataAt
(Address address) Removes the data containing the given address from the current program.final void
removeEntryPoint
(Address address) Removes the entry point at the specified address.final void
removeEquate
(Data data) Removes the equate defined on the data.final void
removeEquate
(Instruction instruction, int operandIndex, long value) Removes the equate defined at the operand index of the instruction with the given value.final void
removeEquates
(Instruction instruction, int operandIndex) Removes the equates defined at the operand index of the instruction.final void
removeFunction
(Function function) Removes the function from the current program.final void
removeFunctionAt
(Address entryPoint) Removes the function with the given entry point.final void
removeInstruction
(Instruction instruction) Removes the given instruction from the current program.final void
removeInstructionAt
(Address address) Removes the instruction containing the given address from the current program.final void
removeMemoryBlock
(MemoryBlock block) Remove the memory block.final void
removeReference
(Reference reference) Removes the given reference.final boolean
removeSymbol
(Address address, String name) Deletes the symbol with the specified name at the specified address.void
saveProgram
(Program program) Saves the changes to the specified program.void
saveProgram
(Program program, List<String> path) Saves changes to the specified program.protected void
set
(Program program, TaskMonitor monitor) Sets the current state.final void
Sets the 'byte' value at the specified address.final void
Sets the 'byte' values starting at the specified address.final void
Sets the 'double' value at the specified address.final boolean
setEOLComment
(Address address, String comment) Sets an EOL comment at the specified addressfinal void
Sets the 'float' value at the specified address.final void
Sets the 'integer' value at the specified address.final void
Sets the 'long' value at the specified address.final boolean
setPlateComment
(Address address, String comment) Sets a PLATE comment at the specified addressfinal boolean
setPostComment
(Address address, String comment) Sets a POST comment at the specified addressfinal boolean
setPreComment
(Address address, String comment) Sets a PRE comment at the specified addressfinal void
setReferencePrimary
(Reference reference) Sets the given reference as primary.final void
setReferencePrimary
(Reference reference, boolean primary) Sets the given reference as primary.final boolean
setRepeatableComment
(Address address, String comment) Sets a repeatable comment at the specified addressfinal void
Sets the 'short' value at the specified address.final void
start()
Starts a transaction on the current program.final Address
toAddr
(int offset) Returns a new address with the specified offset in the default address space.final Address
toAddr
(long offset) Returns a new address with the specified offset in the default address space.final Address
Returns a new address inside the specified program as indicated by the string.
-
Field Details
-
MAX_REFERENCES_TO
public static final int MAX_REFERENCES_TO- See Also:
-
currentProgram
-
monitor
-
-
Constructor Details
-
FlatProgramAPI
protected FlatProgramAPI()Constructs a new flat program API. It will not be usable until the 'set' method has been called. -
FlatProgramAPI
Constructs a new flat program API.- Parameters:
program
- the program
-
FlatProgramAPI
Constructs a new flat program API.- Parameters:
program
- the programmonitor
- the task monitor
-
-
Method Details
-
set
Sets the current state.- Parameters:
program
- the programmonitor
- the task monitor
-
getCurrentProgram
Gets the current program.- Returns:
- the program
-
getMonitor
Gets the current task monitor.- Returns:
- the task monitor
-
start
public final void start()Starts a transaction on the current program. -
end
public final void end(boolean commit) Ends the transactions on the current program.- Parameters:
commit
- true if changes should be committed
-
getProgramFile
Returns theFile
that the program was originally imported from. It does not necessarily still exist on the file system.For example,
c:\temp\test.exe
.- Returns:
- the
File
that the program was originally imported from
-
disassemble
Start disassembling at the specified address. The disassembler will follow code flows.- Parameters:
address
- the address to begin disassembling- Returns:
- true if the program was successfully disassembled
-
analyze
Deprecated, for removal: This API element is subject to removal in a future version.the methodanalyzeAll(ghidra.program.model.listing.Program)
oranalyzeChanges(ghidra.program.model.listing.Program)
should be invoked. These separate methods were created to clarify their true behavior since many times it is only necessary to analyze changes and not the entire program which can take much longer and affect more of the program than is necessary.Starts auto-analysis on the specified program and performs complete analysis of the entire program. This is usually only necessary if full analysis was never performed. This method will block until analysis completes.- Parameters:
program
- the program to analyze
-
analyzeAll
Starts auto-analysis on the specified program and performs complete analysis of the entire program. This is usually only necessary if full analysis was never performed. This method will block until analysis completes.- Parameters:
program
- the program to analyze
-
analyzeChanges
Starts auto-analysis if not started and waits for pending analysis to complete. Only pending analysis on program changes is performed, including changes resulting from any analysis activity. This method will block until analysis completes. NOTE: The auto-analysis manager will only detect program changes once it has been instantiated for a program (i.e, AutoAnalysisManager.getAnalysisManager(program) ). This is automatically done for the initial currentProgram, however, if a script is opening/instantiating its own programs it may be necessary to do this prior to making changes to the program.- Parameters:
program
- the program to analyze
-
clearListing
Clears the code unit (instruction or data) defined at the address.- Parameters:
address
- the address to clear the code unit- Throws:
CancelledException
- if cancelled
-
clearListing
Clears the code units (instructions or data) in the specified range.- Parameters:
start
- the start addressend
- the end address (INCLUSIVE)- Throws:
CancelledException
- if cancelled
-
clearListing
Clears the code units (instructions or data) in the specified set- Parameters:
set
- the set to clear- Throws:
CancelledException
- if cancelled
-
clearListing
public final boolean clearListing(AddressSetView set, boolean code, boolean symbols, boolean comments, boolean properties, boolean functions, boolean registers, boolean equates, boolean userReferences, boolean analysisReferences, boolean importReferences, boolean defaultReferences, boolean bookmarks) Clears the listing in the specified address set.- Parameters:
set
- the address set where to clearcode
- true if code units should be cleared (instructions and defined data)symbols
- true if symbols should be clearedcomments
- true if comments should be clearedproperties
- true if properties should be clearedfunctions
- true if functions should be clearedregisters
- true if registers should be clearedequates
- true if equates should be cleareduserReferences
- true if user references should be clearedanalysisReferences
- true if analysis references should be clearedimportReferences
- true if import references should be cleareddefaultReferences
- true if default references should be clearedbookmarks
- true if bookmarks should be cleared- Returns:
- true if the address set was successfully cleared
-
createMemoryBlock
public final MemoryBlock createMemoryBlock(String name, Address start, InputStream input, long length, boolean overlay) throws Exception Create a new memory block. If the input stream is null, then an uninitialized block will be created.- Parameters:
name
- the name of the blockstart
- start address of the blockinput
- source of the data used to fill the block.length
- the size of the blockoverlay
- true will create an overlay, false will not- Returns:
- the newly created memory block
- Throws:
Exception
- if there is any exception
-
createMemoryBlock
public final MemoryBlock createMemoryBlock(String name, Address start, byte[] bytes, boolean overlay) throws Exception Create a new memory block.- Parameters:
name
- the name of the blockstart
- start address of the blockbytes
- the bytes of the memory blockoverlay
- true will create an overlay, false will not- Returns:
- the newly created memory block
- Throws:
Exception
- if there is any exception
-
getMemoryBlock
Returns the first memory block with the specified name. NOTE: if more than block exists with the same name, the first block with that name will be returned.- Parameters:
name
- the name of the requested block- Returns:
- the the memory block with the specified name
-
getMemoryBlock
Returns the memory block containing the specified address, or null if no memory block contains the address.- Parameters:
address
- the address- Returns:
- the memory block containing the specified address
-
getMemoryBlocks
Returns an array containing all the memory blocks in the current program.- Returns:
- an array containing all the memory blocks
-
removeMemoryBlock
Remove the memory block. NOTE: ALL ANNOTATION (disassembly, comments, etc) defined in this memory block will also be removed!- Parameters:
block
- the block to be removed- Throws:
Exception
- if there is any exception
-
createLabel
Creates a label at the specified address in the global namespace. If makePrimary==true, then the new label is made primary.- Parameters:
address
- the address to create the symbolname
- the name of the symbolmakePrimary
- true if the symbol should be made primary- Returns:
- the newly created code or function symbol
- Throws:
Exception
- if there is any exception
-
createSymbol
@Deprecated(since="7.4", forRemoval=true) public final Symbol createSymbol(Address address, String name, boolean makePrimary) throws Exception Deprecated, for removal: This API element is subject to removal in a future version.usecreateLabel(Address, String, boolean)
instead. Deprecated in Ghidra 7.4- Throws:
Exception
-
createLabel
public final Symbol createLabel(Address address, String name, boolean makePrimary, SourceType sourceType) throws Exception Creates a label at the specified address in the global namespace. If makePrimary==true, then the new label is made primary. If makeUnique==true, then if the name is a duplicate, the address will be concatenated to name to make it unique.- Parameters:
address
- the address to create the symbolname
- the name of the symbolmakePrimary
- true if the symbol should be made primarysourceType
- the source type.- Returns:
- the newly created code or function symbol
- Throws:
Exception
- if there is any exception
-
createLabel
public final Symbol createLabel(Address address, String name, Namespace namespace, boolean makePrimary, SourceType sourceType) throws Exception Creates a label at the specified address in the specified namespace. If makePrimary==true, then the new label is made primary if permitted. If makeUnique==true, then if the name is a duplicate, the address will be concatenated to name to make it unique.- Parameters:
address
- the address to create the symbolname
- the name of the symbolnamespace
- label's parent namespacemakePrimary
- true if the symbol should be made primarysourceType
- the source type.- Returns:
- the newly created code or function symbol
- Throws:
Exception
- if there is any exception
-
createSymbol
@Deprecated(since="7.4", forRemoval=true) public final Symbol createSymbol(Address address, String name, boolean makePrimary, boolean makeUnique, SourceType sourceType) throws Exception Deprecated, for removal: This API element is subject to removal in a future version.usecreateLabel(Address, String, boolean, SourceType)
instead. Deprecated in Ghidra 7.4- Throws:
Exception
-
addEntryPoint
Adds an entry point at the specified address.- Parameters:
address
- address to create entry point
-
removeEntryPoint
Removes the entry point at the specified address.- Parameters:
address
- address of entry point to remove
-
removeSymbol
Deletes the symbol with the specified name at the specified address.- Parameters:
address
- the address of the symbol to deletename
- the name of the symbol to delete- Returns:
- true if the symbol was deleted
-
setPlateComment
Sets a PLATE comment at the specified address- Parameters:
address
- the address to set the PLATE commentcomment
- the PLATE comment- Returns:
- true if the PLATE comment was successfully set
-
setPreComment
Sets a PRE comment at the specified address- Parameters:
address
- the address to set the PRE commentcomment
- the PRE comment- Returns:
- true if the PRE comment was successfully set
-
setPostComment
Sets a POST comment at the specified address- Parameters:
address
- the address to set the POST commentcomment
- the POST comment- Returns:
- true if the POST comment was successfully set
-
setEOLComment
Sets an EOL comment at the specified address- Parameters:
address
- the address to set the EOL commentcomment
- the EOL comment- Returns:
- true if the EOL comment was successfully set
-
setRepeatableComment
Sets a repeatable comment at the specified address- Parameters:
address
- the address to set the repeatable commentcomment
- the repeatable comment- Returns:
- true if the repeatable comment was successfully set
-
getPlateComment
Returns the PLATE comment at the specified address. The comment returned is the raw text of the comment. Contrastingly, callingGhidraScript.getPlateCommentAsRendered(Address)
will return the text of the comment as it is rendered in the display.- Parameters:
address
- the address to get the comment- Returns:
- the PLATE comment at the specified address or null if one does not exist
- See Also:
-
getPreComment
Returns the PRE comment at the specified address. The comment returned is the raw text of the comment. Contrastingly, callingGhidraScript.getPreCommentAsRendered(Address)
will return the text of the comment as it is rendered in the display.- Parameters:
address
- the address to get the comment- Returns:
- the PRE comment at the specified address or null if one does not exist
- See Also:
-
getPostComment
Returns the POST comment at the specified address. The comment returned is the raw text of the comment. Contrastingly, callingGhidraScript.getPostCommentAsRendered(Address)
will return the text of the comment as it is rendered in the display.- Parameters:
address
- the address to get the comment- Returns:
- the POST comment at the specified address or null if one does not exist
- See Also:
-
getEOLComment
Returns the EOL comment at the specified address. The comment returned is the raw text of the comment. Contrastingly, callingGhidraScript.getEOLCommentAsRendered(Address)
will return the text of the comment as it is rendered in the display.- Parameters:
address
- the address to get the comment- Returns:
- the EOL comment at the specified address or null if one does not exist
- See Also:
-
getRepeatableComment
Returns the repeatable comment at the specified address. The comment returned is the raw text of the comment. Contrastingly, callingGhidraScript.getRepeatableCommentAsRendered(Address)
will return the text of the comment as it is rendered in the display.- Parameters:
address
- the address to get the comment- Returns:
- the repeatable comment at the specified address or null if one does not exist
- See Also:
-
find
Finds the first occurrence of the byte starting from the address. If the start address is null, then the find will start from the minimum address of the program.- Parameters:
start
- the address to start searchingvalue
- the byte to search for- Returns:
- the first address where the byte was found
-
find
Finds the first occurrence of the byte array sequence starting from the address. If the start address is null, then the find will start from the minimum address of the program.- Parameters:
start
- the address to start searchingvalues
- the byte array sequence to search for- Returns:
- the first address where the byte was found, or null if the bytes were not found
-
findBytes
Finds the first occurrence of the byte array sequence that matches the given byte string, starting from the address. If the start address is null, then the find will start from the minimum address of the program.The
byteString
may contain regular expressions. The following highlights some example search strings (note the use of double backslashes ("\\")):"\\x80" - A basic search pattern for a byte value of 0x80 "\\x50.{0,10}\\x55" - A regular expression string that searches for the byte 0x50 followed by 0-10 occurrences of any byte value, followed by the byte 0x55
- Parameters:
start
- the address to start searching. If null, then the start of the program will be used.byteString
- the byte pattern for which to search- Returns:
- the first address where the byte was found, or null if the bytes were not found
- Throws:
IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
-
findBytes
Finds the first<matchLimit>
occurrences of the byte array sequence that matches the given byte string, starting from the address. If the start address is null, then the find will start from the minimum address of the program.The
byteString
may contain regular expressions. The following highlights some example search strings (note the use of double backslashes ("\\")):"\\x80" - A basic search pattern for a byte value of 0x80 "\\x50.{0,10}\\x55" - A regular expression string that searches for the byte 0x50 followed by 0-10 occurrences of any byte value, followed by the byte 0x55
- Parameters:
start
- the address to start searching. If null, then the start of the program will be used.byteString
- the byte pattern for which to searchmatchLimit
- The number of matches to which the search should be restricted- Returns:
- the start addresses that contain byte patterns that match the given byteString
- Throws:
IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
-
findBytes
Finds the first<matchLimit>
occurrences of the byte array sequence that matches the given byte string, starting from the address. If the start address is null, then the find will start from the minimum address of the program.The
byteString
may contain regular expressions. The following highlights some example search strings (note the use of double backslashes ("\\")):"\\x80" - A basic search pattern for a byte value of 0x80 "\\x50.{0,10}\\x55" - A regular expression string that searches for the byte 0x50 followed by 0-10 occurrences of any byte value, followed by the byte 0x55
- Parameters:
start
- the address to start searching. If null, then the start of the program will be used.byteString
- the byte pattern for which to searchmatchLimit
- The number of matches to which the search should be restrictedalignment
- byte alignment to use for search starts. For example, a value of 1 searches from every byte. A value of 2 only matches runs that begin on a even address boundary.- Returns:
- the start addresses that contain byte patterns that match the given byteString
- Throws:
IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
-
findBytes
public final Address[] findBytes(AddressSetView set, String byteString, int matchLimit, int alignment) Finds a byte pattern within an addressSet. Note: The ranges within the addressSet are NOT treated as a contiguous set when searchingThe
byteString
may contain regular expressions. The following highlights some example search strings (note the use of double backslashes ("\\")):"\\x80" - A basic search pattern for a byte value of 0x80 "\\x50.{0,10}\\x55" - A regular expression string that searches for the byte 0x50 followed by 0-10 occurrences of any byte value, followed by the byte 0x55
- Parameters:
set
- the addressSet specifying which addresses to search.byteString
- the byte pattern for which to searchmatchLimit
- The number of matches to which the search should be restrictedalignment
- byte alignment to use for search starts. For example, a value of 1 searches from every byte. A value of 2 only matches runs that begin on a even address boundary.- Returns:
- the start addresses that contain byte patterns that match the given byteString
- Throws:
IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
-
findBytes
public final Address[] findBytes(AddressSetView set, String byteString, int matchLimit, int alignment, boolean searchAcrossAddressGaps) Finds a byte pattern within an addressSet. Note: When searchAcrossAddressGaps is set to true, the ranges within the addressSet are treated as a contiguous set when searching.The
byteString
may contain regular expressions. The following highlights some example search strings (note the use of double backslashes ("\\")):"\\x80" - A basic search pattern for a byte value of 0x80 "\\x50.{0,10}\\x55" - A regular expression string that searches for the byte 0x50 followed by 0-10 occurrences of any byte value, followed by the byte 0x55
- Parameters:
set
- the addressSet specifying which addresses to search.byteString
- the byte pattern for which to searchmatchLimit
- The number of matches to which the search should be restrictedalignment
- byte alignment to use for search starts. For example, a value of 1 searches from every byte. A value of 2 only matches runs that begin on a even address boundary.searchAcrossAddressGaps
- when set to 'true' searches for matches across the gaps of each addressRange contained in the addresSet.- Returns:
- the start addresses that contain byte patterns that match the given byteString
- Throws:
IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
-
find
Finds the first occurrence of 'text' in the program listing. The search order is defined as:- PLATE comments
- PRE comments
- labels
- code unit mnemonics and operands
- EOL comments
- repeatable comments
- POST comments
- Parameters:
text
- the text to search for- Returns:
- the first address where the 'text' was found, or null if the text was not found
-
findStrings
public List<FoundString> findStrings(AddressSetView addressSet, int minimumStringLength, int alignment, boolean requireNullTermination, boolean includeAllCharWidths) Search for sequences of Ascii strings in program memory. SeeAsciiCharSetRecognizer
to see exactly what chars are considered ASCII for purposes of this search.- Parameters:
addressSet
- The address set to search. Use null to search all memory;minimumStringLength
- The smallest number of chars in a sequence to be considered a "string".alignment
- specifies any alignment requirements for the start of the string. An alignment of 1, means the string can start at any address. An alignment of 2 means the string must start on an even address and so on. Only allowed values are 1,2, and 4.requireNullTermination
- If true, only strings that end in a null will be returned.includeAllCharWidths
- if true, UTF16 and UTF32 size strings will be included in addition to UTF8.- Returns:
- a list of "FoundString" objects which contain the addresses, length, and type of possible strings.
-
findPascalStrings
public List<FoundString> findPascalStrings(AddressSetView addressSet, int minimumStringLength, int alignment, boolean includePascalUnicode) Search for sequences of Pascal Ascii strings in program memory. SeeAsciiCharSetRecognizer
to see exactly what chars are considered ASCII for purposes of this search.- Parameters:
addressSet
- The address set to search. Use null to search all memory;minimumStringLength
- The smallest number of chars in a sequence to be considered a "string".alignment
- specifies any alignment requirements for the start of the string. An alignment of 1, means the string can start at any address. An alignment of 2 means the string must start on an even address and so on. Only allowed values are 1,2, and 4.includePascalUnicode
- if true, UTF16 size strings will be included in addition to UTF8.- Returns:
- a list of "FoundString" objects which contain the addresses, length, and type of possible strings.
-
createFunction
Creates a function at entry point with the specified name- Parameters:
entryPoint
- the entry point of the functionname
- the name of the function or null for a default function- Returns:
- the new function or null if the function was not created
-
removeFunction
Removes the function from the current program.- Parameters:
function
- the function to remove
-
removeFunctionAt
Removes the function with the given entry point.- Parameters:
entryPoint
- the entry point of the function to remove
-
getFunctionAt
Returns the function with the specified entry point, or null if no function exists.- Parameters:
entryPoint
- the function entry point address- Returns:
- the function with the specified entry point, or null if no function exists
-
getFunctionContaining
Returns the function containing the specified address.- Parameters:
address
- the address- Returns:
- the function containing the specified address
-
getFunctionBefore
Returns the function defined before the specified function in address order.- Parameters:
function
- the function- Returns:
- the function defined before the specified function
-
getFunctionBefore
Returns the function defined before the specified address.- Parameters:
address
- the address- Returns:
- the function defined before the specified address
-
getFunctionAfter
Returns the function defined after the specified function in address order.- Parameters:
function
- the function- Returns:
- the function defined after the specified function
-
getFunctionAfter
Returns the function defined after the specified address.- Parameters:
address
- the address- Returns:
- the function defined after the specified address
-
getFunction
Deprecated, for removal: This API element is subject to removal in a future version.this method makes no sense in the new world order where function names no longer have to be unique. UsegetGlobalFunctions(String)
Deprecated in Ghidra 7.4Returns the function with the specified name, or null if no function exists. (Now returns the first one it finds with that name)- Parameters:
name
- the name of the function- Returns:
- the function with the specified name, or null if no function exists
-
getGlobalFunctions
Returns a list of all functions in the global namespace with the given name.- Parameters:
name
- the name of the function- Returns:
- the function with the specified name, or
-
getFirstFunction
Returns the first function in the current program.- Returns:
- the first function in the current program
-
getLastFunction
Returns the last function in the current program.- Returns:
- the last function in the current program
-
getFirstInstruction
Returns the first instruction in the current program.- Returns:
- the first instruction in the current program
-
getFirstInstruction
Returns the first instruction in the function.- Parameters:
function
- the function- Returns:
- the first instruction in the function
-
getLastInstruction
Returns the last instruction in the current program.- Returns:
- the last instruction in the current program
-
getInstructionAt
Returns the instruction at the specified address or null if no instruction exists.- Parameters:
address
- the instruction address- Returns:
- the instruction at the specified address or null if no instruction exists
-
getInstructionContaining
Returns the instruction containing the specified address or null if no instruction exists.- Parameters:
address
- the instruction address- Returns:
- the instruction containing the specified address or null if no instruction exists
-
getInstructionBefore
Returns the instruction defined before the specified instruction or null if no instruction exists. The instruction that is returned does not have to be contiguous.- Parameters:
instruction
- the instruction- Returns:
- the instruction defined before the specified instruction or null if no instruction exists
-
getInstructionBefore
Returns the instruction defined before the specified address or null if no instruction exists. The instruction that is returned does not have to be contiguous.- Parameters:
address
- the address of the instruction- Returns:
- the instruction defined before the specified address or null if no instruction exists
-
getInstructionAfter
Returns the instruction defined after the specified instruction or null if no instruction exists. The instruction that is returned does not have to be contiguous.- Parameters:
instruction
- the instruction- Returns:
- the instruction defined after the specified instruction or null if no instruction exists
-
getInstructionAfter
Returns the instruction defined after the specified address or null if no instruction exists. The instruction that is returned does not have to be contiguous.- Parameters:
address
- the address of the prior instruction- Returns:
- the instruction defined after the specified address or null if no instruction exists
-
getFirstData
Returns the first defined data in the current program.- Returns:
- the first defined data in the current program
-
getLastData
Returns the last defined data in the current program.- Returns:
- the last defined data in the current program
-
getDataAt
Returns the defined data at the specified address or null if no data exists.- Parameters:
address
- the data address- Returns:
- the data at the specified address or null if no data exists
-
getDataContaining
Returns the defined data containing the specified address or null if no data exists.- Parameters:
address
- the data address- Returns:
- the defined data containing the specified address or null if no data exists
-
getDataBefore
Returns the defined data before the specified data or null if no data exists.- Parameters:
data
- the succeeding data- Returns:
- the defined data before the specified data or null if no data exists
-
getDataBefore
Returns the defined data before the specified address or null if no data exists.- Parameters:
address
- the data address- Returns:
- the defined data before the specified address or null if no data exists
-
getDataAfter
Returns the defined data after the specified data or null if no data exists.- Parameters:
data
- preceeding data- Returns:
- the defined data after the specified data or null if no data exists
-
getDataAfter
Returns the defined data after the specified address or null if no data exists.- Parameters:
address
- the data address- Returns:
- the defined data after the specified address or null if no data exists
-
getUndefinedDataAt
Returns the undefined data at the specified address or null if no undefined data exists.- Parameters:
address
- the undefined data address- Returns:
- the undefined data at the specified address or null if no undefined data exists
-
getUndefinedDataBefore
Returns the undefined data before the specified address or null if no undefined data exists.- Parameters:
address
- the undefined data address- Returns:
- the undefined data before the specified address or null if no undefined data exists
-
getUndefinedDataAfter
Returns the undefined data after the specified address or null if no undefined data exists.- Parameters:
address
- the undefined data address- Returns:
- the undefined data after the specified address or null if no undefined data exists
-
getSymbolAt
@Deprecated(since="7.4", forRemoval=true) public final Symbol getSymbolAt(Address address, String name) Deprecated, for removal: This API element is subject to removal in a future version.Since the same label name can be at the same address if in a different namespace, this method is ambiguous. UsegetSymbolAt(Address, String, Namespace)
instead.Returns the symbol with the specified address and name, or null if no symbol exists.- Parameters:
address
- the symbol addressname
- the symbol name- Returns:
- the symbol with the specified address and name, or null if no symbol exists
-
getSymbolAt
Returns the symbol with the specified address, name, and namespace- Parameters:
address
- the symbol addressname
- the symbol namenamespace
- the parent namespace for the symbol.- Returns:
- the symbol with the specified address, name, and namespace, or null if no symbol exists
-
getSymbolAfter
Returns the next non-default primary symbol defined after the given symbol.- Parameters:
symbol
- the symbol to use as a starting point- Returns:
- the next non-default primary symbol
-
getSymbolAfter
Returns the next non-default primary symbol defined after the given address.- Parameters:
address
- the address to use as a starting point- Returns:
- the next non-default primary symbol
-
getSymbolBefore
Returns the previous non-default primary symbol defined before the given symbol.- Parameters:
symbol
- the symbol to use as a starting point- Returns:
- the previous non-default primary symbol
-
getSymbolBefore
Returns the previous non-default primary symbol defined after the previous address.- Parameters:
address
- the address to use as a starting point- Returns:
- the next non-default primary symbol
-
getSymbolAt
Returns the PRIMARY symbol at the specified address, or null if no symbol exists.- Parameters:
address
- the symbol address- Returns:
- the PRIMARY symbol at the specified address, or null if no symbol exists
-
getSymbol
@Deprecated(since="7.4", forRemoval=true) public final Symbol getSymbol(String name, Namespace namespace) Deprecated, for removal: This API element is subject to removal in a future version.Returns the symbol with the given name in the given namespace if there is only one. Passnull
for namespace to indicate the global namespace.- Parameters:
name
- the name of the symbolnamespace
- the parent namespace, or null for global namespace- Returns:
- the symbol with the given name in the given namespace
- Throws:
IllegalStateException
- if there is more than one symbol with that name.
-
getSymbols
Returns a list of all the symbols with the given name in the given namespace.- Parameters:
name
- the name of the symbols to retrieve.namespace
- the namespace containing the symbols, or null for the global namespace.- Returns:
- a list of all the symbols with the given name in the given namespace.
-
getNamespace
Returns the non-function namespace with the given name contained inside the specified parent namespace. Passnull
for parent to indicate the global namespace.- Parameters:
parent
- the parent namespace, or null for global namespacenamespaceName
- the requested namespace's name- Returns:
- the namespace with the given name or null if not found
-
createNamespace
public final Namespace createNamespace(Namespace parent, String namespaceName) throws DuplicateNameException, InvalidInputException Creates a newNamespace
with the given name contained inside the specified parent namespace. Passnull
for parent to indicate the global namespace. If aNamespace
orGhidraClass
with the given name already exists, the existing one will be returned.- Parameters:
parent
- the parent namespace, or null for global namespacenamespaceName
- the requested namespace's name- Returns:
- the namespace with the given name
- Throws:
DuplicateNameException
- if aLibrary
symbol exists with the given nameInvalidInputException
- if the name is invalidIllegalArgumentException
- if parent Namespace does not correspond tocurrerntProgram
-
createClass
public final GhidraClass createClass(Namespace parent, String className) throws DuplicateNameException, InvalidInputException Creates a newGhidraClass
with the given name contained inside the specified parent namespace. Passnull
for parent to indicate the global namespace. If a GhidraClass with the given name already exists, the existing one will be returned.- Parameters:
parent
- the parent namespace, or null for global namespaceclassName
- the requested classes name- Returns:
- the GhidraClass with the given name
- Throws:
InvalidInputException
- if the name is invalidDuplicateNameException
- thrown if aLibrary
orNamespace
symbol already exists with the given name. UseSymbolTable.convertNamespaceToClass(Namespace)
for converting an existing Namespace to a GhidraClass.IllegalArgumentException
- if the given parent namespace is not from thecurrentProgram
.ConcurrentModificationException
- if the given parent has been deletedIllegalArgumentException
- if parent Namespace does not correspond tocurrerntProgram
- See Also:
-
createFragment
@Deprecated(since="7.4", forRemoval=true) public final ProgramFragment createFragment(String fragmentName, Address start, Address end) throws DuplicateNameException, NotFoundException Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated because it did not allow you to include the largest possible address. Instead use the one that takes a start address and a length.Creates a fragment in the root folder of the default program tree.- Parameters:
fragmentName
- the name of the fragmentstart
- the start addressend
- the end address (NOT INCLUSIVE)- Returns:
- the newly created fragment
- Throws:
DuplicateNameException
- if the given fragment name already existsNotFoundException
- if any address in the fragment would be outside of the program
-
createFragment
public final ProgramFragment createFragment(String fragmentName, Address start, long length) throws DuplicateNameException, NotFoundException Creates a fragment in the root folder of the default program tree.- Parameters:
fragmentName
- the name of the fragmentstart
- the start addresslength
- the length of the fragment- Returns:
- the newly created fragment
- Throws:
DuplicateNameException
- if the given fragment name already existsNotFoundException
- if any address in the fragment would be outside of the program
-
createFragment
@Deprecated(since="7.4", forRemoval=true) public final ProgramFragment createFragment(ProgramModule module, String fragmentName, Address start, Address end) throws DuplicateNameException, NotFoundException Deprecated, for removal: This API element is subject to removal in a future version.This method is deprecated because it did not allow you to include the largest possible address. Instead use the one that takes a start address and a length.Creates a fragment in the given folder of the default program tree.- Parameters:
module
- the parent module (or folder)fragmentName
- the name of the fragmentstart
- the start addressend
- the end address (NOT INCLUSIVE)- Returns:
- the newly created fragment
- Throws:
DuplicateNameException
- if the given fragment name already existsNotFoundException
- if any address in the fragment would be outside of the program
-
createFragment
public final ProgramFragment createFragment(ProgramModule module, String fragmentName, Address start, long length) throws DuplicateNameException, NotFoundException Creates a fragment in the given folder of the default program tree.- Parameters:
module
- the parent module (or folder)fragmentName
- the name of the fragmentstart
- the start addresslength
- the length of the fragment- Returns:
- the newly created fragment
- Throws:
DuplicateNameException
- if the given fragment name already existsNotFoundException
- if any address in the fragment would be outside of the program
-
getFragment
Returns the fragment with the specified name defined in the given module.- Parameters:
module
- the parent modulefragmentName
- the fragment name- Returns:
- the fragment or null if one does not exist
-
createAddressSet
Creates a new mutable address set.- Returns:
- a new mutable address set
-
getAddressFactory
-
getDataTypes
Searches through the datatype manager of the current program and returns an array of datatypes that match the specified name. The datatype manager supports datatypes of the same name in different categories. A zero-length array indicates that no datatypes with the specified name exist.- Parameters:
name
- the name of the desired datatype- Returns:
- an array of datatypes that match the specified name
-
createData
Creates a new defined Data object at the given address.- Parameters:
address
- the address at which to create a new Data object.datatype
- the Data Type that describes the type of Data object to create.- Returns:
- the newly created Data object
- Throws:
CodeUnitInsertionException
- if a conflicting code unit already exists
-
createByte
Creates a byte datatype at the given address.- Parameters:
address
- the address to create the byte- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
createWord
Creates a word datatype at the given address.- Parameters:
address
- the address to create the word- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
createDWord
Creates a dword datatype at the given address.- Parameters:
address
- the address to create the dword- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
createDwords
Creates a list of dword datatypes starting at the given address.- Parameters:
start
- the start address to create the dwordscount
- the number of dwords to create- Throws:
Exception
- if there is any exception
-
createQWord
Creates a qword datatype at the given address.- Parameters:
address
- the address to create the qword- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
createFloat
Creates a float datatype at the given address.- Parameters:
address
- the address to create the float- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
createDouble
Creates a double datatype at the given address.- Parameters:
address
- the address to create the double- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
createChar
Creates a char datatype at the given address.- Parameters:
address
- the address to create the char- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
createAsciiString
Creates a null terminated ascii string starting at the specified address.- Parameters:
address
- the address to create the string- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
createAsciiString
Create an ASCII string at the specified address.- Parameters:
address
- the addresslength
- length of string (a value of 0 or negative will force use of dynamic null terminated string)- Returns:
- string data created
- Throws:
CodeUnitInsertionException
- if there is a data conflict
-
createUnicodeString
Creates a null terminated unicode string starting at the specified address.- Parameters:
address
- the address to create the string- Returns:
- the newly created Data object
- Throws:
Exception
- if there is any exception
-
removeData
Removes the given data from the current program.- Parameters:
data
- the data to remove- Throws:
Exception
- if there is any exception
-
removeDataAt
Removes the data containing the given address from the current program.- Parameters:
address
- the address to remove data- Throws:
Exception
- if there is any exception
-
removeInstruction
Removes the given instruction from the current program.- Parameters:
instruction
- the instruction to remove- Throws:
Exception
- if there is any exception
-
removeInstructionAt
Removes the instruction containing the given address from the current program.- Parameters:
address
- the address to remove instruction- Throws:
Exception
- if there is any exception
-
addInstructionXref
Adds a cross reference (XREF).- Parameters:
from
- the source address of the referenceto
- the destination address of the referenceopIndex
- the operand index (-1 indicates the mnemonic)type
- the flow type- Returns:
- the newly created reference
- See Also:
-
toAddr
Returns a new address with the specified offset in the default address space.- Parameters:
offset
- the offset for the new address- Returns:
- a new address with the specified offset in the default address space
-
toAddr
Returns a new address with the specified offset in the default address space.- Parameters:
offset
- the offset for the new address- Returns:
- a new address with the specified offset in the default address space
-
toAddr
Returns a new address inside the specified program as indicated by the string.- Parameters:
addressString
- string representation of the address desired- Returns:
- the address. Otherwise, return null if the string fails to evaluate to a legitimate address
-
getByte
Returns the signed 'byte' value at the specified address in memory.- Parameters:
address
- the address- Returns:
- the signed 'byte' value at the specified address in memory
- Throws:
MemoryAccessException
- if the memory is not readable
-
getBytes
Reads length number of signed bytes starting at the specified address. Note: this could be inefficient if length is large- Parameters:
address
- the address to start readinglength
- the number of bytes to read- Returns:
- an array of signed bytes
- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized- See Also:
-
setByte
Sets the 'byte' value at the specified address.- Parameters:
address
- the address to set the 'byte'value
- the value to set- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized
-
setBytes
Sets the 'byte' values starting at the specified address.- Parameters:
address
- the address to set the bytesvalues
- the values to set- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized
-
getShort
Returns the 'short' value at the specified address in memory.- Parameters:
address
- the address- Returns:
- the 'short' value at the specified address in memory
- Throws:
MemoryAccessException
- if the memory is not readable
-
setShort
Sets the 'short' value at the specified address.- Parameters:
address
- the address to set the 'short'value
- the value to set- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized
-
getInt
Returns the 'integer' value at the specified address in memory.- Parameters:
address
- the address- Returns:
- the 'integer' value at the specified address in memory
- Throws:
MemoryAccessException
- if the memory is not readable
-
setInt
Sets the 'integer' value at the specified address.- Parameters:
address
- the address to set the 'integer'value
- the value to set- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized
-
getLong
Returns the 'long' value at the specified address in memory.- Parameters:
address
- the address- Returns:
- the 'long' value at the specified address in memory
- Throws:
MemoryAccessException
- if the memory is not readable
-
setLong
Sets the 'long' value at the specified address.- Parameters:
address
- the address to set the 'long'value
- the value to set- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized
-
getFloat
Returns the 'float' value at the specified address in memory.- Parameters:
address
- the address- Returns:
- the 'float' value at the specified address in memory
- Throws:
MemoryAccessException
- if the memory is not readable
-
setFloat
Sets the 'float' value at the specified address.- Parameters:
address
- the address to set the 'float'value
- the value to set- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized
-
getDouble
Returns the 'double' value at the specified address in memory.- Parameters:
address
- the address- Returns:
- the 'double' value at the specified address in memory
- Throws:
MemoryAccessException
- if the memory is not readable
-
setDouble
Sets the 'double' value at the specified address.- Parameters:
address
- the address to set the 'double'value
- the value to set- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized
-
getReferencesFrom
Returns an array of the references FROM the given address.- Parameters:
address
- the from address of the references- Returns:
- an array of the references FROM the given address
-
getReferencesTo
Returns an array of the references TO the given address. Note: If more than 4096 references exists to this address, only the first 4096 will be returned. If you need to access all the references, please refer to the methodReferenceManager::getReferencesTo(Address)
.- Parameters:
address
- the from address of the references- Returns:
- an array of the references TO the given address
-
getReference
Returns the reference from the instruction to the given address.- Parameters:
instruction
- the instructiontoAddress
- the destination address- Returns:
- the reference from the instruction to the given address
-
getReference
Returns the reference from the data to the given address.- Parameters:
data
- the datatoAddress
- the destination address- Returns:
- the reference from the data to the given address
-
createMemoryReference
public final Reference createMemoryReference(Instruction instruction, int operandIndex, Address toAddress, RefType flowType) Creates a memory reference from the given instruction.- Parameters:
instruction
- the instructionoperandIndex
- the operand index on the instructiontoAddress
- the TO addressflowType
- the flow type of the reference- Returns:
- the newly created memory reference
-
createMemoryReference
Creates a memory reference from the given data.- Parameters:
data
- the datatoAddress
- the TO addressdataRefType
- the type of the reference- Returns:
- the newly created memory reference
-
createExternalReference
public final Reference createExternalReference(Instruction instruction, int operandIndex, String libraryName, String externalLabel, Address externalAddr) throws Exception Creates an external reference from the given instruction. For instructions with flow, the FlowType will be assumed, otherwiseRefType.DATA
will be assumed. To specify the appropriate RefType use the alternate form of this method.- Parameters:
instruction
- the instructionoperandIndex
- the operand index on the instructionlibraryName
- the name of the library being referredexternalLabel
- the name of function in the library being referredexternalAddr
- the address of the function in the library being referred- Returns:
- the newly created external reference
- Throws:
Exception
- if an exception occurs
-
createExternalReference
public final Reference createExternalReference(Instruction instruction, int operandIndex, String libraryName, String externalLabel, Address externalAddr, RefType refType) throws Exception Creates an external reference from the given instruction.- Parameters:
instruction
- the instructionoperandIndex
- the operand index on the instructionlibraryName
- the name of the library being referredexternalLabel
- the name of function in the library being referredexternalAddr
- the address of the function in the library being referredrefType
- the appropriate external reference type (e.g., DATA, COMPUTED_CALL, etc.)- Returns:
- the newly created external reference
- Throws:
Exception
- if an exception occurs
-
createExternalReference
public final Reference createExternalReference(Data data, String libraryName, String externalLabel, Address externalAddr) throws Exception Creates an external reference from the given data. The reference typeRefType.DATA
will be used.- Parameters:
data
- the datalibraryName
- the name of the library being referredexternalLabel
- the name of function in the library being referredexternalAddr
- the address of the function in the library being referred- Returns:
- the newly created external reference
- Throws:
Exception
- if an exception occurs
-
createStackReference
public final Reference createStackReference(Instruction instruction, int operandIndex, int stackOffset, boolean isWrite) Create a stack reference from the given instruction- Parameters:
instruction
- the instructionoperandIndex
- the operand index on the instructionstackOffset
- the stack offset of the referenceisWrite
- true if the reference is WRITE access or false if the reference is READ access- Returns:
- the newly created stack reference
-
removeReference
Removes the given reference.- Parameters:
reference
- the reference to remove
-
setReferencePrimary
Sets the given reference as primary.- Parameters:
reference
- the reference to mark as primary
-
setReferencePrimary
Sets the given reference as primary.- Parameters:
reference
- the referenceprimary
- true if primary, false not primary
-
createEquate
public final Equate createEquate(Instruction instruction, int operandIndex, String equateName) throws Exception Creates a new equate on the scalar value at the operand index of the instruction.- Parameters:
instruction
- the instructionoperandIndex
- the operand index on the instructionequateName
- the name of the equate- Returns:
- the newly created equate
- Throws:
Exception
- if a scalar does not exist of the specified operand index of the instruction
-
createEquate
Creates a new equate on the scalar value at the value of the data.- Parameters:
data
- the dataequateName
- the name of the equate- Returns:
- the newly created equate
- Throws:
InvalidInputException
- if a scalar does not exist on the dataException
- if there is any exception
-
getEquate
Returns the equate defined at the operand index of the instruction with the given value.- Parameters:
instruction
- the instructionoperandIndex
- the operand indexvalue
- scalar equate value- Returns:
- the equate defined at the operand index of the instruction
-
getEquates
Returns the equates defined at the operand index of the instruction.- Parameters:
instruction
- the instructionoperandIndex
- the operand index- Returns:
- the equate defined at the operand index of the instruction
-
getEquate
Returns the equate defined on the data.- Parameters:
data
- the data- Returns:
- the equate defined on the data
-
removeEquate
Removes the equate defined at the operand index of the instruction with the given value.- Parameters:
instruction
- the instructionoperandIndex
- the operand indexvalue
- scalar value corresponding to equate
-
removeEquates
Removes the equates defined at the operand index of the instruction.- Parameters:
instruction
- the instructionoperandIndex
- the operand index
-
removeEquate
Removes the equate defined on the data.- Parameters:
data
- the data
-
createBookmark
Creates aNOTE
bookmark at the specified address
NOTE: if aNOTE
bookmark already exists at the address, it will be replaced. This is intentional and is done to match the behavior of setting bookmarks from the UI.- Parameters:
address
- the address to create the bookmarkcategory
- the bookmark category (it may be null)note
- the bookmark text- Returns:
- the newly created bookmark
-
getBookmarks
Returns all of the NOTE bookmarks defined at the specified address- Parameters:
address
- the address to retrieve the bookmark- Returns:
- the bookmarks at the specified address
-
removeBookmark
Removes the specified bookmark.- Parameters:
bookmark
- the bookmark to remove
-
openDataTypeArchive
public final FileDataTypeManager openDataTypeArchive(File archiveFile, boolean readOnly) throws Exception Opens an existing File Data Type Archive.NOTE: If archive has an assigned architecture, issues may arise due to a revised or missing
Language
/CompilerSpec
which will result in a warning but not prevent the archive from being opened. Such a warning condition will be logged and may result in missing or stale information for existing datatypes which have architecture related data. In some case it may be appropriate tocheck for warnings
on the returned archive object prior to its use.- Parameters:
archiveFile
- the archive file to openreadOnly
- should file be opened read only- Returns:
- the data type manager
- Throws:
Exception
- if there is any exception
-
saveProgram
Saves the changes to the specified program. If the program does not already exist in the current project then it will be saved into the root folder. If a program already exists with the specified name, then a time stamp will be appended to the name to make it unique.- Parameters:
program
- the program to save- Throws:
Exception
- if there is any exception
-
saveProgram
Saves changes to the specified program.If the program does not already exist in the current project then it will be saved into a project folder path specified by the path parameter.
If path is NULL, the program will be saved into the root folder. If parts of the path are missing, they will be created if possible.
If a program already exists with the specified name, then a time stamp will be appended to the name to make it unique.
- Parameters:
program
- the program to savepath
- list of string path elements (starting at the root of the project) that specify the project folder to save the program info. Example: { "folder1", "subfolder2", "final_folder" }- Throws:
Exception
- if there is any exception
-
getProjectRootFolder
This method looks up the current project and returns the root domain folder.- Returns:
- the root domain folder of the current project
-
analyzeAll(ghidra.program.model.listing.Program)
oranalyzeChanges(ghidra.program.model.listing.Program)
should be invoked.