Package ghidra.program.model.data
Class PointerTypedefBuilder
java.lang.Object
ghidra.program.model.data.PointerTypedefBuilder
PointerTypedefBuilder
provides a builder for creating Pointer
- TypeDef
s.
These special typedefs allow a modified-pointer datatype to be used for special situations where
a simple pointer will not suffice and special stored pointer interpretation/handling is required.
This builder simplifies the specification of various
Pointer
modifiers during the
construction of an associated TypeDef
.
A convenience method
Pointer.typedefBuilder()
also exists for creating a builder
from a pointer instance. In addition the utility class PointerTypedefInspector
can be used to easily determine pointer-typedef settings.-
Constructor Summary
ConstructorDescriptionPointerTypedefBuilder
(DataType baseDataType, int pointerSize, DataTypeManager dtm) PointerTypedefBuilder
(Pointer pointerDataType, DataTypeManager dtm) -
Method Summary
Modifier and TypeMethodDescriptionaddressSpace
(AddressSpace space) Update pointer referenced address space when translating to an absolute memory offset.addressSpace
(String spaceName) Update pointer referenced address space when translating to an absolute memory offset.bitMask
(long unsignedMask) Update pointer offset bit-mask when translating to an absolute memory offset.bitShift
(int shift) Update pointer offset bit-shift when translating to an absolute memory offset.build()
Build pointer-typedef with specified settings.componentOffset
(long offset) Update pointer relative component-offset.Set pointer-typedef name.type
(PointerType type) Update pointer type.
-
Constructor Details
-
PointerTypedefBuilder
- Parameters:
baseDataType
- baseDataType or null to use a default pointerpointerSize
- pointer size or -1 to use default pointer size for specified datatype manager.dtm
- datatype manager (highly recommended although may be null)
-
PointerTypedefBuilder
- Parameters:
pointerDataType
- base pointer datatype (required)dtm
- datatype manager (highly recommended although may be null)
-
-
Method Details
-
name
Set pointer-typedef name. If not specified a default name will be generated based upon the associated pointer type and the specified settings.- Parameters:
name
- typedef name- Returns:
- this builder
- Throws:
InvalidNameException
- if name contains unsupported characters
-
type
Update pointer type.- Parameters:
type
- pointer type- Returns:
- this builder
-
bitShift
Update pointer offset bit-shift when translating to an absolute memory offset. If specified, bit-shift will be applied after applying any specified bit-mask.- Parameters:
shift
- bit-shift (right: positive, left: negative)- Returns:
- this builder
-
bitMask
Update pointer offset bit-mask when translating to an absolute memory offset. If specified, bit-mask will be AND-ed with stored offset prior to any specified bit-shift.- Parameters:
unsignedMask
- unsigned bit-mask- Returns:
- this builder
-
componentOffset
Update pointer relative component-offset. This setting is interpretted in two ways:- The specified offset is considered to be relative to the start of the base datatype (e.g., structure). It may refer to a component-offset within the base datatype or outside of it.
- When pointer-typedef is initially applied to memory, an
OffsetReference
will be produced by subtracting the component-offset from the stored pointer offset to determine the base-offset for the reference. While the xref will be to the actual referenced location, the reference markup will be shown as <base>+<offset>
- Parameters:
offset
- component offset relative to a base-offset and associated base-datatype- Returns:
- this builder
-
addressSpace
Update pointer referenced address space when translating to an absolute memory offset.- Parameters:
space
- pointer referenced address space or null for default space- Returns:
- this builder
-
addressSpace
Update pointer referenced address space when translating to an absolute memory offset.- Parameters:
spaceName
- pointer referenced address space or null for default space- Returns:
- this builder
-
build
Build pointer-typedef with specified settings.- Returns:
- unresolved pointer typedef
-