DataType interface is the foundation of Ghidra’s type system. All datatypes implement this interface, providing methods for type metadata, encoding/decoding, and type operations.
Overview
Data types in Ghidra represent:- Primitive Types - Built-in types (int, char, float, etc.)
- Pointer Types - References to other types
- Array Types - Fixed-size sequences of elements
- Structure Types - Composite types with named fields
- Union Types - Overlapping field storage
- Function Signatures - Function prototypes
- Typedef - Type aliases
Core Properties
Type Identity
String
Returns the name of the datatype.
String
Returns the display name for this datatype.
String
Returns the full category path including the datatype name.
void
Sets the name of the datatype.
Size and Alignment
int
Returns the length of this datatype as a number of 8-bit bytes.For primitive types, this is the raw data length (smallest varnode size).
Dynamic and factory datatypes return -1.
No datatype except VoidDataType should ever return 0. Zero-length types should return 1 and have isZeroLength() return true.
int
Returns the aligned length, equivalent to C/C++ sizeof().For most types this equals getLength(). For some primitives it may differ due to alignment requirements.
int
Returns the alignment requirement when this type is used within another type.
boolean
Returns true if this datatype is defined with zero length.
Zero-length types still return 1 from getLength().
boolean
Returns true if this datatype has not yet been fully defined (e.g., empty structure).
Category and Path
CategoryPath
Returns the category path for this datatype.
void
Sets the category path for this datatype.
DataTypePath
Returns the complete datatype path.
Description
String
Returns a brief description of this datatype.
void
Sets a brief description for this datatype.
Data Type Manager
DataTypeManager
Returns the DataTypeManager containing this datatype.
boolean
Returns true if the length is determined by the DataOrganization.
Type Operations
Clone and Copy
DataType
Returns an instance using the specified DataTypeManager, retaining unique identity.
Returns the same instance if the DataTypeManager matches.
DataType
Returns a new instance (shallow copy) with a new identity.
Equivalence
boolean
Checks if the given datatype is equivalent to this datatype.The meaning of “equivalent” is datatype-dependent.
boolean
Checks if this datatype depends on the existence of the given datatype.
Replace
void
Replaces the internals of this datatype with the internals of the given datatype.
Value Operations
Get Value
Object
Returns the interpreted data value.For pointers, returns an Address. For integers, returns a Scalar.
Class<?>
Returns the Class of the value object returned by getValue().
Representation
String
Returns a string representation of the data.
Encoding
boolean
Returns true if this type supports encoding (patching).
byte[]
Encodes a value object to bytes.
byte[]
Encodes a string representation to bytes.
Mnemonic and Labels
String
Returns the mnemonic for this datatype.
String
Returns the default label prefix for this datatype.
String
Returns an abbreviated label prefix.
String
Returns the context-aware default label prefix.
Settings
Settings
Returns the default settings for this datatype.
SettingsDefinition[]
Returns the settings definitions available for this datatype.
TypeDefSettingsDefinition[]
Returns settings definitions for use with TypeDef.
Type Metadata
Universal ID
UniversalID
Returns the universal ID for this datatype.This is a unique identifier across all programs and archives.
Source Archive
SourceArchive
Returns the source archive where this type originated.
void
Sets the source archive.
Timestamps
long
Returns the timestamp of the last change within the datatype manager.
void
Sets the last change timestamp.
long
Returns the timestamp of the last sync with the source archive.
void
Sets the source archive sync timestamp.
Type Relationships
Collection<DataType>
Returns the parent datatypes that reference this datatype.
This method is intended for DB-managed datatypes only.
void
Informs this datatype of a parent relationship.
void
Removes a parent datatype relationship.
State Checks
boolean
Returns true if this datatype has been deleted.
Data Organization
DataOrganization
Returns the DataOrganization associated with this datatype.
Common Data Types
Built-in Types
Creating Arrays
Creating Pointers
Creating Structures
Creating Unions
Example Usage
Working with Data Types
Creating Custom Types
Applying Types to Memory
Package Location
Related Interfaces
- DataTypeManager - Type manager
- Structure - Structure types
- Union - Union types
- Array - Array types
- Pointer - Pointer types
Constants
DataType
Singleton instance of default datatype
DataType
Instance of void datatype (deprecated, use VoidDataType.dataType)
String
Datatype name conflict suffix:
".conflict"