decompiler 1.0.0
Classes | Typedefs | Enumerations | Functions | Variables
type.hh File Reference

Classes for describing and printing data-types. More...

#include "address.hh"

Classes

class  Datatype
 The base datatype class for the decompiler. More...
 
class  TypeField
 A field within a structure or union. More...
 
struct  DatatypeCompare
 Compare two Datatype pointers for equivalence of their description. More...
 
struct  DatatypeNameCompare
 Compare two Datatype pointers: first by name, then by id. More...
 
class  TypeBase
 Base class for the fundamental atomic types. More...
 
class  TypeChar
 Base type for character data-types: i.e. char. More...
 
class  TypeUnicode
 The unicode data-type: i.e. wchar. More...
 
class  TypeVoid
 Formal "void" data-type object. More...
 
class  TypePointer
 Datatype object representing a pointer. More...
 
class  TypeArray
 Datatype object representing an array of elements. More...
 
class  TypeEnum
 An enumerated Datatype object: an integer with named values. More...
 
class  TypeStruct
 A composite Datatype object: A structure with component fields. More...
 
class  TypeUnion
 A collection of overlapping Datatype objects: A union of component fields. More...
 
class  TypePartialUnion
 An internal data-type for holding information about a variable's relative position within a union data-type. More...
 
class  TypePointerRel
 Relative pointer: A pointer with a fixed offset into a specific structure or other data-type. More...
 
class  TypeCode
 Datatype object representing executable code. More...
 
class  TypeSpacebase
 Special Datatype object used to describe pointers that index into the symbol table. More...
 
class  TypeFactory
 Container class for all Datatype objects in an Architecture. More...
 

Typedefs

typedef set< Datatype *, DatatypeCompareDatatypeSet
 A set of data-types sorted by function.
 
typedef set< Datatype *, DatatypeNameCompareDatatypeNameSet
 A set of data-types sorted by name.
 

Enumerations

enum  type_metatype {
  TYPE_VOID = 14 , TYPE_SPACEBASE = 13 , TYPE_UNKNOWN = 12 , TYPE_INT = 11 ,
  TYPE_UINT = 10 , TYPE_BOOL = 9 , TYPE_CODE = 8 , TYPE_FLOAT = 7 ,
  TYPE_PTR = 6 , TYPE_PTRREL = 5 , TYPE_ARRAY = 4 , TYPE_STRUCT = 3 ,
  TYPE_UNION = 2 , TYPE_PARTIALSTRUCT = 1 , TYPE_PARTIALUNION = 0
}
 
enum  sub_metatype {
  SUB_VOID = 22 , SUB_SPACEBASE = 21 , SUB_UNKNOWN = 20 , SUB_INT_CHAR = 19 ,
  SUB_UINT_CHAR = 18 , SUB_INT_PLAIN = 17 , SUB_UINT_PLAIN = 16 , SUB_INT_ENUM = 15 ,
  SUB_UINT_ENUM = 14 , SUB_INT_UNICODE = 13 , SUB_UINT_UNICODE = 12 , SUB_BOOL = 11 ,
  SUB_CODE = 10 , SUB_FLOAT = 9 , SUB_PTRREL_UNK = 8 , SUB_PTR = 7 ,
  SUB_PTRREL = 6 , SUB_PTR_STRUCT = 5 , SUB_ARRAY = 4 , SUB_PARTIALSTRUCT = 3 ,
  SUB_STRUCT = 2 , SUB_UNION = 1 , SUB_PARTIALUNION = 0
}
 

Functions

void print_data (ostream &s, uint1 *buffer, int4 size, const Address &baseaddr)
 Print a hex dump of a data buffer to stream. More...
 
void metatype2string (type_metatype metatype, string &res)
 Convert type meta-type to name. More...
 
type_metatype string2metatype (const string &metastring)
 Convert string to type meta-type. More...
 

Variables

AttributeId ATTRIB_ALIGNMENT
 Marshaling attribute "alignment".
 
AttributeId ATTRIB_ARRAYSIZE
 Marshaling attribute "arraysize".
 
AttributeId ATTRIB_CHAR
 Marshaling attribute "char".
 
AttributeId ATTRIB_CORE
 Marshaling attribute "core".
 
AttributeId ATTRIB_ENUM
 Marshaling attribute "enum".
 
AttributeId ATTRIB_ENUMSIGNED
 Marshaling attribute "enumsigned".
 
AttributeId ATTRIB_ENUMSIZE
 Marshaling attribute "enumsize".
 
AttributeId ATTRIB_INTSIZE
 Marshaling attribute "intsize".
 
AttributeId ATTRIB_LONGSIZE
 Marshaling attribute "longsize".
 
AttributeId ATTRIB_OPAQUESTRING
 Marshaling attribute "opaquestring".
 
AttributeId ATTRIB_SIGNED
 Marshaling attribute "signed".
 
AttributeId ATTRIB_STRUCTALIGN
 Marshaling attribute "structalign".
 
AttributeId ATTRIB_UTF
 Marshaling attribute "utf".
 
AttributeId ATTRIB_VARLENGTH
 Marshaling attribute "varlength".
 
ElementId ELEM_CORETYPES
 Marshaling element <coretypes>
 
ElementId ELEM_DATA_ORGANIZATION
 Marshaling element <data_organization>
 
ElementId ELEM_DEF
 Marshaling element <def>
 
ElementId ELEM_ENTRY
 Marshaling element <entry>
 
ElementId ELEM_ENUM
 Marshaling element <enum>
 
ElementId ELEM_FIELD
 Marshaling element <field>
 
ElementId ELEM_INTEGER_SIZE
 Marshaling element <integer_size>
 
