Class GoSlice
java.lang.Object
ghidra.app.util.bin.format.golang.rtti.GoSlice
-
Constructor Summary
ConstructorsConstructorDescriptionGoSlice()
GoSlice
(long array, long len, long cap) GoSlice
(long array, long len, long cap, GoRttiMapper programContext) -
Method Summary
Modifier and TypeMethodDescriptionlong
getArrayEnd
(Class<?> elementClass) long
long
getCap()
long
getLen()
getSubSlice
(long startElement, long elementCount, long elementSize) Return a artificial view of a portion of this slice's contents.boolean
isFull()
boolean
isOffsetWithinData
(long offset, int sizeofElement) boolean
isValid()
boolean
isValid
(int elementSize) void
markupArray
(String sliceName, DataType elementType, boolean ptr, MarkupSession session) Marks up the memory occupied by the array elements with a name and a Ghidra ArrayDataType.void
markupArray
(String sliceName, Class<?> elementClazz, boolean ptr, MarkupSession session) Marks up the memory occupied by the array elements with a name and a Ghidra ArrayDataType, which has elements who's type is determined by the specified structure class.<T> List<T>
markupArrayElements
(Class<T> clazz, MarkupSession session) Marks up each element of the array, useful when the elements are themselves structures.void
markupElementReferences
(int elementSize, List<Address> targetAddrs, MarkupSession session) Marks up each element of the array with an outbound reference to the corresponding address in the targetAddrs list.<T> List<T>
readList
(BinaryReader.ReaderFunction<T> readFunc) Reads the contents of the slice, treating each element as an instance of an object that can be read using the supplied reading function.<T> List<T>
Reads the content of the slice, treating each element as an instance of the specified structure mapped class.long[]
readUIntList
(int intSize) Treats this slice as a array of unsigned integers, of the specified intSize.
-
Constructor Details
-
GoSlice
public GoSlice() -
GoSlice
public GoSlice(long array, long len, long cap) -
GoSlice
-
-
Method Details
-
getSubSlice
Return a artificial view of a portion of this slice's contents.- Parameters:
startElement
- index of element that will be the new sub-slice's starting elementelementCount
- number of elements to include in new sub-sliceelementSize
- size of an individual element- Returns:
- new
GoSlice
instance that is limited to a portion of this slice
-
isValid
public boolean isValid() -
isValid
public boolean isValid(int elementSize) -
getArrayOffset
public long getArrayOffset() -
getArrayAddress
-
getArrayEnd
-
getLen
public long getLen() -
getCap
public long getCap() -
isFull
public boolean isFull() -
isOffsetWithinData
public boolean isOffsetWithinData(long offset, int sizeofElement) -
readList
Reads the content of the slice, treating each element as an instance of the specified structure mapped class.- Type Parameters:
T
- struct mapped type of element- Parameters:
clazz
- element type- Returns:
- list of instances
- Throws:
IOException
- if error reading an element
-
readList
Reads the contents of the slice, treating each element as an instance of an object that can be read using the supplied reading function.- Type Parameters:
T
- struct mapped type of element- Parameters:
readFunc
- function that will read an instance from a BinaryReader- Returns:
- list of instances
- Throws:
IOException
- if error reading an element
-
readUIntList
Treats this slice as a array of unsigned integers, of the specified intSize.- Parameters:
intSize
- size of integer- Returns:
- array of longs, containing the (possibly smaller) integers contained in the slice
- Throws:
IOException
- if error reading
-
markupArray
public void markupArray(String sliceName, Class<?> elementClazz, boolean ptr, MarkupSession session) throws IOException Marks up the memory occupied by the array elements with a name and a Ghidra ArrayDataType, which has elements who's type is determined by the specified structure class.- Parameters:
sliceName
- used to label the memory locationelementClazz
- structure mapped class of the element of the arrayptr
- boolean flag, if true the element type is really a pointer to the supplied data typesession
- state and methods to assist marking up the program- Throws:
IOException
- if error
-
markupArray
public void markupArray(String sliceName, DataType elementType, boolean ptr, MarkupSession session) throws IOException Marks up the memory occupied by the array elements with a name and a Ghidra ArrayDataType.- Parameters:
sliceName
- used to label the memory locationelementType
- Ghidra datatype of the array elements, null ok if ptr == trueptr
- boolean flag, if true the element type is really a pointer to the supplied data typesession
- state and methods to assist marking up the program- Throws:
IOException
- if error
-
markupArrayElements
Marks up each element of the array, useful when the elements are themselves structures.- Type Parameters:
T
- element type- Parameters:
clazz
- structure mapped class of elementsession
- state and methods to assist marking up the program- Returns:
- list of element instances
- Throws:
IOException
- if error reading
-
markupElementReferences
public void markupElementReferences(int elementSize, List<Address> targetAddrs, MarkupSession session) throws IOException Marks up each element of the array with an outbound reference to the corresponding address in the targetAddrs list.Useful when marking up an array of offsets.
The Listing UI doesn't show the outbound reference from each element (for arrays of primitive types), but the target will show the inbound reference.
- Parameters:
elementSize
- size of each element in the arraytargetAddrs
- list of addresses, should be same size as this slicesession
- state and methods to assist marking up the program- Throws:
IOException
- if error creating references
-