From c539822cceaee175486f6b5c6b435cc0adeb0129 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Andr=C3=A9=20Vadla=20Ravn=C3=A5s?= Date: Fri, 27 Apr 2018 21:52:05 +0200 Subject: [PATCH] Replace flush-before-exit logic with rpc.exports.dispose() --- src/frida/tracer.py | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/src/frida/tracer.py b/src/frida/tracer.py index 38d4c86..182d609 100755 --- a/src/frida/tracer.py +++ b/src/frida/tracer.py @@ -402,9 +402,10 @@ var state = {}; var pending = []; var timer = null; -installFlushBeforeExitHandlers(); - rpc.exports = { + dispose: function () { + flush(); + }, add: function (targets) { targets.forEach(function (target) { var h = [parseHandler(target)]; @@ -498,30 +499,6 @@ function parseHandler(target) { return {}; } } - -function installFlushBeforeExitHandlers() { - if (Process.platform === 'windows') { - attachFlushBeforeExitHandler("kernel32.dll", "ExitProcess"); - } else { - attachFlushBeforeExitHandler(null, "abort"); - attachFlushBeforeExitHandler(null, "exit"); - } -} - -function attachFlushBeforeExitHandler(module, name) { - Interceptor.attach(Module.findExportByName(module, name), performFlushBeforeExit); -} - -function performFlushBeforeExit() { - flush(); - - send({ - from: "/events", - name: '+flush', - payload: {} - }); - recv('+flush-ack', function () {}).wait(); -} """ def _process_message(self, message, data, ui): @@ -533,12 +510,6 @@ function performFlushBeforeExit() { events = [(timestamp, thread_id, depth, int(target_address.rstrip("L"), 16), message) for timestamp, thread_id, depth, target_address, message in stanza['payload']['items']] ui.on_trace_events(events) handled = True - elif stanza['name'] == '+flush': - try: - self._script.post({ 'type': '+flush-ack' }) - except Exception as e: - pass - handled = True elif stanza['from'] == "/targets" and stanza['name'] == '+error': ui.on_trace_error(stanza['payload']) handled = True