2 * Copyright (c) 2017 Apple Inc. All rights reserved.
4 * @APPLE_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. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
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.
21 * @APPLE_LICENSE_HEADER_END@
25 #ifndef DyldCacheParser_h
26 #define DyldCacheParser_h
29 #include <uuid/uuid.h>
30 #include <mach-o/loader.h>
32 #include "Diagnostics.h"
33 #include "DyldSharedCache.h"
34 #include "LaunchCacheFormat.h"
38 class VIS_HIDDEN DyldCacheParser
42 static bool isValidDyldCache(Diagnostics
& diag
, const std::string
& archName
, Platform platform
, const void* fileContent
, size_t fileLength
, const std::string
& pathOpened
, bool ignoreMainExecutables
);
45 DyldCacheParser(const DyldSharedCache
* cacheHeader
, bool rawFile
);
46 const DyldSharedCache
* cacheHeader() const;
47 bool cacheIsMappedRaw() const;
52 // Get ImageGroup for cached dylibs built into this cache files
54 const dyld3::launch_cache::binary_format::ImageGroup
* cachedDylibsGroup() const;
58 // Get ImageGroup for other OS dylibs and bundles built into this cache files
60 const dyld3::launch_cache::binary_format::ImageGroup
* otherDylibsGroup() const;
64 // returns closure for given path, or nullptr if no closure found
66 const dyld3::launch_cache::binary_format::Closure
* findClosure(const char* path
) const;
69 // returns what vmOffset of data (r/w) region from cache header will be when cache is used in a process
71 uint64_t dataRegionRuntimeVmOffset() const;
75 // Iterates over closure of OS programs built into shared cache
77 void forEachClosure(void (^handler
)(const char* runtimePath
, const dyld3::launch_cache::binary_format::Closure
*)) const;
81 const dyld_cache_header
* header() const;
83 long _data
; // low bit means rawFile
88 #endif // DyldCacheParser_h