proc_rwmem (9)
Leading comments
Copyright (c) 2015 Mark Johnston <markj@FreeBSD.org> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other...
NAME
proc_rwmem proc_readmem proc_writemem - read from or write to a process address spaceSYNOPSIS
In sys/types.h In sys/ptrace.h Ft int Fn proc_rwmem struct proc *p struct uio *uio Ft ssize_t Fn proc_readmem struct thread *td struct proc *p vm_offset_t va void *buf size_t len Ft ssize_t Fn proc_writemem struct thread *td struct proc *p vm_offset_t va void *buf size_t lenDESCRIPTION
These functions are used to read to or write from the address space of the process Fa p . The Fn proc_rwmem function requires the caller to specify the I/O parameters using a Vt struct uio , described in uio(9). The Fn proc_readmem and Fn proc_writemem functions provide a simpler, less general interface which allows the caller to read into or write the kernel buffer Fa buf of size Fa len from or to the memory at offset Fa va in the address space of Fa p . The operation is performed on behalf of thread Fa td , which will most often be the current thread.These functions may sleep and thus may not be called with any non-sleepable locks held. The process Fa p must be held by the caller using PHOLD(9).
RETURN VALUES
The Fn proc_rwmem function returns 0 on success. EFAULT is returned if the specified user address is invalid, and ENOMEM is returned if the target pages could not be faulted in due to a resource shortage.The Fn proc_readmem and Fn proc_writemem functions return the number of bytes read or written, respectively. This may be smaller than the number of bytes requested, for example if the request spans multiple pages in the process address space and one of them after the first is not mapped. Otherwise, -1 is returned.