]> git.saurik.com Git - cycript.git/blame - Mach/Memory.hpp
Update copyright for 2014 and relicense to AGPLv3.
[cycript.git] / Mach / Memory.hpp
CommitLineData
f95d2598
JF
1/* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2014 Jay Freeman (saurik)
3*/
4
5/* GNU Affero General Public License, Version 3 {{{ */
6/*
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU Affero General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU Affero General Public License for more details.
16
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19**/
20/* }}} */
21
3615a2f7
JF
22#ifndef MACH_MEMORY_HPP
23#define MACH_MEMORY_HPP
24
25static kern_return_t cy_vm_allocate(bool broken, vm_map_t target, mach_vm_address_t *address, mach_vm_size_t size, int flags) {
26 if (!broken)
27 return mach_vm_allocate(target, address, size, flags);
71a333b3 28 vm_address_t address32(0);
3615a2f7
JF
29 kern_return_t value(vm_allocate(target, &address32, size, flags));
30 *address = address32;
31 return value;
32}
33
34#define mach_vm_allocate(a, b, c, d) \
35 cy_vm_allocate(broken, a, b, c, d)
36
37static kern_return_t cy_vm_deallocate(bool broken, vm_map_t target, mach_vm_address_t address, mach_vm_size_t size) {
38 if (!broken)
39 return mach_vm_deallocate(target, address, size);
40 return vm_deallocate(target, address, size);
41}
42
43#define mach_vm_deallocate(a, b, c) \
44 cy_vm_deallocate(broken, a, b, c)
45
46static kern_return_t cy_vm_protect(bool broken, vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, boolean_t set_maximum, vm_prot_t new_protection) {
47 if (!broken)
48 return mach_vm_protect(target_task, address, size, set_maximum, new_protection);
49 return vm_protect(target_task, address, size, set_maximum, new_protection);
50}
51
52#define mach_vm_protect(a, b, c, d, e) \
53 cy_vm_protect(broken, a, b, c, d, e)
54
8964aa08
JF
55static kern_return_t cy_vm_read_overwrite(bool broken, vm_map_t target_task, mach_vm_address_t address, mach_vm_size_t size, mach_vm_address_t data, mach_vm_size_t *outsize) {
56 if (!broken)
57 return mach_vm_read_overwrite(target_task, address, size, data, outsize);
58 vm_size_t outsize32(*outsize);
59 kern_return_t value(vm_read_overwrite(target_task, address, data, size, &outsize32));
60 *outsize = outsize32;
61 return value;
62}
63
64#define mach_vm_read_overwrite(a, b, c, d, e) \
65 cy_vm_read_overwrite(broken, a, b, c, d, e)
66
3615a2f7
JF
67static kern_return_t cy_vm_write(bool broken, vm_map_t target_task, mach_vm_address_t address, vm_offset_t data, mach_msg_type_number_t dataCnt) {
68 if (!broken)
69 return mach_vm_write(target_task, address, data, dataCnt);
70 return vm_write(target_task, address, data, dataCnt);
71}
72
73#define mach_vm_write(a, b, c, d) \
74 cy_vm_write(broken, a, b, c, d)
75
76#endif//MACH_MEMORY_HPP