RzType#

class RzType#
property _kind: RzTypeKind#
static array_of_base_type(btype: RzBaseType, count: size_t) RzType#

Calls function rz_type_array_of_base_type (defined in helpers.c)

Creates a new array RzType from the given RzBaseType.

Parameters:
  • typedb – Type Database instance

  • btype – RzBaseType pointer

  • count – The number of the array elements

static array_of_base_type_str(name: str, count: size_t) RzType#

Calls function rz_type_array_of_base_type_str (defined in helpers.c)

Creates a new array RzType from the given RzBaseType name.

Parameters:
  • typedb – Type Database instance

  • name – RzBaseType name

  • count – The number of the array elements

static array_of_type(type: RzType, count: size_t) RzType#

Calls function rz_type_array_of_type (defined in helpers.c)

Creates a new array RzType from the given RzType.

Parameters:
  • typedb – Type Database instance

  • type – RzType pointer

  • count – The number of the array elements

static as_format(type: RzType) str#

Calls function rz_type_as_format (defined in format.c)

Represents the RzType as a pf format string.

Different from the similar function for the RzBaseType, since the latter shows the pair of <format> <fields>, while this implementation produces only the <format> part.

Parameters:
  • typedb – Types Database instance

  • type – RzType type

static as_format_pair(type: RzType) str#

Calls function rz_type_as_format_pair (defined in format.c)

Represents the RzType as a pf format string pair.

Different from the similar rz_type_as_format and similar to the rz_base_type_as_format since the latter shows the pair of <format> <fields>.

Parameters:
  • typedb – Types Database instance

  • type – RzType type

static as_pretty_string(type: RzType, identifier: str, opts: int, unfold_level: int) str#

Calls function rz_type_as_pretty_string (defined in type.c)

Return a string contining the type pretty printed according to the options provided.

Parameters:
  • typedb – typedb for the current analysis

  • type – type to be pretty printed

  • identifier – name of the variable of the given type (RZ_NULLABLE)

  • opts – options for pretty printing (see RzTypePrintOpts)

  • unfold_level – level of unfolding to do in case of nested structures/unions (any negative number means maximum unfolding, i.e. INT32_MAX. 0 means no unfolding, just the typename and identifier, if any)

Returns:

char* string in pretty printed form

static as_string(type: RzType) str#

Calls function rz_type_as_string (defined in type.c)

Returns the type C representation.

Parameters:
  • typedb – Types Database instance

  • type – RzType type

static atomic_eq(typ1: RzType, typ2: RzType) bool#

Calls function rz_type_atomic_eq (defined in helpers.c)

Checks if two atomic RzTypes are equivalent.

Parameters:
  • typedb – Type Database instance

  • typ1 – First RzType type

  • typ2 – Second RzType type

static atomic_is_const(type: RzType) bool#

Calls function rz_type_atomic_is_const (defined in helpers.c)

Checks if the atomic RzType is “const”.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static atomic_is_void(type: RzType) bool#

Calls function rz_type_atomic_is_void (defined in helpers.c)

Checks if the RzType is “void”.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static atomic_str_eq(typ1: RzType, name: str) bool#

Calls function rz_type_atomic_str_eq (defined in helpers.c)

Checks if two atomic types (RzType and RzBaseType) are equivalent.

Parameters:
  • typedb – Type Database instance

  • typ1 – First RzType type

  • typ2 – Second RzBaseType type name

static base_enum_case_free(user: Any) None#

Calls function rz_type_base_enum_case_free (defined in base.c)

static base_struct_member_free(user: Any) None#

Calls function rz_type_base_struct_member_free (defined in base.c)

static base_type_free() None#

Calls function rz_type_base_type_free (defined in base.c)

Frees the RzBaseType instance and all of its members.

Parameters:

type – RzBaseType pointer

static base_type_kind_as_string() str#

Calls function rz_type_base_type_kind_as_string (defined in base.c)

Returns string representing the kind of base type.

Parameters:

kind – RzBaseTypeKind to return string representation of

static base_type_new() RzBaseType#

Calls function rz_type_base_type_new (defined in base.c)

Allocates a new instance of RzBaseType given the kind.

Parameters:

kind – Kind of RzBaseType to create

static base_union_member_free(user: Any) None#

Calls function rz_type_base_union_member_free (defined in base.c)

static callable_arg_add(arg: RzCallableArg) bool#

Calls function rz_type_callable_arg_add (defined in function.c)

Adds a new argument to the RzCallable.

Parameters:
  • callable – RzCallable instance

  • arg – Argument to add

static callable_arg_clone() RzCallableArg#

Calls function rz_type_callable_arg_clone (defined in function.c)

Creates am exact clone of RzCallableArg.

Parameters:

arg – RzCallable argument pointer

static callable_arg_free() None#

