LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
Engine.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 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_ASM_ENGINE_H
16#define LIEF_ASM_ENGINE_H
18#include "LIEF/iterators.hpp"
19#include "LIEF/visibility.h"
20
23
24#include <string_view>
25#include <memory>
26
27namespace LIEF {
28class Binary;
29
31namespace assembly {
32
33namespace details {
34class Engine;
35}
36
39 public:
42
43 Engine() = delete;
44 Engine(std::unique_ptr<details::Engine> impl);
45
46 Engine(const Engine&) = delete;
47 Engine& operator=(const Engine&) = delete;
48
49 Engine(Engine&&) noexcept;
50 Engine& operator=(Engine&&) noexcept;
51
56 size_t size, uint64_t addr) LIEF_LIFETIMEBOUND;
57
60 instructions_it disassemble(const std::vector<uint8_t>& bytes LIEF_LIFETIMEBOUND,
61 uint64_t addr) LIEF_LIFETIMEBOUND {
62 return disassemble(bytes.data(), bytes.size(), addr);
63 }
64
65 std::vector<uint8_t>
66 assemble(uint64_t address, std::string_view Asm,
68
69 std::vector<uint8_t>
70 assemble(uint64_t address, std::string_view Asm, LIEF::Binary& bin,
72
73 std::vector<uint8_t> assemble(const llvm::MCInst& inst);
74
75 std::vector<uint8_t> assemble(const std::vector<llvm::MCInst>& inst);
76
78
80 LIEF_LOCAL const details::Engine& impl() const LIEF_LIFETIMEBOUND {
81 assert(impl_ != nullptr);
82 return *impl_;
83 }
84
86 LIEF_LOCAL details::Engine& impl() LIEF_LIFETIMEBOUND {
87 assert(impl_ != nullptr);
88 return *impl_;
89 }
90
91 private:
92 std::unique_ptr<details::Engine> impl_;
93};
94}
95}
96
97#endif
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:61
This class exposes the different elements that can be configured to assemble code.
Definition AssemblerConfig.hpp:29
static AssemblerConfig & default_config()
Default configuration.
Definition AssemblerConfig.hpp:50
This class interfaces the assembler/disassembler support.
Definition Engine.hpp:38
Engine(const Engine &)=delete
std::vector< uint8_t > assemble(const std::vector< llvm::MCInst > &inst)
Engine & operator=(const Engine &)=delete
Engine(std::unique_ptr< details::Engine > impl)
Engine(Engine &&) noexcept
std::vector< uint8_t > assemble(uint64_t address, std::string_view Asm, LIEF::Binary &bin, AssemblerConfig &config=AssemblerConfig::default_config())
std::vector< uint8_t > assemble(uint64_t address, std::string_view Asm, AssemblerConfig &config=AssemblerConfig::default_config())
iterator_range< Instruction::Iterator > instructions_it
Disassembly instruction iterator.
Definition Engine.hpp:41
instructions_it disassemble(const uint8_t *buffer, size_t size, uint64_t addr)
Disassemble the provided buffer with the address specified in the second parameter....
std::vector< uint8_t > assemble(const llvm::MCInst &inst)
Definition iterators.hpp:595
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition Engine.hpp:33
Namespace related to assembly/disassembly support.
Definition Abstract/Binary.hpp:49
LIEF namespace.
Definition Abstract/Binary.hpp:42
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46