-
Notifications
You must be signed in to change notification settings - Fork 1k
/
static_dispatcher.py
37 lines (26 loc) · 1.44 KB
/
static_dispatcher.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from archinfo.arch_soot import SootMethodDescriptor
from cle.errors import CLEError
import logging
l = logging.getLogger('angr.engines.soot.static_dispatcher')
# TODO implement properly
# this will need the expression, the class hierarchy, and the position of the instruction (for invoke-super)
# this will also need the current state to try to figure out the dynamic type
def resolve_method(state, expr):
# get binary containing the method
jar = state.regs._ip_binary
try:
# get all methods matching class- and method-name
methods = list(jar.get_method(expr.method_name, expr.class_name))
except CLEError:
# No methods found
# => We are executing code that is not in CLE (typically library code)
# Fallback: use only infos from the invocation, so we can still use SimProcedures
l.warning("Couldn't find method %s.%s" % (expr.method_name, expr.class_name))
return SootMethodDescriptor(expr.class_name, expr.method_name, expr.method_params)
else:
if len(methods) != 1:
# Found several methods matching class- and method-name
# TODO: use information about the function signature to find the right one
l.warning("Function %s is ambiguous in class %s" % (expr.method_name, expr.class_name))
return SootMethodDescriptor.from_soot_method(methods[0])
# return SootMethodDescriptor(expr.class_name, expr.method_name, expr.method_params)