MCPcopy Index your code
hub / github.com/subtrace/subtrace / vmReadBytes

Method vmReadBytes

cmd/run/engine/process/vm.go:74–98  ·  view source on GitHub ↗

vmReadBytes reads at most maxSize bytes from the process's virtual memory starting at ptr. It returns an error if the address range isn't readable or if the notification is invalid.

(n *seccomp.Notif, ptr uintptr, maxSize int)

Source from the content-addressed store, hash-verified

72// starting at ptr. It returns an error if the address range isn't readable or
73// if the notification is invalid.
74func (p *Process) vmReadBytes(n *seccomp.Notif, ptr uintptr, maxSize int) ([]byte, syscall.Errno, error) {
75 if maxSize == 0 {
76 return []byte{}, 0, nil
77 }
78 if ptr == 0 {
79 return nil, unix.EINVAL, nil
80 }
81
82 b := make([]byte, maxSize)
83 read, err := readMemory(int(p.PID), b, ptr)
84 if err != nil {
85 if !n.Valid() {
86 return nil, 0, seccomp.ErrCancelled
87 }
88 var errno syscall.Errno
89 if errors.As(err, &errno) {
90 return nil, errno, nil
91 }
92 return nil, 0, fmt.Errorf("memory read: unknown error: %w", err)
93 }
94 if !n.Valid() {
95 return nil, 0, seccomp.ErrCancelled
96 }
97 return b[:read], 0, nil
98}
99
100// vmReadUint32 reads a uint32 from the process' memory starting at ptr.
101func (p *Process) vmReadUint32(n *seccomp.Notif, ptr uintptr) (uint32, syscall.Errno, error) {

Callers 3

vmReadUint32Method · 0.95
vmReadStringMethod · 0.95
vmReadSockaddrMethod · 0.95

Calls 1

ValidMethod · 0.80

Tested by

no test coverage detected