1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
<table class="head">
<tr>
<td class="head-ltitle">PROC_RWMEM(9)</td>
<td class="head-vol">Kernel Developer's Manual</td>
<td class="head-rtitle">PROC_RWMEM(9)</td>
</tr>
</table>
<div class="manual-text">
<section class="Sh">
<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
<p class="Pp"><code class="Nm">proc_rwmem</code>,
<code class="Nm">proc_readmem</code>, <code class="Nm">proc_writemem</code>
— <span class="Nd">read from or write to a process address
space</span></p>
</section>
<section class="Sh">
<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
<p class="Pp"><code class="In">#include
<<a class="In">sys/types.h</a>></code>
<br/>
<code class="In">#include <<a class="In">sys/ptrace.h</a>></code></p>
<p class="Pp"><var class="Ft">int</var>
<br/>
<code class="Fn">proc_rwmem</code>(<var class="Fa" style="white-space: nowrap;">struct
proc *p</var>, <var class="Fa" style="white-space: nowrap;">struct uio
*uio</var>);</p>
<p class="Pp"><var class="Ft">ssize_t</var>
<br/>
<code class="Fn">proc_readmem</code>(<var class="Fa" style="white-space: nowrap;">struct
thread *td</var>, <var class="Fa" style="white-space: nowrap;">struct proc
*p</var>, <var class="Fa" style="white-space: nowrap;">vm_offset_t va</var>,
<var class="Fa" style="white-space: nowrap;">void *buf</var>,
<var class="Fa" style="white-space: nowrap;">size_t len</var>);</p>
<p class="Pp"><var class="Ft">ssize_t</var>
<br/>
<code class="Fn">proc_writemem</code>(<var class="Fa" style="white-space: nowrap;">struct
thread *td</var>, <var class="Fa" style="white-space: nowrap;">struct proc
*p</var>, <var class="Fa" style="white-space: nowrap;">vm_offset_t va</var>,
<var class="Fa" style="white-space: nowrap;">void *buf</var>,
<var class="Fa" style="white-space: nowrap;">size_t len</var>);</p>
</section>
<section class="Sh">
<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
<p class="Pp">These functions are used to read to or write from the address
space of the process <var class="Fa">p</var>. The
<a class="permalink" href="#proc_rwmem"><code class="Fn" id="proc_rwmem">proc_rwmem</code></a>()
function requires the caller to specify the I/O parameters using a
<var class="Vt">struct uio</var>, described in <a class="Xr">uio(9)</a>. The
<a class="permalink" href="#proc_readmem"><code class="Fn" id="proc_readmem">proc_readmem</code></a>()
and
<a class="permalink" href="#proc_writemem"><code class="Fn" id="proc_writemem">proc_writemem</code></a>()
functions provide a simpler, less general interface which allows the caller
to read into or write the kernel buffer <var class="Fa">buf</var> of size
<var class="Fa">len</var> from or to the memory at offset
<var class="Fa">va</var> in the address space of <var class="Fa">p</var>.
The operation is performed on behalf of thread <var class="Fa">td</var>,
which will most often be the current thread.</p>
<p class="Pp">These functions may sleep and thus may not be called with any
non-sleepable locks held. The process <var class="Fa">p</var> must be held
by the caller using <a class="Xr">PHOLD(9)</a>.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="RETURN_VALUES"><a class="permalink" href="#RETURN_VALUES">RETURN
VALUES</a></h1>
<p class="Pp">The <code class="Fn">proc_rwmem</code>() function returns
<code class="Dv">0</code> on success. <code class="Dv">EFAULT</code> is
returned if the specified user address is invalid, and
<code class="Dv">ENOMEM</code> is returned if the target pages could not be
faulted in due to a resource shortage.</p>
<p class="Pp">The <code class="Fn">proc_readmem</code>() and
<code class="Fn">proc_writemem</code>() 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.</p>
</section>
<section class="Sh">
<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
ALSO</a></h1>
<p class="Pp"><a class="Xr">copyin(9)</a>, <a class="Xr">locking(9)</a>,
<a class="Xr">PHOLD(9)</a>, <a class="Xr">uio(9)</a></p>
</section>
<section class="Sh">
<h1 class="Sh" id="AUTHORS"><a class="permalink" href="#AUTHORS">AUTHORS</a></h1>
<p class="Pp">This manual page was written by <span class="An">Mark
Johnston</span>
<<a class="Mt" href="mailto:markj@FreeBSD.org">markj@FreeBSD.org</a>>.</p>
</section>
</div>
<table class="foot">
<tr>
<td class="foot-date">December 7, 2015</td>
<td class="foot-os">FreeBSD 15.0</td>
</tr>
</table>
|