LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
MachO/utils.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 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 <cstdint>
20#include <functional>
21#include "LIEF/visibility.h"
22
23#include <string>
24#include <vector>
25
26namespace LIEF {
27class BinaryStream;
28namespace MachO {
29class Binary;
30class FatBinary;
31LIEF_API bool is_macho(BinaryStream& stream);
34LIEF_API bool is_macho(const std::string& file);
37LIEF_API bool is_macho(const std::vector<uint8_t>& raw);
40LIEF_API bool is_fat(const std::string& file);
43LIEF_API bool is_64(const std::string& file);
46
47LIEF_API bool is_64(BinaryStream& stream);
48LIEF_API bool check_layout(const Binary& binary, std::string* error = nullptr);
52LIEF_API bool check_layout(const FatBinary& binary, std::string* error = nullptr);
56
57
58using segment_callback_t = std::function<
59 void(const std::string& name, uint64_t offset, uint64_t size, uint64_t addr, uint64_t vsize)
60>;
61
62LIEF_API void foreach_segment(BinaryStream& stream, const segment_callback_t cbk);
63
64}
65}
66
67
68#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
Class which represents a MachO binary.
Definition MachO/Binary.hpp:85
Class which represent a Mach-O (fat) binary This object is also used for representing Mach-O binaries...
Definition FatBinary.hpp:36
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
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:58
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...
void foreach_segment(BinaryStream &stream, const segment_callback_t cbk)
bool is_fat(const std::string &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.
bool is_64(const std::string &file)
Check if the given Mach-O is 64-bits.
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41