angr 9.2.131__py3-none-manylinux2014_aarch64.whl → 9.2.133__py3-none-manylinux2014_aarch64.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.

Files changed (264) hide show
  1. angr/__init__.py +128 -128
  2. angr/analyses/__init__.py +38 -38
  3. angr/analyses/analysis.py +6 -2
  4. angr/analyses/backward_slice.py +3 -4
  5. angr/analyses/binary_optimizer.py +5 -12
  6. angr/analyses/bindiff.py +3 -6
  7. angr/analyses/calling_convention.py +3 -4
  8. angr/analyses/cfg/__init__.py +3 -3
  9. angr/analyses/cfg/cfg_base.py +1 -1
  10. angr/analyses/cfg/cfg_emulated.py +5 -5
  11. angr/analyses/cfg/cfg_fast.py +19 -17
  12. angr/analyses/cfg/indirect_jump_resolvers/__init__.py +5 -5
  13. angr/analyses/cfg/indirect_jump_resolvers/amd64_elf_got.py +1 -1
  14. angr/analyses/cfg/indirect_jump_resolvers/jumptable.py +148 -101
  15. angr/analyses/cfg/indirect_jump_resolvers/x86_elf_pic_plt.py +1 -1
  16. angr/analyses/data_dep/__init__.py +4 -4
  17. angr/analyses/datagraph_meta.py +1 -1
  18. angr/analyses/ddg.py +16 -17
  19. angr/analyses/decompiler/__init__.py +12 -12
  20. angr/analyses/decompiler/ail_simplifier.py +24 -12
  21. angr/analyses/decompiler/block_similarity.py +2 -4
  22. angr/analyses/decompiler/block_simplifier.py +10 -21
  23. angr/analyses/decompiler/callsite_maker.py +1 -1
  24. angr/analyses/decompiler/ccall_rewriters/rewriter_base.py +1 -1
  25. angr/analyses/decompiler/clinic.py +122 -41
  26. angr/analyses/decompiler/condition_processor.py +57 -39
  27. angr/analyses/decompiler/counters/__init__.py +3 -3
  28. angr/analyses/decompiler/decompilation_cache.py +7 -7
  29. angr/analyses/decompiler/dephication/__init__.py +1 -1
  30. angr/analyses/decompiler/dephication/graph_rewriting.py +1 -1
  31. angr/analyses/decompiler/dephication/graph_vvar_mapping.py +11 -3
  32. angr/analyses/decompiler/dephication/rewriting_engine.py +169 -45
  33. angr/analyses/decompiler/dephication/seqnode_dephication.py +5 -4
  34. angr/analyses/decompiler/expression_narrower.py +1 -1
  35. angr/analyses/decompiler/graph_region.py +8 -8
  36. angr/analyses/decompiler/optimization_passes/__init__.py +20 -20
  37. angr/analyses/decompiler/optimization_passes/const_derefs.py +1 -0
  38. angr/analyses/decompiler/optimization_passes/deadblock_remover.py +1 -2
  39. angr/analyses/decompiler/optimization_passes/div_simplifier.py +41 -16
  40. angr/analyses/decompiler/optimization_passes/duplication_reverter/duplication_reverter.py +8 -7
  41. angr/analyses/decompiler/optimization_passes/duplication_reverter/utils.py +1 -3
  42. angr/analyses/decompiler/optimization_passes/engine_base.py +262 -84
  43. angr/analyses/decompiler/optimization_passes/inlined_string_transformation_simplifier.py +175 -39
  44. angr/analyses/decompiler/optimization_passes/ite_region_converter.py +2 -5
  45. angr/analyses/decompiler/optimization_passes/lowered_switch_simplifier.py +5 -5
  46. angr/analyses/decompiler/optimization_passes/mod_simplifier.py +12 -3
  47. angr/analyses/decompiler/optimization_passes/optimization_pass.py +42 -19
  48. angr/analyses/decompiler/optimization_passes/stack_canary_simplifier.py +9 -5
  49. angr/analyses/decompiler/peephole_optimizations/__init__.py +1 -1
  50. angr/analyses/decompiler/peephole_optimizations/base.py +6 -6
  51. angr/analyses/decompiler/peephole_optimizations/remove_noop_conversions.py +2 -0
  52. angr/analyses/decompiler/peephole_optimizations/rewrite_bit_extractions.py +1 -1
  53. angr/analyses/decompiler/presets/__init__.py +1 -1
  54. angr/analyses/decompiler/region_simplifiers/expr_folding.py +3 -3
  55. angr/analyses/decompiler/region_simplifiers/switch_cluster_simplifier.py +8 -12
  56. angr/analyses/decompiler/ssailification/rewriting.py +1 -2
  57. angr/analyses/decompiler/ssailification/rewriting_engine.py +139 -56
  58. angr/analyses/decompiler/ssailification/ssailification.py +2 -1
  59. angr/analyses/decompiler/ssailification/traversal.py +4 -6
  60. angr/analyses/decompiler/ssailification/traversal_engine.py +125 -42
  61. angr/analyses/decompiler/structured_codegen/__init__.py +5 -5
  62. angr/analyses/decompiler/structured_codegen/base.py +3 -3
  63. angr/analyses/decompiler/structured_codegen/c.py +39 -40
  64. angr/analyses/decompiler/structuring/__init__.py +3 -3
  65. angr/analyses/decompiler/structuring/phoenix.py +45 -29
  66. angr/analyses/decompiler/structuring/structurer_base.py +2 -2
  67. angr/analyses/decompiler/structuring/structurer_nodes.py +23 -14
  68. angr/analyses/deobfuscator/__init__.py +3 -3
  69. angr/analyses/deobfuscator/irsb_reg_collector.py +29 -60
  70. angr/analyses/deobfuscator/string_obf_finder.py +2 -2
  71. angr/analyses/deobfuscator/string_obf_opt_passes.py +1 -1
  72. angr/analyses/disassembly.py +4 -4
  73. angr/analyses/forward_analysis/__init__.py +1 -1
  74. angr/analyses/forward_analysis/visitors/graph.py +6 -6
  75. angr/analyses/init_finder.py +47 -22
  76. angr/analyses/loop_analysis.py +1 -1
  77. angr/analyses/loopfinder.py +1 -1
  78. angr/analyses/propagator/engine_base.py +21 -14
  79. angr/analyses/propagator/engine_vex.py +149 -179
  80. angr/analyses/propagator/outdated_definition_walker.py +12 -6
  81. angr/analyses/propagator/propagator.py +10 -28
  82. angr/analyses/propagator/top_checker_mixin.py +211 -5
  83. angr/analyses/propagator/vex_vars.py +4 -4
  84. angr/analyses/reaching_definitions/__init__.py +9 -9
  85. angr/analyses/reaching_definitions/call_trace.py +2 -2
  86. angr/analyses/reaching_definitions/dep_graph.py +1 -1
  87. angr/analyses/reaching_definitions/engine_ail.py +304 -329
  88. angr/analyses/reaching_definitions/engine_vex.py +243 -229
  89. angr/analyses/reaching_definitions/function_handler.py +3 -3
  90. angr/analyses/reaching_definitions/function_handler_library/__init__.py +1 -1
  91. angr/analyses/reaching_definitions/rd_state.py +47 -42
  92. angr/analyses/reassembler.py +26 -31
  93. angr/analyses/s_liveness.py +8 -0
  94. angr/analyses/s_propagator.py +18 -3
  95. angr/analyses/s_reaching_definitions/s_rda_view.py +2 -5
  96. angr/analyses/s_reaching_definitions/s_reaching_definitions.py +9 -5
  97. angr/analyses/stack_pointer_tracker.py +4 -4
  98. angr/analyses/typehoon/simple_solver.py +14 -14
  99. angr/analyses/typehoon/translator.py +10 -2
  100. angr/analyses/typehoon/typeconsts.py +11 -3
  101. angr/analyses/typehoon/typevars.py +26 -26
  102. angr/analyses/unpacker/__init__.py +1 -1
  103. angr/analyses/variable_recovery/engine_ail.py +299 -259
  104. angr/analyses/variable_recovery/engine_base.py +138 -121
  105. angr/analyses/variable_recovery/engine_vex.py +175 -185
  106. angr/analyses/variable_recovery/irsb_scanner.py +49 -38
  107. angr/analyses/variable_recovery/variable_recovery.py +28 -5
  108. angr/analyses/variable_recovery/variable_recovery_base.py +33 -34
  109. angr/analyses/variable_recovery/variable_recovery_fast.py +4 -8
  110. angr/analyses/veritesting.py +2 -2
  111. angr/analyses/vfg.py +5 -5
  112. angr/analyses/xrefs.py +46 -19
  113. angr/angrdb/serializers/__init__.py +1 -1
  114. angr/annocfg.py +20 -15
  115. angr/blade.py +2 -2
  116. angr/block.py +20 -25
  117. angr/calling_conventions.py +12 -14
  118. angr/code_location.py +6 -10
  119. angr/codenode.py +3 -3
  120. angr/engines/__init__.py +12 -14
  121. angr/engines/engine.py +24 -61
  122. angr/engines/light/__init__.py +13 -5
  123. angr/engines/light/data.py +1 -1
  124. angr/engines/light/engine.py +1003 -1185
  125. angr/engines/pcode/__init__.py +1 -1
  126. angr/engines/pcode/behavior.py +1 -1
  127. angr/engines/pcode/cc.py +2 -0
  128. angr/engines/pcode/lifter.py +13 -15
  129. angr/engines/soot/expressions/__init__.py +12 -12
  130. angr/engines/soot/statements/__init__.py +6 -6
  131. angr/engines/soot/values/__init__.py +6 -6
  132. angr/engines/soot/values/arrayref.py +2 -2
  133. angr/engines/soot/values/constants.py +1 -1
  134. angr/engines/soot/values/instancefieldref.py +1 -1
  135. angr/engines/soot/values/paramref.py +1 -1
  136. angr/engines/soot/values/staticfieldref.py +1 -1
  137. angr/engines/successors.py +15 -14
  138. angr/engines/vex/__init__.py +5 -5
  139. angr/engines/vex/claripy/ccall.py +2 -2
  140. angr/engines/vex/claripy/datalayer.py +1 -1
  141. angr/engines/vex/claripy/irop.py +19 -19
  142. angr/engines/vex/heavy/__init__.py +2 -2
  143. angr/engines/vex/heavy/actions.py +1 -3
  144. angr/engines/vex/heavy/heavy.py +4 -6
  145. angr/engines/vex/lifter.py +2 -4
  146. angr/engines/vex/light/light.py +0 -2
  147. angr/engines/vex/light/slicing.py +5 -5
  148. angr/exploration_techniques/__init__.py +19 -142
  149. angr/exploration_techniques/base.py +126 -0
  150. angr/exploration_techniques/bucketizer.py +1 -1
  151. angr/exploration_techniques/dfs.py +3 -1
  152. angr/exploration_techniques/director.py +2 -3
  153. angr/exploration_techniques/driller_core.py +1 -1
  154. angr/exploration_techniques/explorer.py +4 -2
  155. angr/exploration_techniques/lengthlimiter.py +2 -1
  156. angr/exploration_techniques/local_loop_seer.py +2 -1
  157. angr/exploration_techniques/loop_seer.py +5 -5
  158. angr/exploration_techniques/manual_mergepoint.py +2 -1
  159. angr/exploration_techniques/memory_watcher.py +3 -1
  160. angr/exploration_techniques/oppologist.py +4 -5
  161. angr/exploration_techniques/slicecutor.py +4 -2
  162. angr/exploration_techniques/spiller.py +1 -1
  163. angr/exploration_techniques/stochastic.py +2 -1
  164. angr/exploration_techniques/stub_stasher.py +2 -1
  165. angr/exploration_techniques/suggestions.py +3 -1
  166. angr/exploration_techniques/symbion.py +3 -1
  167. angr/exploration_techniques/tech_builder.py +2 -1
  168. angr/exploration_techniques/threading.py +2 -11
  169. angr/exploration_techniques/timeout.py +4 -2
  170. angr/exploration_techniques/tracer.py +4 -3
  171. angr/exploration_techniques/unique.py +3 -2
  172. angr/exploration_techniques/veritesting.py +1 -1
  173. angr/factory.py +36 -6
  174. angr/keyed_region.py +4 -4
  175. angr/knowledge_base.py +1 -1
  176. angr/knowledge_plugins/__init__.py +11 -11
  177. angr/knowledge_plugins/cfg/__init__.py +5 -5
  178. angr/knowledge_plugins/cfg/cfg_manager.py +2 -2
  179. angr/knowledge_plugins/cfg/cfg_model.py +8 -8
  180. angr/knowledge_plugins/cfg/cfg_node.py +19 -19
  181. angr/knowledge_plugins/cfg/indirect_jump.py +6 -6
  182. angr/knowledge_plugins/cfg/memory_data.py +5 -7
  183. angr/knowledge_plugins/functions/function.py +48 -52
  184. angr/knowledge_plugins/functions/function_parser.py +4 -4
  185. angr/knowledge_plugins/key_definitions/__init__.py +3 -3
  186. angr/knowledge_plugins/key_definitions/atoms.py +8 -8
  187. angr/knowledge_plugins/key_definitions/definition.py +1 -1
  188. angr/knowledge_plugins/key_definitions/live_definitions.py +30 -27
  189. angr/knowledge_plugins/labels.py +1 -1
  190. angr/knowledge_plugins/propagations/__init__.py +1 -1
  191. angr/knowledge_plugins/propagations/prop_value.py +2 -2
  192. angr/knowledge_plugins/propagations/propagation_model.py +7 -8
  193. angr/knowledge_plugins/propagations/states.py +44 -39
  194. angr/knowledge_plugins/variables/variable_access.py +2 -2
  195. angr/knowledge_plugins/variables/variable_manager.py +24 -10
  196. angr/knowledge_plugins/xrefs/xref.py +5 -8
  197. angr/misc/__init__.py +4 -4
  198. angr/misc/hookset.py +4 -5
  199. angr/misc/loggers.py +2 -2
  200. angr/misc/telemetry.py +1 -1
  201. angr/procedures/__init__.py +1 -1
  202. angr/procedures/cgc/fdwait.py +2 -2
  203. angr/procedures/definitions/__init__.py +2 -2
  204. angr/procedures/definitions/linux_kernel.py +0 -1
  205. angr/procedures/definitions/parse_syscalls_from_local_system.py +1 -1
  206. angr/procedures/definitions/parse_win32json.py +0 -1
  207. angr/procedures/ntdll/exceptions.py +1 -1
  208. angr/procedures/stubs/format_parser.py +3 -3
  209. angr/procedures/win32/dynamic_loading.py +1 -1
  210. angr/protos/__init__.py +3 -3
  211. angr/sim_manager.py +3 -5
  212. angr/sim_state.py +40 -42
  213. angr/sim_state_options.py +3 -3
  214. angr/sim_type.py +15 -14
  215. angr/sim_variable.py +42 -45
  216. angr/simos/__init__.py +4 -4
  217. angr/simos/cgc.py +1 -1
  218. angr/simos/simos.py +1 -1
  219. angr/simos/userland.py +1 -1
  220. angr/slicer.py +4 -7
  221. angr/state_plugins/__init__.py +34 -34
  222. angr/state_plugins/callstack.py +5 -12
  223. angr/state_plugins/heap/__init__.py +2 -2
  224. angr/state_plugins/heap/heap_brk.py +2 -4
  225. angr/state_plugins/heap/heap_ptmalloc.py +1 -1
  226. angr/state_plugins/jni_references.py +3 -2
  227. angr/state_plugins/scratch.py +1 -1
  228. angr/state_plugins/sim_action.py +1 -4
  229. angr/state_plugins/sim_event.py +1 -1
  230. angr/state_plugins/solver.py +7 -9
  231. angr/state_plugins/uc_manager.py +1 -1
  232. angr/state_plugins/view.py +2 -2
  233. angr/storage/__init__.py +1 -1
  234. angr/storage/file.py +10 -10
  235. angr/storage/memory_mixins/__init__.py +46 -46
  236. angr/storage/memory_mixins/default_filler_mixin.py +1 -3
  237. angr/storage/memory_mixins/javavm_memory_mixin.py +2 -2
  238. angr/storage/memory_mixins/name_resolution_mixin.py +2 -2
  239. angr/storage/memory_mixins/paged_memory/paged_memory_mixin.py +1 -3
  240. angr/storage/memory_mixins/paged_memory/pages/__init__.py +6 -6
  241. angr/storage/memory_mixins/paged_memory/pages/list_page.py +1 -1
  242. angr/storage/memory_mixins/paged_memory/pages/multi_values.py +1 -1
  243. angr/storage/memory_mixins/paged_memory/pages/mv_list_page.py +1 -1
  244. angr/storage/memory_mixins/paged_memory/pages/ultra_page.py +2 -4
  245. angr/storage/memory_mixins/regioned_memory/__init__.py +3 -3
  246. angr/storage/memory_mixins/regioned_memory/region_data.py +5 -5
  247. angr/storage/memory_mixins/regioned_memory/region_meta_mixin.py +7 -9
  248. angr/storage/memory_mixins/regioned_memory/regioned_memory_mixin.py +4 -4
  249. angr/storage/memory_object.py +4 -4
  250. angr/utils/__init__.py +3 -3
  251. angr/utils/bits.py +12 -0
  252. angr/utils/dynamic_dictlist.py +1 -1
  253. angr/utils/graph.py +1 -1
  254. angr/utils/orderedset.py +4 -1
  255. angr/utils/segment_list.py +2 -2
  256. angr/utils/ssa/__init__.py +33 -8
  257. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/METADATA +6 -6
  258. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/RECORD +262 -263
  259. angr/analyses/propagator/engine_ail.py +0 -1562
  260. angr/storage/memory_mixins/__init__.pyi +0 -48
  261. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/LICENSE +0 -0
  262. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/WHEEL +0 -0
  263. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/entry_points.txt +0 -0
  264. {angr-9.2.131.dist-info → angr-9.2.133.dist-info}/top_level.txt +0 -0
