Package ghidra.program.model.data
Class NoisyStructureBuilder
java.lang.Object
ghidra.program.model.data.NoisyStructureBuilder
Build a structure from a "noisy" source of field information.
Feed it field records, either via addDataType(), when we
have more definitive info about the size of the field, or via addReference()
when we have a pointer reference to the field with possibly less info about the field size.
As records come in, overlaps and conflicts in specific field data-types are resolved.
In a conflict, less specific data-types are replaced.
After all information is collected a final Structure can be built by iterating over
the final field entries.
NOTE: No attempt has been made to utilize
DataType.getAlignedLength()
when considering
component type lengths.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDataType
(long offset, DataType dt) Add data-type information about a specific fieldvoid
addReference
(long offset, DataType dt) Adds information for a field given a pointer reference.long
getSize()
iterator()
void
Populate this builder with fields from a preexisting Structure.void
setMinimumSize
(long size) We may have partial information about the size of the structure.
-
Constructor Details
-
NoisyStructureBuilder
public NoisyStructureBuilder()
-
-
Method Details
-
getSize
public long getSize()- Returns:
- the size of the structure in bytes (given current information)
-
addDataType
Add data-type information about a specific field- Parameters:
offset
- of the field within the structuredt
- is the data-type of field if known (null otherwise)
-
addReference
Adds information for a field given a pointer reference. The data-type information is not used unless it is a pointer.- Parameters:
offset
- is the offset of the field within the structuredt
- is the data-type of the pointer to the field (or null)
-
setMinimumSize
public void setMinimumSize(long size) We may have partial information about the size of the structure. This method feeds it to the builder as a minimum size for the structure.- Parameters:
size
- is the minimum size in bytes
-
iterator
- Returns:
- an iterator to the current field entries
-
populateOriginalStructure
Populate this builder with fields from a preexisting Structure. The builder presumes it is rebuilding this Structure so it can check for pathological containment issues.- Parameters:
dt
- is the preexisting Structure
-