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 - 2024 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
21#include <memory>
22
23namespace LIEF {
24class Binary;
25namespace assembly {
28
29namespace details {
30class Engine;
31}
32class LIEF_API Engine {
35 public: using instructions_it = iterator_range<Instruction::Iterator>;
38
39 Engine() = delete;
40 Engine(std::unique_ptr<details::Engine> impl);
41
42 Engine(const Engine&) = delete;
43 Engine& operator=(const Engine&) = delete;
44
45 Engine(Engine&&) noexcept;
46 Engine& operator=(Engine&&) noexcept;
47 instructions_it disassemble(const uint8_t* buffer, size_t size, uint64_t addr);
51 instructions_it disassemble(const std::vector<uint8_t>& bytes, uint64_t addr) {
55 return disassemble(bytes.data(), bytes.size(), addr);
56 }
57
58 std::vector<uint8_t> assemble(uint64_t address, const std::string& Asm);
59 std::vector<uint8_t> assemble(uint64_t address, const std::string& Asm,
60 LIEF::Binary& bin);
61
63 LIEF_LOCAL const details::Engine& impl() const {
66 assert(impl_ != nullptr);
67 return *impl_;
68 }
69 LIEF_LOCAL details::Engine& impl() {
72 assert(impl_ != nullptr);
73 return *impl_;
74 }
75
76 private:
77 std::unique_ptr<details::Engine> impl_;
78};
79}
80}
81
82#endif
Abstract binary that exposes an uniform API for the different executable file formats.
Definition Abstract/Binary.hpp:49
This class interfaces the assembler/disassembler support.
Definition Engine.hpp:34
Engine(const Engine &)=delete
Engine & operator=(const Engine &)=delete
std::vector< uint8_t > assemble(uint64_t address, const std::string &Asm, LIEF::Binary &bin)
Engine()=delete
Engine(std::unique_ptr< details::Engine > impl)
Engine(Engine &&) noexcept
std::vector< uint8_t > assemble(uint64_t address, const std::string &Asm)
~Engine()
Definition Engine.hpp:29
Namespace related to assembly/disassembly support.
Definition Abstract/Binary.hpp:43
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42