LIEF: Library to Instrument Executable Formats
Version 0.17.4
Toggle main menu visibility
Loading...
Searching...
No Matches
install
linux
x86_64
sdk
static
include
LIEF
asm
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
20
#include "
LIEF/asm/Instruction.hpp
"
21
#include "
LIEF/asm/AssemblerConfig.hpp
"
22
23
#include <memory>
24
25
namespace
LIEF
{
26
class
Binary
;
27
29
namespace
assembly
{
30
31
namespace
details
{
32
class
Engine
;
33
}
34
36
class
LIEF_API
Engine
{
37
public
:
39
using
instructions_it
=
iterator_range<Instruction::Iterator>
;
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,
61
AssemblerConfig
& config =
AssemblerConfig::default_config
());
62
63
std::vector<uint8_t>
assemble
(uint64_t address,
const
std::string& Asm,
64
LIEF::Binary
& bin,
AssemblerConfig
& config =
AssemblerConfig::default_config
());
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
72
~Engine
();
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
AssemblerConfig.hpp
Instruction.hpp
LIEF::Binary
Generic interface representing a binary executable.
Definition
Abstract/Binary.hpp:59
LIEF::assembly::AssemblerConfig
This class exposes the different elements that can be configured to assemble code.
Definition
AssemblerConfig.hpp:29
LIEF::assembly::AssemblerConfig::default_config
static AssemblerConfig & default_config()
Default configuration.
Definition
AssemblerConfig.hpp:50
LIEF::assembly::Engine
This class interfaces the assembler/disassembler support.
Definition
Engine.hpp:36
LIEF::assembly::Engine::Engine
Engine(const Engine &)=delete
LIEF::assembly::Engine::operator=
Engine & operator=(const Engine &)=delete
LIEF::assembly::Engine::Engine
Engine()=delete
LIEF::assembly::Engine::Engine
Engine(std::unique_ptr< details::Engine > impl)
LIEF::assembly::Engine::Engine
Engine(Engine &&) noexcept
LIEF::assembly::Engine::assemble
std::vector< uint8_t > assemble(uint64_t address, const std::string &Asm, LIEF::Binary &bin, AssemblerConfig &config=AssemblerConfig::default_config())
LIEF::assembly::Engine::instructions_it
iterator_range< Instruction::Iterator > instructions_it
Disassembly instruction iterator.
Definition
Engine.hpp:39
LIEF::assembly::Engine::disassemble
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.
LIEF::assembly::Engine::assemble
std::vector< uint8_t > assemble(uint64_t address, const llvm::MCInst &inst, LIEF::Binary &bin)
LIEF::assembly::Engine::assemble
std::vector< uint8_t > assemble(uint64_t address, const std::string &Asm, AssemblerConfig &config=AssemblerConfig::default_config())
LIEF::assembly::Engine::~Engine
~Engine()
LIEF::assembly::Engine::assemble
std::vector< uint8_t > assemble(uint64_t address, const std::vector< llvm::MCInst > &inst, LIEF::Binary &bin)
LIEF::iterator_range
Definition
iterators.hpp:486
iterators.hpp
LIEF::assembly::details
Definition
Engine.hpp:31
LIEF::assembly
Namespace related to assembly/disassembly support.
Definition
Abstract/Binary.hpp:47
LIEF
LIEF namespace.
Definition
Abstract/Binary.hpp:40
visibility.h
LIEF_API
#define LIEF_API
Definition
visibility.h:41
LIEF_LOCAL
#define LIEF_LOCAL
Definition
visibility.h:42
Generated by
1.17.0