4 <strong>Function
</strong> - Set access privilege attribute for a region of virtual memory.
7 <strong>kern_return_t vm_protect
</strong>
8 <strong>(vm_task_t
</strong> <var>target_task
</var>,
9 <strong>vm_address_t
</strong> <var>address
</var>,
10 <strong>vm_size_t
</strong> <var>size
</var>,
11 <strong>boolean_t
</strong> <var>set_maximum
</var>,
12 <strong>vm_prot_t
</strong> <var>new_protection
</var><strong>);
</strong>
17 <dt> <var>target_task
</var>
20 The port for the task whose address space contains
23 <dt> <var>address
</var>
26 The starting address for the region.
31 The number of bytes in the region.
33 <dt> <var>set_maximum
</var>
36 Maximum/current indicator. If true, the new protection sets
37 the maximum protection for the region. If false, the new protection sets
38 the current protection for the region. If the maximum protection is set
39 below the current protection, the current protection is also
43 <dt> <var>new_protection
</var>
46 The new protection for the region. Valid values are obtained
47 by or'ing together the following values:
50 <dt> <strong>VM_PROT_READ
</strong>
54 <dt> <strong>VM_PROT_WRITE
</strong>
58 <dt> <strong>VM_PROT_EXECUTE
</strong>
60 Allows execute access.
65 The
<strong>vm_protect
</strong> function sets access privileges for
66 a region within the specified
68 The
<var>new_protection
</var> parameter specifies a combination
70 execute accesses that are allowed (rather than prohibited).
72 The region starts at the beginning of the virtual page containing
73 <var>address
</var>; it ends
74 at the end of the virtual page containing
<var>address
</var> +
75 <var>size
</var> -
1. Because of this
76 rounding to virtual page boundaries, the amount of memory protected may be
77 greater than
<var>size
</var>. Use
<strong>host_page_size
</strong>
78 to find the current virtual page size.
80 The enforcement of virtual memory protection is machine-dependent.
81 Nominally read access requires
<strong>VM_PROT_READ
</strong> permission,
83 <strong>VM_PROT_WRITE
</strong> permission, and execute access requires
84 <strong>VM_PROT_EXECUTE
</strong> permission. However, some combinations
85 of access rights may not be
86 supported. In particular, the kernel interface allows write access to require
87 <strong>VM_PROT_READ
</strong> and
<strong>VM_PROT_WRITE
</strong> permission and execute access to
88 require
<strong>VM_PROT_READ
</strong> permission.
91 This interface is machine word length specific because of the virtual address
93 <h3>RETURN VALUES
</h3>
96 <dt> <strong>KERN_PROTECTION_FAILURE
</strong>
98 The new protection increased the current or maximum protection
99 beyond the existing maximum protection.
101 <dt> <strong>KERN_INVALID_ADDRESS
</strong>
103 The address is illegal or specifies a non-allocated region.
105 <h3>RELATED INFORMATION
</h3>
108 <a href=
"host_page_size.html"><strong>host_page_size
</strong></a>,
109 <a href=
"vm_inherit.html"><strong>vm_inherit
</strong></a>,
110 <a href=
"vm_region.html"><strong>vm_region
</strong></a>.