def UIInputHandler(event): if Global.IsUserInSystemUI(): return threads = Global.ActiveThreads() event.thread_name = Global.ThreadName(event.pid) key = Global.AddNode(event) threads[event.pid] = key
def DefaultHandlerInternal(event): """Use temporal correlation to link events within a thread.""" threads = Global.ActiveThreads() tid = event.pid #key = None key = Global.AddNode(event) if tid in threads: Global.AddEdge(threads[tid], key) threads[tid] = key return key
def BinderConsumeHandler(event): if Global.IsUserInSystemUI(): return ctors = Global.Connectors() threads = Global.ActiveThreads() # find a connector ctor_key = binder_key_func(event) if ctor_key in ctors: key = Global.AddNode(event) Global.AddEdge(ctors[ctor_key], key) del ctors[ctor_key] threads[event.pid] = key
def FindConnectorAndUpdate(event, connector_key_func): ctors = Global.Connectors() threads = Global.ActiveThreads() # find the connector ctor_key = connector_key_func(event) if ctor_key in ctors: # connects previous event to the current event key = Global.AddNode(event) Global.AddEdge(ctors[ctor_key], key) del ctors[ctor_key] # decouple the previous event with the current event in the same thread threads[event.pid] = key
def UIUpdateV2Handler(event): if Global.IsUserInSystemUI(): return ctors = Global.Connectors() threads = Global.ActiveThreads() event.thread_name = Global.ThreadName(event.pid) # find the connector ctor_key = ui_invalidate_key_func(event) if ctor_key in ctors: # connects all previous events to the current event key = Global.AddNode(event) for n in ctors[ctor_key]: Global.AddEdge(n, key) del ctors[ctor_key] # decouple the previous event with the current event in the same thread threads[event.pid] = key
def WaitQueueNotifyHandler(event): if Global.IsUserInSystemUI(): return if Global.isWebViewThread(event.data['pid']): key = DefaultHandlerInternal(event) AddConnector(event, wait_queue_notify_key_func, key) # insert a FAKED_WAITQUEUE_WAKE event in the notified thread thread_state = Global.ThreadState(event.data['pid']) if (key is not None) and (thread_state == 'I' or thread_state == 'U'): new_event = copy.deepcopy(event) new_event.event = 'FAKED_WAITQUEUE_WAKE' new_event.pid = event.data['pid'] del new_event.data['pid'] new_event.json['event'] = new_event.event new_event.json['pid'] = new_event.pid new_key = Global.AddNode(new_event) threads = Global.ActiveThreads() threads[new_event.pid] = new_key Global.AddEdge(key, new_key)
def ForkHandler(event): """ Create a 'FORK_IN_CHILD' event in the new thread.""" threads = Global.ActiveThreads() # Add a node in the parent thread key = DefaultHandlerInternal(event) # Add a node in the child thread if key is not None: new_event = copy.deepcopy(event) new_event.event = 'FORK_IN_CHILD' new_event.pid = event.data['pid'] new_event.json['event'] = new_event.event new_event.json['pid'] = new_event.pid new_key = Global.AddNode(new_event) threads[new_event.pid] = new_key Global.AddEdge(key, new_key) Global.NotifyFork(event.data['pid'], event.pid, event.data['tgid']) Global.NotifyForkWebView(event.data['pid'], event.pid, event.data['tgid'])