angr.sim_type¶
- class angr.sim_type.SimType¶
Bases:
objectSimType exists to track type information for SimProcedures.
- __init__(label=None, qualifier=None)¶
- property alignment¶
The alignment of the type in bytes.
- c_repr(name=None, full=0, memo=None, indent=0, name_parens=True)¶
- copy()¶
- extract_claripy(bits)¶
Given a bitvector bits which was loaded from memory in a big-endian fashion, return a more appropriate or structured representation of the data.
A type must have an arch associated in order to use this method.
- Return type:
- to_json(fields=None, memo=None)¶
Serialize the type class to a JSON-compatible dictionary.
- class angr.sim_type.TypeRef¶
Bases:
SimTypeA TypeRef is a reference to a type with a name. This allows for interactivity in type analysis, by storing a type and having the option to update it later and have all references to it automatically update as well.
- property ty¶
- property type¶
- property name¶
This is a read-only property because it is desirable to store typerefs in a mapping from name to type, and we want the mapping to be in the loop for any updates.
- property size¶
The size of the type in bits, or None if no size is computable.
- property alignment¶
The alignment of the type in bytes.
- with_arch(arch)¶
- copy()¶
- class angr.sim_type.NamedTypeMixin¶
Bases:
objectSimType classes with this mixin in the class hierarchy allows setting custom class names. A typical use case is to represent same or similar type classes with different qualified names, such as “std::basic_string” vs “std::__cxx11::basic_string”. In such cases, .name stores the qualified name, and .unqualified_name() returns the unqualified name of the type.
- class angr.sim_type.SimTypeBottom¶
Bases:
SimTypeSimTypeBottom basically represents a type error.
- copy()¶
- class angr.sim_type.SimTypeTop¶
Bases:
SimTypeSimTypeTop represents any type (mostly used with a pointer for void*).
- copy()¶
- class angr.sim_type.SimTypeReg¶
Bases:
SimTypeSimTypeReg is the base type for all types that are register-sized.
- __init__(size, label=None, qualifier=None)¶
- copy()¶
- class angr.sim_type.SimTypeNum¶
Bases:
SimTypeSimTypeNum is a numeric type of arbitrary length
- __init__(size, signed=True, label=None, qualifier=None)¶
- extract(state, addr, concrete=False)¶
- Overloads:
self, state, addr, concrete (Literal[False]) → claripy.ast.BV
self, state, addr, concrete (Literal[True]) → int
- copy()¶
- class angr.sim_type.SimTypeInt¶
Bases:
SimTypeRegSimTypeInt is a type that specifies a signed or unsigned C integer.
- __init__(signed=True, label=None, qualifier=None)¶
- Parameters:
signed – True if signed, False if unsigned
label – The type label
qualifier (Iterable | None)
- property size¶
The size of the type in bits, or None if no size is computable.
- extract(state, addr, concrete=False)¶
- Overloads:
self, state, addr, concrete (Literal[False]) → claripy.ast.BV
self, state, addr, concrete (Literal[True]) → int
- copy()¶
- class angr.sim_type.SimTypeShort¶
Bases:
SimTypeInt
- class angr.sim_type.SimTypeLong¶
Bases:
SimTypeInt
- class angr.sim_type.SimTypeLongLong¶
Bases:
SimTypeInt
- class angr.sim_type.SimTypeFixedSizeInt¶
Bases:
SimTypeIntThe base class for all fixed-size (i.e., the size stays the same on all platforms) integer types. Do not instantiate this class directly.
- c_repr(name=None, full=0, memo=None, indent=0, name_parens=True)¶
- class angr.sim_type.SimTypeInt128¶
Bases:
SimTypeFixedSizeInt
- class angr.sim_type.SimTypeInt256¶
Bases:
SimTypeFixedSizeInt
- class angr.sim_type.SimTypeInt512¶
Bases:
SimTypeFixedSizeInt
- class angr.sim_type.SimTypeChar¶
Bases:
SimTypeRegSimTypeChar is a type that specifies a character; this could be represented by a byte, but this is meant to be interpreted as a character.
- __init__(signed=True, label=None, qualifier=None)¶
- Parameters:
label – the type label.
qualifier (Iterable | None)
- extract(state, addr, concrete=False)¶
- copy()¶
- class angr.sim_type.SimTypeWideChar¶
Bases:
SimTypeRegSimTypeWideChar is a type that specifies a wide character (a UTF-16 character).
- __init__(signed=True, label=None, endness=Endness.BE, qualifier=None)¶
- copy()¶
- class angr.sim_type.SimTypeBool¶
Bases:
SimTypeReg- __init__(signed=True, label=None, qualifier=None)¶
- Parameters:
label – the type label.
qualifier (Iterable | None)
- extract(state, addr, concrete=False)¶
- Overloads:
self, state, addr, concrete (Literal[False]) → claripy.ast.Bool
self, state, addr, concrete (Literal[True]) → bool
- copy()¶
- class angr.sim_type.SimTypeFd¶
Bases:
SimTypeRegSimTypeFd is a type that specifies a file descriptor.
- __init__(label=None, qualifier=None)¶
- Parameters:
label – the type label
qualifier (Iterable | None)
- property size¶
The size of the type in bits, or None if no size is computable.
- copy()¶
- extract(state, addr, concrete=False)¶
- Overloads:
self, state, addr, concrete (Literal[False]) → claripy.ast.BV
self, state, addr, concrete (Literal[True]) → int
- class angr.sim_type.PointerDisposition¶
Bases:
IntEnum- IN_OUT = 0¶
- IN = 1¶
- OUT = 2¶
- IN_OUTMAYBE = 3¶
- OUTMAYBE = 4¶
- NONE = 5¶
- UNKNOWN = 6¶
- __new__(value)
- class angr.sim_type.SimTypePointer¶
Bases:
SimTypeRegSimTypePointer is a type that specifies a pointer to some other type.
- __init__(pts_to, label=None, offset=0, qualifier=None, disposition=PointerDisposition.UNKNOWN)¶
- Parameters:
label – The type label.
pts_to (
SimType) – The type to which this pointer points.disposition (PointerDisposition | int)
- make(pts_to)¶
- property size¶
The size of the type in bits, or None if no size is computable.
- copy()¶
- extract(state, addr, concrete=False)¶
- Overloads:
self, state, addr, concrete (Literal[False]) → claripy.ast.BV
self, state, addr, concrete (Literal[True]) → int
- class angr.sim_type.SimTypeReference¶
Bases:
SimTypeRegSimTypeReference is a type that specifies a reference to some other type.
- refs: SimType
- make(refs)¶
- property size¶
The size of the type in bits, or None if no size is computable.
- copy()¶
- extract(state, addr, concrete=False)¶
- Overloads:
self, state, addr, concrete (Literal[False]) → claripy.ast.BV
self, state, addr, concrete (Literal[True]) → int
- class angr.sim_type.SimTypeArray¶
Bases:
SimTypeSimTypeArray is a type that specifies a series of data laid out in sequence.
- __init__(elem_type, length=None, label=None, qualifier=None)¶
- Parameters:
label – The type label.
elem_type – The type of each element in the array.
length – An expression of the length of the array, if known.
qualifier (Iterable | None)
- elem_type: SimType
- property size¶
The size of the type in bits, or None if no size is computable.
- property alignment¶
The alignment of the type in bytes.
- copy()¶
- extract(state, addr, concrete=False)¶
- Overloads:
self, state, addr, concrete (Literal[False]) → list[Any]
self, state, addr, concrete (Literal[True]) → list[Any]
- angr.sim_type.SimTypeFixedSizeArray¶
alias of
SimTypeArray
- class angr.sim_type.SimTypeString¶
Bases:
NamedTypeMixin,SimTypeSimTypeString is a type that represents a C-style string, i.e. a NUL-terminated array of bytes.
- __init__(length=None, label=None, name=None, qualifier=None)¶
- extract(state, addr, concrete=False)¶
- Overloads:
self, state, addr, concrete (Literal[False]) → claripy.ast.BV
self, state, addr, concrete (Literal[True]) → bytes
- Parameters:
state (SimState)
- property size¶
The size of the type in bits, or None if no size is computable.
- property alignment¶
The alignment of the type in bytes.
- copy()¶
- class angr.sim_type.SimTypeWString¶
Bases:
NamedTypeMixin,SimTypeA wide-character null-terminated string, where each character is 2 bytes.
- extract(state, addr, concrete=False)¶
- store(state, addr, value)¶
- property size¶
The size of the type in bits, or None if no size is computable.
- property alignment¶
The alignment of the type in bytes.
- copy()¶
- class angr.sim_type.SimTypeFunction¶
Bases:
SimTypeSimTypeFunction is a type that specifies an actual function (i.e. not a pointer) with certain types of arguments and a certain return value.
- __init__(args, returnty, label=None, arg_names=None, variadic=False)¶
- c_repr(name=None, full=0, memo=None, indent=0, name_parens=True, show_void=True)¶
- property size¶
The size of the type in bits, or None if no size is computable.
- copy()¶
- class angr.sim_type.SimTypeCppFunction¶
Bases:
SimTypeFunctionSimTypeCppFunction is a type that specifies an actual C++-style function with information about arguments, return value, and more C++-specific properties.
- Variables:
ctor – Whether the function is a constructor or not.
dtor – Whether the function is a destructor or not.
- copy()¶
- class angr.sim_type.SimTypeLength¶
Bases:
SimTypeLongSimTypeLength is a type that specifies the length of some buffer in memory.
…I’m not really sure what the original design of this class was going for
- __init__(signed=False, addr=None, length=None, label=None)¶
- Parameters:
signed – Whether the value is signed or not
label – The type label.
addr – The memory address (expression).
length – The length (expression).
- property size¶
The size of the type in bits, or None if no size is computable.
- copy()¶
- class angr.sim_type.SimTypeFloat¶
Bases:
SimTypeRegAn IEEE754 single-precision floating point number
- sort = FLOAT
- signed = True¶
- extract(state, addr, concrete=False)¶
- copy()¶
- class angr.sim_type.SimTypeDouble¶
Bases:
SimTypeFloatAn IEEE754 double-precision floating point number
- sort = DOUBLE
- property alignment¶
The alignment of the type in bytes.
- copy()¶
- class angr.sim_type.SimStruct¶
Bases:
NamedTypeMixin,SimType- fields: OrderedDict[str, SimType]
- property pack¶
- property align¶
- property packed¶
- extract(state, addr, concrete=False)¶
- Return type:
- property size¶
The size of the type in bits, or None if no size is computable.
- property alignment¶
The alignment of the type in bytes.
- copy()¶
- class angr.sim_type.SimStructValue¶
Bases:
objectA SimStruct type paired with some real values
- __init__(struct, values=None)¶
- Parameters:
struct – A SimStruct instance describing the type of this struct
values – A mapping from struct fields to values
- property struct¶
- copy()¶
- class angr.sim_type.SimUnion¶
Bases:
NamedTypeMixin,SimType- fields = ('members', 'name')¶
- __init__(members, name=None, label=None, qualifier=None)¶
- property size¶
The size of the type in bits, or None if no size is computable.
- property alignment¶
The alignment of the type in bytes.
- extract(state, addr, concrete=False)¶
- copy()¶
- class angr.sim_type.SimUnionValue¶
Bases:
objectA SimStruct type paired with some real values
- __init__(union, values=None)¶
- Parameters:
union – A SimUnion instance describing the type of this union
values – A mapping from union members to values
- copy()¶
- class angr.sim_type.SimTypeEnum¶
Bases:
NamedTypeMixin,SimTypeAn enum type with named integer constants.
- Parameters:
- property alignment¶
The alignment of the type in bytes.
- resolve(value)¶
Resolve an integer value to its enum member name.
- copy()¶
- extract(state, addr, concrete=False)¶
- store(state, addr, value)¶
- class angr.sim_type.SimTypeBitfield¶
Bases:
NamedTypeMixin,SimTypeA bitfield/flags type where values can be combinations of named bit flags.
This is useful for representing flags like PROT_READ | PROT_WRITE where multiple flags can be combined with bitwise OR.
- Parameters:
- property alignment¶
The alignment of the type in bytes.
- resolve(value)¶
Resolve an integer value to a combination of flag names.
- render(value)¶
Render an integer value as a combination of flag names.
- has_unknown_bits(value)¶
Check if a value contains bits that don’t match any known flag.
- validate(value)¶
Check if a value contains only known flags.
- copy()¶
- extract(state, addr, concrete=False)¶
- store(state, addr, value)¶
- class angr.sim_type.SimCppClass¶
Bases:
SimStruct- property members¶
- property size¶
The size of the type in bits, or None if no size is computable.
- extract(state, addr, concrete=False)¶
- Return type:
- copy()¶
- class angr.sim_type.SimCppClassValue¶
Bases:
SimStructValueA SimCppClass type paired with some real values
- copy()¶
- class angr.sim_type.SimTypeNumOffset¶
Bases:
SimTypeNumlike SimTypeNum, but supports an offset of 1 to 7 to a byte aligned address to allow structs with bitfields
- extract(state, addr, concrete=False)¶
- Overloads:
self, state (SimState), addr, concrete (Literal[False]) → claripy.ast.BV
self, state (SimState), addr, concrete (Literal[True]) → int
- Parameters:
state (SimState)
- store(state, addr, value)¶
- copy()¶
- class angr.sim_type.SimTypeRef¶
Bases:
SimTypeSimTypeRef is a to-be-resolved reference to another SimType.
SimTypeRef is not SimTypeReference.
- angr.sim_type.register_types(types)¶
Pass in some types and they will be registered to the global type store.
The argument may be either a mapping from name to SimType, or a plain SimType. The plain SimType must be either a struct or union type with a name present.
>>> register_types(parse_types("typedef int x; typedef float y;")) >>> register_types(parse_type("struct abcd { int ab; float cd; }"))
- angr.sim_type.parse_signature(defn, predefined_types=None, arch=None)¶
Parse a single function prototype and return its type
- Return type:
- angr.sim_type.parse_defns(defn, predefined_types=None, arch=None)¶
Parse a series of C definitions, returns a mapping from variable name to variable type object
- angr.sim_type.parse_types(defn, predefined_types=None, arch=None)¶
Parse a series of C definitions, returns a mapping from type name to type object
- angr.sim_type.parse_file(defn, predefined_types=None, arch=None, side_effect_types=None)¶
Parse a series of C definitions, returns a tuple of two type mappings, one for variable definitions and one for type definitions.
- angr.sim_type.type_parser_singleton()¶
- Return type:
CParser
- angr.sim_type.parse_type(defn, predefined_types=None, arch=None)¶
Parse a simple type expression into a SimType
>>> parse_type('int *')
- angr.sim_type.parse_type_with_name(defn, preprocess=True, predefined_types=None, arch=None, side_effect_types=None)¶
Parse a simple type expression into a SimType, returning a tuple of the type object and any associated name that might be found in the place a name would go in a type declaration.
>>> parse_type_with_name('int *foo')