Calls function rz_type_callable_arg_free (defined in function.c)

Frees the RzCallableArg.

Parameters:

arg – RzCallableArg instance

static callable_arg_new(name: str, type: RzType) RzCallableArg#

Calls function rz_type_callable_arg_new (defined in function.c)

Creates a new RzCallableArg given the name and type.

Parameters:
  • typedb – RzTypeDB instance

  • name – Name of the argument

  • type – RzType type of the argument

static callable_as_string(callable: RzCallable) str#

Calls function rz_type_callable_as_string (defined in function.c)

Returns the callable C representation.

Parameters:
  • typedb – Types Database instance

  • callable – RzCallable instance

static callable_clone() RzCallable#

Calls function rz_type_callable_clone (defined in function.c)

Creates an exact clone of the RzCallable type.

Parameters:

callable – RzCallable instance to clone

static callable_free() None#

Calls function rz_type_callable_free (defined in function.c)

Frees the RzCallable.

Parameters:

callable – RzCallable type

static callable_new() RzCallable#

Calls function rz_type_callable_new (defined in function.c)

Creates a new RzCallable type.

Parameters:
  • name – Name of the callable type

  • type – A return type of the callable type

static callable_ptr_as_string(type: RzType) str#

Calls function rz_type_callable_ptr_as_string (defined in function.c)

Returns the callable pointer C representation.

Parameters:
  • typedb – Types Database instance

  • callable – RzCallable instance

static cond_eval(arg0: int, arg1: int) bool#

Calls function rz_type_cond_eval (defined in helpers.c)

evaluate the type condition on the arguments and return a bool accordingly.

Parameters:
  • cond – RzTypeCond

  • arg0

  • arg1

Returns:

bool

static cond_eval_single(arg0: int) bool#

Calls function rz_type_cond_eval_single (defined in helpers.c)

Same as rz_type_cond_eval, but it assumes arg1 to be 0.

Parameters:
  • cond – RzTypeCond

  • arg0

Returns:

bool

static cond_invert() RzTypeCond#

Calls function rz_type_cond_invert (defined in helpers.c)

return the inverted condition

Parameters:

cond – RzTypeCond

Returns:

RzTypeCond

static cond_tostring() str#

Calls function rz_type_cond_tostring (defined in helpers.c)

RzTypeCond enum to string.

Parameters:

cc – RzTypeCond

Returns:

const char *

static db_all() RzList[char]#

Calls function rz_type_db_all (defined in type.c)

Returns the list of all type names.

Parameters:

typedb – Types Database instance

static db_atomic_bitsize(btype: RzBaseType) int#

Calls function rz_type_db_atomic_bitsize (defined in type.c)

Returns the atomic type size in bits (target dependent)

Parameters:
  • typedb – Types Database instance

  • btype – The base type

static db_base_get_bitsize(btype: RzBaseType) int#

Calls function rz_type_db_base_get_bitsize (defined in type.c)

Returns the base type size in bits (target dependent)

Parameters:
  • typedb – Types Database instance

  • btype – The base type

static db_base_type_as_pretty_string(btype: RzBaseType, opts: int, unfold_level: int) str#

Calls function rz_type_db_base_type_as_pretty_string (defined in base.c)

Returns C representation as string of RzBaseType.

Parameters:
  • typedb – type database instance

  • btype – RzBaseType to convert

  • opts – options for pretty printing (see RzTypePrintOpts)

  • unfold_level – level of unfolding to do in case of nested structures/unions (any negative number means maximum unfolding, i.e. INT32_MAX. 0 means no unfolding, just the typename and identifier, if any)

Returns:

char* pretty printed form of the base string (similar to rz_type_as_pretty_string, but for RzBaseType)

static db_base_type_as_string(btype: RzBaseType) str#

Calls function rz_type_db_base_type_as_string (defined in base.c)

Returns C representation as string of RzBaseType (see rz_type_db_base_type_as_pretty_string for cusom print options)

Parameters:
  • typedb – type database instance

  • btype – RzBaseType to convert

Returns:

char* one line C representation of the string with no semicolon at the end and no unfolding of inner types

static db_del(name: str) bool#

Calls function rz_type_db_del (defined in type.c)

Removes the type from the database.

Can remove either RzBaseType or RzCallable type

Parameters:
  • typedb – RzTypeDB instance

  • name – RzBaseType or RzCallable type name

static db_delete_base_type(type: RzBaseType) bool#

Calls function rz_type_db_delete_base_type (defined in base.c)

Removes RzBaseType from the Types DB.

Parameters:
  • typedb – Type Database instance

  • type – RzBaseType to remove

static db_edit_base_type(name: str, typestr: str) bool#

Calls function rz_type_db_edit_base_type (defined in type.c)

Edits the existing base type given the new C code.

