Contains classes and instances related to the description of data types.
The primary use of the classes in this module is to build the type argument ty to the reven2.trace.Context.read
and reven2.trace.Context.deref
methods, that allow to read a register or part of the memory as a specific data type. For more information on reading as type, please refer to the documentation of the reven2.trace.Context.read
method.
This package mainly defines primitive types (such as Bool
, F32
, U64
) as well as type constructors, e.g. classes whose instances are a type, and named, user-defined types constructors such as Structs or Enumerations.
It also provides instance types, such as StructInstance
, that represent the result of reading certain types.
Primitives
Bool
is the boolean type.U8
,U16
,U32
,U64
,U128
are unsigned integers of respective size 8, 16, 32 and 64 bits, in the native x86_64 endiannessI8
,I16
,I32
,I64
andI128
for signed integersUSize
andISize
for (un)signed integers whose size is the same as an address. When using context.read(address, USize), the actual length of the read will depend on whether the context is in 64 or in 32 bits mode.F16
,F32
andF64
are 16, 32 and 64 bits floating point numbers.
Type constructors
FixedWidthInteger
allows to build any size of integers.LittleEndian
andBigEndian
accept an integer type as a parameter, and forces its endianness to little or big.Pointer
takes a type T as a parameter, and returns type "pointer to T" (T* in C speak). Its main use is with thereven2.trace.Context.deref
method.Array
takes a type T and a count as parameters, and returns the type describing a contiguous array of T. T ([T; n]).RawBuffer
is a specialized version ofArray
on bytes.CString
accepts a maximum count N, and return the type that designates "NUL-terminated strings of a maximum size N"
User-defined named type constructors
Struct
represents a user-defined, named struct, class or union.Enumeration
represents a user-defined, named enumeration.
Instance types
StructInstance
represents the result of reading aStruct
at some context.EnumerationInstance
represents the result of reading anEnumeration
at some context.ArrayInstance
represents the result of reading anArray
at some context.PointerInstance
represents the result of reading aPointer
at some context. Note that, for backcompatibility concerns, ctx.read(src, pointer) currently returns an address rather than aPointerInstance
.
Special types
ErrorType
represents a type that couldn't be built for some reason, stored in itsErrorType.message
method.VoidType
represents any opaque type that can be stored behind a level of indirection.
Forward declarations types
UnresolvedEnumeration
represents a forward declaration of an enumeration.UnresolvedStruct
represents a forward declaration of a struct, class or union.
Utils
TypeResolver
represents a type resolver that can be used to resolve user-made forward declaration.
Context
Some Type
methods accept a context parameter (that defaults to None).
This parameter represents the current context of execution, and should generally be of type reven2.trace.Context
.
This parameter is necessary, because the size and value of certain types may depend on the context of execution. For instance, a Pointer is 8 bytes in a 64 bits context, and 4 bytes in a 32 bits context (if its size argument was not specified).
Generally, users of the API should not have to provide explicit values for the context parameter, as the methods of Type objects will be called by the context instance itself rather than directly by the user.
Some types are context-insensitive. This means that their properties will not be affected by the context value passed to the various methods of the type. For context-insensitive types, the is_context_sensitive method will return False, and you can pass any object as context parameter (even None).
Module | _array |
This module provides the Array type. |
Module | _declaration |
This module provides several types that represent unresolved types, such as type forward declarations in C. |
Module | _enum |
This module provides the Enumeration type and associated types. |
Module | _error |
This module provides the ErrorType type and associated types. |
Module | _instance |
This module provides the various instance types that represents the result of reading certain types, such as a Struct . |
Module | _integer |
Provides the Integer types and type constructors operating on integers such as BigEndian as well as the Endianness and Signedness enums. |
Module | _pointer |
This modules contains the Pointer type. |
Module | _primitive |
This module defines the primitive types manipulated by the API. |
Module | _string |
The module defining the CString type and the Encoding enum describing the available encodings. |
Module | _struct |
The module defining the Struct type and related types. |
Module | _type |
Module defining the Type class. |
Module | _typeinfo |
Undocumented |
Module | _void |
The module containing the void type and its associated error type. |