PROC_RWMEM(9)
π PROC_RWMEM π
okay bestie so this is the manual page for proc_rwmem and friends, straight outta the Kernel Developer's Manual, section 9. kernel devs only, iykyk π«Ά
β¨ NAME β¨
proc_rwmem, proc_readmem, proc_writemem β read from or write to a process address space
πΈ SYNOPSIS πΈ
#include <sys/types.h>
#include <sys/ptrace.h>
int
proc_rwmem(struct proc *p, struct uio *uio);
ssize_t
proc_readmem(struct thread *td, struct proc *p, vm_offset_t va,
void *buf, size_t len);
ssize_t
proc_writemem(struct thread *td, struct proc *p, vm_offset_t va,
void *buf, size_t len);
π DESCRIPTION π
so these functions are literally how you read from or write to the address space of the process p. yes, someone else's memory. we're in there. main character energy π
proc_rwmem() is the β¨fancyβ¨ one β you, the caller, have to hand it all the I/O deets yourself using a struct uio, which is described over in uio(9). very general, very flexible, very much on you to get right.
proc_readmem() and proc_writemem() are the chill, simpler, less-general-girlie interface π they let you read into β or write β the kernel buffer buf of size len, from or to the memory at offset va inside p's address space. easy. clean. no uio drama.
and the whole operation is done on behalf of the thread td, which ngl will most often just be the current thread.
β οΈ okay important, no skipping: these functions may sleep, so you cannot call them while holding any non-sleepable locks. periodt. andphas to be held by the caller usingPHOLD(9). do not forget the PHOLD. do not. π
π RETURN VALUES π
proc_rwmem() returns 0 when it slays. if the specified user address is invalid you get EFAULT, and if the target pages could not be faulted in because of a resource shortage you get ENOMEM. rough out there. π
proc_readmem() and proc_writemem() return the number of bytes read or written, respectively β and heads up, that number may be smaller than the number of bytes you requested. like, for example, if your request spans multiple pages in the process address space and one of them after the first is not mapped. π otherwise, you get -1.
π¦ SEE ALSO π¦
π AUTHORS π
This manual page was written by Mark Johnston <markj@FreeBSD.org>. ty for your service king π«Ά
and that's the whole page bestie!! this one shipped on Debian, dated December 7, 2015 β a whole vibe, a whole era, and now it's yours. go forth and read some process memory responsibly πβ¨π
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms