// Begins tracing an already existing process
Begins tracing an already existing process
// Begins tracing an already existing process
func newTracedProc(pid int, pie PieOffsetter, regions []Region, breaks map[uintptr][]byte) (*Proc, error) {
	off, err := pie.PieOffset(pid)
	if err != nil {
		return nil, err
	}
	logger.Printf("%d: PIE offset is 0x%x\n", pid, off)
	p := &Proc{
		tracer:      ptrace.NewTracer(pid),
		regions:     make([]activeRegion, 0, len(regions)),
		pieOffset:   off,
		breakpoints: make(map[uintptr][]byte),
	}
	for id, r := range regions {
		addr := uintptr(r.Start(p))
		if orig, ok := breaks[addr]; ok {
			p.breakpoints[addr] = make([]byte, len(orig))
			copy(p.breakpoints[addr], orig)
		} else {
			err := p.setBreak(r.Start(p))
			if err != nil {
				return nil, err
			}
		}
		p.regions = append(p.regions, activeRegion{
			region:       r,
			state:        RegionStart,
			curInterrupt: r.Start(p),
			id:           id,
		})
	}
	return p, nil
}
func newTracedProc ( pid int , pie PieOffsetter , regions [ ] Region , breaks map [ uintptr ] [ ] byte ) ( * Proc , error ) { off , err := pie . PieOffset ( pid ) if err != nil { return nil , err } logger . Printf ( " \n " , pid , off ) p := & Proc { tracer : ptrace . NewTracer ( pid ) , regions : make ( [ ] activeRegion , 0 , len ( regions ) ) , pieOffset : off , breakpoints : make ( map [ uintptr ] [ ] byte ) , } for id , r := range regions { addr := uintptr ( r . Start ( p ) ) if orig , ok := breaks [ addr ] ; ok { p . breakpoints [ addr ] = make ( [ ] byte , len ( orig ) ) copy ( p . breakpoints [ addr ] , orig ) } else { err := p . setBreak ( r . Start ( p ) ) if err != nil { return nil , err } } p . regions = append ( p . regions , activeRegion { region : r , state : RegionStart , curInterrupt : r . Start ( p ) , id : id , } ) } return p , nil }
Begins tracing an already existing process
Begins tracing an already existing process