Searches the base type in the types database given the name. If it exists - parses the typestr as the new C type. If there is any error during the parsing it restores the original type in the database.

Parameters:
  • typedb – Type Database instance

  • name – Name of the base type

  • typestr – C string of the new definition of the type

static db_enum_bitsize(btype: RzBaseType) int#

Calls function rz_type_db_enum_bitsize (defined in type.c)

Returns the enum type size in bits (target dependent)

Parameters:
  • typedb – Types Database instance

  • btype – The base type

static db_enum_get_bitfield(name: str, val: int) str#

Calls function rz_type_db_enum_get_bitfield (defined in type.c)

Returns all matching bitfields as an OR mask given the resulting value.

Parameters:
  • typedb – Types Database instance

  • name – The name of the bitfield enum

  • val – The value to search for

static db_enum_member_by_name(name: str, member: str) int#

Calls function rz_type_db_enum_member_by_name (defined in type.c)

Returns the enum case value matched by the enum case name.

Parameters:
  • typedb – Types Database instance

  • name – The name of the enum to search in

  • member – The enum case name to search for

static db_enum_member_by_val(name: str, val: int) str#

Calls function rz_type_db_enum_member_by_val (defined in type.c)

Returns the enum case name matching the cpecified value.

Parameters:
  • typedb – Types Database instance

  • name – The name of the enum to search in

  • val – The value to search for

static db_enum_names() RzList[char]#

Calls function rz_type_db_enum_names (defined in type.c)

Returns the list of all enum names.

Parameters:

typedb – Types Database instance

static db_find_enums_by_val(val: int) RzList[char]#

Calls function rz_type_db_find_enums_by_val (defined in type.c)

Returns all enums and cases name matching the specified value.

Parameters:
  • typedb – Types Database instance

  • val – The value to search for

static db_format_all() RzList[char]#

Calls function rz_type_db_format_all (defined in format.c)

static db_format_delete(name: str) None#

Calls function rz_type_db_format_delete (defined in format.c)

static db_format_get(name: str) str#

Calls function rz_type_db_format_get (defined in format.c)

static db_format_purge() None#

Calls function rz_type_db_format_purge (defined in type.c)

Purges formats in the instance of the RzTypeDB.

static db_format_set(name: str, fmt: str) None#

Calls function rz_type_db_format_set (defined in format.c)

static db_free() None#

Calls function rz_type_db_free (defined in type.c)

Frees the instance of the RzTypeDB.

Destroys hashtables for RzBaseType, RzCallable, type formats.

static db_get_base_type(name: str) RzBaseType#

Calls function rz_type_db_get_base_type (defined in base.c)

Searches for the RzBaseType in the types database given the name.

Parameters:
  • typedb – Type Database instance

  • name – Name of the RzBaseType

static db_get_base_types() RzList[RzBaseType]#

Calls function rz_type_db_get_base_types (defined in base.c)

Returns the list of all basic types.

Parameters:

typedb – Types Database instance

static db_get_base_types_of_kind(kind: RzBaseTypeKind) RzList[RzBaseType]#

Calls function rz_type_db_get_base_types_of_kind (defined in base.c)

Returns the list of all basic types of the chosen kind.

Parameters:
  • typedb – Types Database instance

  • kind – Kind of the types to list

static db_get_bitsize(type: RzType) int#

Calls function rz_type_db_get_bitsize (defined in type.c)

Returns the type size in bits (target dependent)

Parameters:
  • typedb – Types Database instance

  • type – The type

static db_get_by_offset(offset: int) RzList[RzTypePath]#

Calls function rz_type_db_get_by_offset (defined in path.c)

Returns the list of all structured types that have members matching the offset.

Parameters:
  • typedb – Types Database instance

  • offset – The offset of the member to match against

static db_get_compound_type(name: str) RzBaseType#

Calls function rz_type_db_get_compound_type (defined in base.c)

Searches for the compound RzBaseType in the types database given the name.

Returns all types except atomic - structures, unions, enums, typedefs

Parameters:
  • typedb – Type Database instance

  • name – Name of the RzBaseType

static db_get_enum(name: str) RzBaseType#

Calls function rz_type_db_get_enum (defined in type.c)

Returns the enum base type matching the specified name.

Parameters:
  • typedb – Types Database instance

  • name – The name of the enum to match against

static db_get_struct(name: str) RzBaseType#

Calls function rz_type_db_get_struct (defined in type.c)

returns the struct base type matching the specified name

Parameters:
  • typedb – types database instance

  • name – the name of the struct to match against

static db_get_typedef(name: str) RzBaseType#

Calls function rz_type_db_get_typedef (defined in type.c)

Returns the typedef base type matching the specified name.

Parameters:
  • typedb – Types Database instance

  • name – The name of the typedef to match against

static db_get_union(name: str) RzBaseType#

Calls function rz_type_db_get_union (defined in type.c)

