LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
CodeViewPDB.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_DEBUG_CODE_VIEW_PDB_H
17#define LIEF_PE_DEBUG_CODE_VIEW_PDB_H
19
20#include <cstdint>
21#include <array>
22#include <ostream>
23
24namespace LIEF {
25namespace PE {
26class Parser;
27class Builder;
28
29namespace details {
30struct pe_pdb_70;
31struct pe_pdb_20;
32}
33
36 friend class Parser;
37 friend class Builder;
38
39 public:
40 using signature_t = std::array<uint8_t, 16>;
43
44 CodeViewPDB(std::string filename) :
46 signature_{0},
47 filename_(std::move(filename)) {}
48
49 CodeViewPDB(const details::pe_debug& debug_info,
50 const details::pe_pdb_70& pdb_70, Section* sec);
51
52 CodeViewPDB(const details::pe_debug& debug_info,
53 const details::pe_pdb_20& pdb_70, Section* sec);
54
55 CodeViewPDB(const CodeViewPDB& other) = default;
56 CodeViewPDB& operator=(const CodeViewPDB& other) = default;
57
58 CodeViewPDB(CodeViewPDB&& other) = default;
59 CodeViewPDB& operator=(CodeViewPDB&& other) = default;
60
63 std::string guid() const;
64
68 uint32_t age() const {
69 return age_;
70 }
71
73 const signature_t& signature() const {
74 return signature_;
75 }
76
78 const std::string& filename() const {
79 return filename_;
80 }
81
82 void age(uint32_t age) {
83 age_ = age;
84 }
85
86 void signature(const signature_t& sig) {
87 signature_ = sig;
88 }
89
90 void filename(std::string filename) {
91 filename_ = std::move(filename);
92 }
93
94 std::unique_ptr<Debug> clone() const override {
95 return std::unique_ptr<Debug>(new CodeViewPDB(*this));
96 }
97
98 static bool classof(const Debug* debug) {
99 if (!CodeView::classof(debug)) {
100 return false;
101 }
102 const auto& cv = static_cast<const CodeView&>(*debug);
103
104 return cv.signature() == SIGNATURES::PDB_20 ||
105 cv.signature() == SIGNATURES::PDB_70;
106 }
107
108 void accept(Visitor& visitor) const override;
109
110 std::string to_string() const override;
111
112 ~CodeViewPDB() override = default;
113
114 protected:
115 uint32_t age_ = 0;
116 signature_t signature_ = {0};
117 std::string filename_;
118};
119
120} // namespace PE
121} // namespace LIEF
122#endif
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
CodeViewPDB & operator=(const CodeViewPDB &other)=default
CodeViewPDB(std::string filename)
Definition CodeViewPDB.hpp:44
std::string guid() const
The GUID signature to verify against the .pdb file signature. This attribute might be used to lookup ...
void age(uint32_t age)
Definition CodeViewPDB.hpp:82
void accept(Visitor &visitor) const override
std::array< uint8_t, 16 > signature_t
Definition CodeViewPDB.hpp:40
static bool classof(const Debug *debug)
Definition CodeViewPDB.hpp:98
CodeViewPDB(const CodeViewPDB &other)=default
const std::string & filename() const
The path to the .pdb file.
Definition CodeViewPDB.hpp:78
uint32_t age() const
Age value to verify. The age does not necessarily correspond to any known time value,...
Definition CodeViewPDB.hpp:68
friend class Builder
Definition CodeViewPDB.hpp:37
void signature(const signature_t &sig)
Definition CodeViewPDB.hpp:86
CodeViewPDB(CodeViewPDB &&other)=default
CodeViewPDB()
Definition CodeViewPDB.hpp:41
friend class Parser
Definition CodeViewPDB.hpp:36
CodeViewPDB(const details::pe_debug &debug_info, const details::pe_pdb_70 &pdb_70, Section *sec)
~CodeViewPDB() override=default
const signature_t & signature() const
The 32-bit signature to verify against the .pdb file signature.
Definition CodeViewPDB.hpp:73
CodeViewPDB & operator=(CodeViewPDB &&other)=default
std::string to_string() const override
void filename(std::string filename)
Definition CodeViewPDB.hpp:90
CodeViewPDB(const details::pe_debug &debug_info, const details::pe_pdb_20 &pdb_70, Section *sec)
std::unique_ptr< Debug > clone() const override
Definition CodeViewPDB.hpp:94
static bool classof(const Debug *debug)
Definition CodeView.hpp:69
SIGNATURES
Code view signatures.
Definition CodeView.hpp:33
@ PDB_20
Definition CodeView.hpp:37
@ PDB_70
Definition CodeView.hpp:36
CodeView()
Definition CodeView.hpp:42
This class represents a generic entry in the debug data directory. For known types,...
Definition debug/Debug.hpp:40
Main interface to parse PE binaries. In particular, the static Parser::parse functions should be used...
Definition PE/Parser.hpp:52
Class which represents a PE section.
Definition PE/Section.hpp:46
Definition Visitor.hpp:212
Definition DataDirectory.hpp:37
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:45