angr.analyses.decompiler.structured_codegen.rust¶
- angr.analyses.decompiler.structured_codegen.rust.unpack_typeref(ty)¶
- angr.analyses.decompiler.structured_codegen.rust.squash_array_reference(ty)¶
- angr.analyses.decompiler.structured_codegen.rust.qualifies_for_simple_cast(ty1, ty2)¶
- angr.analyses.decompiler.structured_codegen.rust.qualifies_for_implicit_cast(ty1, ty2)¶
- angr.analyses.decompiler.structured_codegen.rust.extract_terms(expr)¶
- Return type:
- Parameters:
expr (RustExpression)
- angr.analyses.decompiler.structured_codegen.rust.is_machine_word_size_type(type_, arch)¶
- angr.analyses.decompiler.structured_codegen.rust.guess_value_type(value, project)¶
- angr.analyses.decompiler.structured_codegen.rust.type_to_rust_repr_chunks(ty, name=None, name_type=None, full=False, indent_str='')¶
Helper generator function to turn a SimType into generated tuples of (C-string, AST node).
- Parameters:
ty (SimType | RustSimType)
- class angr.analyses.decompiler.structured_codegen.rust.RustConstruct¶
Bases:
objectRepresents a program construct in C. Acts as the base class for all other representation constructions.
- __init__(codegen)¶
- codegen: RustStructuredCodeGenerator
- c_repr(indent=0, pos_to_node=None, pos_to_addr=None, addr_to_pos=None)¶
Creates the C representation of the code and displays it by constructing a large string. This function is called by each program function that needs to be decompiled. The map_pos_to_node and map_pos_to_addr act as position maps for the location of each variable and statement to be tracked for later GUI operations. The map_pos_to_addr also contains expressions that are nested inside of statements.
- c_repr_chunks(indent=0, asexpr=False)¶
- static indent_str(indent=0)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustFunction¶
Bases:
RustConstructRepresents a function in Rust.
- __init__(addr, name, functy, arg_list, statements, variables_in_use, variable_manager, demangled_name=None, show_demangled_name=True, **kwargs)¶
- Parameters:
functy (RustSimTypeFunction)
arg_list (list[RustVariable])
- addr
- name
- functy
- arg_list
- statements
- variables_in_use
- variable_manager: VariableManagerInternal
- demangled_name
- unified_local_vars: dict[SimVariable, set[tuple[RustVariable, SimType]]]
- show_demangled_name
- get_unified_local_vars()¶
- Return type:
- variable_list_repr_chunks(indent=0)¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustStatement¶
Bases:
RustConstructRepresents a statement in C.
- class angr.analyses.decompiler.structured_codegen.rust.RustExpression¶
Bases:
RustConstructBase class for C expressions.
- __init__(collapsed=False, **kwargs)¶
- collapsed
- property type¶
- set_type(v)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustStatements¶
Bases:
RustStatementRepresents a sequence of statements in C.
- __init__(statements, **kwargs)¶
- statements
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustAILBlock¶
Bases:
RustStatementRepresents a block of AIL statements.
- __init__(block, **kwargs)¶
- block
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustLoop¶
Bases:
RustStatementRepresents a loop in Rust.
- class angr.analyses.decompiler.structured_codegen.rust.RustInfiniteLoop¶
Bases:
RustLoopRepresents an infinite loop in Rust.
- __init__(body, tags=None, **kwargs)¶
- body
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustWhileLoop¶
Bases:
RustLoopRepresents a while loop in C.
- __init__(condition, body, tags=None, **kwargs)¶
- condition
- body
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustDoWhileLoop¶
Bases:
RustLoopRepresents a do-while loop in C.
- __init__(condition, body, tags=None, **kwargs)¶
- condition
- body
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustForLoop¶
Bases:
RustStatementRepresents a for-loop in C.
- __init__(initializer, condition, iterator, body, tags=None, **kwargs)¶
- initializer
- condition
- iterator
- body
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustIfElse¶
Bases:
RustStatementRepresents an if-else construct in Rust.
- __init__(condition_and_nodes, else_node=None, simplify_else_scope=False, cstyle_ifs=True, tags=None, **kwargs)¶
- Parameters:
condition_and_nodes (list[tuple[RustExpression, RustStatement | None]])
- condition_and_nodes
- else_node
- simplify_else_scope
- cstyle_ifs
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustIfBreak¶
Bases:
RustStatementRepresents an if-break statement in C.
- __init__(condition, cstyle_ifs=True, tags=None, **kwargs)¶
- condition
- cstyle_ifs
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustBreak¶
Bases:
RustStatementRepresents a break statement in C.
- __init__(tags=None, **kwargs)¶
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustContinue¶
Bases:
RustStatementRepresents a continue statement in C.
- __init__(tags=None, **kwargs)¶
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustSwitchCase¶
Bases:
RustStatementRepresents a switch-case statement in C.
- __init__(switch, cases, default, tags=None, **kwargs)¶
- switch
- default
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustPatternMatch¶
Bases:
RustStatementRepresents a pattern-match statement in Rust.
- __init__(match_expr, cases, default, tags=None, **kwargs)¶
- scrutinee
- arms: list[tuple[tuple[EnumVariant, tuple[RustExpression, ...]], RustStatements]]
- default
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustIfLet¶
Bases:
RustStatementRepresents an if let statement in Rust.
- __init__(pattern, scrutinee, true_node, false_node, tags=None, **kwargs)¶
- pattern
- scrutinee
- true_node
- false_node
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustAssignment¶
Bases:
RustStatementa = b
- __init__(lhs, rhs, tags=None, **kwargs)¶
- lhs
- rhs
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustFunctionLikeMacro¶
Bases:
RustStatement,RustExpression- __init__(name, args, delimiter, is_expr, returnty=None, tags=None, **kwargs)¶
- c_repr_chunks(indent=0, asexpr=False)¶
- property type¶
- class angr.analyses.decompiler.structured_codegen.rust.RustFunctionCall¶
Bases:
RustStatement,RustExpressionfunc(arg0, arg1)
- Variables:
callee_func (Function) – The function getting called.
is_expr – True if the return value of the function is written to ret_expr; Essentially, ret_expr = call().
- __init__(callee_target, callee_func, args, returning=True, ret_expr=None, receiver=None, tags=None, is_expr=False, show_demangled_name=True, show_disambiguated_name=True, callsite_prototype=None, **kwargs)¶
- Parameters:
is_expr (bool)
show_disambiguated_name (bool)
callsite_prototype (RustSimTypeFunction | None)
- callee_target
- args
- returning
- ret_expr
- receiver
- tags
- is_expr
- show_demangled_name
- show_disambiguated_name
- callsite_prototype
- property prototype: SimTypeFunction | None¶
- property type¶
- class angr.analyses.decompiler.structured_codegen.rust.RustReturn¶
Bases:
RustStatement- __init__(retval, tags=None, **kwargs)¶
- retval
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustGoto¶
Bases:
RustStatement- __init__(target, target_idx, tags=None, **kwargs)¶
- target: int | RustExpression
- target_idx
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustUnsupportedStatement¶
Bases:
RustStatementA wrapper for unsupported AIL statement.
- __init__(stmt, **kwargs)¶
- stmt
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustLabel¶
Bases:
RustStatementRepresents a label in C code.
- __init__(name, ins_addr, block_idx, tags=None, **kwargs)¶
- name
- ins_addr
- block_idx
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustStruct¶
Bases:
RustExpression- __init__(name, fields, field_names, tags=None, **kwargs)¶
- name
- fields
- field_names
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustEnum¶
Bases:
RustExpression- __init__(name, fields, tags=None, **kwargs)¶
- name
- fields
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustStructField¶
Bases:
RustExpression- struct_type
- offset
- field
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustArray¶
Bases:
RustExpression- __init__(elements, tags=None, **kwargs)¶
- elements
- tags
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustLet¶
Bases:
RustExpression- let_expr
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- tags
- class angr.analyses.decompiler.structured_codegen.rust.RustStringLiteral¶
Bases:
RustExpression- __init__(data, tags=None, **kwargs)¶
- data
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- tags
- class angr.analyses.decompiler.structured_codegen.rust.RustFakeVariable¶
Bases:
RustExpressionAn uninterpreted name to display in the decompilation output. Pretty much always represents an error?
- name
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustVariable¶
Bases:
RustExpressionCVariable represents access to a variable with the specified type (variable_type).
variable must be a SimVariable.
- __init__(variable, unified_variable=None, variable_type=None, tags=None, **kwargs)¶
- Parameters:
variable (SimVariable)
- variable: SimVariable
- unified_variable: SimVariable | None
- variable_type: SimType
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustIndexedVariable¶
Bases:
RustExpressionRepresent a variable (an array) that is indexed.
- __init__(variable, index, variable_type=None, tags=None, **kwargs)¶
- Parameters:
variable (RustExpression)
index (RustExpression)
- index: RustExpression
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- collapsed
- class angr.analyses.decompiler.structured_codegen.rust.RustVariableField¶
Bases:
RustExpressionRepresent a field of a variable.
- __init__(variable, field, var_is_ptr=False, tags=None, **kwargs)¶
- Parameters:
variable (RustExpression)
field (RustStructField)
var_is_ptr (bool)
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- collapsed
- class angr.analyses.decompiler.structured_codegen.rust.RustUnaryOp¶
Bases:
RustExpressionUnary operations.
- __init__(op, operand, tags=None, **kwargs)¶
- Parameters:
operand (RustExpression)
- op
- operand
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustBinaryOp¶
Bases:
RustExpressionBinary operations.
- __init__(op, lhs, rhs, tags=None, **kwargs)¶
- op
- lhs
- rhs
- tags
- common_type
- static compute_common_type(op, lhs_ty, rhs_ty)¶
- property type¶
- property op_precedence¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustTypeCast¶
Bases:
RustExpression- __init__(src_type, dst_type, expr, tags=None, **kwargs)¶
- Parameters:
src_type (RustSimType | SimType | None)
dst_type (RustSimType | SimType)
expr (RustExpression)
- src_type
- dst_type
- expr
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustConstant¶
Bases:
RustExpression- __init__(value, type_, reference_values=None, tags=None, **kwargs)¶
- value
- reference_values
- tags
- property fmt¶
- property fmt_hex¶
- property fmt_neg¶
- property fmt_char¶
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustRegister¶
Bases:
RustExpression- __init__(reg, tags=None, **kwargs)¶
- reg
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustITE¶
Bases:
RustExpression- __init__(cond, iftrue, iffalse, tags=None, **kwargs)¶
- cond
- iftrue
- iffalse
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustMultiStatementExpression¶
Bases:
RustExpression(stmt0, stmt1, stmt2, expr)
- __init__(stmts, expr, tags=None, **kwargs)¶
- Parameters:
stmts (RustStatements)
expr (RustExpression)
- stmts
- expr
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustVEXCCallExpression¶
Bases:
RustExpressionccall_name(arg0, arg1, …)
- __init__(callee, operands, tags=None, **kwargs)¶
- Parameters:
callee (str)
operands (list[RustExpression])
- callee
- operands
- tags
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustDirtyExpression¶
Bases:
RustExpressionIdeally all dirty expressions should be handled and converted to proper conversions during conversion from VEX to AIL. Eventually this class should not be used at all.
- __init__(dirty, **kwargs)¶
- dirty
- property type¶
- c_repr_chunks(indent=0, asexpr=False)¶
- class angr.analyses.decompiler.structured_codegen.rust.RustClosingObject¶
Bases:
objectA class to represent all objects that can be closed by it’s correspodning character. Examples: (), {}, []
- __init__(opening_symbol)¶
- opening_symbol
- class angr.analyses.decompiler.structured_codegen.rust.RustArrayTypeLength¶
Bases:
objectA class to represent the type information of fixed-size array lengths. Examples: In “char foo[20]”, this would be the “[20]”.
- __init__(text)¶
- text
- class angr.analyses.decompiler.structured_codegen.rust.RustStructFieldNameDef¶
Bases:
objectA class to represent the name of a defined field in a struct. Needed because it’s not a CVariable or a CStructField (because CStructField is the access of a CStructField). Example: In “struct foo { int bar; }, this would be “bar”.
- __init__(name)¶
- name
- class angr.analyses.decompiler.structured_codegen.rust.RustStructuredCodeGenerator¶
Bases:
BaseStructuredCodeGenerator,Analysis- __init__(func, sequence, indent=0, cfg=None, variable_kb=None, func_args=None, binop_depth_cutoff=16, show_casts=True, braces_on_own_lines=False, use_compound_assignments=True, show_local_types=False, comment_gotos=False, cstyle_null_cmp=True, flavor=None, stmt_comments=None, expr_comments=None, show_externs=False, externs=None, const_formats=None, show_demangled_name=True, show_disambiguated_name=True, ail_graph=None, simplify_else_scope=True, cstyle_ifs=True, omit_func_header=False, display_block_addrs=False, display_vvar_ids=False, min_data_addr=4194304, notes=None, display_notes=True)¶
- Parameters:
func_args (list[SimVariable] | None)
binop_depth_cutoff (int)
min_data_addr (int)
display_notes (bool)
- ailexpr2cnode: dict[tuple[Expression, bool], RustExpression] | None
- cnode2ailexpr: dict[RustExpression, Expression] | None
- map_ast_to_pos: dict[SimVariable, set[PositionMappingElement]] | None
- rust_func: RustFunction | None
- cexterns: set[RustVariable] | None
- reapply_options(options)¶
- cleanup()¶
Remove existing rendering results.
- regenerate_text()¶
Re-render text and re-generate all sorts of mapping information.
- Return type:
- RENDER_TYPE
alias of
tuple[str,PositionMapping,PositionMapping,InstructionMapping,dict[Any,set[Any]]]
- render_text(rust_func)¶
- Return type:
RENDER_TYPE
- Parameters:
rust_func (RustFunction)
- render_notes()¶
Render decompilation notes.
- Return type:
- Returns:
A string containing all notes.
- default_simtype_from_size(n, signed=True)¶
- Return type:
- Parameters:
- class angr.analyses.decompiler.structured_codegen.rust.RustStructuredCodeWalker¶
Bases:
object- classmethod handle(obj)¶
- classmethod handle_default(obj)¶
- classmethod handle_RustFunction(obj)¶
- classmethod handle_RustStatements(obj)¶
- classmethod handle_RustWhileLoop(obj)¶
- classmethod handle_RustInfiniteLoop(obj)¶
- classmethod handle_RustDoWhileLoop(obj)¶
- classmethod handle_RustForLoop(obj)¶
- classmethod handle_RustIfElse(obj)¶
- classmethod handle_RustIfBreak(obj)¶
- classmethod handle_RustSwitchCase(obj)¶
- classmethod handle_RustAssignment(obj)¶
- classmethod handle_RustFunctionCall(obj)¶
- classmethod handle_RustReturn(obj)¶
- classmethod handle_RustGoto(obj)¶
- classmethod handle_RustIndexedVariable(obj)¶
- classmethod handle_RustVariableField(obj)¶
- classmethod handle_RustUnaryOp(obj)¶
- classmethod handle_RustBinaryOp(obj)¶
- classmethod handle_RustTypeCast(obj)¶
- classmethod handle_RustITE(obj)¶
- class angr.analyses.decompiler.structured_codegen.rust.MakeTypecastsImplicit¶
Bases:
RustStructuredCodeWalker- classmethod collapse(dst_ty, child)¶
- Return type:
- Parameters:
dst_ty (SimType | RustSimType | None)
child (RustExpression)
- classmethod handle_RustAssignment(obj)¶
- classmethod handle_RustFunctionCall(obj)¶
- Parameters:
obj (RustFunctionCall)
- classmethod handle_RustReturn(obj)¶
- Parameters:
obj (RustReturn)
- classmethod handle_RustBinaryOp(obj)¶
- Parameters:
obj (RustBinaryOp)
- classmethod handle_RustTypeCast(obj)¶
- Parameters:
obj (RustTypeCast)
- class angr.analyses.decompiler.structured_codegen.rust.FieldReferenceCleanup¶
Bases:
RustStructuredCodeWalker- classmethod handle_RustTypeCast(obj)¶
- class angr.analyses.decompiler.structured_codegen.rust.PointerArithmeticFixer¶
Bases:
RustStructuredCodeWalkerBefore calling this fixer class, pointer arithmetics are purely integer-based and ignoring the pointer type.
For example, in the following case:
struct A* a_ptr; // assume struct A is 24 bytes in size a_ptr = a_ptr + 24;
It means adding 24 to the address of a_ptr, without considering the size of struct A. This fixer class will make pointer arithmetics aware of the pointer type. In this case, the fixer class will convert the code to a_ptr = a_ptr + 1.
- classmethod handle_RustBinaryOp(obj)¶
- Parameters:
obj (RustBinaryOp)