1 /* -*- mode: C++; c-basic-offset: 4; tab-width: 4 -*-
3 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
5 * @APPLE_LICENSE_HEADER_START@
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
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.
22 * @APPLE_LICENSE_HEADER_END@
24 #ifndef __DYLD_CACHE_ABSTRACTION__
25 #define __DYLD_CACHE_ABSTRACTION__
27 #include "dyld_cache_format.h"
29 #include "FileAbstraction.hpp"
30 #include "Architectures.hpp"
33 class dyldCacheHeader {
35 const char* magic() const INLINE { return fields.magic; }
36 void set_magic(const char* value) INLINE { memcpy(fields.magic, value, 16); }
38 //uint32_t architecture() const INLINE { return E::get32(fields.architecture); }
39 //void set_architecture(uint32_t value) INLINE { E::set32(fields.architecture, value); }
41 uint32_t mappingOffset() const INLINE { return E::get32(fields.mappingOffset); }
42 void set_mappingOffset(uint32_t value) INLINE { E::set32(fields.mappingOffset, value); }
44 uint32_t mappingCount() const INLINE { return E::get32(fields.mappingCount); }
45 void set_mappingCount(uint32_t value) INLINE { E::set32(fields.mappingCount, value); }
47 uint32_t imagesOffset() const INLINE { return E::get32(fields.imagesOffset); }
48 void set_imagesOffset(uint32_t value) INLINE { E::set32(fields.imagesOffset, value); }
50 uint32_t imagesCount() const INLINE { return E::get32(fields.imagesCount); }
51 void set_imagesCount(uint32_t value) INLINE { E::set32(fields.imagesCount, value); }
53 uint64_t dyldBaseAddress() const INLINE { return E::get64(fields.dyldBaseAddress); }
54 void set_dyldBaseAddress(uint64_t value) INLINE { E::set64(fields.dyldBaseAddress, value); }
56 //uint32_t dependenciesOffset() const INLINE { return E::get32(fields.dependenciesOffset); }
57 //void set_dependenciesOffset(uint32_t value) INLINE { E::set32(fields.dependenciesOffset, value); }
59 //uint32_t dependenciesCount() const INLINE { return E::get32(fields.dependenciesCount); }
60 //void set_dependenciesCount(uint32_t value) INLINE { E::set32(fields.dependenciesCount, value); }
63 dyld_cache_header fields;
68 class dyldCacheFileMapping {
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); }
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); }
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); }
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); }
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); }
86 shared_file_mapping_np fields;
91 class dyldCacheImageInfo {
93 uint64_t address() const INLINE { return E::get64(fields.address); }
94 void set_address(uint64_t value) INLINE { E::set64(fields.address, value); }
96 uint64_t modTime() const INLINE { return E::get64(fields.modTime); }
97 void set_modTime(uint64_t value) INLINE { E::set64(fields.modTime, value); }
99 uint64_t inode() const INLINE { return E::get64(fields.inode); }
100 void set_inode(uint64_t value) INLINE { E::set64(fields.inode, value); }
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; }
105 //uint32_t dependenciesStartOffset() const INLINE { return E::get32(fields.dependenciesStartOffset); }
106 //void set_dependenciesStartOffset(uint32_t value) INLINE { E::set32(fields.dependenciesStartOffset, value); }
109 dyld_cache_image_info fields;
114 #endif // __DYLD_CACHE_ABSTRACTION__