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