angr 9.2.175__cp310-abi3-win_amd64.whl → 9.2.177__cp310-abi3-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of angr might be problematic. Click here for more details.
- angr/__init__.py +1 -1
- angr/analyses/calling_convention/calling_convention.py +12 -0
- angr/analyses/complete_calling_conventions.py +39 -26
- angr/analyses/decompiler/ail_simplifier.py +14 -12
- angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +5 -1
- angr/analyses/decompiler/clinic.py +54 -40
- angr/analyses/decompiler/optimization_passes/ite_region_converter.py +3 -3
- angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +2 -2
- angr/analyses/decompiler/peephole_optimizations/__init__.py +4 -4
- angr/analyses/decompiler/peephole_optimizations/cas_intrinsics.py +69 -12
- angr/analyses/decompiler/peephole_optimizations/{inlined_wstrcpy.py → inlined_wcscpy.py} +16 -8
- angr/analyses/decompiler/peephole_optimizations/inlined_wcscpy_consolidation.py +296 -0
- angr/analyses/decompiler/ssailification/rewriting_engine.py +14 -1
- angr/analyses/decompiler/structured_codegen/c.py +6 -5
- angr/analyses/decompiler/structuring/dream.py +2 -2
- angr/analyses/decompiler/structuring/phoenix.py +101 -23
- angr/analyses/decompiler/utils.py +10 -3
- angr/analyses/flirt/flirt.py +5 -4
- angr/analyses/stack_pointer_tracker.py +4 -3
- angr/analyses/typehoon/lifter.py +29 -18
- angr/analyses/typehoon/simple_solver.py +157 -50
- angr/analyses/typehoon/translator.py +34 -34
- angr/analyses/typehoon/typeconsts.py +33 -15
- angr/analyses/typehoon/typevars.py +9 -2
- angr/analyses/variable_recovery/engine_ail.py +43 -2
- angr/analyses/variable_recovery/engine_base.py +4 -1
- angr/analyses/variable_recovery/variable_recovery_fast.py +3 -1
- angr/emulator.py +2 -1
- angr/engines/hook.py +1 -1
- angr/engines/icicle.py +21 -5
- angr/engines/vex/claripy/ccall.py +3 -3
- angr/knowledge_plugins/functions/function.py +19 -2
- angr/procedures/definitions/__init__.py +9 -0
- angr/procedures/definitions/parse_win32json.py +11 -0
- angr/procedures/definitions/wdk/ntoskrnl.json +4 -0
- angr/procedures/posix/pthread.py +4 -4
- angr/procedures/stubs/format_parser.py +3 -3
- angr/rustylib.pyd +0 -0
- angr/sim_type.py +11 -6
- angr/simos/windows.py +1 -1
- angr/storage/memory_mixins/paged_memory/page_backer_mixins.py +1 -1
- angr/unicornlib.dll +0 -0
- angr/utils/constants.py +1 -1
- angr/utils/strings.py +20 -0
- {angr-9.2.175.dist-info → angr-9.2.177.dist-info}/METADATA +5 -5
- {angr-9.2.175.dist-info → angr-9.2.177.dist-info}/RECORD +50 -49
- angr/analyses/decompiler/peephole_optimizations/inlined_wstrcpy_consolidation.py +0 -113
- {angr-9.2.175.dist-info → angr-9.2.177.dist-info}/WHEEL +0 -0
- {angr-9.2.175.dist-info → angr-9.2.177.dist-info}/entry_points.txt +0 -0
- {angr-9.2.175.dist-info → angr-9.2.177.dist-info}/licenses/LICENSE +0 -0
- {angr-9.2.175.dist-info → angr-9.2.177.dist-info}/top_level.txt +0 -0
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
# pylint:disable=arguments-differ
|
|
2
|
-
from __future__ import annotations
|
|
3
|
-
|
|
4
|
-
from angr.ailment.expression import Expression, BinaryOp, Const, Register, StackBaseOffset, UnaryOp, VirtualVariable
|
|
5
|
-
from angr.ailment.statement import Call, Store
|
|
6
|
-
|
|
7
|
-
from angr.sim_type import SimTypePointer, SimTypeWideChar
|
|
8
|
-
from .base import PeepholeOptimizationMultiStmtBase
|
|
9
|
-
from .inlined_wstrcpy import InlinedWstrcpy
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
class InlinedWstrcpyConsolidation(PeepholeOptimizationMultiStmtBase):
|
|
13
|
-
"""
|
|
14
|
-
Consolidate multiple inlined wstrcpy/wstrncpy calls.
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
__slots__ = ()
|
|
18
|
-
|
|
19
|
-
NAME = "Consolidate multiple inlined wstrncpy calls"
|
|
20
|
-
stmt_classes = ((Call, Call), (Call, Store))
|
|
21
|
-
|
|
22
|
-
def optimize( # type:ignore
|
|
23
|
-
self, stmts: list[Call], stmt_idx: int | None = None, block=None, **kwargs
|
|
24
|
-
): # pylint:disable=unused-argument
|
|
25
|
-
last_stmt, stmt = stmts
|
|
26
|
-
if InlinedWstrcpy.is_inlined_wstrncpy(last_stmt):
|
|
27
|
-
assert last_stmt.args is not None
|
|
28
|
-
assert self.kb is not None
|
|
29
|
-
s_last: bytes = self.kb.custom_strings[last_stmt.args[1].value]
|
|
30
|
-
addr_last = last_stmt.args[0]
|
|
31
|
-
new_str = None # will be set if consolidation should happen
|
|
32
|
-
|
|
33
|
-
if isinstance(stmt, Call) and InlinedWstrcpy.is_inlined_wstrncpy(stmt):
|
|
34
|
-
assert stmt.args is not None
|
|
35
|
-
# consolidating two calls
|
|
36
|
-
s_curr: bytes = self.kb.custom_strings[stmt.args[1].value]
|
|
37
|
-
addr_curr = stmt.args[0]
|
|
38
|
-
# determine if the two addresses are consecutive
|
|
39
|
-
delta = self._get_delta(addr_last, addr_curr)
|
|
40
|
-
if delta is not None and delta == len(s_last):
|
|
41
|
-
# consolidate both calls!
|
|
42
|
-
new_str = s_last + s_curr
|
|
43
|
-
elif isinstance(stmt, Store) and isinstance(stmt.data, Const) and isinstance(stmt.data.value, int):
|
|
44
|
-
# consolidating a call and a store, in case the store statement is storing the suffix of a string (but
|
|
45
|
-
# the suffix is too short to qualify an inlined strcpy optimization)
|
|
46
|
-
addr_curr = stmt.addr
|
|
47
|
-
delta = self._get_delta(addr_last, addr_curr)
|
|
48
|
-
if delta is not None and delta == len(s_last):
|
|
49
|
-
if stmt.size == 2 and stmt.data.value == 0:
|
|
50
|
-
# it's probably the terminating null byte
|
|
51
|
-
r, s = True, b"\x00\x00"
|
|
52
|
-
else:
|
|
53
|
-
r, s = InlinedWstrcpy.is_integer_likely_a_wide_string(
|
|
54
|
-
stmt.data.value, stmt.size, stmt.endness, min_length=1 # type:ignore
|
|
55
|
-
)
|
|
56
|
-
if r and s is not None:
|
|
57
|
-
new_str = s_last + s
|
|
58
|
-
|
|
59
|
-
if new_str is not None:
|
|
60
|
-
assert self.project is not None
|
|
61
|
-
wstr_type = SimTypePointer(SimTypeWideChar()).with_arch(self.project.arch)
|
|
62
|
-
if new_str.endswith(b"\x00\x00"):
|
|
63
|
-
call_name = "wstrcpy"
|
|
64
|
-
new_str_idx = self.kb.custom_strings.allocate(new_str[:-2])
|
|
65
|
-
args = [
|
|
66
|
-
last_stmt.args[0],
|
|
67
|
-
Const(None, None, new_str_idx, last_stmt.args[0].bits, custom_string=True, type=wstr_type),
|
|
68
|
-
]
|
|
69
|
-
prototype = None
|
|
70
|
-
else:
|
|
71
|
-
call_name = "wstrncpy"
|
|
72
|
-
new_str_idx = self.kb.custom_strings.allocate(new_str)
|
|
73
|
-
args = [
|
|
74
|
-
last_stmt.args[0],
|
|
75
|
-
Const(None, None, new_str_idx, last_stmt.args[0].bits, custom_string=True, type=wstr_type),
|
|
76
|
-
Const(None, None, len(new_str) // 2, self.project.arch.bits),
|
|
77
|
-
]
|
|
78
|
-
prototype = None
|
|
79
|
-
|
|
80
|
-
return [Call(stmt.idx, call_name, args=args, prototype=prototype, **stmt.tags)]
|
|
81
|
-
|
|
82
|
-
return None
|
|
83
|
-
|
|
84
|
-
@staticmethod
|
|
85
|
-
def _parse_addr(addr: Expression) -> tuple[Expression, int]:
|
|
86
|
-
if isinstance(addr, Register):
|
|
87
|
-
return addr, 0
|
|
88
|
-
if isinstance(addr, StackBaseOffset):
|
|
89
|
-
return StackBaseOffset(None, addr.bits, 0), addr.offset
|
|
90
|
-
if (
|
|
91
|
-
isinstance(addr, UnaryOp)
|
|
92
|
-
and addr.op == "Reference"
|
|
93
|
-
and isinstance(addr.operand, VirtualVariable)
|
|
94
|
-
and addr.operand.was_stack
|
|
95
|
-
):
|
|
96
|
-
return StackBaseOffset(None, addr.bits, 0), addr.operand.stack_offset
|
|
97
|
-
if isinstance(addr, BinaryOp):
|
|
98
|
-
if addr.op == "Add" and isinstance(addr.operands[1], Const) and isinstance(addr.operands[1].value, int):
|
|
99
|
-
base_0, offset_0 = InlinedWstrcpyConsolidation._parse_addr(addr.operands[0])
|
|
100
|
-
return base_0, offset_0 + addr.operands[1].value
|
|
101
|
-
if addr.op == "Sub" and isinstance(addr.operands[1], Const) and isinstance(addr.operands[1].value, int):
|
|
102
|
-
base_0, offset_0 = InlinedWstrcpyConsolidation._parse_addr(addr.operands[0])
|
|
103
|
-
return base_0, offset_0 - addr.operands[1].value
|
|
104
|
-
|
|
105
|
-
return addr, 0
|
|
106
|
-
|
|
107
|
-
@staticmethod
|
|
108
|
-
def _get_delta(addr_0: Expression, addr_1: Expression) -> int | None:
|
|
109
|
-
base_0, offset_0 = InlinedWstrcpyConsolidation._parse_addr(addr_0)
|
|
110
|
-
base_1, offset_1 = InlinedWstrcpyConsolidation._parse_addr(addr_1)
|
|
111
|
-
if base_0.likes(base_1):
|
|
112
|
-
return offset_1 - offset_0
|
|
113
|
-
return None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|