Class MarkupSession
java.lang.Object
ghidra.app.util.bin.format.golang.structmapping.MarkupSession
State and methods needed for structure mapped objects to add markup, comments, labels, etc
to a program.
-
Field Summary
Modifier and TypeFieldDescriptionprotected DataTypeMapper
protected AddressSet
protected TaskMonitor
protected Program
-
Constructor Summary
ConstructorDescriptionMarkupSession
(DataTypeMapper programContext, TaskMonitor monitor) Creates a new markup session -
Method Summary
Modifier and TypeMethodDescriptionvoid
addReference
(FieldContext<?> fieldContext, Address refDest) Creates a reference from the specified field to the specified address.void
appendComment
(FieldContext<?> fieldContext, int commentType, String prefix, String comment, String sep) Adds a comment to the specified field, appending to any previous values already there.void
appendComment
(StructureContext<?> structureContext, int commentType, String prefix, String comment, String sep) Adds a comment to the specified structure, appending to any previous values already there.void
appendComment
(Function func, String prefix, String comment) createFunctionIfMissing
(String name, Namespace ns, Address addr) Creates a default function at the specified address.Returns the program level mapping contextReturns the Ghidra programvoid
labelAddress
(Address addr, String symbolName) Places a label at the specified address.void
labelAddress
(Address addr, String symbolName, String namespaceName) Places a label at the specified address.<T> void
labelStructure
(T obj, String symbolName, String namespaceName) Places a label at the specified structure mapped object's address.void
logWarningAt
(Address addr, String msg) static void
logWarningAt
(Program program, Address addr, String msg) <T> void
markup
(T obj, boolean nested) Decorates the specified object's memory using the various structure mapping tags that were applied the object's class definition.void
markupAddress
(Address addr, DataType dt) void
markupAddress
(Address addr, DataType dt, int length) void
markupAddressIfUndefined
(Address addr, DataType dt) void
markupArrayElementReferences
(Address arrayAddr, int elementSize, List<Address> targetAddrs) Creates references from each element of an array to a list of target addresses.<T> void
markupStructure
(StructureContext<T> structureContext, boolean nested) Decorates a structure mapped structure, and everything it contains.
-
Field Details
-
program
-
mappingContext
-
markedupStructs
-
markedupAddrs
-
monitor
-
-
Constructor Details
-
MarkupSession
Creates a new markup session- Parameters:
programContext
- program-level structure mapping contextmonitor
- allows user to cancel
-
-
Method Details
-
getProgram
Returns the Ghidra program- Returns:
- Ghidra
Program
-
getMappingContext
Returns the program level mapping context- Returns:
DataTypeMapper
-
getMarkedupAddresses
-
markup
Decorates the specified object's memory using the various structure mapping tags that were applied the object's class definition.The object can be a structure mapped object, or a collection, array or iterator of structure mapped objects.
- Type Parameters:
T
- structure mapped object type- Parameters:
obj
- structure mapped object instancenested
- boolean flag, if true the specified object is contained inside another object who's data type has already been laid down in memory, removing the need for this object's data type to be applied to memory- Throws:
IOException
- if error or cancelledCancelledException
- if cancelledIllegalArgumentException
- if object instance is not a supported type
-
markupAddress
- Parameters:
addr
- location to place DataTypedt
-DataType
- Throws:
IOException
- if error marking up address
-
markupAddress
- Parameters:
addr
- location to place DataTypedt
-DataType
length
- length of the data type instance, or -1 if the data type is fixed length- Throws:
IOException
- if error marking up address
-
markupAddressIfUndefined
- Parameters:
addr
- location to place DataTypedt
-DataType
- Throws:
IOException
- if error marking up address
-
labelStructure
Places a label at the specified structure mapped object's address.- Type Parameters:
T
- structure mapped object type- Parameters:
obj
- structure mapped objectsymbolName
- namenamespaceName
- name of namespace to place the label symbol in, or null if root- Throws:
IOException
- if error
-
labelAddress
Places a label at the specified address.- Parameters:
addr
-Address
symbolName
- name- Throws:
IOException
- if error
-
labelAddress
Places a label at the specified address.- Parameters:
addr
-Address
symbolName
- namenamespaceName
- name of namespace to place the label symbol in, or null if root- Throws:
IOException
- if error
-
appendComment
public void appendComment(FieldContext<?> fieldContext, int commentType, String prefix, String comment, String sep) throws IOException Adds a comment to the specified field, appending to any previous values already there. If the existing comment already contains the specified comment value, the operation is skipped.- Parameters:
fieldContext
- the fieldcommentType
-CodeUnit.EOL_COMMENT
,CodeUnit.PLATE_COMMENT
,CodeUnit.POST_COMMENT
,CodeUnit.PRE_COMMENT
prefix
- String prefix to place in front of the comment stringcomment
- String value to appendsep
- separator to use between existing comments (for example, "\n")- Throws:
IOException
- if error adding comment
-
appendComment
public void appendComment(StructureContext<?> structureContext, int commentType, String prefix, String comment, String sep) throws IOException Adds a comment to the specified structure, appending to any previous values already there. If the existing comment already contains the specified comment value, the operation is skipped.- Parameters:
structureContext
- the structurecommentType
-CodeUnit.EOL_COMMENT
,CodeUnit.PLATE_COMMENT
,CodeUnit.POST_COMMENT
,CodeUnit.PRE_COMMENT
prefix
- String prefix to place in front of the comment stringcomment
- String value to appendsep
- separator to use between existing comments (for example, "\n")- Throws:
IOException
- if error adding comment
-
appendComment
-
markupStructure
public <T> void markupStructure(StructureContext<T> structureContext, boolean nested) throws IOException, CancelledException Decorates a structure mapped structure, and everything it contains.- Type Parameters:
T
- structure mapped type- Parameters:
structureContext
-StructureContext
nested
- if true, it is assumed that the Ghidra data types have already been placed and only markup needs to be performed.- Throws:
IOException
- if error marking up structureCancelledException
- if cancelled
-
markupArrayElementReferences
public void markupArrayElementReferences(Address arrayAddr, int elementSize, List<Address> targetAddrs) throws IOException Creates references from each element of an array to a list of target addresses.- Parameters:
arrayAddr
- the address of the start of the arrayelementSize
- the size of each array elementtargetAddrs
- list of addresses that will receive references from each array elements- Throws:
IOException
- if error
-
createFunctionIfMissing
Creates a default function at the specified address.- Parameters:
name
- name of the new functionns
- namespace function should be inaddr
- address of the new function- Returns:
Function
that was created
-
addReference
Creates a reference from the specified field to the specified address.- Parameters:
fieldContext
- field, is the source of the referencerefDest
- destination address of the reference
-
logWarningAt
-
logWarningAt
-