2 * Copyright (c) 2011 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
30 * Make sure we don't accidentally include the external definitions of
31 * the routines we're interposing on below.
34 #define _mach_vm_user_
35 #include <mach/mach.h>
36 #include <mach/mach_traps.h>
38 #include <mach/vm_map_internal.h>
40 #include <mach/mach_vm_internal.h>
44 mach_port_name_t target
,
45 mach_vm_address_t
*address
,
51 rv
= _kernelrpc_mach_vm_allocate_trap(target
, address
, size
, flags
);
53 if (rv
== MACH_SEND_INVALID_DEST
)
54 rv
= _kernelrpc_mach_vm_allocate(target
, address
, size
, flags
);
61 mach_port_name_t target
,
62 mach_vm_address_t address
,
67 rv
= _kernelrpc_mach_vm_deallocate_trap(target
, address
, size
);
69 if (rv
== MACH_SEND_INVALID_DEST
)
70 rv
= _kernelrpc_mach_vm_deallocate(target
, address
, size
);
77 mach_port_name_t task
,
78 mach_vm_address_t address
,
80 boolean_t set_maximum
,
81 vm_prot_t new_protection
)
85 rv
= _kernelrpc_mach_vm_protect_trap(task
, address
, size
, set_maximum
,
88 if (rv
== MACH_SEND_INVALID_DEST
)
89 rv
= _kernelrpc_mach_vm_protect(task
, address
, size
,
90 set_maximum
, new_protection
);
97 mach_port_name_t task
,
98 vm_address_t
*address
,
103 mach_vm_address_t mach_addr
;
105 mach_addr
= (mach_vm_address_t
)*address
;
106 rv
= mach_vm_allocate(task
, &mach_addr
, size
, flags
);
107 #if defined(__LP64__)
108 *address
= mach_addr
;
110 *address
= (vm_address_t
)(mach_addr
& ((vm_address_t
)-1));
118 mach_port_name_t task
,
119 vm_address_t address
,
124 rv
= mach_vm_deallocate(task
, address
, size
);
131 mach_port_name_t task
,
132 vm_address_t address
,
134 boolean_t set_maximum
,
135 vm_prot_t new_protection
)
139 rv
= mach_vm_protect(task
, address
, size
, set_maximum
, new_protection
);