Returns the union base type matching the specified name.

Parameters:
  • typedb – Types Database instance

  • name – The name of the union to match against

static db_init(dir_prefix: str, arch: str, bits: int, os: str) None#

Calls function rz_type_db_init (defined in type.c)

Initializes the types database for specified arch, bits, OS.

Loads pre-shipped type libraries for base types and function types. Different architectures, operating systems, bitness affects on what exact types are loaded, also some atomic types sizes are different. In some cases the same type, for example, structure type could have a different layout, depending on the operating system or bitness.

Parameters:
  • typedb – Types Database instance

  • types_dir – Directory where all type libraries are installed

  • arch – Architecture of the analysis session

  • bits – Bitness of the analysis session

  • os – Operating system of the analysis session

static db_load_callables_sdb(path: str) bool#

Calls function rz_type_db_load_callables_sdb (defined in serialize_functions.c)

Loads the callable types from compiled SDB specified by path.

Parameters:
  • typedb – RzTypeDB instance

  • path – A path to the compiled SDB containing serialized types

static db_load_callables_sdb_str(str: str) bool#

Calls function rz_type_db_load_callables_sdb_str (defined in serialize_functions.c)

Loads the callable types from SDB KV string.

Parameters:
  • typedb – RzTypeDB instance

  • str – A string in Key-Value format as for non-compiled SDB

static db_load_sdb(path: str) bool#

Calls function rz_type_db_load_sdb (defined in serialize_types.c)

Loads the types from compiled SDB specified by path.

Parameters:
  • typedb – RzTypeDB instance

  • path – A path to the compiled SDB containing serialized types

static db_load_sdb_str(str: str) bool#

Calls function rz_type_db_load_sdb_str (defined in serialize_types.c)

Loads the types from SDB KV string.

Parameters:
  • typedb – RzTypeDB instance

  • str – A string in Key-Value format as for non-compiled SDB

static db_new() RzTypeDB#

Calls function rz_type_db_new (defined in type.c)

Creates a new instance of the RzTypeDB.

Creates the RzTypeDB instance, initializes hashtables for RzBaseType, RzCallable, type formats. Also initializes default “target” (arch, bits, platform) parameters.

static db_pointer_size() int#

Calls function rz_type_db_pointer_size (defined in type.c)

Returns the pointer size for the current RzTypeDB target set.

Parameters:

typedb – RzTypeDB instance

static db_purge() None#

Calls function rz_type_db_purge (defined in type.c)

Purges the instance of the RzTypeDB.

Destroys all loaded base types and callable types.

static db_reload(dir_prefix: str) None#

Calls function rz_type_db_reload (defined in type.c)

Re-initializes the types database for current target.

Similarly to rz_type_db_init loads pre-shipped type libraries for base types and function types.

Parameters:
  • typedb – Types Database instance

  • types_dir – Directory where all type libraries are installed

static db_save_base_type(type: RzBaseType) None#

Calls function rz_type_db_save_base_type (defined in base.c)

Saves RzBaseType into the Types DB.

Parameters:
  • typedb – Type Database instance

  • type – RzBaseType to save

static db_set_address_bits(addr_bits: int) None#

Calls function rz_type_db_set_address_bits (defined in type.c)

Set the RzType target adress size.

Important for calculating some types size, especially pointers’s size.

Parameters:
  • typedb – RzTypeDB instance

  • bits – size of an address in bits. If <= 0, then the value from rz_type_db_set_bits() is used.

static db_set_bits(bits: int) None#

Calls function rz_type_db_set_bits (defined in type.c)

Set the RzType target architecture bits.

Important for calculating some types size, especially pointers’s size.

Parameters:
  • typedb – RzTypeDB instance

  • bits – Architecture bits to set

static db_set_cpu(cpu: str) None#

Calls function rz_type_db_set_cpu (defined in type.c)

Set the RzType target architecture CPU.

Important for calculating some types size, especially pointers’s size.

Parameters:
  • typedb – RzTypeDB instance

  • cpu – Architecture name to set

static db_set_endian(big_endian: bool) None#

Calls function rz_type_db_set_endian (defined in type.c)

Set the RzType target architecture CPU.

Important for calculating complex types layout.

Parameters:
  • typedb – RzTypeDB instance

  • big_endian – True if the big endian, false if the opposite

static db_set_os(os: str) None#

Calls function rz_type_db_set_os (defined in type.c)

Set the RzType target architecture operating system.

Important for calculating some types size, especially pointers’s size.

Parameters:
  • typedb – RzTypeDB instance

  • os – Operating system name to set

static db_struct_bitsize(btype: RzBaseType) int#

Calls function rz_type_db_struct_bitsize (defined in type.c)

Returns the struct type size in bits (target dependent)

Parameters:
  • typedb – Types Database instance

  • btype – The base type

