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
PE
RichHeader.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_PE_RICH_HEADER_H
17
#define LIEF_PE_RICH_HEADER_H
18
#include <ostream>
19
20
#include "
LIEF/Object.hpp
"
21
#include "
LIEF/visibility.h
"
22
23
#include "
LIEF/iterators.hpp
"
24
25
#include "
LIEF/PE/RichEntry.hpp
"
26
#include "
LIEF/PE/enums.hpp
"
27
28
namespace
LIEF
{
29
namespace
PE
{
30
37
class
LIEF_API
RichHeader
:
public
Object
{
38
public
:
39
using
entries_t
= std::vector<RichEntry>;
40
using
it_entries
=
ref_iterator<entries_t&>
;
41
using
it_const_entries
=
const_ref_iterator<const entries_t&>
;
42
43
static
constexpr
uint8_t
RICH_MAGIC
[] = {
'R'
,
'i'
,
'c'
,
'h'
};
44
static
constexpr
uint32_t
RICH_MAGIC_INT
= 0x68636952;
// 'Rich'
45
static
constexpr
uint32_t
DANS_MAGIC_NUMBER
= 0x536E6144;
// 'Rich'
46
47
RichHeader
() =
default
;
48
RichHeader
(
const
RichHeader
&) =
default
;
49
RichHeader
&
operator=
(
const
RichHeader
&) =
default
;
50
~RichHeader
()
override
=
default
;
51
53
uint32_t
key
()
const
{
54
return
key_;
55
}
56
58
it_entries
entries
() {
59
return
entries_;
60
}
61
62
it_const_entries
entries
()
const
{
63
return
entries_;
64
}
65
66
void
key
(uint32_t
key
) {
67
key_ =
key
;
68
}
69
71
void
add_entry
(
RichEntry
entry) {
72
entries_.push_back(std::move(entry));
73
}
74
76
void
add_entry
(uint16_t
id
, uint16_t build_id, uint32_t count) {
77
entries_.emplace_back(
id
, build_id, count);
78
}
79
83
std::vector<uint8_t>
raw
()
const
{
84
return
raw
(
/*xor_key=*/
0);
85
}
86
93
std::vector<uint8_t>
raw
(uint32_t xor_key)
const
;
94
97
std::vector<uint8_t>
hash
(
ALGORITHMS
algo)
const
{
98
return
hash
(algo,
/*xor_key=*/
0);
99
}
100
102
std::vector<uint8_t>
hash
(
ALGORITHMS
algo, uint32_t xor_key)
const
;
103
104
void
accept
(
Visitor
& visitor)
const override
;
105
106
LIEF_API
friend
std::ostream&
operator<<
(std::ostream& os,
const
RichHeader
& rich_header);
107
108
private
:
109
uint32_t key_ = 0;
110
entries_t
entries_;
111
112
};
113
}
114
}
115
116
#endif
117
Object.hpp
enums.hpp
RichEntry.hpp
LIEF::Object::Object
Object()
LIEF::PE::RichEntry
Class which represents an entry associated to the RichHeader.
Definition
RichEntry.hpp:28
LIEF::PE::RichHeader::raw
std::vector< uint8_t > raw() const
The raw structure of the Rich header without xor-encoding.
Definition
RichHeader.hpp:83
LIEF::PE::RichHeader::raw
std::vector< uint8_t > raw(uint32_t xor_key) const
Given this rich header, this function re-computes the raw bytes of the structure with the provided xo...
LIEF::PE::RichHeader::it_entries
ref_iterator< entries_t & > it_entries
Definition
RichHeader.hpp:40
LIEF::PE::RichHeader::RICH_MAGIC_INT
static constexpr uint32_t RICH_MAGIC_INT
Definition
RichHeader.hpp:44
LIEF::PE::RichHeader::RICH_MAGIC
static constexpr uint8_t RICH_MAGIC[]
Definition
RichHeader.hpp:43
LIEF::PE::RichHeader::accept
void accept(Visitor &visitor) const override
LIEF::PE::RichHeader::entries
it_const_entries entries() const
Definition
RichHeader.hpp:62
LIEF::PE::RichHeader::entries_t
std::vector< RichEntry > entries_t
Definition
RichHeader.hpp:39
LIEF::PE::RichHeader::RichHeader
RichHeader(const RichHeader &)=default
LIEF::PE::RichHeader::operator=
RichHeader & operator=(const RichHeader &)=default
LIEF::PE::RichHeader::RichHeader
RichHeader()=default
LIEF::PE::RichHeader::operator<<
friend std::ostream & operator<<(std::ostream &os, const RichHeader &rich_header)
LIEF::PE::RichHeader::entries
it_entries entries()
Return an iterator over the PE::RichEntry within the header.
Definition
RichHeader.hpp:58
LIEF::PE::RichHeader::add_entry
void add_entry(uint16_t id, uint16_t build_id, uint32_t count)
Add a new entry given the id, build_id and count.
Definition
RichHeader.hpp:76
LIEF::PE::RichHeader::hash
std::vector< uint8_t > hash(ALGORITHMS algo) const
Compute the hash of the decoded rich header structure with the given hash algorithm.
Definition
RichHeader.hpp:97
LIEF::PE::RichHeader::hash
std::vector< uint8_t > hash(ALGORITHMS algo, uint32_t xor_key) const
Compute the hash of the rich header structure encoded with the provided key.
LIEF::PE::RichHeader::~RichHeader
~RichHeader() override=default
LIEF::PE::RichHeader::add_entry
void add_entry(RichEntry entry)
Add a new PE::RichEntry.
Definition
RichHeader.hpp:71
LIEF::PE::RichHeader::DANS_MAGIC_NUMBER
static constexpr uint32_t DANS_MAGIC_NUMBER
Definition
RichHeader.hpp:45
LIEF::PE::RichHeader::it_const_entries
const_ref_iterator< const entries_t & > it_const_entries
Definition
RichHeader.hpp:41
LIEF::PE::RichHeader::key
void key(uint32_t key)
Definition
RichHeader.hpp:66
LIEF::PE::RichHeader::key
uint32_t key() const
Key used to encode the header (xor operation).
Definition
RichHeader.hpp:53
LIEF::Visitor
Definition
Visitor.hpp:210
LIEF::ref_iterator
Iterator which returns reference on container's values.
Definition
iterators.hpp:46
iterators.hpp
LIEF::PE
Namespace related to the LIEF's PE module.
Definition
Abstract/Header.hpp:32
LIEF::PE::ALGORITHMS
ALGORITHMS
Cryptography algorithms.
Definition
PE/enums.hpp:28
LIEF
LIEF namespace.
Definition
Abstract/Binary.hpp:40
LIEF::const_ref_iterator
ref_iterator< CT, U, typename decay_t< CT >::const_iterator > const_ref_iterator
Iterator which return const ref on container's values.
Definition
iterators.hpp:257
visibility.h
LIEF_API
#define LIEF_API
Definition
visibility.h:41
Generated by
1.17.0