1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2015 Joyent, Inc.
13.\"
14.Dd November 27, 2023
15.Dt PR_MEMCNTL 3PROC
16.Os
17.Sh NAME
18.Nm pr_memcntl
19.Nd inject memcntl system call into victim process
20.Sh LIBRARY
21.Lb libproc
22.Sh SYNOPSIS
23.In libproc.h
24.Ft int
25.Fo pr_memcntl
26.Fa "struct ps_prochandle *P"
27.Fa "caddr_t addr"
28.Fa "size_t len"
29.Fa "int cmd"
30.Fa "caddr_t arg"
31.Fa "int attr"
32.Fa "int mask"
33.Fc
34.Sh DESCRIPTION
35The
36.Fn pr_memcntl
37function injects the
38.Xr memcntl 2
39system call into the target process
40.Fa P
41by means of the agent LWP.
42If the process handle
43.Fa P
44is the value
45.Dv NULL
46then this will be equivalent to calling
47.Xr memcntl 2
48on the currently running process.
49.Pp
50The arguments
51.Fa addr ,
52.Fa len ,
53.Fa cmd ,
54.Fa arg ,
55.Fa attr ,
56and
57.Fa mask
58have the same meaning as in
59.Xr memcntl 2 .
60See
61.Xr memcntl 2
62for the full description and purpose of the
63.Sy memcntl
64system call and its arguments.
65.Pp
66The
67.Fn pr_memcntl
68function only works on active processes.
69Process handles that correspond to core files, zombie processes, or ELF objects
70do not support system call injection.
71.Sh RETURN VALUES
72Upon successful completion, the
73.Fn pr_memcntl
74function's return value is that described in
75.Xr memcntl 2 .
76Otherwise,
77.Sy -1
78is returned and
79.Sy errno
80is set to
81.Er ENOSYS
82to indicate that the system call could not be injected.
83.Sh ERRORS
84For the full list of errors see the
85.Sy ERRORS
86section in
87.Xr memcntl 2 .
88.Pp
89The
90.Fn pr_memcntl
91function will fail if:
92.Bl -tag -width Er
93.It Er ENOSYS
94An error occurred while trying to invoke the agent LWP and inject a
95system call in the process handle
96.Fa P
97or the process handle
98.Fa P
99does not support system call injection.
100.El
101.Sh INTERFACE STABILITY
102.Sy Uncommitted
103.Sh MT-LEVEL
104See
105.Sy LOCKING
106in
107.Xr libproc 3LIB .
108.Sh SEE ALSO
109.Xr memcntl 2 ,
110.Xr libproc 3LIB ,
111.Xr proc 5
112