LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
Pogo.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2024 R. Thomas
2 * Copyright 2017 - 2024 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_POGO_H
17#define LIEF_PE_POGO_H
18#include <ostream>
19
20#include "LIEF/visibility.h"
21#include "LIEF/iterators.hpp"
24
25namespace LIEF {
26namespace PE {
27
28class Builder;
29class Parser;
30
33class LIEF_API Pogo : public Debug {
34
35 friend class Builder;
36 friend class Parser;
37
38 public:
39 using entries_t = std::vector<PogoEntry>;
42
43 enum class SIGNATURES {
44 UNKNOWN = 0x0fffffff,
45 ZERO = 0x00000000,
46 LCTG = 0x4C544347, // LCTG
47 PGI = 0x50474900, // PGI\0
48 };
49
52 Debug{Debug::TYPES::POGO},
53 sig_{sig}
54 {}
55
56 Pogo(const details::pe_debug& debug, SIGNATURES sig);
57 Pogo(const Pogo&) = default;
58 Pogo& operator=(const Pogo&) = default;
59
60 std::unique_ptr<Debug> clone() const override {
61 return std::unique_ptr<Debug>(new Pogo(*this));
62 }
63
65 return sig_;
66 }
67
70 return entries_;
71 }
72
74 return entries_;
75 }
76
77 void add(PogoEntry entry) {
78 entries_.push_back(std::move(entry));
79 }
80
81 static bool classof(const Debug* debug) {
82 return debug->type() == Debug::TYPES::POGO;
83 }
84
85 void accept(Visitor& visitor) const override;
86
87 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Pogo& entry);
88
89 ~Pogo() override = default;
90
91 protected:
92 SIGNATURES sig_ = SIGNATURES::UNKNOWN;
93 entries_t entries_;
94};
95
97
98} // Namespace PE
99} // Namespace LIEF
100
101#endif
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
This class represents a generic entry in the debug data directory. For known types,...
Definition debug/Debug.hpp:38
TYPES type() const
The format DEBUG_TYPES of the debugging information.
Definition debug/Debug.hpp:100
TYPES
The entry types.
Definition debug/Debug.hpp:44
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
Definition PogoEntry.hpp:30
This class represents a Profile Guided Optimization entry from the debug directory (IMAGE_DEBUG_TYPE_...
Definition Pogo.hpp:33
Pogo(SIGNATURES sig)
Definition Pogo.hpp:51
std::unique_ptr< Debug > clone() const override
Definition Pogo.hpp:60
std::vector< PogoEntry > entries_t
Definition Pogo.hpp:39
~Pogo() override=default
static bool classof(const Debug *debug)
Definition Pogo.hpp:81
SIGNATURES
Definition Pogo.hpp:43
Pogo(const Pogo &)=default
void accept(Visitor &visitor) const override
Pogo & operator=(const Pogo &)=default
it_entries entries()
An iterator over the different POGO elements.
Definition Pogo.hpp:69
it_const_entries entries() const
Definition Pogo.hpp:73
Pogo(const details::pe_debug &debug, SIGNATURES sig)
void add(PogoEntry entry)
Definition Pogo.hpp:77
friend std::ostream & operator<<(std::ostream &os, const Pogo &entry)
SIGNATURES signature() const
Definition Pogo.hpp:64
Definition Visitor.hpp:224
Iterator which returns reference on container's values.
Definition iterators.hpp:48
const char * to_string(DataDirectory::TYPES e)
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41