
As of go version 1.4 the standard library syscall package is "locked down" and code outside of the standard library is recommended to migrate to the go.sys subrepository. Reference: https://golang.org/s/go1.4-syscall
42 lines
808 B
Go
42 lines
808 B
Go
package proctl
|
|
|
|
import sys "golang.org/x/sys/unix"
|
|
|
|
type Regs struct {
|
|
regs *sys.PtraceRegs
|
|
}
|
|
|
|
func (r *Regs) PC() uint64 {
|
|
return r.regs.PC()
|
|
}
|
|
|
|
func (r *Regs) SP() uint64 {
|
|
return r.regs.Rsp
|
|
}
|
|
|
|
func (r *Regs) SetPC(tid int, pc uint64) error {
|
|
r.regs.SetPC(pc)
|
|
return sys.PtraceSetRegs(tid, r.regs)
|
|
}
|
|
|
|
func registers(tid int) (Registers, error) {
|
|
var regs sys.PtraceRegs
|
|
err := sys.PtraceGetRegs(tid, ®s)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &Regs{®s}, nil
|
|
}
|
|
|
|
func writeMemory(tid int, addr uintptr, data []byte) (int, error) {
|
|
return sys.PtracePokeData(tid, addr, data)
|
|
}
|
|
|
|
func readMemory(tid int, addr uintptr, data []byte) (int, error) {
|
|
return sys.PtracePeekData(tid, addr, data)
|
|
}
|
|
|
|
func clearHardwareBreakpoint(reg, tid int) error {
|
|
return setHardwareBreakpoint(reg, tid, 0)
|
|
}
|