Beispiel #1
0
static int
elf_loadnotes(struct lwp *lp, prpsinfo_t *psinfo, prstatus_t *status,
	   prfpregset_t *fpregset, prsavetls_t *tls)
{
	struct proc *p = lp->lwp_proc;
	//struct lwp *nlp;
	int error;

	/* validate status and psinfo */
	TRACE_ENTER;
	if (status->pr_version != PRSTATUS_VERSION ||
	    status->pr_statussz != sizeof(prstatus_t) ||
	    status->pr_gregsetsz != sizeof(gregset_t) ||
	    status->pr_fpregsetsz != sizeof(fpregset_t) ||
	    psinfo->pr_version != PRPSINFO_VERSION ||
	    psinfo->pr_psinfosz != sizeof(prpsinfo_t)) {
	        PRINTF(("status check failed\n"));
		error = EINVAL;
		goto done;
	}
	/* XXX lwp handle more than one lwp*/
	/* XXX restore each thread */
	if ((error = set_regs(lp, &status->pr_reg)) != 0)
		goto done;
	error = set_fpregs(lp, fpregset);

	/* XXX SJG */
	kprintf("Avem la load %i\n", p->p_nthreads);
	kprintf("xxx: restoring TLS-fu\n");
	bcopy(tls, &lp->lwp_thread->td_tls, sizeof *tls);
//	crit_enter();
//	set_user_TLS();
//	crit_exit();

	/* Try to recreate another thread */
#if 0
	kprintf("xxx restoring a second thread\n");	
	status++; fpregset++; tls++;
	// create new thread
	lwp_rb_tree_RB_INSERT(&p->p_lwp_tree, nlp);
	//nlp->lwp_cpumask = (cpumask_t)-1;
	//nlp->lwp_thread ?
	p->p_nthreads++;
	p->p_lasttid++;
	nlp->lwp_proc = p;
	// append stored info
	if ((error = set_regs(nlp, &status->pr_reg)) != 0)
		goto done;
	error = set_fpregs(nlp, fpregset);
	bcopy(tls, &nlp->lwp_thread->td_tls, sizeof *tls);
#endif

	
	strlcpy(p->p_comm, psinfo->pr_fname, sizeof(p->p_comm));
	/* XXX psinfo->pr_psargs not yet implemented */

 done:	
	TRACE_EXIT;
	return error;
}
Beispiel #2
0
static int
arch_set_error(struct tcb *tcp)
{
	if (aarch64_io.iov_len == sizeof(arm_regs))
		return arm_set_error(tcp);

	aarch64_regs.regs[0] = -tcp->u_error;
	return set_regs(tcp->pid);
}
Beispiel #3
0
int main(int ac, char** av)
{
	instr_t*	imem;
	int		imem_size;
	int		yyparse();
	int		yylex_destroy();

	progname = av[0];
	output = stdout;

	init_func();
	init_instr();
	init_stmt();
	init_sim();

	params(ac, av);

	if (yyin == NULL) {
		warning("no input file");
		exit(0);	
	}
		
	if (cfg_fp == NULL)
		yyparse();
	
	fclose(yyin);
	yylex_destroy();

	opt();

	if (cfg_fp != NULL)
		exit(0);

	imem = stmt2instr(&imem_size);

	free_func();
	deinit_symtab();
	deinit_sym();

	set_dmem_size(100000);
	set_imem(imem, imem_size);
	set_regs(32);

	run(); 

	print_stats();
		
	free_sim();

	if (output != NULL)
		fclose(output);

	if (yyin != NULL)
		fclose(yyin);

	return 0;
}
Beispiel #4
0
long int ptrace (enum __ptrace_request __request, ...)
{
    pid_t pid;
    void *addr, *data;
    va_list ap;

    va_start(ap, __request);
    pid = va_arg(ap, pid_t);
    addr = va_arg(ap, void *);
    data = va_arg(ap, void *);
    va_end(ap);

    if(__request == PTRACE_GETREGS)
    {
        return get_regs(pid, addr, data);
    }
    else if(__request == PTRACE_SETREGS)
    {
        return set_regs(pid, addr, data);
    }
#if 0
    //some old system may require this command to get register
    else if(__request == PTRACE_PEEKUSER)
    {

    }
#endif
    else if(__request == PTRACE_GETFPREGS)
    {
        return get_fpregs(pid, addr, data, FALSE);
    }
    else if(__request == PTRACE_SETFPREGS)
    {
        return set_fpregs(pid, addr, data, FALSE);

    }
    else if(__request == PTRACE_GETFPXREGS)
    {
        return get_fpregs(pid, addr, data, TRUE);
    }
    else if(__request == PTRACE_SETFPXREGS)
    {
        return set_fpregs(pid, addr, data, TRUE);
    }

    //xstave for avx
    else if(__request == PTRACE_GETREGSET)
    {
        return get_regset(pid, addr, data);
    }
    else if(__request == PTRACE_SETREGSET)
    {
        return set_regset(pid, addr, data);
    }
    //For other request just forward it to real ptrace call;
    return g_sys_ptrace(__request, pid, addr, data);
}
Beispiel #5
0
static int
arch_set_scno(struct tcb *tcp, kernel_ulong_t scno)
{
	if (ia64_ia32mode)
		ia64_regs.gr[0] = scno;
	else
		ia64_regs.gr[15] = scno;

	return set_regs(tcp->pid);
}
Beispiel #6
0
int
set_regs32(struct thread *td, struct reg32 *regs)
{
	struct reg r;
	unsigned i;

	for (i = 0; i < NUMSAVEREGS; i++)
		r.r_regs[i] = regs->r_regs[i];

	return (set_regs(td, &r));
}
Beispiel #7
0
static int
arch_set_error(struct tcb *tcp)
{
#ifdef HAVE_GETREGS_OLD
	x86_64_regs.rax = - (long long) tcp->u_error;
	return upoke(tcp->pid, 8 * RAX, x86_64_regs.rax);
#else
	if (x86_io.iov_len == sizeof(i386_regs))
		return i386_set_error(tcp);

	x86_64_regs.rax = - (long long) tcp->u_error;
	return set_regs(tcp->pid);
#endif
}
Beispiel #8
0
int main(int argc, char *argv[]) {
  char shell[strlen(stub) + strlen(shellcode) + 1];
  sprintf(shell, "%s%s", stub, shellcode);

  parseopts(argc, argv);
  int pid = atoi(argv[1]);

  attach(pid);
  struct user_regs_struct *tmp = inject(pid, shell);
  
  struct sigaction hook_ret;
  memset(&hook_ret, 0, sizeof(struct sigaction));
  hook_ret.sa_handler = ret_handler;
  sigaction(0xc, &hook_ret, 0);

  cont(pid);

  while(hit == 0) {}

  set_regs(pid, tmp);

  detach(pid);
  return 0;
}
Beispiel #9
0
static int
arch_set_scno(struct tcb *tcp, kernel_ulong_t scno)
{
	ARCH_REGSET.gprs[2] = scno;
	return set_regs(tcp->pid);
}
Beispiel #10
0
static int
arch_set_error(struct tcb *tcp)
{
	arc_regs.scratch.r0 = -tcp->u_error;
	return set_regs(tcp->pid);
}
Beispiel #11
0
int
procfs_write_regs(struct lwp *lp, struct reg *regs)
{
	return (set_regs(lp, regs));
}
Beispiel #12
0
static int
arch_set_scno(struct tcb *tcp, kernel_ulong_t scno)
{
	s390_regset.gprs[2] = scno;
	return set_regs(tcp->pid);
}
Beispiel #13
0
static int
arch_set_error(struct tcb *tcp)
{
	metag_regs.dx[0][0] = -tcp->u_error;
	return set_regs(tcp->pid);
}
Beispiel #14
0
static int
arch_set_success(struct tcb *tcp)
{
	arm_regs.ARM_r0 = tcp->u_rval;
	return set_regs(tcp->pid);
}
Beispiel #15
0
static int
arch_set_error(struct tcb *tcp)
{
	arm_regs.ARM_r0 = -tcp->u_error;
	return set_regs(tcp->pid);
}
Beispiel #16
0
int
proc_write_regs(struct thread *td, struct reg *regs)
{

	PROC_ACTION(set_regs(td, regs));
}
Beispiel #17
0
static int
arch_set_scno(struct tcb *tcp, kernel_ulong_t scno)
{
	tile_regs.regs[10] = scno;
	return set_regs(tcp->pid);
}
Beispiel #18
0
static int
arch_set_success(struct tcb *tcp)
{
	metag_regs.dx[0][0] = tcp->u_rval;
	return set_regs(tcp->pid);
}