ElementId ELEM_LONG_SIZE
 Marshaling element <long_size>
 
ElementId ELEM_SIZE_ALIGNMENT_MAP
 Marshaling element <size_alignment_map>
 
ElementId ELEM_TYPE
 Marshaling element <type>
 
ElementId ELEM_TYPEGRP
 Marshaling element <typegrp>
 
ElementId ELEM_TYPEREF
 Marshaling element <typeref>
 

Detailed Description

Classes for describing and printing data-types.

Enumeration Type Documentation

◆ sub_metatype

Specializations of the core meta-types. Each enumeration is associated with a specific type_metatype. Ordering is important: The lower the number, the more specific the data-type, affecting propagation.

Enumerator
SUB_VOID 

Compare as a TYPE_VOID.

SUB_SPACEBASE 

Compare as a TYPE_SPACEBASE.

SUB_UNKNOWN 

Compare as a TYPE_UNKNOWN.

SUB_INT_CHAR 

Signed 1-byte character, sub-type of TYPE_INT.

SUB_UINT_CHAR 

Unsigned 1-byte character, sub-type of TYPE_UINT.

SUB_INT_PLAIN 

Compare as a plain TYPE_INT.

SUB_UINT_PLAIN 

Compare as a plain TYPE_UINT.

SUB_INT_ENUM 

Signed enum, sub-type of TYPE_INT.

SUB_UINT_ENUM 

Unsigned enum, sub-type of TYPE_UINT.

SUB_INT_UNICODE 

Signed wide character, sub-type of TYPE_INT.

SUB_UINT_UNICODE 

Unsigned wide character, sub-type of TYPE_UINT.

SUB_BOOL 

Compare as TYPE_BOOL.

SUB_CODE 

Compare as TYPE_CODE.

SUB_FLOAT 

Compare as TYPE_FLOAT.

SUB_PTRREL_UNK 

Pointer to unknown field of struct, sub-type of TYPE_PTR.

SUB_PTR 

Compare as TYPE_PTR.

SUB_PTRREL 

Pointer relative to another data-type, sub-type of TYPE_PTR.

SUB_PTR_STRUCT 

Pointer into struct, sub-type of TYPE_PTR.

SUB_ARRAY 

Compare as TYPE_ARRAY.

SUB_PARTIALSTRUCT 

Compare as TYPE_PARTIALSTRUCT.

SUB_STRUCT 

Compare as TYPE_STRUCT.

SUB_UNION 

Compare as TYPE_UNION.

SUB_PARTIALUNION 

Compare as a TYPE_PARTIALUNION.

◆ type_metatype

The core meta-types supported by the decompiler. These are sizeless templates for the elements making up the type algebra. Index is important for Datatype::base2sub array.

Enumerator
TYPE_VOID 

Standard "void" type, absence of type.

TYPE_SPACEBASE 

Placeholder for symbol/type look-up calculations.

TYPE_UNKNOWN 

An unknown low-level type. Treated as an unsigned integer.

TYPE_INT 

Signed integer. Signed is considered less specific than unsigned in C.

TYPE_UINT 

Unsigned integer.

TYPE_BOOL 

Boolean.

TYPE_CODE 

Data is actual executable code.

TYPE_FLOAT 

Floating-point.

TYPE_PTR 

Pointer data-type.

TYPE_PTRREL 

Pointer relative to another data-type (specialization of TYPE_PTR)

TYPE_ARRAY 

Array data-type, made up of a sequence of "element" datatype.

TYPE_STRUCT 

Structure data-type, made up of component datatypes.

TYPE_UNION 

An overlapping union of multiple datatypes.

TYPE_PARTIALSTRUCT 

Part of a structure, stored separately from the whole.

TYPE_PARTIALUNION 

Part of a union.

Function Documentation

◆ metatype2string()

void metatype2string ( type_metatype  metatype,
string &  res 
)

Convert type meta-type to name.

Convert a type meta-type into the string name of the meta-type

Parameters
metatypeis the encoded type meta-type
reswill hold the resulting string

References TYPE_ARRAY, TYPE_BOOL, TYPE_CODE, TYPE_FLOAT, TYPE_INT, TYPE_PARTIALSTRUCT, TYPE_PARTIALUNION, TYPE_PTR, TYPE_PTRREL, TYPE_SPACEBASE, TYPE_STRUCT, TYPE_UINT, TYPE_UNION, TYPE_UNKNOWN, and TYPE_VOID.

Referenced by Datatype::encodeBasic().

◆ print_data()

void print_data ( ostream &  s,
uint1 *  buffer,
int4  size,
const Address baseaddr 
)

Print a hex dump of a data buffer to stream.

Display an array of bytes as a hex dump at a given address. Each line displays an address and 16 bytes in hexadecimal

Parameters
sis the stream to write to
bufferis a pointer to the bytes
sizeis the number of bytes
baseaddris the address of the first byte in the buffer

References Address::getOffset().

Referenced by IfcDump::execute().

◆ string2metatype()

type_metatype string2metatype ( const string &  metastring)

Convert string to type meta-type.

Given a string description of a type meta-type. Return the meta-type.

Parameters
metastringis the description of the meta-type
Returns
the encoded type meta-type

References TYPE_ARRAY, TYPE_BOOL, TYPE_CODE, TYPE_FLOAT, TYPE_INT, TYPE_PARTIALSTRUCT, TYPE_PARTIALUNION, TYPE_PTR, TYPE_PTRREL, TYPE_SPACEBASE, TYPE_STRUCT, TYPE_UINT, TYPE_UNION, TYPE_UNKNOWN, and TYPE_VOID.

Referenced by ParamEntry::decode(), Datatype::decodeBasic(), and TypeFactory::decodeTypeNoRef().