def force_notify_RegisterProtocolNotify(ql: Qiling, address: int, params): event_id = params['Event'] if event_id in ql.loader.events: # let's force notify event = ql.loader.events[event_id] event['Guid'] = params["Protocol"] event["Set"] = False signal_event(ql, event_id) execute_protocol_notifications(ql, True) return EFI_SUCCESS return EFI_INVALID_PARAMETER
def __module_exit_trap(ql: Qiling): # this trap will be called when the current module entry point function # returns. this is done do regain control, run necessary tear down code # and proceed to the execution of the next module. if no more modules # left, terminate gracefully. # # the tear down code may include queued protocol notifications and module # unload callbacks. in such case the trap returns without calling 'os.stop' # and the execution resumes with the current cpu state. # # note that the trap may be called multiple times for a single module, # every time a tear down code needs to be executed, or for any other # reason defined by the user. if ql.os.notify_after_module_execution(len(self.modules)): return if utils.execute_protocol_notifications(ql): return if self.modules: self.execute_next_module() else: if self.unload_modules( self.smm_context) or self.unload_modules( self.dxe_context): return ql.log.info(f'No more modules to run') ql.os.stop()
def force_notify_RegisterProtocolNotify(ql, address, params): print("\n") print("=" * 40) print(" Enter into set_api mode") print("=" * 40) print("\n") event_id = params['Event'] self.set_api = event_id if event_id in ql.loader.events: ql.loader.events[event_id]['Guid'] = params["Protocol"] # let's force notify event = ql.loader.events[event_id] event["Set"] = True ql.loader.notify_list.append( (event_id, event['NotifyFunction'], event['CallbackArgs'])) execute_protocol_notifications(ql, True) ###### return EFI_SUCCESS return EFI_INVALID_PARAMETER
def force_notify_RegisterProtocolNotify(ql: Qiling, address: int, params): ql.log.info(f'[force_notify] address = {address:#x}, params = {params}') self.ck.visited_oncall = True event_id = params['Event'] if event_id in ql.loader.events: event = ql.loader.events[event_id] # let's force notify event["Set"] = False utils.signal_event(ql, event_id) utils.execute_protocol_notifications(ql, True) return EFI_SUCCESS return EFI_INVALID_PARAMETER
def notify_protocol(self, handle, protocol, interface, from_hook): for (event_id, event_dic) in self.ql.loader.events.items(): if event_dic['Guid'] == protocol: if event_dic['CallbackArgs'] == None: # To support smm notification, we use None for CallbackArgs on SmmRegisterProtocolNotify # and updare it here. guid = str_to_guid(protocol) guid_ptr = self.heap.alloc(guid.sizeof()) guid.saveTo(self.ql, guid_ptr) event_dic['CallbackArgs'] = [guid_ptr, interface, handle] # The event was previously registered by 'RegisterProtocolNotify'. signal_event(self.ql, event_id) return execute_protocol_notifications(self.ql, from_hook)