github.com/criyle/go-sandbox@v0.10.3/ptracer/context_linux_amd64.go (about) 1 package ptracer 2 3 import ( 4 "syscall" 5 6 unix "golang.org/x/sys/unix" 7 ) 8 9 // SyscallNo get current syscall no 10 func (c *Context) SyscallNo() uint { 11 return uint(c.regs.Orig_rax) 12 } 13 14 // Arg0 gets the arg0 for the current syscall 15 func (c *Context) Arg0() uint { 16 return uint(c.regs.Rdi) 17 } 18 19 // Arg1 gets the arg1 for the current syscall 20 func (c *Context) Arg1() uint { 21 return uint(c.regs.Rsi) 22 } 23 24 // Arg2 gets the arg2 for the current syscall 25 func (c *Context) Arg2() uint { 26 return uint(c.regs.Rdx) 27 } 28 29 // Arg3 gets the arg3 for the current syscall 30 func (c *Context) Arg3() uint { 31 return uint(c.regs.R10) 32 } 33 34 // Arg4 gets the arg4 for the current syscall 35 func (c *Context) Arg4() uint { 36 return uint(c.regs.R8) 37 } 38 39 // Arg5 gets the arg5 for the current syscall 40 func (c *Context) Arg5() uint { 41 return uint(c.regs.R9) 42 } 43 44 // SetReturnValue set the return value if skip the syscall 45 func (c *Context) SetReturnValue(retval int) { 46 c.regs.Rax = uint64(retval) 47 } 48 49 func (c *Context) skipSyscall() error { 50 c.regs.Orig_rax = ^uint64(0) //-1 51 return syscall.PtraceSetRegs(c.Pid, &c.regs) 52 } 53 54 func getIovec(base *byte, l int) unix.Iovec { 55 return unix.Iovec{ 56 Base: base, 57 Len: uint64(l), 58 } 59 }