Package ghidra.program.model.listing
Class DataStub
- java.lang.Object
-
- ghidra.program.model.listing.DataStub
-
public class DataStub extends java.lang.Object implements Data
DataStub can be extended for use by tests. It throws an UnsupportedOperationException for all methods in the Data interface. Any method that is needed for your test can then be overridden so it can provide its own test implementation and return value.
-
-
Field Summary
-
Fields inherited from interface ghidra.program.model.listing.CodeUnit
COMMENT_PROPERTY, DEFINED_DATA_PROPERTY, EOL_COMMENT, INSTRUCTION_PROPERTY, MNEMONIC, NO_COMMENT, PLATE_COMMENT, POST_COMMENT, PRE_COMMENT, REPEATABLE_COMMENT, SPACE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description DataStub()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addMnemonicReference(Address refAddr, RefType refType, SourceType sourceType)
Add a reference to the mnemonic for this code unit.void
addOperandReference(int index, Address refAddr, RefType type, SourceType sourceType)
Add a memory reference to the operand at the given index.void
addValueReference(Address refAddr, RefType type)
Add a memory reference to the value.void
clearAllSettings()
Removes all name-value pairs from this settings objectvoid
clearSetting(java.lang.String name)
Removes any value associated with the given nameint
compareTo(Address addr)
Compares the given address to the address range of this node.boolean
contains(Address testAddr)
Returns true if address is contained in the range of this codeUnitAddress
getAddress()
Get the Address which corresponds to the offset 0.Address
getAddress(int opIndex)
Get the Address for the given operand index if one exists.java.lang.String
getAddressString(boolean showBlockName, boolean pad)
Get the string representation of the starting address for this code unit.DataType
getBaseDataType()
If the dataType is a typeDef, then the typeDef's base type is returned, otherwise, the datatType is returned.java.math.BigInteger
getBigInteger(int offset, int size, boolean signed)
returns the value at the given offset, taking into account the endianess.byte
getByte(int offset)
Get one byte from memory at the current position plus offset.byte[]
getByteArray(java.lang.String name)
Gets the byte[] value associated with the given namebyte[]
getBytes()
Get the bytes that make up this code unit.int
getBytes(byte[] b, int memoryBufferOffset)
Readsb.length
bytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position.void
getBytesInCodeUnit(byte[] buffer, int bufferOffset)
Copies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.java.lang.String
getComment(int commentType)
Get the comment for the given typejava.lang.String[]
getCommentAsArray(int commentType)
Get the comment for the given type and parse it into an array of strings such that each line is its own string.Data
getComponent(int index)
Returns the immediate n'th component or null if none exists.Data
getComponent(int[] componentPath)
Get a data item given the index path.Data
getComponentAt(int offset)
Return the first immediate child component that contains the byte at the given offset.Data
getComponentContaining(int offset)
RReturn the first immediate child component that contains the byte at the given offset.int
getComponentIndex()
Get the index of this component in its parentint
getComponentLevel()
Get this data's component level in its hierarchy of components.int[]
getComponentPath()
Get the component path if this is a component.java.lang.String
getComponentPathName()
Returns the component path name (dot notation) for this fieldjava.util.List<Data>
getComponentsContaining(int offset)
Returns a list of all the immediate child components that contain the byte at the given offset.DataType
getDataType()
Get the Data type for the data.java.lang.String
getDefaultLabelPrefix(DataTypeDisplayOptions options)
Returns the appropriate string to use as the default label prefix or null if it has no preferred default label prefix;Settings
getDefaultSettings()
Returns the underlying default settings for these settings or null if there are nonejava.lang.String
getDefaultValueRepresentation()
Returns a string that represents the data value without markup.ExternalReference
getExternalReference(int opIndex)
Gets the external reference (if any) at the opIndexjava.lang.String
getFieldName()
Get the field name of this data item if it is "inside" another data item, otherwise return null.int
getInt(int offset)
returns the int at the given offset, taking into account the endianess.int
getIntProperty(java.lang.String name)
Get the int property for name.java.lang.String
getLabel()
Get the label for this code unit.int
getLength()
Get length of this code unit.long
getLong(int offset)
returns the long at the given offset, taking into account the endianess.java.lang.Long
getLong(java.lang.String name)
Gets the Long value associated with the given nameAddress
getMaxAddress()
Get the ending address for this code unit.Memory
getMemory()
Get the Memory object actually used by the MemBuffer.Address
getMinAddress()
Get the starting address for this code unit.Reference[]
getMnemonicReferences()
Get references for the mnemonic for this code unit.java.lang.String
getMnemonicString()
Get the mnemonic for this code unit, e.g., MOV, JMPjava.lang.String[]
getNames()
Get this list of keys that currently have values associated with themint
getNumComponents()
Return the number of components that make up this data item.int
getNumOperands()
Get the number of operands for this code unit.Saveable
getObjectProperty(java.lang.String name)
Get the object property for name; returns null if there is no name property for this code unit.Reference[]
getOperandReferences(int index)
Get the references for the operand index.Data
getParent()
Get the immediate parent data item of this data item or null if this data item is not contained in another data item.int
getParentOffset()
Get the offset of this Data item from the start of its immediate parent.java.lang.String
getPathName()
Returns the full path name (dot notation) for this field.Reference
getPrimaryReference(int index)
Get the primary reference for the operand index.Symbol
getPrimarySymbol()
Get the Primary Symbol for this code unit.Data
getPrimitiveAt(int offset)
Returns the primitive component containing this offset (i.e., one that does not have sub-components).Program
getProgram()
Returns the program that generated this CodeUnit.ReferenceIterator
getReferenceIteratorTo()
Get an iterator over all references TO this code unit.Reference[]
getReferencesFrom()
Get ALL memory references FROM this code unit.Data
getRoot()
Get the highest level Data item in a hierarchy of structures containing this component.int
getRootOffset()
Get the offset of this Data item from the start of the root data item of some hierarchy of structures.Scalar
getScalar(int opIndex)
Returns the scalar at the given operand index.short
getShort(int offset)
returns the short at the given offset, taking into account the endianess.java.lang.String
getString(java.lang.String name)
Gets the String value associated with the given namejava.lang.String
getStringProperty(java.lang.String name)
Get the string property for name; returns null if there is no name property for this code unit.Symbol[]
getSymbols()
Get the Symbols for this code unit.java.lang.Object
getValue()
Returns the value of the data item.java.lang.Object
getValue(java.lang.String name)
Gets the object associated with the given namejava.lang.Class<?>
getValueClass()
Get the class used to express the value of this data.Reference[]
getValueReferences()
Get the references for the value.boolean
getVoidProperty(java.lang.String name)
Returns whether this code unit is marked as having the name property.boolean
hasProperty(java.lang.String name)
Returns true if the codeunit has the given property defined.boolean
hasStringValue()
Returns true if this data corresponds to string data.boolean
isArray()
Returns true if this data item is an Array of DataTypesboolean
isBigEndian()
Returns true if the underlying bytes are in big-endian order, false if they are little endian.boolean
isConstant()
boolean
isDefined()
Returns true if the data type is defined.boolean
isDynamic()
Returns true if this data item is a dynamic DataType.boolean
isEmpty()
Returns true if there are no key-value pairs stored in this settings objectboolean
isPointer()
Returns true if this is a pointer, implies getValue() will will return an Object that is an Address.boolean
isStructure()
Returns true if this data item is a Structure.boolean
isSuccessor(CodeUnit codeUnit)
Return true if the given CodeUnit follows directly after this code unit.boolean
isUnion()
Returns true if this data item is a Union.boolean
isVolatile()
java.util.Iterator<java.lang.String>
propertyNames()
Get an iterator over the property names.void
removeExternalReference(int opIndex)
Remove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.void
removeMnemonicReference(Address refAddr)
Remove a reference to the mnemonic for this code unit.void
removeOperandReference(int index, Address refAddr)
Remove a reference to the operand.void
removeProperty(java.lang.String name)
Remove the property with the given name from this code unit.void
removeValueReference(Address refAddr)
Remove a reference to the value.void
setByteArray(java.lang.String name, byte[] value)
Associates the given byte[] with the namevoid
setComment(int commentType, java.lang.String comment)
Set the comment for the given comment type.void
setCommentAsArray(int commentType, java.lang.String[] comment)
Set the comment (with each line in its own string) for the given comment typevoid
setLong(java.lang.String name, long value)
Associates the given long value with the namevoid
setPrimaryMemoryReference(Reference ref)
Sets a memory reference to be the primary reference at its address/opIndex location.void
setProperty(java.lang.String name)
Set the named property.void
setProperty(java.lang.String name, int value)
Set the named property with the given value at the address of this codeunit.void
setProperty(java.lang.String name, Saveable value)
Set the named property with the given value at the address of this codeunit.void
setProperty(java.lang.String name, java.lang.String value)
Set the named property with the given value at the address of this codeunit.void
setRegisterReference(int opIndex, Register reg, SourceType sourceType, RefType refType)
Sets a register reference at theoffset
on the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this register referencevoid
setStackReference(int opIndex, int offset, SourceType sourceType, RefType refType)
Sets a stack reference at theoffset
on the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this stack referencevoid
setString(java.lang.String name, java.lang.String value)
Associates the given String value with the namevoid
setValue(java.lang.String name, java.lang.Object value)
Associates the given object with the namevoid
visitProperty(PropertyVisitor visitor, java.lang.String propertyName)
Invokes the visit() method of the specified PropertyVisitor if the named property exists for this code unit.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface ghidra.program.model.mem.MemBuffer
getUnsignedByte, getUnsignedInt, getUnsignedShort, getVarLengthInt, getVarLengthUnsignedInt, isInitializedMemory
-
-
-
-
Method Detail
-
getAddressString
public java.lang.String getAddressString(boolean showBlockName, boolean pad)
Description copied from interface:CodeUnit
Get the string representation of the starting address for this code unit.- Specified by:
getAddressString
in interfaceCodeUnit
- Parameters:
showBlockName
- true if the string should include the memory block namepad
- if true, the address will be padded with leading zeros. Even if pad is false, the string will be padded to make the address string contain at least 4 digits.- Returns:
- string representation of address
-
setProperty
public void setProperty(java.lang.String name, Saveable value)
Description copied from interface:CodeUnit
Set the named property with the given value at the address of this codeunit.- Specified by:
setProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property.value
- value to be stored.
-
setProperty
public void setProperty(java.lang.String name, java.lang.String value)
Description copied from interface:CodeUnit
Set the named property with the given value at the address of this codeunit.- Specified by:
setProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property.value
- value to be stored.
-
setProperty
public void setProperty(java.lang.String name, int value)
Description copied from interface:CodeUnit
Set the named property with the given value at the address of this codeunit.- Specified by:
setProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property.value
- value to be stored.
-
setProperty
public void setProperty(java.lang.String name)
Description copied from interface:CodeUnit
Set the named property. This method is used for "void" properites. The property is either set or not set - there is no value- Specified by:
setProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property.
-
getObjectProperty
public Saveable getObjectProperty(java.lang.String name)
Description copied from interface:CodeUnit
Get the object property for name; returns null if there is no name property for this code unit.- Specified by:
getObjectProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property
-
getStringProperty
public java.lang.String getStringProperty(java.lang.String name)
Description copied from interface:CodeUnit
Get the string property for name; returns null if there is no name property for this code unit.- Specified by:
getStringProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property
-
getIntProperty
public int getIntProperty(java.lang.String name) throws NoValueException
Description copied from interface:CodeUnit
Get the int property for name.- Specified by:
getIntProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property- Throws:
NoValueException
- if there is not name property for this code unit
-
hasProperty
public boolean hasProperty(java.lang.String name)
Description copied from interface:CodeUnit
Returns true if the codeunit has the given property defined.- Specified by:
hasProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property
-
getVoidProperty
public boolean getVoidProperty(java.lang.String name)
Description copied from interface:CodeUnit
Returns whether this code unit is marked as having the name property.- Specified by:
getVoidProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property
-
propertyNames
public java.util.Iterator<java.lang.String> propertyNames()
Description copied from interface:CodeUnit
Get an iterator over the property names.- Specified by:
propertyNames
in interfaceCodeUnit
-
removeProperty
public void removeProperty(java.lang.String name)
Description copied from interface:CodeUnit
Remove the property with the given name from this code unit.- Specified by:
removeProperty
in interfaceCodeUnit
- Parameters:
name
- the name of the property
-
visitProperty
public void visitProperty(PropertyVisitor visitor, java.lang.String propertyName)
Description copied from interface:CodeUnit
Invokes the visit() method of the specified PropertyVisitor if the named property exists for this code unit.- Specified by:
visitProperty
in interfaceCodeUnit
- Parameters:
visitor
- the class implementing the PropertyVisitor interface.propertyName
- the name of the property to be visited.
-
getLabel
public java.lang.String getLabel()
Description copied from interface:CodeUnit
Get the label for this code unit.
-
getSymbols
public Symbol[] getSymbols()
Description copied from interface:CodeUnit
Get the Symbols for this code unit.- Specified by:
getSymbols
in interfaceCodeUnit
-
getPrimarySymbol
public Symbol getPrimarySymbol()
Description copied from interface:CodeUnit
Get the Primary Symbol for this code unit.- Specified by:
getPrimarySymbol
in interfaceCodeUnit
-
getMinAddress
public Address getMinAddress()
Description copied from interface:CodeUnit
Get the starting address for this code unit.- Specified by:
getMinAddress
in interfaceCodeUnit
-
getMaxAddress
public Address getMaxAddress()
Description copied from interface:CodeUnit
Get the ending address for this code unit.- Specified by:
getMaxAddress
in interfaceCodeUnit
-
getMnemonicString
public java.lang.String getMnemonicString()
Description copied from interface:CodeUnit
Get the mnemonic for this code unit, e.g., MOV, JMP- Specified by:
getMnemonicString
in interfaceCodeUnit
-
getComment
public java.lang.String getComment(int commentType)
Description copied from interface:CodeUnit
Get the comment for the given type- Specified by:
getComment
in interfaceCodeUnit
- Parameters:
commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENT- Returns:
- the comment string of the appropriate type or null if no comment of that type exists for this codeunit
-
getCommentAsArray
public java.lang.String[] getCommentAsArray(int commentType)
Description copied from interface:CodeUnit
Get the comment for the given type and parse it into an array of strings such that each line is its own string.- Specified by:
getCommentAsArray
in interfaceCodeUnit
- Parameters:
commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENT- Returns:
- an array of strings where each item in the array is a line of text in the comment. If there is no comment of the requested type, an empty array is returned.
-
setComment
public void setComment(int commentType, java.lang.String comment)
Description copied from interface:CodeUnit
Set the comment for the given comment type. Passingnull
clears the comment- Specified by:
setComment
in interfaceCodeUnit
- Parameters:
commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENTcomment
- comment for code unit; null clears the comment
-
setCommentAsArray
public void setCommentAsArray(int commentType, java.lang.String[] comment)
Description copied from interface:CodeUnit
Set the comment (with each line in its own string) for the given comment type- Specified by:
setCommentAsArray
in interfaceCodeUnit
- Parameters:
commentType
- either EOL_COMMENT, PRE_COMMENT, POST_COMMENT, or REPEATABLE_COMMENTcomment
- an array of strings where each string is a single line of the comment.
-
isSuccessor
public boolean isSuccessor(CodeUnit codeUnit)
Description copied from interface:CodeUnit
Return true if the given CodeUnit follows directly after this code unit.- Specified by:
isSuccessor
in interfaceCodeUnit
- Parameters:
codeUnit
- the codeUnit being tested to see if it follows this codeUnit.
-
getLength
public int getLength()
Description copied from interface:CodeUnit
Get length of this code unit.
-
getBytes
public byte[] getBytes() throws MemoryAccessException
Description copied from interface:CodeUnit
Get the bytes that make up this code unit.- Specified by:
getBytes
in interfaceCodeUnit
- Returns:
- an array of bytes that are in memory at the codeunits address. The array length is the same as the codeUnits length
- Throws:
MemoryAccessException
- if the full number of bytes could not be read.
-
getBytesInCodeUnit
public void getBytesInCodeUnit(byte[] buffer, int bufferOffset) throws MemoryAccessException
Description copied from interface:CodeUnit
Copies max(buffer.length, code unit length) bytes into buffer starting at location offset in buffer.- Specified by:
getBytesInCodeUnit
in interfaceCodeUnit
- Parameters:
buffer
- byte array to copy intobufferOffset
- offset in byte array the copy will start- Throws:
MemoryAccessException
- if the full number of bytes could not be read.
-
contains
public boolean contains(Address testAddr)
Description copied from interface:CodeUnit
Returns true if address is contained in the range of this codeUnit
-
compareTo
public int compareTo(Address addr)
Description copied from interface:CodeUnit
Compares the given address to the address range of this node.
-
addMnemonicReference
public void addMnemonicReference(Address refAddr, RefType refType, SourceType sourceType)
Description copied from interface:CodeUnit
Add a reference to the mnemonic for this code unit.- Specified by:
addMnemonicReference
in interfaceCodeUnit
- Parameters:
refAddr
- address to add as a reference.refType
- the type of reference to add.sourceType
- the source of this reference
-
removeMnemonicReference
public void removeMnemonicReference(Address refAddr)
Description copied from interface:CodeUnit
Remove a reference to the mnemonic for this code unit.- Specified by:
removeMnemonicReference
in interfaceCodeUnit
- Parameters:
refAddr
- the address to remove as a reference.
-
getMnemonicReferences
public Reference[] getMnemonicReferences()
Description copied from interface:CodeUnit
Get references for the mnemonic for this code unit.- Specified by:
getMnemonicReferences
in interfaceCodeUnit
- Returns:
- an array of memory references. A zero length array will be returned if there are no references for the mnemonic.
-
getOperandReferences
public Reference[] getOperandReferences(int index)
Description copied from interface:CodeUnit
Get the references for the operand index.- Specified by:
getOperandReferences
in interfaceCodeUnit
- Parameters:
index
- operand index (0 is the first operand)
-
getPrimaryReference
public Reference getPrimaryReference(int index)
Description copied from interface:CodeUnit
Get the primary reference for the operand index.- Specified by:
getPrimaryReference
in interfaceCodeUnit
- Parameters:
index
- operand index (0 is the first operand)
-
addOperandReference
public void addOperandReference(int index, Address refAddr, RefType type, SourceType sourceType)
Description copied from interface:CodeUnit
Add a memory reference to the operand at the given index.- Specified by:
addOperandReference
in interfaceCodeUnit
- Parameters:
index
- operand indexrefAddr
- reference addresstype
- the reference type to be added.sourceType
- the source of this reference
-
removeOperandReference
public void removeOperandReference(int index, Address refAddr)
Description copied from interface:CodeUnit
Remove a reference to the operand.- Specified by:
removeOperandReference
in interfaceCodeUnit
- Parameters:
index
- operand indexrefAddr
- address referencing the operand
-
getReferencesFrom
public Reference[] getReferencesFrom()
Description copied from interface:CodeUnit
Get ALL memory references FROM this code unit.- Specified by:
getReferencesFrom
in interfaceCodeUnit
- Returns:
- an array of memory references from this codeUnit or an empty array if there are no references.
-
getReferenceIteratorTo
public ReferenceIterator getReferenceIteratorTo()
Description copied from interface:CodeUnit
Get an iterator over all references TO this code unit.- Specified by:
getReferenceIteratorTo
in interfaceCodeUnit
-
getProgram
public Program getProgram()
Description copied from interface:CodeUnit
Returns the program that generated this CodeUnit.- Specified by:
getProgram
in interfaceCodeUnit
-
getExternalReference
public ExternalReference getExternalReference(int opIndex)
Description copied from interface:CodeUnit
Gets the external reference (if any) at the opIndex- Specified by:
getExternalReference
in interfaceCodeUnit
- Parameters:
opIndex
- the operand index to look for external references- Returns:
- the external reference at the operand or null if none exists.
-
removeExternalReference
public void removeExternalReference(int opIndex)
Description copied from interface:CodeUnit
Remove external reference (if any) at the given opIndex opIndex the index of the operand from which to remove any external reference.- Specified by:
removeExternalReference
in interfaceCodeUnit
-
setPrimaryMemoryReference
public void setPrimaryMemoryReference(Reference ref)
Description copied from interface:CodeUnit
Sets a memory reference to be the primary reference at its address/opIndex location. The primary reference is the one that is used in the getOperandRepresentation() method.- Specified by:
setPrimaryMemoryReference
in interfaceCodeUnit
- Parameters:
ref
- the reference to be set as primary.
-
setStackReference
public void setStackReference(int opIndex, int offset, SourceType sourceType, RefType refType)
Description copied from interface:CodeUnit
Sets a stack reference at theoffset
on the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this stack reference- Specified by:
setStackReference
in interfaceCodeUnit
- Parameters:
opIndex
- the index of the operand to set this stack referenceoffset
- the (+/-) offset from stack base addresssourceType
- the source of this referencerefType
- type of reference, RefType.READ,WRITE,PTR...
-
setRegisterReference
public void setRegisterReference(int opIndex, Register reg, SourceType sourceType, RefType refType)
Description copied from interface:CodeUnit
Sets a register reference at theoffset
on the specified operand index, which effectively substitutes the previous operation interpretation
NOTE: If another reference was previously set on the operand, then it will be replaced with this register reference- Specified by:
setRegisterReference
in interfaceCodeUnit
- Parameters:
opIndex
- the index of the operand to set this register referencereg
- a registersourceType
- the source of this referencerefType
- type of reference, RefType.READ,WRITE,PTR...
-
getNumOperands
public int getNumOperands()
Description copied from interface:CodeUnit
Get the number of operands for this code unit.- Specified by:
getNumOperands
in interfaceCodeUnit
-
getAddress
public Address getAddress(int opIndex)
Description copied from interface:CodeUnit
Get the Address for the given operand index if one exists. Data objects have one operand (the value).- Specified by:
getAddress
in interfaceCodeUnit
- Parameters:
opIndex
- index of the operand.- Returns:
- An addres if the operand represents a fully qualified address (given the context), or if the operand is a Scalar treated as an address. Null is returned if no address or scalar exists on that operand.
-
getScalar
public Scalar getScalar(int opIndex)
Description copied from interface:CodeUnit
Returns the scalar at the given operand index. Data objects have one operand (the value).
-
getByte
public byte getByte(int offset) throws MemoryAccessException
Description copied from interface:MemBuffer
Get one byte from memory at the current position plus offset.- Specified by:
getByte
in interfaceMemBuffer
- Parameters:
offset
- the displacement from the current position.- Returns:
- the data at offset from the current position.
- Throws:
MemoryAccessException
- if memory cannot be read at the specified offset
-
getBytes
public int getBytes(byte[] b, int memoryBufferOffset)
Description copied from interface:MemBuffer
Readsb.length
bytes from this memory buffer starting at the address of this memory buffer plus the given memoryBufferOffset from that position. The actual number of bytes may be fewer if bytes can't be read.- Specified by:
getBytes
in interfaceMemBuffer
- Parameters:
b
- the buffer into which bytes will be placedmemoryBufferOffset
- the offset in this memory buffer from which to start reading bytes.- Returns:
- the number of bytes read which may be fewer than b.length if available bytes are exhausted or no bytes are available at the specified offset.
-
getAddress
public Address getAddress()
Description copied from interface:MemBuffer
Get the Address which corresponds to the offset 0.- Specified by:
getAddress
in interfaceMemBuffer
- Returns:
- the current address of offset 0.
-
getMemory
public Memory getMemory()
Description copied from interface:MemBuffer
Get the Memory object actually used by the MemBuffer.
-
isBigEndian
public boolean isBigEndian()
Description copied from interface:MemBuffer
Returns true if the underlying bytes are in big-endian order, false if they are little endian.- Specified by:
isBigEndian
in interfaceMemBuffer
- Returns:
- true if the underlying bytes are in big-endian order, false if they are little endian.
-
getShort
public short getShort(int offset) throws MemoryAccessException
Description copied from interface:MemBuffer
returns the short at the given offset, taking into account the endianess.- Specified by:
getShort
in interfaceMemBuffer
- Parameters:
offset
- the offset from the membuffers origin (the address that it is set at)- Returns:
- the short at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException
- if a 2-byte short value cannot be read at the specified offset
-
getInt
public int getInt(int offset) throws MemoryAccessException
Description copied from interface:MemBuffer
returns the int at the given offset, taking into account the endianess.- Specified by:
getInt
in interfaceMemBuffer
- Parameters:
offset
- the offset from the membuffers origin (the address that it is set at)- Returns:
- the int at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException
- if a 4-byte integer value cannot be read at the specified offset
-
getLong
public long getLong(int offset) throws MemoryAccessException
Description copied from interface:MemBuffer
returns the long at the given offset, taking into account the endianess.- Specified by:
getLong
in interfaceMemBuffer
- Parameters:
offset
- the offset from the membuffers origin (the address that it is set at)- Returns:
- the long at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException
- if a 8-byte long value cannot be read at the specified offset
-
getBigInteger
public java.math.BigInteger getBigInteger(int offset, int size, boolean signed) throws MemoryAccessException
Description copied from interface:MemBuffer
returns the value at the given offset, taking into account the endianess.- Specified by:
getBigInteger
in interfaceMemBuffer
- Parameters:
offset
- the offset from the membuffers origin (the address that it is set at)size
- the number of bytes to include in the valuesigned
- true if value should be treated as a signed twos-compliment value.- Returns:
- the value at the given offset, taking into account the endianess.
- Throws:
MemoryAccessException
- if the request size value cannot be read at the specified offset
-
getLong
public java.lang.Long getLong(java.lang.String name)
Description copied from interface:Settings
Gets the Long value associated with the given name
-
getString
public java.lang.String getString(java.lang.String name)
Description copied from interface:Settings
Gets the String value associated with the given name
-
getByteArray
public byte[] getByteArray(java.lang.String name)
Description copied from interface:Settings
Gets the byte[] value associated with the given name- Specified by:
getByteArray
in interfaceSettings
- Parameters:
name
- the key used to retrieve a value- Returns:
- the byte[] value for a key
-
getValue
public java.lang.Object getValue(java.lang.String name)
Description copied from interface:Settings
Gets the object associated with the given name
-
setLong
public void setLong(java.lang.String name, long value)
Description copied from interface:Settings
Associates the given long value with the name
-
setString
public void setString(java.lang.String name, java.lang.String value)
Description copied from interface:Settings
Associates the given String value with the name
-
setByteArray
public void setByteArray(java.lang.String name, byte[] value)
Description copied from interface:Settings
Associates the given byte[] with the name- Specified by:
setByteArray
in interfaceSettings
- Parameters:
name
- the keyvalue
- the value associated with the key
-
setValue
public void setValue(java.lang.String name, java.lang.Object value)
Description copied from interface:Settings
Associates the given object with the name
-
clearSetting
public void clearSetting(java.lang.String name)
Description copied from interface:Settings
Removes any value associated with the given name- Specified by:
clearSetting
in interfaceSettings
- Parameters:
name
- the key to remove any association
-
clearAllSettings
public void clearAllSettings()
Description copied from interface:Settings
Removes all name-value pairs from this settings object- Specified by:
clearAllSettings
in interfaceSettings
-
getNames
public java.lang.String[] getNames()
Description copied from interface:Settings
Get this list of keys that currently have values associated with them
-
isEmpty
public boolean isEmpty()
Description copied from interface:Settings
Returns true if there are no key-value pairs stored in this settings object
-
getDefaultSettings
public Settings getDefaultSettings()
Description copied from interface:Settings
Returns the underlying default settings for these settings or null if there are none- Specified by:
getDefaultSettings
in interfaceSettings
-
getValue
public java.lang.Object getValue()
Description copied from interface:Data
Returns the value of the data item. The value may be an address, a scalar, register or null if no value.
-
getValueClass
public java.lang.Class<?> getValueClass()
Description copied from interface:Data
Get the class used to express the value of this data.NOTE: This determination is made based upon data type and settings only and does not examine memory bytes which are used to construct the data value object.
- Specified by:
getValueClass
in interfaceData
- Returns:
- value class or null if a consistent class is not utilized.
-
hasStringValue
public boolean hasStringValue()
Description copied from interface:Data
Returns true if this data corresponds to string data. This is determined by the corresponding data type producing a String value.- Specified by:
hasStringValue
in interfaceData
- Returns:
- true if this data returns a String value and can be treated as string data.
-
isConstant
public boolean isConstant()
- Specified by:
isConstant
in interfaceData
- Returns:
- true if data is constant. If true, isConstant will always be false
-
isVolatile
public boolean isVolatile()
- Specified by:
isVolatile
in interfaceData
- Returns:
- true if data is volatile. If true, isVolatile will always be false
-
isDefined
public boolean isDefined()
Description copied from interface:Data
Returns true if the data type is defined. Any address that has not been defined to be code or data is treated as undefined data.
-
getDataType
public DataType getDataType()
Description copied from interface:Data
Get the Data type for the data.- Specified by:
getDataType
in interfaceData
- Returns:
- the data type
-
getBaseDataType
public DataType getBaseDataType()
Description copied from interface:Data
If the dataType is a typeDef, then the typeDef's base type is returned, otherwise, the datatType is returned.- Specified by:
getBaseDataType
in interfaceData
- Returns:
- the data type
-
getValueReferences
public Reference[] getValueReferences()
Description copied from interface:Data
Get the references for the value.- Specified by:
getValueReferences
in interfaceData
- Returns:
- the references
-
addValueReference
public void addValueReference(Address refAddr, RefType type)
Description copied from interface:Data
Add a memory reference to the value.- Specified by:
addValueReference
in interfaceData
- Parameters:
refAddr
- address referenced.type
- the type of reference to be added.
-
removeValueReference
public void removeValueReference(Address refAddr)
Description copied from interface:Data
Remove a reference to the value.- Specified by:
removeValueReference
in interfaceData
- Parameters:
refAddr
- address of reference to be removed.
-
getFieldName
public java.lang.String getFieldName()
Description copied from interface:Data
Get the field name of this data item if it is "inside" another data item, otherwise return null.- Specified by:
getFieldName
in interfaceData
- Returns:
- the name of this data as known from some parent data item or null if this data item is not a component of another data item.
-
getPathName
public java.lang.String getPathName()
Description copied from interface:Data
Returns the full path name (dot notation) for this field. This includes the symbol name at this address.- Specified by:
getPathName
in interfaceData
- Returns:
- the path name
-
getComponentPathName
public java.lang.String getComponentPathName()
Description copied from interface:Data
Returns the component path name (dot notation) for this field- Specified by:
getComponentPathName
in interfaceData
- Returns:
- the component path name
-
isPointer
public boolean isPointer()
Description copied from interface:Data
Returns true if this is a pointer, implies getValue() will will return an Object that is an Address.
-
isUnion
public boolean isUnion()
Description copied from interface:Data
Returns true if this data item is a Union.
-
isStructure
public boolean isStructure()
Description copied from interface:Data
Returns true if this data item is a Structure.- Specified by:
isStructure
in interfaceData
- Returns:
- true if a structure
-
isArray
public boolean isArray()
Description copied from interface:Data
Returns true if this data item is an Array of DataTypes
-
isDynamic
public boolean isDynamic()
Description copied from interface:Data
Returns true if this data item is a dynamic DataType.
-
getParent
public Data getParent()
Description copied from interface:Data
Get the immediate parent data item of this data item or null if this data item is not contained in another data item.
-
getRoot
public Data getRoot()
Description copied from interface:Data
Get the highest level Data item in a hierarchy of structures containing this component.
-
getRootOffset
public int getRootOffset()
Description copied from interface:Data
Get the offset of this Data item from the start of the root data item of some hierarchy of structures.- Specified by:
getRootOffset
in interfaceData
- Returns:
- the offset
-
getParentOffset
public int getParentOffset()
Description copied from interface:Data
Get the offset of this Data item from the start of its immediate parent.- Specified by:
getParentOffset
in interfaceData
- Returns:
- the offset
-
getComponent
public Data getComponent(int index)
Description copied from interface:Data
Returns the immediate n'th component or null if none exists.- Specified by:
getComponent
in interfaceData
- Parameters:
index
- the index of the component to get.- Returns:
- the component
-
getComponent
public Data getComponent(int[] componentPath)
Description copied from interface:Data
Get a data item given the index path. Each integer in the array represents an index into the data item at that level.- Specified by:
getComponent
in interfaceData
- Parameters:
componentPath
- the array of indexes to use to find the requested data item.- Returns:
- the component
-
getComponentPath
public int[] getComponentPath()
Description copied from interface:Data
Get the component path if this is a component. The component path is an array of integers that represent each index in the tree of data items. Top level data items have an empty array for their component path.- Specified by:
getComponentPath
in interfaceData
- Returns:
- the path
-
getNumComponents
public int getNumComponents()
Description copied from interface:Data
Return the number of components that make up this data item. if this is an Array, return the number of elements in the array.- Specified by:
getNumComponents
in interfaceData
- Returns:
- the number of components
-
getComponentAt
public Data getComponentAt(int offset)
Description copied from interface:Data
Return the first immediate child component that contains the byte at the given offset. It is important to note that with certain datatypes there may be more than one component containing the specified offset (seeData.getComponentsContaining(int)
).- Specified by:
getComponentAt
in interfaceData
- Parameters:
offset
- the amount to add to this data items address to get the address of the requested data item.- Returns:
- first data component containing offset or null
-
getComponentContaining
public Data getComponentContaining(int offset)
Description copied from interface:Data
RReturn the first immediate child component that contains the byte at the given offset. It is important to note that with certain datatypes there may be more than one component containing the specified offset (seeData.getComponentsContaining(int)
).- Specified by:
getComponentContaining
in interfaceData
- Parameters:
offset
- the amount to add to this data items address to get the- Returns:
- first data component containing offset or null address of the requested data item.
-
getComponentsContaining
public java.util.List<Data> getComponentsContaining(int offset)
Description copied from interface:Data
Returns a list of all the immediate child components that contain the byte at the given offset.For a union, this will return all the components (if the offset is 0). The presence of bit-fields or zero-length components may cause multiple components to be returned.
- Specified by:
getComponentsContaining
in interfaceData
- Parameters:
offset
- the amount to add to this data items address to get the address of the requested data item.- Returns:
- a list of all the immediate child components that contain the byte at the given offset or null if offset is out of bounds.
-
getPrimitiveAt
public Data getPrimitiveAt(int offset)
Description copied from interface:Data
Returns the primitive component containing this offset (i.e., one that does not have sub-components). This is useful for data items which are made up of multiple layers of other data items. This method immediately goes to the lowest level data item. If the minimum offset of a component is specified, the only first component containing the offset will be considered (e.g., 0-element array).- Specified by:
getPrimitiveAt
in interfaceData
- Parameters:
offset
- the offset- Returns:
- primitive component containing this offset
-
getComponentIndex
public int getComponentIndex()
Description copied from interface:Data
Get the index of this component in its parent- Specified by:
getComponentIndex
in interfaceData
- Returns:
- -1 if this data item is not a component of another data item.
-
getComponentLevel
public int getComponentLevel()
Description copied from interface:Data
Get this data's component level in its hierarchy of components.- Specified by:
getComponentLevel
in interfaceData
- Returns:
- the level of this data item with 0 being the level of top data items.
-
getDefaultValueRepresentation
public java.lang.String getDefaultValueRepresentation()
Description copied from interface:Data
Returns a string that represents the data value without markup.- Specified by:
getDefaultValueRepresentation
in interfaceData
- Returns:
- the string
-
getDefaultLabelPrefix
public java.lang.String getDefaultLabelPrefix(DataTypeDisplayOptions options)
Description copied from interface:Data
Returns the appropriate string to use as the default label prefix or null if it has no preferred default label prefix;- Specified by:
getDefaultLabelPrefix
in interfaceData
- Parameters:
options
- the options- Returns:
- the prefix
-
-