]> git.saurik.com Git - apple/dyld.git/blob - launch-cache/CacheFileAbstraction.hpp
dyld-95.3.tar.gz
[apple/dyld.git] / launch-cache / CacheFileAbstraction.hpp
1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
2 *
3 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 *
5 * @APPLE_LICENSE_HEADER_START@
6 *
7 * This file contains Original Code and/or Modifications of Original Code
8 * as defined in and that are subject to the Apple Public Source License
9 * Version 2.0 (the 'License'). You may not use this file except in
10 * compliance with the License. Please obtain a copy of the License at
11 * http://www.opensource.apple.com/apsl/ and read it before using this
12 * file.
13 *
14 * The Original Code and all software distributed under the License are
15 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
16 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
17 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
19 * Please see the License for the specific language governing rights and
20 * limitations under the License.
21 *
22 * @APPLE_LICENSE_HEADER_END@
23 */
24 #ifndef __DYLD_CACHE_ABSTRACTION__
25 #define __DYLD_CACHE_ABSTRACTION__
26
27 #include "dyld_cache_format.h"
28
29 #include "FileAbstraction.hpp"
30 #include "Architectures.hpp"
31
32 template <typename E>
33 class dyldCacheHeader {
34 public:
35 const char* magic() const INLINE { return fields.magic; }
36 void set_magic(const char* value) INLINE { memcpy(fields.magic, value, 16); }
37
38 //uint32_t architecture() const INLINE { return E::get32(fields.architecture); }
39 //void set_architecture(uint32_t value) INLINE { E::set32(fields.architecture, value); }
40
41 uint32_t mappingOffset() const INLINE { return E::get32(fields.mappingOffset); }
42 void set_mappingOffset(uint32_t value) INLINE { E::set32(fields.mappingOffset, value); }
43
44 uint32_t mappingCount() const INLINE { return E::get32(fields.mappingCount); }
45 void set_mappingCount(uint32_t value) INLINE { E::set32(fields.mappingCount, value); }
46
47 uint32_t imagesOffset() const INLINE { return E::get32(fields.imagesOffset); }
48 void set_imagesOffset(uint32_t value) INLINE { E::set32(fields.imagesOffset, value); }
49
50 uint32_t imagesCount() const INLINE { return E::get32(fields.imagesCount); }
51 void set_imagesCount(uint32_t value) INLINE { E::set32(fields.imagesCount, value); }
52
53 uint64_t dyldBaseAddress() const INLINE { return E::get64(fields.dyldBaseAddress); }
54 void set_dyldBaseAddress(uint64_t value) INLINE { E::set64(fields.dyldBaseAddress, value); }
55
56 //uint32_t dependenciesOffset() const INLINE { return E::get32(fields.dependenciesOffset); }
57 //void set_dependenciesOffset(uint32_t value) INLINE { E::set32(fields.dependenciesOffset, value); }
58
59 //uint32_t dependenciesCount() const INLINE { return E::get32(fields.dependenciesCount); }
60 //void set_dependenciesCount(uint32_t value) INLINE { E::set32(fields.dependenciesCount, value); }
61
62 private:
63 dyld_cache_header fields;
64 };
65
66
67 template <typename E>
68 class dyldCacheFileMapping {
69 public:
70 uint64_t address() const INLINE { return E::get64(fields.sfm_address); }
71 void set_address(uint64_t value) INLINE { E::set64(fields.sfm_address, value); }
72
73 uint64_t size() const INLINE { return E::get64(fields.sfm_size); }
74 void set_size(uint64_t value) INLINE { E::set64(fields.sfm_size, value); }
75
76 uint64_t file_offset() const INLINE { return E::get64(fields.sfm_file_offset); }
77 void set_file_offset(uint64_t value) INLINE { E::set64(fields.sfm_file_offset, value); }
78
79 uint32_t max_prot() const INLINE { return E::get32(fields.sfm_max_prot); }
80 void set_max_prot(uint32_t value) INLINE { E::set32((uint32_t&)fields.sfm_max_prot, value); }
81
82 uint32_t init_prot() const INLINE { return E::get32(fields.sfm_init_prot); }
83 void set_init_prot(uint32_t value) INLINE { E::set32((uint32_t&)fields.sfm_init_prot, value); }
84
85 private:
86 shared_file_mapping_np fields;
87 };
88
89
90 template <typename E>
91 class dyldCacheImageInfo {
92 public:
93 uint64_t address() const INLINE { return E::get64(fields.address); }
94 void set_address(uint64_t value) INLINE { E::set64(fields.address, value); }
95
96 uint64_t modTime() const INLINE { return E::get64(fields.modTime); }
97 void set_modTime(uint64_t value) INLINE { E::set64(fields.modTime, value); }
98
99 uint64_t inode() const INLINE { return E::get64(fields.inode); }
100 void set_inode(uint64_t value) INLINE { E::set64(fields.inode, value); }
101
102 uint32_t pathFileOffset() const INLINE { return E::get32(fields.pathFileOffset); }
103 void set_pathFileOffset(uint32_t value) INLINE { E::set32(fields.pathFileOffset, value); fields.pad=0; }
104
105 //uint32_t dependenciesStartOffset() const INLINE { return E::get32(fields.dependenciesStartOffset); }
106 //void set_dependenciesStartOffset(uint32_t value) INLINE { E::set32(fields.dependenciesStartOffset, value); }
107
108 private:
109 dyld_cache_image_info fields;
110 };
111
112
113
114 #endif // __DYLD_CACHE_ABSTRACTION__
115
116