LIEF: Library to Instrument Executable Formats Version 1.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
17#include "LIEF/visibility.h"
18#include "LIEF/iterators.hpp"
20
23
24#include <memory>
25
26namespace LIEF {
27class Binary;
28
30namespace assembly {
31
32namespace details {
33class Engine;
34}
35
38 public:
41
42 Engine() = delete;
43 Engine(std::unique_ptr<details::Engine> impl);
44
45 Engine(const Engine&) = delete;
46 Engine& operator=(const Engine&) = delete;
47
48 Engine(Engine&&) noexcept;
49 Engine& operator=(Engine&&) noexcept;
50
53 instructions_it disassemble(const uint8_t* buffer, size_t size, uint64_t addr);
54
57 instructions_it disassemble(const std::vector<uint8_t>& bytes, uint64_t addr) {
58 return disassemble(bytes.data(), bytes.size(), addr);
59 }
60
61 std::vector<uint8_t>
62 assemble(uint64_t address, const std::string& Asm,
64
65 std::vector<uint8_t>
66 assemble(uint64_t address, const std::string& Asm, LIEF::Binary& bin,
68
69 std::vector<uint8_t> assemble(const llvm::MCInst& inst);
70
71 std::vector<uint8_t> assemble(const std::vector<llvm::MCInst>& inst);
72
74
76 LIEF_LOCAL const details::Engine& impl() const LIEF_LIFETIMEBOUND {
77 assert(impl_ != nullptr);
78 return *impl_;
79 }
80
82 LIEF_LOCAL details::Engine& impl() LIEF_LIFETIMEBOUND {
83 assert(impl_ != nullptr);
84 return *impl_;
85 }
86
87 private:
88 std::unique_ptr<details::Engine> impl_;
89};
90}
91}
92
93#endif
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:60
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:37
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, const std::string &Asm, LIEF::Binary &bin, AssemblerConfig &config=AssemblerConfig::default_config())
iterator_range< Instruction::Iterator > instructions_it
Disassembly instruction iterator.
Definition Engine.hpp:40
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)
std::vector< uint8_t > assemble(uint64_t address, const std::string &Asm, AssemblerConfig &config=AssemblerConfig::default_config())
Definition iterators.hpp:603
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition Engine.hpp:32
Namespace related to assembly/disassembly support.
Definition Abstract/Binary.hpp:48
LIEF namespace.
Definition Abstract/Binary.hpp:41
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46