From 57d7a5de92ce73b3da4d12d0c0bbd9061df4c129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Thu, 14 Jan 2016 14:35:29 +0100 Subject: [PATCH] Fix crash when attempting to trace partially resolved imports --- src/frida/tracer.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/frida/tracer.py b/src/frida/tracer.py index 4b32a8b..f271659 100644 --- a/src/frida/tracer.py +++ b/src/frida/tracer.py @@ -10,7 +10,7 @@ import subprocess import threading import time -from frida.core import Module, ModuleFunction, ObjCMethod +from frida.core import Function, Module, ModuleFunction, ObjCMethod class TracerProfileBuilder(object): @@ -106,19 +106,25 @@ class TracerProfile(object): working_set = [] for target in data['targets']: - module_id = target.get('module') - if module_id is not None: - module = modules[module_id] - relative_address = int(target["address"], 16) - module.base_address - exported = not target.get('private', False) - mf = ModuleFunction(module, target["name"], relative_address, exported) - if not self._is_blacklisted(mf): - working_set.append(mf) - else: - objc = target['objc'] + objc = target.get('objc') + if objc is not None: method = objc['method'] of = ObjCMethod(method['type'], objc['className'], method['name'], int(target['address'], 16)) working_set.append(of) + else: + name = target['name'] + absolute_address = int(target['address'], 16) + module_id = target.get('module') + if module_id is not None: + module = modules[module_id] + relative_address = absolute_address - module.base_address + exported = not target.get('private', False) + mf = ModuleFunction(module, name, relative_address, exported) + if not self._is_blacklisted(mf): + working_set.append(mf) + else: + f = Function(name, absolute_address) + working_set.append(f) return working_set def _is_blacklisted(self, module_function):