static db_struct_member_offset(name: str, member: str) int#

Calls function rz_type_db_struct_member_offset (defined in path.c)

Returns the offset in bytes of the structure member if there is a match.

Parameters:
  • typedb – Types Database instance

  • name – The structure type name

  • name – The structure member name

static db_struct_member_packed_offset(name: str, member: str) int#

Calls function rz_type_db_struct_member_packed_offset (defined in path.c)

Returns the packed offset in bits of the structure member if there is a match.

Parameters:
  • typedb – Types Database instance

  • name – The structure type name

  • name – The structure member name

static db_struct_names() RzList[char]#

Calls function rz_type_db_struct_names (defined in type.c)

Returns the list of all struct names.

Parameters:

typedb – Types Database instance

static db_typedef_bitsize(btype: RzBaseType) int#

Calls function rz_type_db_typedef_bitsize (defined in type.c)

Returns the typedef type size in bits (target dependent)

Parameters:
  • typedb – Types Database instance

  • btype – The base type

static db_typedef_names() RzList[char]#

Calls function rz_type_db_typedef_names (defined in type.c)

Returns the list of all typedef (type aliases) names.

Parameters:

typedb – Types Database instance

static db_union_bitsize(btype: RzBaseType) int#

Calls function rz_type_db_union_bitsize (defined in type.c)

Returns the union type size in bits (target dependent)

Parameters:
  • typedb – Types Database instance

  • btype – The base type

static db_union_names() RzList[char]#

Calls function rz_type_db_union_names (defined in type.c)

Returns the list of all union names.

Parameters:

typedb – Types Database instance

static declaration_as_string(type: RzType) str#

Calls function rz_type_declaration_as_string (defined in type.c)

Returns the type C declaration representation.

Parameters:
  • typedb – Types Database instance

  • type – RzType type

static exists(name: str) bool#

Calls function rz_type_exists (defined in type.c)

Checks if the type exists in the Type database.

Parameters:
  • typedb – Types Database instance

  • name – Name of the type

static format(type: str) str#

Calls function rz_type_format (defined in format.c)

Represents the RzBaseType as a pf format string.

Produces the pair of of <format> <fields>. If the type is atomic it searches if the type database has predefined format assigned to it and uses it.

Parameters:
  • typedb – Types Database instance

  • name – RzBaseType type name

static format_data(p: RzPrint, seek: int, b: int, len: int, formatname: str, mode: int, setval: str, ofield: str) str#

Calls function rz_type_format_data (defined in format.c)

static format_struct_size(f: str, mode: int, n: int) int#

Calls function rz_type_format_struct_size (defined in format.c)

static func_arg_add(func_name: str, arg_name: str, arg_type: RzType) bool#

Calls function rz_type_func_arg_add (defined in function.c)

Adds a new argument to the RzCallable type at the end of the arguments vector.

Parameters:
  • typedb – Type Database instance

  • func_name – Name of the callable to search

  • arg_name – Name of the new argument

  • arg_type – RzType type of the new argument

static func_args_count(func_name: str) int#

Calls function rz_type_func_args_count (defined in function.c)

Searches for the RzCallable type in types database and returns arguments’ count.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

static func_args_name(func_name: str, i: int) str#

Calls function rz_type_func_args_name (defined in function.c)

Searches for the RzCallable type in types database and returns argument name.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

  • i – Index of the argument go get type of

static func_args_type(func_name: str, i: int) RzType#

Calls function rz_type_func_args_type (defined in function.c)

Searches for the RzCallable type in types database and returns argument type.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

  • i – Index of the argument go get type of

static func_cc(func_name: str) str#

Calls function rz_type_func_cc (defined in function.c)

Searches for the RzCallable type in types database and returns calling convention.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

static func_cc_set(name: str, cc: str) bool#

Calls function rz_type_func_cc_set (defined in function.c)

Searches for the RzCallable type in types database and set the calling convention.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

  • name – Name of the calling convention to set

static func_delete(func_name: str) bool#

Calls function rz_type_func_delete (defined in function.c)

Removes RzCallable type from the types database.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

static func_delete_all() None#

Calls function rz_type_func_delete_all (defined in function.c)

Removes all RzCallable types.

static func_exist(func_name: str) bool#

Calls function rz_type_func_exist (defined in function.c)

Checks if the RzCallable type exists in the database given the name.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

static func_get(func_name: str) RzCallable#

Calls function rz_type_func_get (defined in function.c)

Returns the RzCallable from the database by name.

Parameters:
  • typedb – Type Database instance

  • name – RzCallable (function) name to search

static func_is_noreturn(name: str) bool#

Calls function rz_type_func_is_noreturn (defined in function.c)

Checks if the RzCallable type is defined as “noreturn”.

Parameters:
  • typedb – Types Database instance

  • name – Name of the RzCallable type

