value

package
v0.0.0-...-6c7272e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package value contains the value types used by the replay virtual machine.

Each numerical and boolean value type is backed by a corresponding primitive Go type for convenience of construction and usage. Pointer values can belong to various different address spaces, and for compatibility with both 32 and 64 bit architectures, are all backed by uint64.

Index

Constants

View Source
const FirstValidAddress = 0x1001

Anything very low in application address-space is extremely unlikely to be a valid pointer.

Variables

Functions

This section is empty.

Types

type AbsolutePointer

type AbsolutePointer uint64

AbsolutePointer is a pointer in the absolute address-space that will not be altered before being passed to the protocol.

func (AbsolutePointer) Get

func (p AbsolutePointer) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeAbsolutePointer and the uint64 value of the absolute pointer.

func (AbsolutePointer) IsValid

func (p AbsolutePointer) IsValid() bool

IsValid returns true for all absolute pointers.

func (AbsolutePointer) Offset

func (p AbsolutePointer) Offset(offset uint64) Pointer

Offset returns the sum of the pointer with offset.

type AbsoluteStackPointer

type AbsoluteStackPointer struct{}

AbsoluteStackPointer represents a pointer on the top of the stack in the absolute address-space that will not be altered before being passed to the protocol.

func (AbsoluteStackPointer) Get

func (p AbsoluteStackPointer) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeAbsolutePointer and the uint64 value of the absolute pointer.

func (AbsoluteStackPointer) IsValid

func (p AbsoluteStackPointer) IsValid() bool

IsValid returns true for all absolute pointers.

func (AbsoluteStackPointer) Offset

func (p AbsoluteStackPointer) Offset(offset uint64) Pointer

Offset returns the sum of the pointer with offset.

type Bool

type Bool bool

Bool is a Value of type TypeBool.

func (Bool) Get

func (v Bool) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeBool and 1 if the Bool is true, otherwise 0.

type ConstantPointer

type ConstantPointer uint64

ConstantPointer is a pointer in the constant address-space that will not be altered before being passed to the protocol.

func (ConstantPointer) Get

func (p ConstantPointer) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeConstantPointer and the uint64 value of the pointer in constant address-space.

func (ConstantPointer) IsValid

func (p ConstantPointer) IsValid() bool

IsValid returns true.

func (ConstantPointer) Offset

func (p ConstantPointer) Offset(offset uint64) Pointer

Offset returns the sum of the pointer with offset.

type F32

type F32 float32

F32 is a Value of type TypeFloat.

func (F32) Get

func (v F32) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeFloat and the IEEE 754 representation of the value packed into the low part of a uint64.

type F64

type F64 float64

F64 is a Value of type TypeDouble.

func (F64) Get

func (v F64) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeDouble and the IEEE 754 representation of the value packed into a uint64.

type ObservedPointer

type ObservedPointer uint64

ObservedPointer is a pointer that was observed at capture time. Pointers of this type are remapped to an equivalent volatile address-space pointer, or absolute address-space pointer before being passed to the protocol.

func (ObservedPointer) Get

