LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
MachO/utils.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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_MACHO_UTILS_H
17#define LIEF_MACHO_UTILS_H
18
19#include "LIEF/visibility.h"
20#include <cstdint>
21#include <functional>
22
23#include <string_view>
24#include <string>
25#include <vector>
26
27namespace LIEF {
28class BinaryStream;
29namespace MachO {
30class Binary;
31class FatBinary;
32
35
37LIEF_API bool is_macho(std::string_view file);
38
40LIEF_API bool is_macho(const std::vector<uint8_t>& raw);
41
43LIEF_API bool is_fat(std::string_view file);
44
46LIEF_API bool is_64(std::string_view file);
47
49
52LIEF_API bool check_layout(const Binary& binary, std::string* error = nullptr);
53
56LIEF_API bool check_layout(const FatBinary& binary, std::string* error = nullptr);
57
58
60 std::function<void(const std::string& name, uint64_t offset, uint64_t size,
61 uint64_t addr, uint64_t vsize)>;
62
64
65}
66}
67
68
69#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:35
Class which represents a MachO binary.
Definition MachO/Binary.hpp:94
Class which represents a Mach-O (fat) binary This object is also used for representing Mach-O binarie...
Definition FatBinary.hpp:36
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
bool check_layout(const Binary &binary, std::string *error=nullptr)
Check the layout of the given Mach-O binary. It checks if it can be signed according to cctools-921/l...
bool is_64(std::string_view file)
Check if the given Mach-O is 64-bits.
bool is_fat(std::string_view file)
Check if the given file is a FAT Mach-O.
bool is_macho(BinaryStream &stream)
Check if the given stream wraps a Mach-O binary.
void foreach_segment(BinaryStream &stream, const segment_callback_t &cbk)
std::function< void(const std::string &name, uint64_t offset, uint64_t size, uint64_t addr, uint64_t vsize)> segment_callback_t
Definition MachO/utils.hpp:59
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:45