static func_new(name: str, type: RzType) RzCallable#

Calls function rz_type_func_new (defined in function.c)

Creates a new RzCallable type.

Parameters:
  • typedb – RzTypeDB instance

  • name – Name of the callable type

  • type – A return type of the callable type

static func_noreturn_add(name: str) bool#

Calls function rz_type_func_noreturn_add (defined in function.c)

Adds the “noreturn” attribute to the RzCallable type.

Parameters:
  • typedb – Types Database instance

  • name – Name of the RzCallable type

static func_noreturn_drop(name: str) bool#

Calls function rz_type_func_noreturn_drop (defined in function.c)

Drops the “noreturn” attribute from the RzCallable type.

Parameters:
  • typedb – Types Database instance

  • name – Name of the RzCallable type

static func_ret(func_name: str) RzType#

Calls function rz_type_func_ret (defined in function.c)

Searches for the RzCallable type in types database and returns return type.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

static func_ret_set(func_name: str, type: RzType) bool#

Calls function rz_type_func_ret_set (defined in function.c)

Sets the new return type for the RzCallable.

Parameters:
  • typedb – Type Database instance

  • name – Name of the callable to search

  • type – RzType return type

static func_save(callable: RzCallable) bool#

Calls function rz_type_func_save (defined in function.c)

Stores RzCallable type in the types database.

Parameters:
  • typedb – Type Database instance

  • callable – RzCallable type to save

static function_names() RzList[char]#

Calls function rz_type_function_names (defined in function.c)

Returns the list of all function type names.

Parameters:

typedb – Types Database instance

static get_base_type(type: RzType) RzBaseType#

Calls function rz_type_get_base_type (defined in type.c)

Returns the RzBaseType for the chosen RzType.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static identifier_declaration_as_string(type: RzType, identifier: str) str#

Calls function rz_type_identifier_declaration_as_string (defined in type.c)

Returns the type C representation with identifier.

Parameters:
  • typedb – Types Database instance

  • type – RzType type

static identifier_of_base_type(btype: RzBaseType, is_const: bool) RzType#

Calls function rz_type_identifier_of_base_type (defined in helpers.c)

Creates a new RzType indentifier from the given RzBaseType.

Parameters:
  • typedb – Type Database instance

  • btype – RzBaseType pointer

  • is_const – Set the identifier to “const” if true

static identifier_of_base_type_str(name: str) RzType#

Calls function rz_type_identifier_of_base_type_str (defined in helpers.c)

Creates a new RzType indentifier from the given RzBaseType name.

Parameters:
  • typedb – Type Database instance

  • name – RzBaseType name

static integral_set_sign(type: Pointer[Pointer[RzType]], sign: bool) bool#

Calls function rz_type_integral_set_sign (defined in helpers.c)

If the type is unsigned it sets the sign.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static is_atomic(type: RzType) bool#

Calls function rz_type_is_atomic (defined in helpers.c)

Checks if the RzType is atomic or derivative of it.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static is_default(type: RzType) bool#

Calls function rz_type_is_default (defined in helpers.c)

Checks if the RzType is default.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static is_floating(type: RzType) bool#

Calls function rz_type_is_floating (defined in typeclass.c)

Checks if the RzType is Floating typeclass.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static is_integral(type: RzType) bool#

Calls function rz_type_is_integral (defined in typeclass.c)

Checks if the RzType is Integral typeclass.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static is_integral_signed(type: RzType) bool#

Calls function rz_type_is_integral_signed (defined in typeclass.c)

Checks if the RzType is Integral and Signed typeclass.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static is_integral_unsigned(type: RzType) bool#

Calls function rz_type_is_integral_unsigned (defined in typeclass.c)

Checks if the RzType is Integral and Unsigned typeclass.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static is_num(type: RzType) bool#

Calls function rz_type_is_num (defined in typeclass.c)

Checks if the RzType is Num typeclass.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static is_strictly_atomic(type: RzType) bool#

Calls function rz_type_is_strictly_atomic (defined in helpers.c)

Checks if the RzType is strictly atomic.

Parameters:
  • typedb – Type Database instance

  • type – RzType type pointer

static kind(name: str) int#

Calls function rz_type_kind (defined in type.c)

Returns the kind (RzBaseTypeKind) of the type.

Parameters:
  • typedb – Types Database instance

  • name – Name of the type

static new_default() RzType#

Calls function rz_type_new_default (defined in helpers.c)

Creates a new instance of the default RzType type.

Parameters:

typedb – Type Database instance

static noreturn_function_names() RzList[char]#

Calls function rz_type_noreturn_function_names (defined in function.c)

Returns the list of all noreturn function type names.

Parameters:

typedb – Types Database instance

static offset_by_path(path: str) int#

Calls function rz_type_offset_by_path (defined in path.c)

