LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
DyldSharedCache/utils.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2025 R. Thomas
2 * Copyright 2017 - 2025 Quarkslab
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef LIEF_DSC_UTILS_H
17#define LIEF_DSC_UTILS_H
18
19#include <LIEF/visibility.h>
20
23
24#include <string>
25
26namespace LIEF {
27namespace dsc {
28
31
33inline bool is_shared_cache(const std::string& file) {
34 auto fs = LIEF::FileStream::from_file(file);
35 if (!fs) {
36 return false;
37 }
38 return is_shared_cache(*fs);
39}
40
42inline bool is_shared_cache(const uint8_t* buffer, size_t size) {
43 LIEF::SpanStream strm(buffer, size);
44 return is_shared_cache(strm);
45}
46
48inline bool is_shared_cache(const std::vector<uint8_t>& buffer) {
49 return is_shared_cache(buffer.data(), buffer.size());
50}
51
52}
53}
54#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
static result< FileStream > from_file(const std::string &file)
Definition SpanStream.hpp:32
Namespace related to the dyld shared cache support.
Definition caching.hpp:22
bool is_shared_cache(BinaryStream &stream)
Check if the given stream wraps a Dyld Shared Cache.
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41