LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
FPO.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2025 R. Thomas
2 * Copyright 2017 - 2025 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_FPO_H
17#define LIEF_PE_FPO_H
18
19#include <vector>
20#include "LIEF/iterators.hpp"
21#include "LIEF/visibility.h"
23
24namespace LIEF {
25namespace PE {
26class LIEF_API FPO : public Debug {
29 public:
30
31 enum class FRAME_TYPE {
32 FPO = 0,
33 TRAP = 1,
34 TSS = 2,
35 NON_FPO = 3,
36 };
37 struct LIEF_API entry_t { uint32_t rva = 0;
43 uint32_t proc_size = 0;
46 uint32_t nb_locals = 0;
49 uint32_t parameters_size = 0;
52 uint16_t prolog_size = 0;
55 uint16_t nb_saved_regs = 0;
58 bool use_seh = false;
61 bool use_bp = false;
64 uint16_t reserved = 0;
67 FRAME_TYPE type = FRAME_TYPE::FPO;
70
71 std::string to_string() const;
72
73 friend LIEF_API
74 std::ostream& operator<<(std::ostream& os, const entry_t& entry)
75 {
76 os << entry.to_string();
77 return os;
78 }
79 };
80
81 using entries_t = std::vector<entry_t>;
82 using it_entries = ref_iterator<entries_t&>;
83 using it_const_entries = const_ref_iterator<const entries_t&>;
84
85 static std::unique_ptr<FPO>
86 parse(const details::pe_debug& hdr, Section* section, span<uint8_t> payload);
87
88 FPO(const details::pe_debug& hdr, Section* section) :
89 Debug(hdr, section)
90 {}
91
92 FPO(const FPO& other) = default;
93 FPO& operator=(const FPO& other) = default;
94
95 FPO(FPO&&) = default;
96 FPO& operator=(FPO&& other) = default;
97
98 std::unique_ptr<Debug> clone() const override {
99 return std::unique_ptr<Debug>(new FPO(*this));
100 }
101 it_const_entries entries() const {
104 return entries_;
105 }
106
107 it_entries entries() {
108 return entries_;
109 }
110
111 static bool classof(const Debug* debug) {
112 return debug->type() == Debug::TYPES::FPO;
113 }
114
115 ~FPO() override = default;
116
117 std::string to_string() const override;
118
119 private:
120 entries_t entries_;
121};
122
123LIEF_API const char* to_string(FPO::FRAME_TYPE e);
124
125}
126}
127
128#endif
LIEF::PE::Debug
This class represents a generic entry in the debug data directory. For known types,...
Definition debug/Debug.hpp:40
LIEF::PE::FPO
This class represents the IMAGE_DEBUG_TYPE_FPO debug entry.
Definition FPO.hpp:28
LIEF::PE::FPO::FPO
FPO(const FPO &other)=default
LIEF::PE::FPO::entries
it_entries entries()
Definition FPO.hpp:107
LIEF::PE::FPO::operator=
FPO & operator=(FPO &&other)=default
LIEF::PE::FPO::entries
it_const_entries entries() const
Iterator over the FPO entries.
Definition FPO.hpp:103
LIEF::PE::FPO::classof
static bool classof(const Debug *debug)
Definition FPO.hpp:111
LIEF::PE::FPO::FPO
FPO(const details::pe_debug &hdr, Section *section)
Definition FPO.hpp:88
LIEF::PE::FPO::~FPO
~FPO() override=default
LIEF::PE::FPO::to_string
std::string to_string() const override
LIEF::PE::FPO::FPO
FPO(FPO &&)=default
LIEF::PE::FPO::parse
static std::unique_ptr< FPO > parse(const details::pe_debug &hdr, Section *section, span< uint8_t > payload)
LIEF::PE::FPO::FRAME_TYPE
FRAME_TYPE
Definition FPO.hpp:31
LIEF::PE::FPO::clone
std::unique_ptr< Debug > clone() const override
Definition FPO.hpp:98
LIEF::PE::FPO::operator=
FPO & operator=(const FPO &other)=default
Debug.hpp
iterators.hpp
LIEF::PE
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF::PE::to_string
const char * to_string(AuxiliaryWeakExternal::CHARACTERISTICS e)
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
LIEF::PE::FPO::entry_t::to_string
std::string to_string() const
LIEF::PE::FPO::entry_t::operator<<
friend std::ostream & operator<<(std::ostream &os, const entry_t &entry)
Definition FPO.hpp:74
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41