Returns the offset of the member given path.

Resolves the path in the form of “a.b[20].c” where “b” is a member of “a” and “c” is a member of “b” array and located inside the 20-th element, and calculates the offset. Opposite function of “rz_type_path_by_offset”

Parameters:

type – RzTypePath

static parse_file(path: str, dir: str, error_msg: Pointer[Pointer[int]]) int#

Calls function rz_type_parse_file (defined in c_cpp_parser.c)

Parses the C types file creating the new parser state.

Parameters:
  • typedb – RzTypeDB instance

  • path – The path to the C file to parse

  • dir – The directory where the C file is located

  • error_msg – A pointer where all error messages will be stored

static parse_file_stateless(path: str, dir: str, error_msg: Pointer[Pointer[int]]) int#

Calls function rz_type_parse_file_stateless (defined in c_cpp_parser.c)

Parses the C types file reusing the existing parser state.

Parameters:
  • parser – RzTypeParser instance

  • path – The path to the C file to parse

  • dir – The directory where the C file is located

  • error_msg – A pointer where all error messages will be stored

static parse_reset() None#

Calls function rz_type_parse_reset (defined in c_cpp_parser.c)

Reset the C parser state.

Parameters:

typedb – RzTypeDB instance

static parse_string(code: str, error_msg: Pointer[Pointer[int]]) int#

Calls function rz_type_parse_string (defined in c_cpp_parser.c)

Parses the C type string creating the new parser state.

Parameters:
  • typedb – RzTypeDB instance

  • code – The C type itself

  • error_msg – A pointer where all error messages will be stored

static parse_string_declaration_single(code: str, error_msg: Pointer[Pointer[int]]) RzType#

Calls function rz_type_parse_string_declaration_single (defined in c_cpp_parser.c)

Parses the single C type declaration.

Parameters:
  • parser – RzTypeParser parser instance

  • code – The C type itself

  • error_msg – A pointer where all error messages will be stored

static parse_string_single(code: str, error_msg: Pointer[Pointer[int]]) RzType#

Calls function rz_type_parse_string_single (defined in c_cpp_parser.c)

Parses the single C type definition.

Parameters:
  • parser – RzTypeParser parser instance

  • code – The C type itself

  • error_msg – A pointer where all error messages will be stored

static parse_string_stateless(code: str, error_msg: Pointer[Pointer[int]]) int#

Calls function rz_type_parse_string_stateless (defined in c_cpp_parser.c)

Parses the C type string reusing the existing parser state.

Parameters:
  • parser – RzTypeParser instance

  • code – The C type itself

  • error_msg – A pointer where all error messages will be stored

static parser_free() None#

Calls function rz_type_parser_free (defined in c_cpp_parser.c)

Frees the instance of the C type parser without destroying hashtables.

static parser_free_purge() None#

Calls function rz_type_parser_free_purge (defined in c_cpp_parser.c)

Frees the instance of the C type parser and destroy the hashtables.

static parser_init(callables: HtPP) RzTypeParser#

Calls function rz_type_parser_init (defined in c_cpp_parser.c)

Creates a new instance of the C type parser.

Creates the new instance of the C types parser preloaded hashtables for RzBaseTypes and RzCallable types. It will use provided hashtables for storing the parsed types as well.

Parameters:
  • type – RzBaseTypes hashtable to preload into the parser state

  • type – RzCallable hashtable to preload into the parser state

static parser_new() RzTypeParser#

Calls function rz_type_parser_new (defined in c_cpp_parser.c)

Creates a new instance of the C type parser.

Creates the new instance of the C types parser with empty hashtables for RzBaseTypes and RzCallable types.

static path_by_offset(btype: RzBaseType, offset: int) RzList[RzTypePath]#

Calls function rz_type_path_by_offset (defined in path.c)

Returns the list of all type paths matching the offset.

Parameters:
  • typedb – Types Database instance

  • btype – The base type

  • offset – The offset of the path to match against

static path_free() None#

Calls function rz_type_path_free (defined in path.c)

Frees the RzTypePath.

Doesn’t free the underlying RzBaseType, only the path.

Parameters:

type – RzTypePath

static pointer_of_base_type(btype: RzBaseType, is_const: bool) RzType#

Calls function rz_type_pointer_of_base_type (defined in helpers.c)

Creates a new pointer RzType from the given RzBaseType.

Parameters:
  • typedb – Type Database instance

  • btype – RzBaseType pointer

  • is_const – Set the pointer to “const” if true

static pointer_of_base_type_str(name: str, is_const: bool) RzType#

Calls function rz_type_pointer_of_base_type_str (defined in helpers.c)

Creates a new pointer RzType from the given RzBaseType name.

Parameters:
  • typedb – Type Database instance

  • name – RzBaseType name

  • is_const – Set the pointer to “const” if true

