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

Method vmWriteBytes

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

vmWriteBytes writes b to the process's memory starting at ptr. It returns an error if the address range isn't writable or if the notification is invalid.

(n *seccomp.Notif, ptr uintptr, b []byte)

Source from the content-addressed store, hash-verified

167// vmWriteBytes writes b to the process's memory starting at ptr. It returns an
168// error if the address range isn't writable or if the notification is invalid.
169func (p *Process) vmWriteBytes(n *seccomp.Notif, ptr uintptr, b []byte) (syscall.Errno, error) {
170 if !n.Valid() {
171 return 0, seccomp.ErrCancelled
172 }
173
174 if len(b) == 0 {
175 return 0, nil
176 }
177 if ptr == 0 {
178 return unix.EINVAL, nil
179 }
180
181 wrote, err := writeMemory(int(p.PID), b, ptr)
182 if err != nil {
183 if !n.Valid() {
184 return 0, seccomp.ErrCancelled
185 }
186 var errno syscall.Errno
187 if errors.As(err, &errno) {
188 return errno, nil
189 }
190 return 0, fmt.Errorf("memory write: unknown error: %w", err)
191 }
192 if wrote < len(b) {
193 if !n.Valid() {
194 return 0, seccomp.ErrCancelled
195 }
196 return 0, fmt.Errorf("memory write: partial write: wrote %d, expected %d", wrote, len(b))
197 }
198 return 0, nil
199}
200
201// vmWriteInt32 writes a uint32 to the process' memory at ptr.
202func (p *Process) vmWriteUint32(n *seccomp.Notif, ptr uintptr, val uint32) (syscall.Errno, error) {

Callers 4

handleFstatatMethod · 0.95
handleStatxMethod · 0.95
vmWriteUint32Method · 0.95
vmWriteSockaddrMethod · 0.95

Calls 1

ValidMethod · 0.80

Tested by

no test coverage detected