@@ -19,7 +19,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
19
19
  """
20
20
 
21
21
  @staticmethod
22
- def _check_divisor(a, b, ndigits=6):
22
+ def _check_divisor(a: int, b: int, ndigits: int = 6) -> int | None:
23
23
  if b == 0:
24
24
  return None
25
25
  divisor_1 = 1 + (a // b)
@@ -27,7 +27,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
27
27
  return divisor_1 if divisor_1 == divisor_2 else None
28
28
 
29
29
  # pylint: disable=too-many-boolean-expressions
30
- def _ail_handle_Convert(self, expr: Expr.Convert):
30
+ def _handle_expr_Convert(self, expr: Expr.Convert):
31
31
  if expr.from_bits == 128 and expr.to_bits == 64:
32
32
  operand_expr = self._expr(expr.operand)
33
33
  if (
@@ -42,18 +42,20 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
42
42
  ):
43
43
  if operand_expr.operands[0].op == "Shr":
44
44
  Y = operand_expr.operands[0].operands[1].value
45
+ assert isinstance(Y, int)
45
46
  else:
46
47
  Y = int(math.log2(operand_expr.operands[0].operands[1].value))
47
48
  C = operand_expr.operands[1].value
49
+ assert isinstance(C, int)
48
50
  divisor = self._check_divisor(pow(2, 64 + Y), C)
49
51
  if divisor:
50
52
  X = operand_expr.operands[0].operands[0]
51
53
  new_const = Expr.Const(expr.idx, None, divisor, 64)
52
54
  return Expr.BinaryOp(expr.idx, "Div", [X, new_const], expr.signed, **expr.tags)
53
55
 
54
- return super()._ail_handle_Convert(expr)
56
+ return expr
55
57
 
56
- def _ail_handle_Shr(self, expr):
58
+ def _handle_binop_Shr(self, expr):
57
59
  operand_0 = self._expr(expr.operands[0])
58
60
  operand_1 = self._expr(expr.operands[1])
59
61
 
@@ -90,6 +92,8 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
90
92
  if isinstance(operand_0.operand.operands[1], Expr.Const):
91
93
  C = operand_0.operand.operands[1].value
92
94
  Y = operand_1.value
95
+ assert isinstance(C, int)
96
+ assert isinstance(Y, int)
93
97
  divisor = self._check_divisor(pow(2, 64 + Y), C)
94
98
  X = operand_0.operand.operands[0]
95
99
  elif isinstance(operand_0.operand.operands[0], Expr.BinaryOp) and operand_0.operand.operands[0].op in {
@@ -102,6 +106,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
102
106
  Y = operand_0.operand.operands[0].operands[1].value
103
107
  else:
104
108
  Y = int(math.log2(operand_0.operand.operands[0].operands[1].value))
109
+ assert isinstance(C, int)
110
+ assert isinstance(Y, int)
111
+ assert isinstance(Z, int)
105
112
  divisor = self._check_divisor(pow(2, 64 + Z + Y), C)
106
113
  X = operand_0.operand.operands[0].operands[0]
107
114
  if isinstance(operand_1, Expr.Const) and isinstance(operand_0, Expr.BinaryOp) and operand_0.op == "Add":
@@ -127,6 +134,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
127
134
  and V_.operands[0] == X
128
135
  and V_.operands[1] == xC
129
136
  ):
137
+ assert isinstance(Y, int)
138
+ assert isinstance(Z, int)
139
+ assert isinstance(V, int)
130
140
  divisor = self._check_divisor(
131
141
  pow(2, Y + V + Z), C * (pow(2, V) - 1) + pow(2, Y)
132
142
  )
@@ -141,6 +151,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
141
151
  if isinstance(V, Expr.Const):
142
152
  V = V.value
143
153
  if isinstance(V_, Expr.BinaryOp) and V_.op == "Sub" and V_.operands[1] == xC:
154
+ assert isinstance(Y, int)
155
+ assert isinstance(Z, int)
156
+ assert isinstance(V, int)
144
157
  divisor = self._check_divisor(pow(2, Y + V + Z), C * (pow(2, V) - 1) + pow(2, Y))
145
158
  elif (
146
159
  isinstance(xC, Expr.BinaryOp)
@@ -164,6 +177,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
164
177
  Y = xC.operands[1].value
165
178
  V = x_xC.operands[1].value
166
179
  if x_xC.operands[0].operands[0] == X:
180
+ assert isinstance(Y, int)
181
+ assert isinstance(Z, int)
182
+ assert isinstance(V, int)
167
183
  divisor = self._check_divisor(pow(2, Y + V + Z), C * (pow(2, V) - 1) + pow(2, Y))
168
184
 
169
185
  # unsigned int
@@ -178,6 +194,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
178
194
  C = operand_0.operands[1].value
179
195
  Z = operand_1.value
180
196
  X = operand_0.operands[0]
197
+ assert isinstance(C, int)
198
+ assert isinstance(Z, int)
199
+ assert isinstance(V, int)
181
200
  divisor = self._check_divisor(pow(2, V + Z), C)
182
201
  elif (
183
202
  isinstance(operand_0.operands[0], Expr.BinaryOp)
@@ -196,11 +215,17 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
196
215
  if operand_0.operands[0].op == "Mod":
197
216
  Y = int(math.log2(operand_0.operands[0].operands[1].value))
198
217
  Z = operand_1.value
218
+ assert isinstance(Y, int)
219
+ assert isinstance(Z, int)
220
+ assert isinstance(V, int)
221
+ assert isinstance(C, int)
199
222
  divisor = self._check_divisor(pow(2, Y + Z + V), C, ndigits)
200
223
  else:
201
224
  X = operand_0.operands[0]
202
225
  Y = operand_1.value
203
226
  C = operand_0.operands[1].value
227
+ assert isinstance(Y, int)
228
+ assert isinstance(C, int)
204
229
  divisor = self._check_divisor(pow(2, Y), C)
205
230
 
206
231
  if divisor and X:
@@ -225,7 +250,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
225
250
  return Expr.BinaryOp(expr.idx, "Shr", [operand_0, operand_1], expr.signed)
226
251
  return expr
227
252
 
228
- def _ail_handle_Mul(self, expr):
253
+ def _handle_binop_Mul(self, expr):
229
254
  operand_0, operand_1 = expr.operands
230
255
 
231
256
  if (
@@ -234,6 +259,8 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
234
259
  and isinstance(operand_0.operands[1], Expr.Const)
235
260
  and operand_0.op in {"Mod", "Shr"}
236
261
  ):
262
+ assert isinstance(operand_0.operands[1].value, int)
263
+ assert isinstance(operand_1.value, int)
237
264
  Y = int(math.log2(operand_0.operands[1].value)) if operand_0.op == "Mod" else operand_0.operands[1].value
238
265
  C = operand_1.value
239
266
  X = operand_0.operands[0]
@@ -242,8 +269,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
242
269
  if isinstance(X, Expr.Convert):
243
270
  V = X.from_bits - X.to_bits
244
271
  ndigits = 5 if V == 32 else 6
245
- if self._check_divisor(pow(2, V + Y), C, ndigits) and X:
246
- divisor = self._check_divisor(pow(2, Y + V), C, ndigits)
272
+ if (divisor := self._check_divisor(pow(2, V + Y), C, ndigits)) and X:
247
273
  new_const = Expr.Const(expr.idx, None, divisor, 64)
248
274
  return Expr.BinaryOp(expr.idx, "Div", [X, new_const], expr.signed, **expr.tags)
249
275
  if (
@@ -252,7 +278,9 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
252
278
  and isinstance(operand_0.operand, Expr.BinaryOp)
253
279
  and isinstance(operand_0.operand.operands[1], Expr.Const)
254
280
  and operand_0.operand.op in {"Mod", "Shr"}
281
+ and isinstance(operand_1.value, int)
255
282
  ):
283
+ assert isinstance(operand_0.operand.operands[1].value, int)
256
284
  if operand_0.operand.op == "Mod":
257
285
  Y = int(math.log2(operand_0.operand.operands[1].value))
258
286
  else:
@@ -261,13 +289,12 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
261
289
  X = operand_0.operand.operands[0]
262
290
  V = operand_0.from_bits - operand_0.to_bits
263
291
  ndigits = 5 if V == 32 else 6
264
- if self._check_divisor(pow(2, V + Y), C, ndigits) and X:
265
- divisor = self._check_divisor(pow(2, Y + V), C, ndigits)
292
+ if (divisor := self._check_divisor(pow(2, V + Y), C, ndigits)) and X:
266
293
  new_const = Expr.Const(expr.idx, None, divisor, 64)
267
294
  return Expr.BinaryOp(expr.idx, "Div", [X, new_const], expr.signed, **expr.tags)
268
- return super()._ail_handle_Mul(expr)
295
+ return expr
269
296
 
270
- def _ail_handle_Div(self, expr):
297
+ def _handle_binop_Div(self, expr):
271
298
  operand_0 = self._expr(expr.operands[0])
272
299
  operand_1 = self._expr(expr.operands[1])
273
300
 
@@ -285,10 +312,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
285
312
  return Expr.BinaryOp(expr.idx, "Div", [operand_0, operand_1], expr.signed, **expr.tags)
286
313
  return expr
287
314
 
288
- def _ail_handle_Add(self, expr):
289
- if len(expr.operands) != 2:
290
- return super()._ail_handle_Add(expr)
291
-
315
+ def _handle_binop_Add(self, expr):
292
316
  op0 = self._expr(expr.operands[0])
293
317
  op1 = self._expr(expr.operands[1])
294
318
 
@@ -350,6 +374,7 @@ class DivSimplifierAILEngine(SimplifierAILEngine):
350
374
  X = operand_1
351
375
  V = bits
352
376
  ndigits = 5 if V == 32 else 6
377
+ assert isinstance(C, int)
353
378
  divisor = self._check_divisor(pow(2, V), C, ndigits)
354
379
  if divisor is not None and X:
355
380
  new_const = Expr.Const(None, None, divisor, V)
@@ -380,7 +405,7 @@ class DivSimplifier(OptimizationPass):
380
405
  super().__init__(func, **kwargs)
381
406
 
382
407
  self.state = SimplifierAILState(self.project.arch)
383
- self.engine = DivSimplifierAILEngine()
408
+ self.engine = DivSimplifierAILEngine(self.project)
384
409
 
385
410
  self.analyze()
386
411
 
@@ -242,11 +242,8 @@ class DuplicationReverter(StructuringOptimizationPass):
242
242
  target_candidates = []
243
243
  for mblock, oblocks in ail_merge_graph.merge_blocks_to_originals.items():
244
244
  for oblock in oblocks:
245
- if (
246
- isinstance(oblock, AILBlockSplit)
247
- and oblock.original.addr == target_addr
248
- or isinstance(oblock, Block)
249
- and oblock.addr == target_addr
245
+ if (isinstance(oblock, AILBlockSplit) and oblock.original.addr == target_addr) or (
246
+ isinstance(oblock, Block) and oblock.addr == target_addr
250
247
  ):
251
248
  target_candidates.append(mblock)
252
249
 
@@ -287,7 +284,9 @@ class DuplicationReverter(StructuringOptimizationPass):
287
284
  break
288
285
 
289
286
  if new_target is None:
290
- raise RuntimeError("Unable to correct a predecessor, this is a bug!")
287
+ _l.debug("Unable to correct a predecessor, this is a bug!")
288
+ self.write_graph = self.read_graph.copy()
289
+ return False
291
290
 
292
291
  replacement_map[target_addr] = new_target.addr
293
292
  self.write_graph.add_edge(orig_pred, new_target)
@@ -316,7 +315,9 @@ class DuplicationReverter(StructuringOptimizationPass):
316
315
  break
317
316
 
318
317
  if new_succ is None:
319
- raise RuntimeError("Unable to find the successor for block with no jump or condition!")
318
+ _l.debug("Unable to find the successor for block with no jump or condition!")
319
+ self.write_graph = self.read_graph.copy()
320
+ return False
320
321
 
321
322
  self.write_graph.add_edge(orig_pred, new_succ)
322
323
 
@@ -8,8 +8,8 @@ from ailment import Const
8
8
  from ailment.block import Block
9
9
  from ailment.statement import Statement, ConditionalJump, Jump
10
10
 
11
- from .errors import UnsupportedAILNodeError
12
11
  from angr.analyses.decompiler.structuring.structurer_nodes import IncompleteSwitchCaseHeadStatement
12
+ from .errors import UnsupportedAILNodeError
13
13
 
14
14
 
15
15
  _l = logging.getLogger(name=__name__)
@@ -47,8 +47,6 @@ def replace_node_in_graph(graph: nx.DiGraph, node, replace_with):
47
47
  else:
48
48
  graph.add_edge(replace_with, dst)
49
49
 
50
- assert node not in graph
51
-
52
50
 
53
51
  def bfs_list_blocks(start_block: Block, graph: nx.DiGraph):
54
52
  blocks = []