static pointer_of_type(type: RzType, is_const: bool) RzType#

Calls function rz_type_pointer_of_type (defined in helpers.c)

Creates a new pointer RzType from the given RzType.

Parameters:
  • typedb – Type Database instance

  • type – RzType pointer

  • is_const – Set the pointer to “const” if true

static typeclass(type: RzType) RzTypeTypeclass#

Calls function rz_type_typeclass (defined in typeclass.c)

Gets the type class.

Parameters:
  • typedb – Type Database instance

  • type – RzBaseType type pointer

static typeclass_as_string() str#

Calls function rz_type_typeclass_as_string (defined in typeclass.c)

Returns the string representation of a typeclass.

Parameters:

typeclass – A typeclass

static typeclass_from_string() RzTypeTypeclass#

Calls function rz_type_typeclass_from_string (defined in typeclass.c)

Returns the typeclass from the string name of it.

Parameters:

typeclass – A typeclass name

static typeclass_get_all(typeclass: RzTypeTypeclass) RzList[RzBaseType]#

Calls function rz_type_typeclass_get_all (defined in typeclass.c)

Returns the list of all base types given the typeclass.

Parameters:
  • typedb – Type Database instance

  • typeclass – typeclass (cannot be None)

static typeclass_get_all_sized(typeclass: RzTypeTypeclass, size: size_t) RzList[RzBaseType]#

Calls function rz_type_typeclass_get_all_sized (defined in typeclass.c)

Returns the list of all base types given the typeclass and size.

Parameters:
  • typedb – Type Database instance

  • typeclass – typeclass (cannot be None)

  • size – The bitsize of a type to select from

static typeclass_get_default_sized(typeclass: RzTypeTypeclass, size: size_t) RzBaseType#

Calls function rz_type_typeclass_get_default_sized (defined in typeclass.c)

Returns the default base type given the typeclass and size.

Parameters:
  • typedb – Type Database instance

  • typeclass – typeclass (cannot be None)

  • size – The bitsize of a type to select from

clone() RzType#

Calls function rz_type_clone (defined in type.c)

Creates an exact clone of the RzType.

Parameters:

type – RzType pointer

free() None#

Calls function rz_type_free (defined in type.c)

Frees the RzType.

Doesn’t free the underlying RzBaseType, only the RzType wrapper. Same goes for the RzCallable. Both are stored in the corresponding hashtables and should not be touched until deleted explicitly.

Parameters:

type – RzType type

identifier() str#

Calls function rz_type_identifier (defined in type.c)

Returns the type C identifier.

In case of the compound types it returns the name of identifier For example, for “char **ptr” it will return “char”, for “const int **arr[56][76]” it will return “int”

Parameters:

type – RzType type

is_callable() bool#

Calls function rz_type_is_callable (defined in function.c)

Checks if the RzType is the pointer to the RzCallable.

Parameters:
  • typedb – Types Database instance

  • type – RzType

is_callable_ptr() bool#

Calls function rz_type_is_callable_ptr (defined in function.c)

Checks if the RzType is the pointer to the RzCallable.

Parameters:
  • typedb – Types Database instance

  • type – RzType

is_callable_ptr_nested() bool#

Calls function rz_type_is_callable_ptr_nested (defined in function.c)

Checks if the RzType is the nested pointer to the RzCallable.

For example it could be one of those:

  • int (*func)(int a, char *b)

  • int (**func)(int a, char *b)

  • int (****func)(int a, char *b)

Parameters:
  • typedb – Types Database instance

  • type – RzType

is_char_ptr() bool#

Calls function rz_type_is_char_ptr (defined in helpers.c)

Checks if the pointer RzType is a string (“char *” or “const char *”)

Parameters:

type – RzType type pointer

is_char_ptr_nested() bool#

Calls function rz_type_is_char_ptr_nested (defined in helpers.c)

Checks if the pointer RzType is a nested pointer of string (“char **”, “char ***”, etc)

Parameters:

type – RzType type pointer

is_identifier() bool#

Calls function rz_type_is_identifier (defined in helpers.c)

Checks if the RzType is identifier.

Parameters:

type – RzType type pointer

is_void_ptr() bool#

Calls function rz_type_is_void_ptr (defined in helpers.c)

Checks if the pointer RzType is abstract pointer (“void *”)

Parameters:

type – RzType type pointer

is_void_ptr_nested() bool#

Calls function rz_type_is_void_ptr_nested (defined in helpers.c)

Checks if the pointer RzType is a nested abstract pointer (“void **”, “vpod ***”, etc)

Parameters:

type – RzType type pointer

path_new(path: str) RzTypePath#

Calls function rz_type_path_new (defined in path.c)

Creates a new instance of RzTypePath.

Parameters:
  • type – RzType pointer

  • path – String representation of type path