angr.utils.library

angr.utils.library.get_function_name(s)

Get the function name from a C-style function declaration string.

Parameters:

s (str) – A C-style function declaration string.

Returns:

The function name.

Return type:

str

angr.utils.library.register_kernel_types()
angr.utils.library.convert_cproto_to_py(c_decl)

Convert a C-style function declaration string to its corresponding SimTypes-based Python representation.

Parameters:

c_decl (str) – The C-style function declaration string.

Return type:

tuple[str, SimTypeFunction, str]

Returns:

A tuple of the function name, the prototype, and a string representing the SimType-based Python representation.

angr.utils.library.convert_cppproto_to_py(cpp_decl, with_param_names=False)

Pre-process a C++-style function declaration string to its corresponding SimTypes-based Python representation.

Parameters:
  • cpp_decl (str) – The C++-style function declaration string.

  • with_param_names (bool)

Return type:

tuple[str | None, SimTypeCppFunction | None, str | None]

Returns:

A tuple of the function name, the prototype, and a string representing the SimType-based Python representation.

angr.utils.library.parsedcprotos2py(parsed_cprotos, fd_spots=frozenset({}), remove_sys_prefix=False)

Parse a list of C function declarations and output to Python code that can be embedded into angr.procedures.definitions.

>>> # parse the list of glibc C prototypes and output to a file
>>> from angr.procedures.definitions import glibc
>>> with open("glibc_protos", "w") as f: f.write(cprotos2py(glibc._libc_c_decls))
Parameters:

parsed_cprotos (list[tuple[str, SimTypeFunction, str]]) – A list of tuples where each tuple is (function name, parsed C function prototype, the original function declaration).

Return type:

str

Returns:

A Python string.

angr.utils.library.cprotos2py(cprotos, fd_spots=frozenset({}), remove_sys_prefix=False)

Parse a list of C function declarations and output to Python code that can be embedded into angr.procedures.definitions.

>>> # parse the list of glibc C prototypes and output to a file
>>> from angr.procedures.definitions import glibc
>>> with open("glibc_protos", "w") as f: f.write(cprotos2py(glibc._libc_c_decls))
Parameters:

cprotos (list[str]) – A list of C prototype strings.

Return type:

str

Returns:

A Python string.

angr.utils.library.get_cpp_function_name_and_metadata(demangled_name)

Parse a demangled C++ declaration into a function name.

Note that the extracted name may include template instantiation, for example:

example_func<int>

Parameters:

demangled_name (str) – The demangled C++ function name.

Return type:

tuple[str, dict[str, bool]]

Returns:

The qualified function name, excluding return type and parameters, and a dictionary with keys indicating if the function is a constructor or a destructor.

angr.utils.library.get_cpp_function_name(demangled_name)

Parse a demangled C++ declaration into a function name.

Note that the extracted name may include template instantiation, for example:

example_func<int>

Parameters:

demangled_name (str) – The demangled C++ function name.

Return type:

str

Returns:

The qualified function name, excluding return type and parameters.

angr.utils.library.get_rust_function_name(demangled_name)