]> git.saurik.com Git - apple/dyld.git/blob - dyld3/DyldCacheParser.h
dyld-519.2.2.tar.gz
[apple/dyld.git] / dyld3 / DyldCacheParser.h
1 /*
2 * Copyright (c) 2017 Apple Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
11 * file.
12 *
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
20 *
21 * @APPLE_LICENSE_HEADER_END@
22 */
23
24
25 #ifndef DyldCacheParser_h
26 #define DyldCacheParser_h
27
28 #include <stdint.h>
29 #include <uuid/uuid.h>
30 #include <mach-o/loader.h>
31
32 #include "Diagnostics.h"
33 #include "DyldSharedCache.h"
34 #include "LaunchCacheFormat.h"
35
36 namespace dyld3 {
37
38 class VIS_HIDDEN DyldCacheParser
39 {
40 public:
41 #if !DYLD_IN_PROCESS
42 static bool isValidDyldCache(Diagnostics& diag, const std::string& archName, Platform platform, const void* fileContent, size_t fileLength, const std::string& pathOpened, bool ignoreMainExecutables);
43 #endif
44
45 DyldCacheParser(const DyldSharedCache* cacheHeader, bool rawFile);
46 const DyldSharedCache* cacheHeader() const;
47 bool cacheIsMappedRaw() const;
48
49
50
51 //
52 // Get ImageGroup for cached dylibs built into this cache files
53 //
54 const dyld3::launch_cache::binary_format::ImageGroup* cachedDylibsGroup() const;
55
56
57 //
58 // Get ImageGroup for other OS dylibs and bundles built into this cache files
59 //
60 const dyld3::launch_cache::binary_format::ImageGroup* otherDylibsGroup() const;
61
62
63 //
64 // returns closure for given path, or nullptr if no closure found
65 //
66 const dyld3::launch_cache::binary_format::Closure* findClosure(const char* path) const;
67
68 //
69 // returns what vmOffset of data (r/w) region from cache header will be when cache is used in a process
70 //
71 uint64_t dataRegionRuntimeVmOffset() const;
72
73 #if !DYLD_IN_PROCESS
74 //
75 // Iterates over closure of OS programs built into shared cache
76 //
77 void forEachClosure(void (^handler)(const char* runtimePath, const dyld3::launch_cache::binary_format::Closure*)) const;
78 #endif
79
80 private:
81 const dyld_cache_header* header() const;
82
83 long _data; // low bit means rawFile
84 };
85
86 } // namespace dyld3
87
88 #endif // DyldCacheParser_h