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"
19
22
23#include <memory>
24
25namespace LIEF {
26class Binary;
27
29namespace assembly {
30
31namespace details {
32class Engine;
33}
34
37 public:
40
41 Engine() = delete;
42 Engine(std::unique_ptr<details::Engine> impl);
43
44 Engine(const Engine&) = delete;
45 Engine& operator=(const Engine&) = delete;
46
47 Engine(Engine&&) noexcept;
48 Engine& operator=(Engine&&) noexcept;
49
52 instructions_it disassemble(const uint8_t* buffer, size_t size, uint64_t addr);
53
56 instructions_it disassemble(const std::vector<uint8_t>& bytes, uint64_t addr) {
57 return disassemble(bytes.data(), bytes.size(), addr);
58 }
59
60 std::vector<uint8_t>
61 assemble(uint64_t address, const std::string& Asm,
63
64 std::vector<uint8_t>
65 assemble(uint64_t address, const std::string& Asm, LIEF::Binary& bin,
67
68 std::vector<uint8_t> assemble(uint64_t address, const llvm::MCInst& inst,
69 LIEF::Binary& bin);
70
71 std::vector<uint8_t> assemble(uint64_t address,
72 const std::vector<llvm::MCInst>& inst,
73 LIEF::Binary& bin);
74
76
78 LIEF_LOCAL const details::Engine& impl() const {
79 assert(impl_ != nullptr);
80 return *impl_;
81 }
82
84 LIEF_LOCAL details::Engine& impl() {
85 assert(impl_ != nullptr);
86 return *impl_;
87 }
88
89 private:
90 std::unique_ptr<details::Engine> impl_;
91};
92}
93}
94
95#endif
Generic interface representing a binary executable.
Definition Abstract/Binary.hpp:59
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:36
Engine(const Engine &)=delete
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:39
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(uint64_t address, const llvm::MCInst &inst, LIEF::Binary &bin)
std::vector< uint8_t > assemble(uint64_t address, const std::string &Asm, AssemblerConfig &config=AssemblerConfig::default_config())
std::vector< uint8_t > assemble(uint64_t address, const std::vector< llvm::MCInst > &inst, LIEF::Binary &bin)
Definition iterators.hpp:567
Definition Engine.hpp:31
Namespace related to assembly/disassembly support.
Definition Abstract/Binary.hpp:47
LIEF namespace.
Definition Abstract/Binary.hpp:40
Definition string.h:155
#define LIEF_API
Definition visibility.h:43
#define LIEF_LOCAL
Definition visibility.h:44