Class FlatProgramAPI
- java.lang.Object
-
- ghidra.program.flatapi.FlatProgramAPI
-
- Direct Known Subclasses:
AppleSingleDoubleBinaryAnalysisCommand
,CoffArchiveBinaryAnalysisCommand
,CoffBinaryAnalysisCommand
,ElfBinaryAnalysisCommand
,GhidraScript
,MachoBinaryAnalysisCommand
,PefBinaryAnalysisCommand
,PortableExecutableBinaryAnalysisCommand
public class FlatProgramAPI extends java.lang.Object
This class is a flattened version of the Program API.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
Fields Modifier and Type Field Description protected Program
currentProgram
static int
MAX_REFERENCES_TO
protected TaskMonitor
monitor
-
Constructor Summary
Constructors Modifier Constructor Description protected
FlatProgramAPI()
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
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addEntryPoint(Address address)
Adds an entry point at the specified address.Reference
addInstructionXref(Address from, Address to, int opIndex, FlowType type)
Adds a cross reference (XREF).void
analyze(Program program)
Deprecated.the methodanalyzeAll(ghidra.program.model.listing.Program)
oranalyzeChanges(ghidra.program.model.listing.Program)
should be invoked.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.void
clearListing(Address address)
Clears the code unit (instruction or data) defined at the address.void
clearListing(Address start, Address end)
Clears the code units (instructions or data) in the specified range.void
clearListing(AddressSetView set)
Clears the code units (instructions or data) in the specified setboolean
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.AddressSet
createAddressSet()
Creates a new mutable address set.Data
createAsciiString(Address address)
Creates a null terminated ascii string starting at the specified address.Data
createAsciiString(Address address, int length)
Create an ASCII string at the specified address.Bookmark
createBookmark(Address address, java.lang.String category, java.lang.String note)
Creates aNOTE
bookmark at the specified address
NOTE: if aNOTE
bookmark already exists at the address, it will be replaced.Data
createByte(Address address)
Creates a byte datatype at the given address.Data
createChar(Address address)
Creates a char datatype at the given address.Data
createData(Address address, DataType datatype)
Creates a new defined Data object at the given address.Data
createDouble(Address address)
Creates a double datatype at the given address.Data
createDWord(Address address)
Creates a dword datatype at the given address.void
createDwords(Address start, int count)
Creates a list of dword datatypes starting at the given address.Equate
createEquate(Data data, java.lang.String equateName)
Creates a new equate on the scalar value at the value of the data.Equate
createEquate(Instruction instruction, int operandIndex, java.lang.String equateName)
Creates a new equate on the scalar value at the operand index of the instruction.Reference
createExternalReference(Data data, java.lang.String libraryName, java.lang.String externalLabel, Address externalAddr)
Creates an external reference from the given data.Reference
createExternalReference(Instruction instruction, int operandIndex, java.lang.String libraryName, java.lang.String externalLabel, Address externalAddr)
Creates an external reference from the given instruction.Reference
createExternalReference(Instruction instruction, int operandIndex, java.lang.String libraryName, java.lang.String externalLabel, Address externalAddr, RefType refType)
Creates an external reference from the given instruction.Data
createFloat(Address address)
Creates a float datatype at the given address.ProgramFragment
createFragment(ProgramModule module, java.lang.String fragmentName, Address start, long length)
Creates a fragment in the given folder of the default program tree.ProgramFragment
createFragment(ProgramModule module, java.lang.String fragmentName, Address start, Address end)
Deprecated.This method is deprecated because it did not allow you to include the largest possible address.ProgramFragment
createFragment(java.lang.String fragmentName, Address start, long length)
Creates a fragment in the root folder of the default program tree.ProgramFragment
createFragment(java.lang.String fragmentName, Address start, Address end)
Deprecated.This method is deprecated because it did not allow you to include the largest possible address.Function
createFunction(Address entryPoint, java.lang.String name)
Creates a function at entry point with the specified nameSymbol
createLabel(Address address, java.lang.String name, boolean makePrimary)
Creates a label at the specified address in the global namespace.Symbol
createLabel(Address address, java.lang.String name, boolean makePrimary, SourceType sourceType)
Creates a label at the specified address in the global namespace.Symbol
createLabel(Address address, java.lang.String name, Namespace namespace, boolean makePrimary, SourceType sourceType)
Creates a label at the specified address in the specified namespace.MemoryBlock
createMemoryBlock(java.lang.String name, Address start, byte[] bytes, boolean overlay)
Create a new memory block.MemoryBlock
createMemoryBlock(java.lang.String name, Address start, java.io.InputStream input, long length, boolean overlay)
Create a new memory block.Reference
createMemoryReference(Data data, Address toAddress, RefType dataRefType)
Creates a memory reference from the given data.Reference
createMemoryReference(Instruction instruction, int operandIndex, Address toAddress, RefType flowType)
Creates a memory reference from the given instruction.Data
createQWord(Address address)
Creates a qword datatype at the given address.Reference
createStackReference(Instruction instruction, int operandIndex, int stackOffset, boolean isWrite)
Create a stack reference from the given instructionSymbol
createSymbol(Address address, java.lang.String name, boolean makePrimary)
Deprecated.usecreateLabel(Address, String, boolean)
instead.Symbol
createSymbol(Address address, java.lang.String name, boolean makePrimary, boolean makeUnique, SourceType sourceType)
Deprecated.usecreateLabel(Address, String, boolean, SourceType)
instead.Data
createUnicodeString(Address address)
Creates a null terminated unicode string starting at the specified address.Data
createWord(Address address)
Creates a word datatype at the given address.boolean
disassemble(Address address)
Start disassembling at the specified address.void
end(boolean commit)
Ends the transactions on the current program.Address
find(Address start, byte value)
Finds the first occurrence of the byte starting from the address.Address
find(Address start, byte[] values)
Finds the first occurrence of the byte array sequence starting from the address.Address
find(java.lang.String text)
Finds the first occurrence of 'text' in the program listing.Address
findBytes(Address start, java.lang.String byteString)
Finds the first occurrence of the byte array sequence that matches the given byte string, starting from the address.Address[]
findBytes(Address start, java.lang.String byteString, int matchLimit)
Finds the first<matchLimit>
occurrences of the byte array sequence that matches the given byte string, starting from the address.Address[]
findBytes(Address start, java.lang.String byteString, int matchLimit, int alignment)
Finds the first<matchLimit>
occurrences of the byte array sequence that matches the given byte string, starting from the address.Address[]
findBytes(AddressSetView set, java.lang.String byteString, int matchLimit, int alignment)
Finds a byte pattern within an addressSet.Address[]
findBytes(AddressSetView set, java.lang.String byteString, int matchLimit, int alignment, boolean searchAcrossAddressGaps)
Finds a byte pattern within an addressSet.java.util.List<FoundString>
findPascalStrings(AddressSetView addressSet, int minimumStringLength, int alignment, boolean includePascalUnicode)
Search for sequences of Pascal Ascii strings in program memory.java.util.List<FoundString>
findStrings(AddressSetView addressSet, int minimumStringLength, int alignment, boolean requireNullTermination, boolean includeAllCharWidths)
Search for sequences of Ascii strings in program memory.AddressFactory
getAddressFactory()
Bookmark[]
getBookmarks(Address address)
Returns all of the NOTE bookmarks defined at the specified addressbyte
getByte(Address address)
Returns the 'byte' value at the specified address in memory.byte[]
getBytes(Address address, int length)
Reads length number of bytes starting at the specified address.Program
getCurrentProgram()
Gets the current program.Data
getDataAfter(Address address)
Returns the defined data after the specified address or null if no data exists.Data
getDataAfter(Data data)
Returns the defined data after the specified data or null if no data exists.Data
getDataAt(Address address)
Returns the defined data at the specified address or null if no data exists.Data
getDataBefore(Address address)
Returns the defined data before the specified address or null if no data exists.Data
getDataBefore(Data data)
Returns the defined data before the specified data or null if no data exists.Data
getDataContaining(Address address)
Returns the defined data containing the specified address or null if no data exists.DataType[]
getDataTypes(java.lang.String name)
Searches through the datatype manager of the current program and returns an array of datatypes that match the specified name.double
getDouble(Address address)
Returns the 'double' value at the specified address in memory.java.lang.String
getEOLComment(Address address)
Returns the EOL comment at the specified address.Equate
getEquate(Data data)
Returns the equate defined on the data.Equate
getEquate(Instruction instruction, int operandIndex, long value)
Returns the equate defined at the operand index of the instruction with the given value.java.util.List<Equate>
getEquates(Instruction instruction, int operandIndex)
Returns the equates defined at the operand index of the instruction.Data
getFirstData()
Returns the first defined data in the current program.Function
getFirstFunction()
Returns the first function in the current program.Instruction
getFirstInstruction()
Returns the first instruction in the current program.Instruction
getFirstInstruction(Function function)
Returns the first instruction in the function.float
getFloat(Address address)
Returns the 'float' value at the specified address in memory.ProgramFragment
getFragment(ProgramModule module, java.lang.String fragmentName)
Returns the fragment with the specified name defined in the given module.Function
getFunction(java.lang.String name)
Deprecated.this method makes no sense in the new world order where function names no longer have to be unique.Function
getFunctionAfter(Address address)
Returns the function defined after the specified address.Function
getFunctionAfter(Function function)
Returns the function defined before the specified function in address order.Function
getFunctionAt(Address entryPoint)
Returns the function with the specified entry point, or null if no function exists.Function
getFunctionBefore(Address address)
Returns the function defined before the specified address.Function
getFunctionBefore(Function function)
Returns the function defined before the specified function in address order.Function
getFunctionContaining(Address address)
Returns the function containing the specified address.java.util.List<Function>
getGlobalFunctions(java.lang.String name)
Returns a list of all functions in the global namespace with the given name.Instruction
getInstructionAfter(Address address)
Returns the instruction defined after the specified address or null if no instruction exists.Instruction
getInstructionAfter(Instruction instruction)
Returns the instruction defined after the specified instruction or null if no instruction exists.Instruction
getInstructionAt(Address address)
Returns the instruction at the specified address or null if no instruction exists.Instruction
getInstructionBefore(Address address)
Returns the instruction defined before the specified address or null if no instruction exists.Instruction
getInstructionBefore(Instruction instruction)
Returns the instruction defined before the specified instruction or null if no instruction exists.Instruction
getInstructionContaining(Address address)
Returns the instruction containing the specified address or null if no instruction exists.int
getInt(Address address)
Returns the 'integer' value at the specified address in memory.Data
getLastData()
Returns the last defined data in the current program.Function
getLastFunction()
Returns the last function in the current program.Instruction
getLastInstruction()
Returns the last instruction in the current program.long
getLong(Address address)
Returns the 'long' value at the specified address in memory.MemoryBlock
getMemoryBlock(Address address)
Returns the memory block containing the specified address, or null if no memory block contains the address.MemoryBlock
getMemoryBlock(java.lang.String name)
Returns the first memory block with the specified name.MemoryBlock[]
getMemoryBlocks()
Returns an array containing all the memory blocks in the current program.TaskMonitor
getMonitor()
Gets the current task monitor.Namespace
getNamespace(Namespace parent, java.lang.String namespaceName)
Returns the non-function namespace with the given name contained inside the specified parent namespace.java.lang.String
getPlateComment(Address address)
Returns the PLATE comment at the specified address.java.lang.String
getPostComment(Address address)
Returns the POST comment at the specified address.java.lang.String
getPreComment(Address address)
Returns the PRE comment at the specified address.java.io.File
getProgramFile()
Returns the path to the program's executable file.DomainFolder
getProjectRootFolder()
This method looks up the current project and returns the root domain folder.Reference
getReference(Data data, Address toAddress)
Returns the reference from the data to the given address.Reference
getReference(Instruction instruction, Address toAddress)
Returns the reference from the instruction to the given address.Reference[]
getReferencesFrom(Address address)
Returns an array of the references FROM the given address.Reference[]
getReferencesTo(Address address)
Returns an array of the references TO the given address.java.lang.String
getRepeatableComment(Address address)
Returns the repeatable comment at the specified address.short
getShort(Address address)
Returns the 'short' value at the specified address in memory.Symbol
getSymbol(java.lang.String name, Namespace namespace)
Deprecated.Symbol
getSymbolAfter(Address address)
Returns the next non-default primary symbol defined after the given address.Symbol
getSymbolAfter(Symbol symbol)
Returns the next non-default primary symbol defined after the given symbol.Symbol
getSymbolAt(Address address)
Returns the PRIMARY symbol at the specified address, or null if no symbol exists.Symbol
getSymbolAt(Address address, java.lang.String name)
Deprecated.Since the same label name can be at the same address if in a different namespace, this method is ambiguous.Symbol
getSymbolAt(Address address, java.lang.String name, Namespace namespace)
Returns the symbol with the specified address, name, and namespaceSymbol
getSymbolBefore(Address address)
Returns the previous non-default primary symbol defined after the previous address.Symbol
getSymbolBefore(Symbol symbol)
Returns the previous non-default primary symbol defined before the given symbol.java.util.List<Symbol>
getSymbols(java.lang.String name, Namespace namespace)
Returns a list of all the symbols with the given name in the given namespace.Data
getUndefinedDataAfter(Address address)
Returns the undefined data after the specified address or null if no undefined data exists.Data
getUndefinedDataAt(Address address)
Returns the undefined data at the specified address or null if no undefined data exists.Data
getUndefinedDataBefore(Address address)
Returns the undefined data before the specified address or null if no undefined data exists.FileDataTypeManager
openDataTypeArchive(java.io.File archiveFile, boolean readOnly)
Opens a Data Type Archivevoid
removeBookmark(Bookmark bookmark)
Removes the specified bookmark.void
removeData(Data data)
Removes the given data from the current program.void
removeDataAt(Address address)
Removes the data containing the given address from the current program.void
removeEntryPoint(Address address)
Removes the entry point at the specified address.void
removeEquate(Data data)
Removes the equate defined on the data.void
removeEquate(Instruction instruction, int operandIndex, long value)
Removes the equate defined at the operand index of the instruction with the given value.void
removeEquates(Instruction instruction, int operandIndex)
Removes the equates defined at the operand index of the instruction.void
removeFunction(Function function)
Removes the function from the current program.void
removeFunctionAt(Address entryPoint)
Removes the function with the given entry point.void
removeInstruction(Instruction instruction)
Removes the given instruction from the current program.void
removeInstructionAt(Address address)
Removes the instruction containing the given address from the current program.void
removeMemoryBlock(MemoryBlock block)
Remove the memory block.void
removeReference(Reference reference)
Removes the given reference.boolean
removeSymbol(Address address, java.lang.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, java.util.List<java.lang.String> path)
Saves changes to the specified program.protected void
set(Program program, TaskMonitor monitor)
Sets the current state.void
setByte(Address address, byte value)
Sets the 'byte' value at the specified address.void
setBytes(Address address, byte[] values)
Sets the 'byte' values starting at the specified address.void
setDouble(Address address, double value)
Sets the 'double' value at the specified address.boolean
setEOLComment(Address address, java.lang.String comment)
Sets an EOL comment at the specified addressvoid
setFloat(Address address, float value)
Sets the 'float' value at the specified address.void
setInt(Address address, int value)
Sets the 'integer' value at the specified address.void
setLong(Address address, long value)
Sets the 'long' value at the specified address.boolean
setPlateComment(Address address, java.lang.String comment)
Sets a PLATE comment at the specified addressboolean
setPostComment(Address address, java.lang.String comment)
Sets a POST comment at the specified addressboolean
setPreComment(Address address, java.lang.String comment)
Sets a PRE comment at the specified addressvoid
setReferencePrimary(Reference reference)
Sets the given reference as primary.void
setReferencePrimary(Reference reference, boolean primary)
Sets the given reference as primary.boolean
setRepeatableComment(Address address, java.lang.String comment)
Sets a repeatable comment at the specified addressvoid
setShort(Address address, short value)
Sets the 'short' value at the specified address.void
start()
Starts a transaction on the current program.Address
toAddr(int offset)
Returns a new address with the specified offset in the default address space.Address
toAddr(long offset)
Returns a new address with the specified offset in the default address space.Address
toAddr(java.lang.String addressString)
Returns a new address inside the specified program as indicated by the string.
-
-
-
Field Detail
-
MAX_REFERENCES_TO
public static final int MAX_REFERENCES_TO
- See Also:
- Constant Field Values
-
currentProgram
protected Program currentProgram
-
monitor
protected TaskMonitor monitor
-
-
Constructor Detail
-
FlatProgramAPI
protected FlatProgramAPI()
Constructs a new flat program API. It will not be usable until the 'set' method has been called.
-
FlatProgramAPI
public FlatProgramAPI(Program program)
Constructs a new flat program API.- Parameters:
program
- the program
-
FlatProgramAPI
public FlatProgramAPI(Program program, TaskMonitor monitor)
Constructs a new flat program API.- Parameters:
program
- the programmonitor
- the task monitor
-
-
Method Detail
-
set
protected void set(Program program, TaskMonitor monitor)
Sets the current state.- Parameters:
program
- the programmonitor
- the task monitor
-
getCurrentProgram
public Program getCurrentProgram()
Gets the current program.- Returns:
- the program
-
getMonitor
public TaskMonitor 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
public final java.io.File getProgramFile()
Returns the path to the program's executable file. For example,c:\temp\test.exe
.- Returns:
- path to program's executable file
-
disassemble
public final boolean disassemble(Address address)
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 public void analyze(Program program)
Deprecated.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
public void analyzeAll(Program program)
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
public void analyzeChanges(Program program)
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
public final void clearListing(Address address) throws CancelledException
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
public final void clearListing(Address start, Address end) throws CancelledException
Clears the code units (instructions or data) in the specified range.- Parameters:
start
- the start addressend
- the end address- Throws:
CancelledException
- if cancelled
-
clearListing
public final void clearListing(AddressSetView set) throws CancelledException
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(java.lang.String name, Address start, java.io.InputStream input, long length, boolean overlay) throws java.lang.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:
java.lang.Exception
- if there is any exception
-
createMemoryBlock
public final MemoryBlock createMemoryBlock(java.lang.String name, Address start, byte[] bytes, boolean overlay) throws java.lang.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:
java.lang.Exception
- if there is any exception
-
getMemoryBlock
public final MemoryBlock getMemoryBlock(java.lang.String name)
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
public final MemoryBlock getMemoryBlock(Address address)
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
public final MemoryBlock[] getMemoryBlocks()
Returns an array containing all the memory blocks in the current program.- Returns:
- an array containing all the memory blocks
-
removeMemoryBlock
public final void removeMemoryBlock(MemoryBlock block) throws java.lang.Exception
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:
java.lang.Exception
- if there is any exception
-
createLabel
public final Symbol createLabel(Address address, java.lang.String name, boolean makePrimary) throws java.lang.Exception
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:
java.lang.Exception
- if there is any exception
-
createSymbol
@Deprecated public final Symbol createSymbol(Address address, java.lang.String name, boolean makePrimary) throws java.lang.Exception
Deprecated.usecreateLabel(Address, String, boolean)
instead. Deprecated in Ghidra 7.4- Throws:
java.lang.Exception
-
createLabel
public final Symbol createLabel(Address address, java.lang.String name, boolean makePrimary, SourceType sourceType) throws java.lang.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:
java.lang.Exception
- if there is any exception
-
createLabel
public final Symbol createLabel(Address address, java.lang.String name, Namespace namespace, boolean makePrimary, SourceType sourceType) throws java.lang.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:
java.lang.Exception
- if there is any exception
-
createSymbol
@Deprecated public final Symbol createSymbol(Address address, java.lang.String name, boolean makePrimary, boolean makeUnique, SourceType sourceType) throws java.lang.Exception
Deprecated.usecreateLabel(Address, String, boolean, SourceType)
instead. Deprecated in Ghidra 7.4- Throws:
java.lang.Exception
-
addEntryPoint
public final void addEntryPoint(Address address)
Adds an entry point at the specified address.- Parameters:
address
- address to create entry point
-
removeEntryPoint
public final void removeEntryPoint(Address address)
Removes the entry point at the specified address.- Parameters:
address
- address of entry point to remove
-
removeSymbol
public final boolean removeSymbol(Address address, java.lang.String name)
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
public final boolean setPlateComment(Address address, java.lang.String comment)
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
public final boolean setPreComment(Address address, java.lang.String comment)
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
public final boolean setPostComment(Address address, java.lang.String comment)
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
public final boolean setEOLComment(Address address, java.lang.String comment)
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
public final boolean setRepeatableComment(Address address, java.lang.String comment)
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
public final java.lang.String getPlateComment(Address address)
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:
GhidraScript.getPlateCommentAsRendered(Address)
-
getPreComment
public final java.lang.String getPreComment(Address address)
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:
GhidraScript.getPreCommentAsRendered(Address)
-
getPostComment
public final java.lang.String getPostComment(Address address)
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:
GhidraScript.getPostCommentAsRendered(Address)
-
getEOLComment
public final java.lang.String getEOLComment(Address address)
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:
GhidraScript.getEOLCommentAsRendered(Address)
-
getRepeatableComment
public final java.lang.String getRepeatableComment(Address address)
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:
GhidraScript.getRepeatableCommentAsRendered(Address)
-
find
public final Address find(Address start, byte value)
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
public final Address find(Address start, byte[] values)
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
public final Address findBytes(Address start, java.lang.String byteString)
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:
java.lang.IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
findBytes(Address, String, int)
-
findBytes
public final Address[] findBytes(Address start, java.lang.String byteString, int matchLimit)
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:
java.lang.IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
findBytes(Address, String)
-
findBytes
public final Address[] findBytes(Address start, java.lang.String byteString, int matchLimit, int alignment)
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:
java.lang.IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
findBytes(Address, String)
-
findBytes
public final Address[] findBytes(AddressSetView set, java.lang.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:
java.lang.IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
findBytes(Address, String)
-
findBytes
public final Address[] findBytes(AddressSetView set, java.lang.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:
java.lang.IllegalArgumentException
- if the byteString is not a valid regular expression- See Also:
findBytes(Address, String)
-
find
public final Address find(java.lang.String text)
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 java.util.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 java.util.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
public final Function createFunction(Address entryPoint, java.lang.String name)
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
public final void removeFunction(Function function)
Removes the function from the current program.- Parameters:
function
- the function to remove
-
removeFunctionAt
public final void removeFunctionAt(Address entryPoint)
Removes the function with the given entry point.- Parameters:
entryPoint
- the entry point of the function to remove
-
getFunctionAt
public final Function getFunctionAt(Address entryPoint)
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
public final Function getFunctionContaining(Address address)
Returns the function containing the specified address.- Parameters:
address
- the address- Returns:
- the function containing the specified address
-
getFunctionBefore
public final Function getFunctionBefore(Function function)
Returns the function defined before the specified function in address order.- Parameters:
function
- the function- Returns:
- the function defined before the specified function
-
getFunctionBefore
public final Function getFunctionBefore(Address address)
Returns the function defined before the specified address.- Parameters:
address
- the address- Returns:
- the function defined before the specified address
-
getFunctionAfter
public final Function getFunctionAfter(Function function)
Returns the function defined before the specified function in address order.- Parameters:
function
- the function- Returns:
- the function defined before the specified function
-
getFunctionAfter
public final Function getFunctionAfter(Address address)
Returns the function defined after the specified address.- Parameters:
address
- the address- Returns:
- the function defined after the specified address
-
getFunction
@Deprecated public final Function getFunction(java.lang.String name)
Deprecated.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
public final java.util.List<Function> getGlobalFunctions(java.lang.String name)
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
public final Function getFirstFunction()
Returns the first function in the current program.- Returns:
- the first function in the current program
-
getLastFunction
public final Function getLastFunction()
Returns the last function in the current program.- Returns:
- the last function in the current program
-
getFirstInstruction
public final Instruction getFirstInstruction()
Returns the first instruction in the current program.- Returns:
- the first instruction in the current program
-
getFirstInstruction
public final Instruction getFirstInstruction(Function function)
Returns the first instruction in the function.- Parameters:
function
- the function- Returns:
- the first instruction in the function
-
getLastInstruction
public final Instruction getLastInstruction()
Returns the last instruction in the current program.- Returns:
- the last instruction in the current program
-
getInstructionAt
public final Instruction getInstructionAt(Address address)
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
public final Instruction getInstructionContaining(Address address)
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
public final Instruction getInstructionBefore(Instruction instruction)
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
public final Instruction getInstructionBefore(Address address)
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
public final Instruction getInstructionAfter(Instruction instruction)
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
public final Instruction getInstructionAfter(Address address)
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
public final Data getFirstData()
Returns the first defined data in the current program.- Returns:
- the first defined data in the current program
-
getLastData
public final Data getLastData()
Returns the last defined data in the current program.- Returns:
- the last defined data in the current program
-
getDataAt
public final Data getDataAt(Address address)
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
public final Data getDataContaining(Address address)
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
public final Data getDataBefore(Data data)
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
public final Data getDataBefore(Address address)
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
public final Data getDataAfter(Data data)
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
public final Data getDataAfter(Address address)
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
public final Data getUndefinedDataAt(Address address)
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
public final Data getUndefinedDataBefore(Address address)
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
public final Data getUndefinedDataAfter(Address address)
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 public final Symbol getSymbolAt(Address address, java.lang.String name)
Deprecated.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
public final Symbol getSymbolAt(Address address, java.lang.String name, Namespace namespace)
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
public final Symbol getSymbolAfter(Symbol symbol)
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
public final Symbol getSymbolAfter(Address address)
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
public final Symbol getSymbolBefore(Symbol symbol)
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
public final Symbol getSymbolBefore(Address address)
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
public final Symbol getSymbolAt(Address address)
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 public final Symbol getSymbol(java.lang.String name, Namespace namespace)
Deprecated.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:
java.lang.IllegalStateException
- if there is more than one symbol with that name.
-
getSymbols
public final java.util.List<Symbol> getSymbols(java.lang.String name, Namespace namespace)
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
public final Namespace getNamespace(Namespace parent, java.lang.String namespaceName)
Returns the non-function namespace with the given name contained inside the specified parent namespace. Passnull
for namespace 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
-
createFragment
@Deprecated public final ProgramFragment createFragment(java.lang.String fragmentName, Address start, Address end) throws DuplicateNameException, NotFoundException
Deprecated.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(java.lang.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 public final ProgramFragment createFragment(ProgramModule module, java.lang.String fragmentName, Address start, Address end) throws DuplicateNameException, NotFoundException
Deprecated.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, java.lang.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
public final ProgramFragment getFragment(ProgramModule module, java.lang.String fragmentName)
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
public final AddressSet createAddressSet()
Creates a new mutable address set.- Returns:
- a new mutable address set
-
getAddressFactory
public final AddressFactory getAddressFactory()
-
getDataTypes
public final DataType[] getDataTypes(java.lang.String name)
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
public final Data createData(Address address, DataType datatype) throws java.lang.Exception
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:
java.lang.Exception
- if there is any exception
-
createByte
public final Data createByte(Address address) throws java.lang.Exception
Creates a byte datatype at the given address.- Parameters:
address
- the address to create the byte- Returns:
- the newly created Data object
- Throws:
java.lang.Exception
- if there is any exception
-
createWord
public final Data createWord(Address address) throws java.lang.Exception
Creates a word datatype at the given address.- Parameters:
address
- the address to create the word- Returns:
- the newly created Data object
- Throws:
java.lang.Exception
- if there is any exception
-
createDWord
public final Data createDWord(Address address) throws java.lang.Exception
Creates a dword datatype at the given address.- Parameters:
address
- the address to create the dword- Returns:
- the newly created Data object
- Throws:
java.lang.Exception
- if there is any exception
-
createDwords
public final void createDwords(Address start, int count) throws java.lang.Exception
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:
java.lang.Exception
- if there is any exception
-
createQWord
public final Data createQWord(Address address) throws java.lang.Exception
Creates a qword datatype at the given address.- Parameters:
address
- the address to create the qword- Returns:
- the newly created Data object
- Throws:
java.lang.Exception
- if there is any exception
-
createFloat
public final Data createFloat(Address address) throws java.lang.Exception
Creates a float datatype at the given address.- Parameters:
address
- the address to create the float- Returns:
- the newly created Data object
- Throws:
java.lang.Exception
- if there is any exception
-
createDouble
public final Data createDouble(Address address) throws java.lang.Exception
Creates a double datatype at the given address.- Parameters:
address
- the address to create the double- Returns:
- the newly created Data object
- Throws:
java.lang.Exception
- if there is any exception
-
createChar
public final Data createChar(Address address) throws java.lang.Exception
Creates a char datatype at the given address.- Parameters:
address
- the address to create the char- Returns:
- the newly created Data object
- Throws:
java.lang.Exception
- if there is any exception
-
createAsciiString
public final Data createAsciiString(Address address) throws java.lang.Exception
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:
java.lang.Exception
- if there is any exception
-
createAsciiString
public final Data createAsciiString(Address address, int length) throws CodeUnitInsertionException
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
public final Data createUnicodeString(Address address) throws java.lang.Exception
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:
java.lang.Exception
- if there is any exception
-
removeData
public final void removeData(Data data) throws java.lang.Exception
Removes the given data from the current program.- Parameters:
data
- the data to remove- Throws:
java.lang.Exception
- if there is any exception
-
removeDataAt
public final void removeDataAt(Address address) throws java.lang.Exception
Removes the data containing the given address from the current program.- Parameters:
address
- the address to remove data- Throws:
java.lang.Exception
- if there is any exception
-
removeInstruction
public final void removeInstruction(Instruction instruction) throws java.lang.Exception
Removes the given instruction from the current program.- Parameters:
instruction
- the instruction to remove- Throws:
java.lang.Exception
- if there is any exception
-
removeInstructionAt
public final void removeInstructionAt(Address address) throws java.lang.Exception
Removes the instruction containing the given address from the current program.- Parameters:
address
- the address to remove instruction- Throws:
java.lang.Exception
- if there is any exception
-
addInstructionXref
public final Reference addInstructionXref(Address from, Address to, int opIndex, FlowType type)
Adds a cross reference (XREF).
-
toAddr
public final Address toAddr(int offset)
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
public final Address toAddr(long offset)
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
public final Address toAddr(java.lang.String addressString)
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
public final byte getByte(Address address) throws MemoryAccessException
Returns the 'byte' value at the specified address in memory.- Parameters:
address
- the address- Returns:
- the 'byte' value at the specified address in memory
- Throws:
MemoryAccessException
- if the memory is not readable
-
getBytes
public final byte[] getBytes(Address address, int length) throws MemoryAccessException
Reads length number of 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 bytes
- Throws:
MemoryAccessException
- if memory does not exist or is uninitialized- See Also:
Memory
-
setByte
public final void setByte(Address address, byte value) throws MemoryAccessException
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
public final void setBytes(Address address, byte[] values) throws MemoryAccessException
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
public final short getShort(Address address) throws MemoryAccessException
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
public final void setShort(Address address, short value) throws MemoryAccessException
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
public final int getInt(Address address) throws MemoryAccessException
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
public final void setInt(Address address, int value) throws MemoryAccessException
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
public final long getLong(Address address) throws MemoryAccessException
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
public final void setLong(Address address, long value) throws MemoryAccessException
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
public final float getFloat(Address address) throws MemoryAccessException
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
public final void setFloat(Address address, float value) throws MemoryAccessException
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
public final double getDouble(Address address) throws MemoryAccessException
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
public final void setDouble(Address address, double value) throws MemoryAccessException
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
public final Reference[] getReferencesFrom(Address address)
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
public final Reference[] getReferencesTo(Address address)
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
public final Reference getReference(Instruction instruction, Address toAddress)
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
public final Reference getReference(Data data, Address toAddress)
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
public final Reference createMemoryReference(Data data, Address toAddress, RefType dataRefType)
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, java.lang.String libraryName, java.lang.String externalLabel, Address externalAddr) throws java.lang.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:
java.lang.Exception
- if an exception occurs
-
createExternalReference
public final Reference createExternalReference(Instruction instruction, int operandIndex, java.lang.String libraryName, java.lang.String externalLabel, Address externalAddr, RefType refType) throws java.lang.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:
java.lang.Exception
- if an exception occurs
-
createExternalReference
public final Reference createExternalReference(Data data, java.lang.String libraryName, java.lang.String externalLabel, Address externalAddr) throws java.lang.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:
java.lang.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
public final void removeReference(Reference reference)
Removes the given reference.- Parameters:
reference
- the reference to remove
-
setReferencePrimary
public final void setReferencePrimary(Reference reference)
Sets the given reference as primary.- Parameters:
reference
- the reference to mark as primary
-
setReferencePrimary
public final void setReferencePrimary(Reference reference, boolean primary)
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, java.lang.String equateName) throws java.lang.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:
java.lang.Exception
- if a scalar does not exist of the specified operand index of the instruction
-
createEquate
public final Equate createEquate(Data data, java.lang.String equateName) throws java.lang.Exception
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 datajava.lang.Exception
- if there is any exception
-
getEquate
public final Equate getEquate(Instruction instruction, int operandIndex, long value)
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
public final java.util.List<Equate> getEquates(Instruction instruction, int operandIndex)
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
public final Equate getEquate(Data data)
Returns the equate defined on the data.- Parameters:
data
- the data- Returns:
- the equate defined on the data
-
removeEquate
public final void removeEquate(Instruction instruction, int operandIndex, long value)
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
public final void removeEquates(Instruction instruction, int operandIndex)
Removes the equates defined at the operand index of the instruction.- Parameters:
instruction
- the instructionoperandIndex
- the operand index
-
removeEquate
public final void removeEquate(Data data)
Removes the equate defined on the data.- Parameters:
data
- the data
-
createBookmark
public final Bookmark createBookmark(Address address, java.lang.String category, java.lang.String note)
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
public final Bookmark[] getBookmarks(Address address)
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
public final void removeBookmark(Bookmark bookmark)
Removes the specified bookmark.- Parameters:
bookmark
- the bookmark to remove
-
openDataTypeArchive
public final FileDataTypeManager openDataTypeArchive(java.io.File archiveFile, boolean readOnly) throws java.lang.Exception
Opens a Data Type Archive- Parameters:
archiveFile
- the archive file to openreadOnly
- should file be opened read only- Returns:
- the data type manager
- Throws:
java.lang.Exception
- if there is any exception
-
saveProgram
public void saveProgram(Program program) throws java.lang.Exception
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:
java.lang.Exception
- if there is any exception
-
saveProgram
public void saveProgram(Program program, java.util.List<java.lang.String> path) throws java.lang.Exception
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:
java.lang.Exception
- if there is any exception
-
getProjectRootFolder
public DomainFolder getProjectRootFolder()
This method looks up the current project and returns the root domain folder.- Returns:
- the root domain folder of the current project
-
-