LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
windows/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_WIN_MODULE_H
17#define LIEF_RUNTIME_WIN_MODULE_H
18
21
22namespace LIEF {
23
24namespace PE {
25class Binary;
26struct ParserConfig;
27}
28
29namespace runtime {
30namespace windows {
31
34 public:
36
37 static std::unique_ptr<Module> from_handle(void* H);
38
42 void* handle() const;
43
45 void* dlsym(const std::string& name) const;
46
48 std::unique_ptr<PE::Binary> parse_from_path() const;
49
52 std::unique_ptr<PE::Binary>
53 parse_from_path(const PE::ParserConfig& config) const;
54
56 std::unique_ptr<PE::Binary>
57 parse_from_memory(const PE::ParserConfig& config) const;
58
60 std::unique_ptr<PE::Binary> parse_from_memory() const;
61
62 ~Module() override = default;
63
64 static constexpr bool classof(const runtime::Module*) {
65 return platform() == PLATFORMS::WINDOWS;
66 }
67};
68
70LIEF_API std::unique_ptr<Module> dlopen(const std::string& name);
71
85LIEF_API std::unique_ptr<Module> find_module(const std::string& name);
86
87}
88}
89}
90#endif
Class which represents a PE binary This is the main interface to manage and modify a PE executable.
Definition PE/Binary.hpp:57
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).
std::unique_ptr< PE::Binary > parse_from_memory() const
Parse the PE module from memory.
std::unique_ptr< PE::Binary > parse_from_path() const
Parse the PE module from its path on the filesystem.
std::unique_ptr< PE::Binary > parse_from_memory(const PE::ParserConfig &config) const
Parse the PE module from memory with the given configuration.
~Module() override=default
static std::unique_ptr< Module > from_handle(void *H)
void * handle() const
Return the HMODULE handle as an opaque pointer.
static constexpr bool classof(const runtime::Module *)
Definition windows/Module.hpp:64
std::unique_ptr< PE::Binary > parse_from_path(const PE::ParserConfig &config) const
Parse the PE module from its path on the filesystem and given the parser configuration.
void * dlsym(const std::string &name) const
Resolve the symbol with the given name for the current module.
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
Definition windows/Host.hpp:25
std::unique_ptr< Module > find_module(const std::string &name)
Try to get the Module with the given name.
std::unique_ptr< Module > dlopen(const std::string &name)
Load the windows library with the given path or name.
Definition android/Host.hpp:24
@ WINDOWS
Definition runtime/utils.hpp:31
LIEF namespace.
Definition Abstract/Binary.hpp:41
This structure is used to configure the behavior of the PE Parser (PE::Parser).
Definition PE/ParserConfig.hpp:27
#define LIEF_API
Definition visibility.h:45