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 module mainly defines primitive types (such as Bool, F32, U64) as well as type constructors, e.g. classes whose instances are a type.

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 endianness
  • I8, I16, I32, I64 and I128 for signed integers
  • USize and ISize 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.
  • F32 and F64 are 32 and 64 bits floating point numbers.

Type constructors

  • FixedWidthInteger allows to build any size of integers.
  • LittleEndian and BigEndian 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 the reven2.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 of Array on bytes.
  • CString accepts a maximum count N, and return the type that designates "NUL-terminated strings of a maximum size N"

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.

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).

API Documentation for reven2, generated by pydoctor at 2019-11-13 18:38:15.