angr.analyses.decompiler.structured_codegen¶
- class angr.analyses.decompiler.structured_codegen.BaseStructuredCodeGenerator
Bases:
object- __init__(flavor=None, notes=None, expr_comments=None, stmt_comments=None, const_formats=None)
- map_ast_to_pos: dict[SimVariable, set[PositionMappingElement]] | None
- version: str
- timestamp: int
- static adjust_mapping_positions(offset, pos_to_node, pos_to_addr, addr_to_pos)
Adjust positions in the mappings to account for the notes that are prepended to the text.
- Parameters:
offset (
int) – The length of the notes to prepend.pos_to_node (
PositionMapping) – The position to node mapping.pos_to_addr (
PositionMapping) – The position to address mapping.addr_to_pos (
InstructionMapping) – The address to position mapping.
- Return type:
- Returns:
Adjusted mappings.
- reapply_options(options)
- regenerate_text()
- Return type:
- reload_variable_types()
- Return type:
- reset_ident_counters()
- Return type:
- next_node_idx()
- Return type:
- class angr.analyses.decompiler.structured_codegen.BinaryOpNode
Bases:
CodegenNode
- class angr.analyses.decompiler.structured_codegen.CStructuredCodeGenerator
Bases:
BaseStructuredCodeGenerator,Analysis,Serializable- __init__(func, sequence, indent=0, cfg=None, func_args=None, binop_depth_cutoff=16, show_casts=True, braces_on_own_lines=True, use_compound_assignments=True, show_local_types=True, comment_gotos=False, cstyle_null_cmp=True, flavor=None, stmt_comments=None, expr_comments=None, show_externs=True, 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, max_str_len=None, prettify_thiscall=False, cstyle_void_param=True, indent_size=4, variable_map=None, stl_accessor_calls=False, func_prototype=None)
- Parameters:
func (Function)
func_args (list[SimVariable] | None)
binop_depth_cutoff (int)
min_data_addr (int)
display_notes (bool)
max_str_len (int | None)
prettify_thiscall (bool)
cstyle_void_param (bool)
indent_size (int)
variable_map (VariableMap | None)
stl_accessor_calls (bool)
func_prototype (SimTypeFunction | None)
- ailexpr2cnode: dict[tuple[Expression, bool, bool], CExpression] | None
- cnode2ailexpr: dict[CExpression, Expression] | None
- map_ast_to_pos: dict[SimVariable, set[PositionMappingElement]] | 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_text(cfunc)
- Return type:
- Parameters:
cfunc (CFunction)
- render_notes()
Render decompilation notes.
- Return type:
- Returns:
A string containing all notes.
- reload_variable_types()
- Return type:
- variables_unify(v1, v2)
- Return type:
- Parameters:
v1 (VirtualVariable)
v2 (VirtualVariable)
- ERRNO_LOCATION_FUNCS = frozenset({'__errno', '__errno_location', '__error', '_errno'})¶
The libc functions that return
&errno.errnois a macro that dereferences one of them, so it never survives into a binary as a symbol; what reaches decompilation is*(__errno_location()), which is both correct and unreadable.
- class angr.analyses.decompiler.structured_codegen.CStructuredCodeWalker
Bases:
object- handle(obj)
- handle_default(obj)
- handle_CFunction(obj)
- handle_CStatements(obj)
- handle_CWhileLoop(obj)
- handle_CDoWhileLoop(obj)
- handle_CForLoop(obj)
- handle_CIfElse(obj)
- handle_CIfBreak(obj)
- handle_CSwitchCase(obj)
- handle_CAssignment(obj)
- handle_CExpressionStatement(obj)
- handle_CFunctionCall(obj)
- handle_CReturn(obj)
- handle_CGoto(obj)
- handle_CIndexedVariable(obj)
- handle_CVariableField(obj)
- handle_CUnaryOp(obj)
- handle_CBinaryOp(obj)
- handle_CTypeCast(obj)
- handle_CITE(obj)
- handle_CMultiStatementExpression(obj)
- handle_CVectorConvert(obj)
- handle_CVEXCCallExpression(obj)
- handle_CDirtyExpression(obj)
- class angr.analyses.decompiler.structured_codegen.ClosingObjectNode
Bases:
CodegenNodeA closing bracket, brace, or parenthesis.
- class angr.analyses.decompiler.structured_codegen.CodegenNode
Bases:
objectMarker base of every structured-codegen node kind shared across flavors.
- class angr.analyses.decompiler.structured_codegen.ConstantNode
Bases:
CodegenNodeA constant; has
valueandreference_values.
- class angr.analyses.decompiler.structured_codegen.DummyStructuredCodeGenerator
Bases:
BaseStructuredCodeGenerator,SerializableA dummy structured code generator that only stores user-specified information.
- __init__(flavor, expr_comments=None, stmt_comments=None, configuration=None, const_formats=None)
- Parameters:
flavor (str)
- class angr.analyses.decompiler.structured_codegen.ExpressionNode
Bases:
CodegenNode
- class angr.analyses.decompiler.structured_codegen.FunctionCallNode
Bases:
CodegenNodeA call; has
callee_func(a Function or None) andcallee_target.
- class angr.analyses.decompiler.structured_codegen.FunctionNode
Bases:
CodegenNodeThe function being decompiled; has
addrandname.
- class angr.analyses.decompiler.structured_codegen.GoStructuredCodeGenerator
Bases:
BaseStructuredCodeGenerator,Analysis,Serializable- __init__(func, sequence, indent=0, cfg=None, func_args=None, binop_depth_cutoff=16, show_casts=True, braces_on_own_lines=False, use_compound_assignments=True, show_local_types=True, comment_gotos=False, cstyle_null_cmp=True, flavor=None, stmt_comments=None, expr_comments=None, show_externs=True, 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, max_str_len=None, prettify_thiscall=False, cstyle_void_param=True, indent_size=4, variable_map=None, stl_accessor_calls=False)
- reapply_options(options)
- cleanup()
Remove existing rendering results.
- regenerate_text()
Re-render text and re-generate all sorts of mapping information.
- Return type:
- render_text(cfunc)
- Return type:
- Parameters:
cfunc (GoFunction)
- render_notes()
Render decompilation notes.
- Return type:
- Returns:
A string containing all notes.
- reload_variable_types()
- Return type:
- variables_unify(v1, v2)
- Return type:
- Parameters:
v1 (VirtualVariable)
v2 (VirtualVariable)
- property map_ast_to_pos: dict[Any, set[PositionMappingElement]] | None
- class angr.analyses.decompiler.structured_codegen.ImportSourceCode
Bases:
BaseStructuredCodeGenerator,Analysis- __init__(function, flavor='source', source_root=None, encoding='utf-8')
- regenerate_text()
- class angr.analyses.decompiler.structured_codegen.IndexedVariableNode
Bases:
CodegenNode
- class angr.analyses.decompiler.structured_codegen.InstructionMapping
Bases:
object- __init__()
- items()
- values()
- add_mapping(ins_addr, posmap_pos)
- class angr.analyses.decompiler.structured_codegen.InstructionMappingElement
Bases:
object- __init__(ins_addr, posmap_pos)
- ins_addr: int
- posmap_pos: int
- class angr.analyses.decompiler.structured_codegen.LabelNode
Bases:
CodegenNode
- class angr.analyses.decompiler.structured_codegen.PositionMapping
Bases:
object- DUPLICATION_CHECK = True¶
- __init__()
- items()
- values()
- add_mapping(start_pos, length, obj)
- get_node(pos)
- Parameters:
pos (int)
- get_element(pos)
- Return type:
- Parameters:
pos (int)
- class angr.analyses.decompiler.structured_codegen.PositionMappingElement
Bases:
object- __init__(start, length, obj)
- start: int
- length: int
- obj
- class angr.analyses.decompiler.structured_codegen.RustStructuredCodeGenerator
Bases:
BaseStructuredCodeGenerator,Analysis- __init__(func, sequence, indent=0, cfg=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, max_str_len=None, prettify_thiscall=False, cstyle_void_param=True, indent_size=4, variable_map=None, stl_accessor_calls=False)
- 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:
tuple[str,PositionMapping,PositionMapping,InstructionMapping,dict[Any,set[Any]]]- Parameters:
rust_func (RustFunction)
- render_notes()
Render decompilation notes.
- Return type:
- Returns:
A string containing all notes.
- reload_variable_types()
- Return type:
- default_simtype_from_size(n, signed=True)
- Return type:
- Parameters:
- class angr.analyses.decompiler.structured_codegen.StructFieldNode
Bases:
CodegenNodeA struct field name; has
struct_type,offset, andfield.
- class angr.analyses.decompiler.structured_codegen.UnaryOpNode
Bases:
CodegenNode
- class angr.analyses.decompiler.structured_codegen.VariableFieldNode
Bases:
CodegenNode
- class angr.analyses.decompiler.structured_codegen.VariableNode
Bases:
CodegenNodeA variable access; has
variableandunified_variable.
Submodules
Protobuf serialization helpers for the C AST defined in |
|
Go-flavored structured code generator. |
|
Protobuf serialization for the Go AST defined in |
|
Intel-intrinsics view of 128-bit SSE vector AIL: lane kinds of variables, |
|