void ptrace_attach(pid_t pid, struct user_regs_struct *regs) { if(ptrace(PTRACE_ATTACH, pid, NULL, NULL) < 0) { printf("ptrace_attach error "); } waitpid(pid, NULL, WUNTRACED); if(ptrace(PTRACE_GETREGS, pid, NULL, regs)) { printf("ptrace_getregs error! "); } } 这里省略了查...
for (;;) { /* Enter next system call */ ptrace(PTRACE_SYSCALL, pid, 0, 0); waitpid(pid, 0, 0); struct user_regs_struct regs; ptrace(PTRACE_GETREGS, pid, 0, ®s); /* Is this system call permitted? */ int blocked = 0; if (is_syscall_blocked(regs.orig_rax)) { blocked ...
写到这里不得不提到两个相关重要的两个结构体:pt_regs和cpu_context,他俩都是处理器架构相关的结构。 pt_regs描述的发生异常的时候保存的现场信息,主要是一些通用寄存器,我们这里称为异常现场: struct pt_regs { union { struct user_pt_regs user_regs; struct { u64 regs[31]; //通用寄存器 u64 sp; u...
®s, sizeof(struct user_regs_struct));// 修改rip为mem_addr(shellcode的地址)regs.rip = (u_int64_t) mem_addr;regs.rip += 2// 设置tracee寄存器ptrace(PTRACE_SETREGS, tracee_pid, NULL, ®s)// 执行shellcode,假设shellcode结尾执行了getpid系统调用for (;;) { ptrace(PTRACE_SYSCALL...
struct FTraceHookContext context={.Hook=container_of(ops,struct FTraceHook,FTraceOPS),.KernelRegisters=kernel_regs,.UserRegisters=user_regs,.SysCallNR=&argument_regs->ax,.Arguments={&argument_regs->bx,&argument_regs->cx,&argument_regs->dx,&argument_regs->si,&argument_regs->di,&argument_regs...
(PTRACE_PEEKDATA,pid,addr,NULL);user_regs_struct old_regs;ptrace(PTRACE_GETREGS,pid,NULL,&old_regs);long trap_code=old_code;unsigned char*p=(unsigned char*)&trap_code;// Trap 中断指令的十六进制数值p[0]=0xcc;// 用 Trap 覆盖 addr 数值,等 cpu 执行至此就会中断if(ptrace(PTRACE_POKEDATA...
->从dts中获取信息,填充并初始化struct rkcif_hw结构体。 ->rkcif_plat_drv--匹配"rockchip,rkcif-mipi-lvds"进行 ->rkcif_subdev_driver-- rkcif_csi2_plat_drv_init--初始化CSI2。 2.2 RKCIF IOMMU 选用IOMMU作为RKCIF的MMU: rkcif_mmu: iommu@fdce0800 { ...
70struct user_struct*user;71char comm[TASK_COMM_LEN];/* 除去路径后的可执行文件名称-用[gs]et_task_comm访问(其中用task_lock()锁定它)-通常由flush_old_exec初始化 */72/* 文件系统信息 */73int link_count,total_link_count;74/* ipc相关 */75struct sysv_sem sysvsem;76/* 当前进程特定于CPU...
if (addr != vma->vm_start) { /* * It is a bit too late to pretend changing the virtual * area of the mapping, we just corrupted userspace * in the do_munmap, so FIXME (not in 2.4 to avoid breaking * the driver API). */ struct vm_area_struct * stale_vma; /* Since addr...
↓staticintdo_execveat_common(int fd,structfilename*filename,structuser_arg_ptrargv,structuser_arg_ptrenvp, int flags) {char*pathbuf = NULL;structlinux_binprm*bprm;structfile*file;structfiles_struct*displaced; int retval;if(IS_ERR(filename))returnPTR_ERR(filename);/* ...