class Pointer(Type):
A type constructor that accepts a type T as parameter and builds the type representing "a pointer to T" (T*).
The main use of pointer types is that they can be dereferenced. See reven2.trace.Context.deref for more information.
When an instance of a pointer type is read, it is returned as an address, built from the read offset and from a base address stored in the pointer type.
Note: when reading the address of a pointer, it is considered like an integer of the same endianness, signedness and size as USize.
| Method | __init__ |
Initializes a new pointer type from its element type and the kind of address it should produce. |
| Method | size_bytes |
The minimal number of bytes necessary to hold an instance of a pointer, depending on the context. |
| Method | parse |
Parses the value of a pointer from a raw buffer, depending on the context. Always returns an address |
| Property | elem_type |
Property: The pointed-to type. |
| Method | is_context_sensitive |
Whether the context argument needed by some methods actually has an effect. |
| Instance Variable | _elem_type |
Undocumented |
| Instance Variable | _base_address |
Undocumented |
| Method | _construct_type |
Return the underlying construct instance |
| Static Method | _compute_base_address |
Undocumented |
Inherited from Type:
| Method | to_bytes |
Build a byte buffer from a value of this type. |
Initializes a new pointer type from its element type and the kind of address it should produce.
When the value of a Pointer is read, it is returned as an address. Since there are logical addresses with various segments, linear addresses and physical addresses, it is important that a Pointer instance knows which kind of addresses it should produce.
To determine the kind of address produced by a Pointer instance, one of the following arguments can be provided to its constructor:
If none of these arguments is provided, then the address kind will default to logical addresses with the default segment (ds).
| Parameters | elem_type | the pointed-to type. |
| segment_register | a segment register indicating that logical addresses using this segment register should be produced. | |
| segment_index | an integer indicating that logical addresses using this segment index should be produced. | |
| is_linear | if True, indicates that linear addresses should be produced. | |
| is_physical | if True, indicates that physical addresses should be produced. | |
| base_address | the base address from which addresses should be produced. | |
| Raises | TypeError | if elem_type is not a type |
| TypeError | if base_address is not an address | |
| ValueError | if more than one in 'segment_register', 'segment_index', 'is_linear', 'is_physical' or 'base_address' is provided |
reven2.types._type.Type.size_bytesThe minimal number of bytes necessary to hold an instance of a pointer, depending on the context.
| Parameters | context | The context object. See package documentation. |
| Returns | An integer. | |
reven2.types._type.Type.parseParses the value of a pointer from a raw buffer, depending on the context. Always returns an address
| Parameters | buf | Undocumented |
| context | The context object. See package documentation. | |
| Returns | An address from reven2.address. | |
reven2.types._type.Type._construct_typeReturn the underlying construct instance
Whether the context argument needed by some methods actually has an effect.
Types that return False to this method are context-insensitive types. You can safely pass any object as context parameter (including None) to the methods of such type.
Note that the context-sensitivity of a type may change in the future.
Getting the size of a type without needing a context for context-insensitive types: >>> types.U32.is_context_sensitive() False >>> types.U32.size_bytes(context=None) 4 >>> array32_12 = types.Array(types.U32, 12) >>> array32_12.is_context_sensitive() False >>> array32_12.size_bytes() # context=None by default 48
Context-sensitive types may raise errors when attempting to get the size without a context: >>> types.USize.is_context_sensitive() True >>> types.USize.size_bytes(context=None) ValueError: Please provide a context when using a context-sensitive type