func (p ObservedPointer) Get(r PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns the pointer type and the pointer translated to either an equivalent volatile address-space pointer or absolute pointer.

func (ObservedPointer) IsValid

func (p ObservedPointer) IsValid() bool

IsValid returns true if the pointer considered valid. Currently this is a test for the pointer being greater than 0x1000 as low addresses are likely to be a wrong interpretation of the value. This may change in the future.

func (ObservedPointer) Offset

func (p ObservedPointer) Offset(offset uint64) Pointer

Offset returns the sum of the pointer with offset.

type Pointer

type Pointer interface {
	Value

	// Offset returns the Pointer offset by v.
	Offset(v uint64) Pointer

	// IsValid returns true if the pointer is within acceptable ranges.
	IsValid() bool
}

Pointer is a pointer-typed Value.

type PointerIndex

type PointerIndex uint64

PointerIndex is an index to a pointer in the pointer table.

func (PointerIndex) Get

func (p PointerIndex) Get(r PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeVolatilePointer and the volatile address of the pointer.

func (PointerIndex) IsValid

func (p PointerIndex) IsValid() bool

IsValid returns true.

func (PointerIndex) Offset

func (p PointerIndex) Offset(offset uint64) Pointer

Offset returns the sum of the pointer index with offset.

type PointerResolver

type PointerResolver interface {
	// ResolveTemporaryPointer returns the temporary address-space pointer ptr
	// translated to volatile address-space.
	ResolveTemporaryPointer(TemporaryPointer) VolatilePointer

	// ResolveObservedPointer returns the pointer translated to volatile or
	// absolute address-space.
	ResolveObservedPointer(ObservedPointer) (protocol.Type, uint64)

	// ResolvePointerIndex returns the pointer to the pointer with the specified
	// index.
	ResolvePointerIndex(PointerIndex) (protocol.Type, uint64)
}

PointerResolver is used to translate pointers into the volatile address-space.

type S16

type S16 int16

S16 is a Value of type TypeInt16.

func (S16) Get

func (v S16) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeInt16 and the value sign-extended to a uint64.

type S32

type S32 int32

S32 is a Value of type TypeInt32.

func (S32) Get

func (v S32) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeInt32 and the value sign-extended to a uint64.

type S64

type S64 int64

S64 is a Value of type TypeInt64.

func (S64) Get

func (v S64) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeInt64 and the value reinterpreted as a uint64.

type S8

type S8 int8

S8 is a Value of type TypeInt8.

func (S8) Get

func (v S8) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeInt8 and the value sign-extended to a uint64.

type TemporaryPointer

type TemporaryPointer uint64

TemporaryPointer is a pointer to in temporary address-space. The temporary address-space sits within a reserved area of the the volatile address space and its offset is calculated dynamically. TODO: REMOVE

func (TemporaryPointer) Get

func (p TemporaryPointer) Get(r PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeVolatilePointer and the dynamically calculated offset of the temporary pointer within volatile address-space.

func (TemporaryPointer) IsValid

func (p TemporaryPointer) IsValid() bool

IsValid returns true.

func (TemporaryPointer) Offset

func (p TemporaryPointer) Offset(offset uint64) Pointer

Offset returns the sum of the pointer with offset.

type U16

type U16 uint16

U16 is a Value of type TypeUint16.

func (U16) Get

func (v U16) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeUint16 and the value zero-extended to a uint64.

type U32

type U32 uint32

U32 is a Value of type TypeUint32.

func (U32) Get

func (v U32) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeUint32 and the value zero-extended to a uint64.

type U64

type U64 uint64

U64 is a Value of type TypeUint64.

func (U64) Get

func (v U64) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeUint64 the value zero-extended to a uint64.

type U8

type U8 uint8

U8 is a Value of type TypeUint8.

func (U8) Get

func (v U8) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeUint8 and the value zero-extended to a uint64.

type Value

type Value interface {
	// Get returns the protocol type and the bit-representation of the value.
	// For example a boolean value would either be 0 or 1, a uint32 value would be
	// zero-extended, a float64 would be the IEEE 754 representation
	// reinterpreted as a uint64.
	// If onStack returns true then the value is stored on the top of the VM
	// stack, and val should be ignored.
	Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)
}

Value is the interface for all values to be passed either in opcodes or constant memory to the replay virtual machine.

type VolatilePointer

type VolatilePointer uint64

VolatilePointer is a pointer to the volatile address-space. Unlike ObservedPointer, there is no remapping.

func (VolatilePointer) Get

func (p VolatilePointer) Get(PointerResolver) (ty protocol.Type, val uint64, onStack bool)

Get returns TypeVolatilePointer and the uint64 value of the pointer in volatile address-space.

func (VolatilePointer) IsValid

func (p VolatilePointer) IsValid() bool

IsValid returns true.

func (VolatilePointer) Offset

func (p VolatilePointer) Offset(offset uint64) Pointer

Offset returns the sum of the pointer with offset.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL