LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
Engine.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2025 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> assemble(uint64_t address, const std::string& Asm,
62
63 std::vector<uint8_t> assemble(uint64_t address, const std::string& Asm,
65
66 std::vector<uint8_t> assemble(uint64_t address, const llvm::MCInst& inst,
67 LIEF::Binary& bin);
68
69 std::vector<uint8_t> assemble(
70 uint64_t address, const std::vector<llvm::MCInst>& inst, LIEF::Binary& bin);
71
73
75 LIEF_LOCAL const details::Engine& impl() const {
76 assert(impl_ != nullptr);
77 return *impl_;
78 }
79
81 LIEF_LOCAL details::Engine& impl() {
82 assert(impl_ != nullptr);
83 return *impl_;
84 }
85
86 private:
87 std::unique_ptr<details::Engine> impl_;
88};
89}
90}
91
92#endif
Abstract binary that exposes an uniform API for the different executable file formats.
Definition Abstract/Binary.hpp:53
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:486
Definition Engine.hpp:31
Namespace related to assembly/disassembly support.
Definition Abstract/Binary.hpp:47
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42