LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
osx/Module.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_RUNTIME_OSX_MODULE_H
17#define LIEF_RUNTIME_OSX_MODULE_H
18
21
22namespace LIEF {
23
24namespace MachO {
25class Binary;
26struct ParserConfig;
27}
28
29namespace runtime {
30namespace osx {
31
34 public:
36
38 static std::unique_ptr<Module> from_handle(void* handle);
39
43 void* handle() const;
44
46 void* dlsym(const std::string& name) const;
47
49 std::unique_ptr<MachO::Binary> parse_from_path() const;
50
53 std::unique_ptr<MachO::Binary>
55
57 std::unique_ptr<MachO::Binary> parse_from_memory() const;
58
60 std::unique_ptr<MachO::Binary>
62
63 ~Module() override = default;
64
65 static constexpr bool classof(const runtime::Module*) {
66 return platform() == PLATFORMS::OSX;
67 }
68};
69
71LIEF_API std::unique_ptr<Module> dlopen(const std::string& name);
72
73}
74}
75}
76#endif
Class which represents a MachO binary.
Definition MachO/Binary.hpp:91
This class represents an in-memory module which can be an executable or a library.
Definition Module.hpp:42
std::string name() const
Name of the module (e.g. libc.so.6, kernel32.dll, libsystem_c.dylib).
static std::unique_ptr< Module > from_handle(void *handle)
Instantiate a Module from the given dlopen handle.
void * handle() const
Return the dlopen handle for this library.
~Module() override=default
void * dlsym(const std::string &name) const
Resolve the symbol with the given name for the current module.
std::unique_ptr< MachO::Binary > parse_from_path() const
Parse the Mach-O module from its path on the filesystem.
std::unique_ptr< MachO::Binary > parse_from_memory(const MachO::ParserConfig &config) const
Parse the Mach-O module from memory with the given configuration.
std::unique_ptr< MachO::Binary > parse_from_memory() const
Parse the Mach-O module from memory.
std::unique_ptr< MachO::Binary > parse_from_path(const MachO::ParserConfig &config) const
Parse the Mach-O module from its path on the filesystem with the given parser configuration.
static constexpr bool classof(const runtime::Module *)
Definition osx/Module.hpp:65
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
Definition osx/Host.hpp:25
std::unique_ptr< Module > dlopen(const std::string &name)
Load the library with the given path or name.
Definition android/Host.hpp:24
@ OSX
Definition runtime/utils.hpp:33
LIEF namespace.
Definition Abstract/Binary.hpp:41
This structure is used to tweak the MachO Parser (MachO::Parser).
Definition MachO/ParserConfig.hpp:24
#define LIEF_API
Definition visibility.h:45