LIEF: Library to Instrument Executable Formats
Version 1.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
lief-install
x86_64
static
include
LIEF
Abstract
Abstract/Header.hpp
Go to the documentation of this file.
1
/* Copyright 2017 - 2026 R. Thomas
2
* Copyright 2017 - 2026 Quarkslab
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
#ifndef LIEF_ABSTRACT_HEADER_H
17
#define LIEF_ABSTRACT_HEADER_H
18
19
#include <ostream>
20
#include <cstdint>
21
#include <vector>
22
23
#include "
LIEF/Object.hpp
"
24
#include "
LIEF/visibility.h
"
25
#include "
LIEF/enums.hpp
"
26
27
namespace
LIEF
{
28
namespace
ELF
{
29
class
Binary
;
30
}
31
32
namespace
PE
{
33
class
Binary
;
34
}
35
36
namespace
MachO
{
37
class
Binary
;
38
}
39
40
class
LIEF_API
Header
:
public
Object
{
41
public
:
42
enum class
ARCHITECTURES
{
43
UNKNOWN = 0,
44
ARM,
45
ARM64,
46
MIPS,
47
X86,
48
X86_64,
49
PPC,
50
SPARC,
51
SYSZ,
52
XCORE,
53
RISCV,
54
LOONGARCH,
55
PPC64,
56
};
57
58
enum class
ENDIANNESS
{
59
UNKNOWN = 0,
60
BIG,
61
LITTLE,
62
};
63
64
enum
MODES
: uint64_t {
65
NONE
= 0,
66
67
BITS_16
= 1LLU << 0,
68
BITS_32
= 1LLU << 1,
69
BITS_64
= 1LLU << 2,
70
THUMB
= 1LLU << 3,
71
72
ARM64E
= 1LLU << 4,
73
};
74
75
enum class
OBJECT_TYPES
{
76
UNKNOWN = 0,
77
EXECUTABLE,
78
LIBRARY,
79
OBJECT,
80
};
81
82
static
Header
from
(
const
LIEF::ELF::Binary
& elf);
83
static
Header
from
(
const
LIEF::PE::Binary
& pe);
84
static
Header
from
(
const
LIEF::MachO::Binary
& macho);
85
86
Header
() =
default
;
87
Header
(
const
Header
&) =
default
;
88
Header
&
operator=
(
const
Header
&) =
default
;
89
~Header
()
override
=
default
;
90
92
ARCHITECTURES
architecture
()
const
{
93
return
architecture_;
94
}
95
97
MODES
modes
()
const
{
98
return
modes_;
99
}
100
102
std::vector<MODES>
modes_list
()
const
;
103
104
bool
is
(
MODES
m)
const
{
105
return
((uint64_t)m & (uint64_t)modes_) != 0;
106
}
107
108
OBJECT_TYPES
object_type
()
const
{
109
return
object_type_;
110
}
111
uint64_t
entrypoint
()
const
{
112
return
entrypoint_;
113
}
114
115
ENDIANNESS
endianness
()
const
{
116
return
endianness_;
117
}
118
119
bool
is_32
()
const
{
120
return
((uint64_t)modes_ & (uint64_t)
MODES::BITS_32
) != 0;
121
}
122
123
bool
is_64
()
const
{
124
return
((uint64_t)modes_ & (uint64_t)
MODES::BITS_64
) != 0;
125
}
126
127
void
accept
(
Visitor
& visitor)
const override
;
128
129
LIEF_API
friend
std::ostream&
operator<<
(std::ostream& os,
const
Header
& hdr);
130
131
protected
:
132
ARCHITECTURES
architecture_ =
ARCHITECTURES::UNKNOWN
;
133
OBJECT_TYPES
object_type_ =
OBJECT_TYPES::UNKNOWN
;
134
uint64_t entrypoint_ = 0;
135
ENDIANNESS
endianness_ =
ENDIANNESS::UNKNOWN
;
136
MODES
modes_ =
MODES::NONE
;
137
};
138
139
LIEF_API
const
char
*
to_string
(
Header::ARCHITECTURES
e);
140
LIEF_API
const
char
*
to_string
(
Header::OBJECT_TYPES
e);
141
LIEF_API
const
char
*
to_string
(
Header::MODES
e);
142
LIEF_API
const
char
*
to_string
(
Header::ENDIANNESS
e);
143
}
144
145
ENABLE_BITMASK_OPERATORS
(
LIEF::Header::MODES
);
146
147
#endif
Object.hpp
LIEF::ELF::Binary
Class which represents an ELF binary.
Definition
ELF/Binary.hpp:59
LIEF::Header::entrypoint
uint64_t entrypoint() const
Definition
Abstract/Header.hpp:111
LIEF::Header::architecture
ARCHITECTURES architecture() const
Target architecture.
Definition
Abstract/Header.hpp:92
LIEF::Header::from
static Header from(const LIEF::ELF::Binary &elf)
LIEF::Header::modes_list
std::vector< MODES > modes_list() const
MODES as a vector.
LIEF::Header::modes
MODES modes() const
Optional features for the given architecture.
Definition
Abstract/Header.hpp:97
LIEF::Header::Header
Header()=default
LIEF::Header::from
static Header from(const LIEF::MachO::Binary &macho)
LIEF::Header::Header
Header(const Header &)=default
LIEF::Header::object_type
OBJECT_TYPES object_type() const
Definition
Abstract/Header.hpp:108
LIEF::Header::ARCHITECTURES
ARCHITECTURES
Definition
Abstract/Header.hpp:42
LIEF::Header::ARCHITECTURES::UNKNOWN
@ UNKNOWN
Definition
Abstract/Header.hpp:43
LIEF::Header::OBJECT_TYPES
OBJECT_TYPES
Definition
Abstract/Header.hpp:75
LIEF::Header::OBJECT_TYPES::UNKNOWN
@ UNKNOWN
Definition
Abstract/Header.hpp:76
LIEF::Header::operator<<
friend std::ostream & operator<<(std::ostream &os, const Header &hdr)
LIEF::Header::is
bool is(MODES m) const
Definition
Abstract/Header.hpp:104
LIEF::Header::endianness
ENDIANNESS endianness() const
Definition
Abstract/Header.hpp:115
LIEF::Header::ENDIANNESS
ENDIANNESS
Definition
Abstract/Header.hpp:58
LIEF::Header::ENDIANNESS::UNKNOWN
@ UNKNOWN
Definition
Abstract/Header.hpp:59
LIEF::Header::operator=
Header & operator=(const Header &)=default
LIEF::Header::accept
void accept(Visitor &visitor) const override
LIEF::Header::from
static Header from(const LIEF::PE::Binary &pe)
LIEF::Header::~Header
~Header() override=default
LIEF::Header::is_32
bool is_32() const
Definition
Abstract/Header.hpp:119
LIEF::Header::MODES
MODES
Definition
Abstract/Header.hpp:64
LIEF::Header::BITS_16
@ BITS_16
Definition
Abstract/Header.hpp:67
LIEF::Header::NONE
@ NONE
Definition
Abstract/Header.hpp:65
LIEF::Header::BITS_64
@ BITS_64
32-bits architecture
Definition
Abstract/Header.hpp:69
LIEF::Header::ARM64E
@ ARM64E
Support ARM Thumb mode.
Definition
Abstract/Header.hpp:72
LIEF::Header::THUMB
@ THUMB
64-bits architecture
Definition
Abstract/Header.hpp:70
LIEF::Header::BITS_32
@ BITS_32
16-bits architecture
Definition
Abstract/Header.hpp:68
LIEF::Header::is_64
bool is_64() const
Definition
Abstract/Header.hpp:123
LIEF::MachO::Binary
Class which represents a MachO binary.
Definition
MachO/Binary.hpp:88
LIEF::Object::Object
Object()
LIEF::PE::Binary
Class which represents a PE binary This is the main interface to manage and modify a PE executable.
Definition
PE/Binary.hpp:57
LIEF::Visitor
Definition
Visitor.hpp:210
enums.hpp
ENABLE_BITMASK_OPERATORS
#define ENABLE_BITMASK_OPERATORS(X)
Definition
enums.hpp:24
LIEF::ELF
Namespace related to the LIEF's ELF module.
Definition
Abstract/Header.hpp:28
LIEF::MachO
Namespace related to the LIEF's Mach-O module.
Definition
Abstract/Header.hpp:36
LIEF::PE
Namespace related to the LIEF's PE module.
Definition
Abstract/Header.hpp:32
LIEF
LIEF namespace.
Definition
Abstract/Binary.hpp:40
LIEF::to_string
const char * to_string(Binary::VA_TYPES e)
visibility.h
LIEF_API
#define LIEF_API
Definition
visibility.h:41
Generated by
1.17.0