[docs]classSimEngineSyscall(SuccessorsMixin,ProcedureMixin):""" A SimEngine mixin which adds a successors handling step that checks if a syscall was just requested and if so handles it as a step. """
[docs]defprocess_successors(self,successors,**kwargs):state=self.state# we have at this point entered the next step so we need to check the previous jumpkindif(notstate.historyornotstate.history.parentornotstate.history.parent.jumpkindornotstate.history.parent.jumpkind.startswith("Ijk_Sys")):returnsuper().process_successors(successors,**kwargs)l.debug("Invoking system call handler")sys_procedure=self.project.simos.syscall(state)ifsys_procedureisNone:ifangr.sim_options.BYPASS_UNSUPPORTED_SYSCALLnotinstate.options:raiseAngrUnsupportedSyscallError("Trying to perform a syscall on an emulated system which is not currently cofigured to support ""syscalls. To resolve this, make sure that your SimOS is a subclass of SimUserspace, or set the ""BYPASS_UNSUPPORTED_SYSCALL state option.")else:try:cc=angr.SYSCALL_CC[state.arch.name][state.os_name](state.arch)exceptKeyError:try:l.warning("No syscall calling convention available for %s/%s",state.arch.name,state.os_name)cc=angr.SYSCALL_CC[state.arch.name]["default"](state.arch)exceptKeyError:cc=None# some default will get picked down the line...sys_procedure=angr.SIM_PROCEDURES["stubs"]["syscall"](cc=cc)returnself.process_procedure(state,successors,sys_procedure,**kwargs)