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
23namespace LIEF {
24namespace PE {
25class Parser;
26class Builder;
27
28namespace details {
29struct pe_pdb_70;
30struct pe_pdb_20;
31}
32
35 friend class Parser;
36 friend class Builder;
37
38 public:
39 using signature_t = std::array<uint8_t, 16>;
42
43 CodeViewPDB(std::string filename) :
45 signature_{0},
46 filename_(std::move(filename)) {}
47
48 CodeViewPDB(const details::pe_debug& debug_info,
49 const details::pe_pdb_70& pdb_70, Section* sec);
50
51 CodeViewPDB(const details::pe_debug& debug_info,
52 const details::pe_pdb_20& pdb_70, Section* sec);
53
54 CodeViewPDB(const CodeViewPDB& other) = default;
55 CodeViewPDB& operator=(const CodeViewPDB& other) = default;
56
57 CodeViewPDB(CodeViewPDB&& other) = default;
58 CodeViewPDB& operator=(CodeViewPDB&& other) = default;
59
62 std::string guid() const;
63
67 uint32_t age() const {
68 return age_;
69 }
70
72 const signature_t& signature() const {
73 return signature_;
74 }
75
77 const std::string& filename() const {
78 return filename_;
79 }
80
81 void age(uint32_t age) {
82 age_ = age;
83 }
84
85 void signature(const signature_t& sig) {
86 signature_ = sig;
87 }
88
89 void filename(std::string filename) {
90 filename_ = std::move(filename);
91 }
92
93 std::unique_ptr<Debug> clone() const override {
94 return std::unique_ptr<Debug>(new CodeViewPDB(*this));
95 }
96
97 static bool classof(const Debug* debug) {
98 if (!CodeView::classof(debug)) {
99 return false;
100 }
101 const auto& cv = static_cast<const CodeView&>(*debug);
102
103 return cv.signature() == SIGNATURES::PDB_20 ||
104 cv.signature() == SIGNATURES::PDB_70;
105 }
106
107 void accept(Visitor& visitor) const override;
108
109 std::string to_string() const override;
110
111 ~CodeViewPDB() override = default;
112
113 protected:
114 uint32_t age_ = 0;
115 signature_t signature_ = {0};
116 std::string filename_;
117};
118
119} // namespace PE
120} // namespace LIEF
121#endif
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:44
CodeViewPDB & operator=(const CodeViewPDB &other)=default
CodeViewPDB(std::string filename)
Definition CodeViewPDB.hpp:43
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:81
void accept(Visitor &visitor) const override
std::array< uint8_t, 16 > signature_t
Definition CodeViewPDB.hpp:39
static bool classof(const Debug *debug)
Definition CodeViewPDB.hpp:97
CodeViewPDB(const CodeViewPDB &other)=default
const std::string & filename() const
The path to the .pdb file.
Definition CodeViewPDB.hpp:77
uint32_t age() const
Age value to verify. The age does not necessarily correspond to any known time value,...
Definition CodeViewPDB.hpp:67
friend class Builder
Definition CodeViewPDB.hpp:36
void signature(const signature_t &sig)
Definition CodeViewPDB.hpp:85
CodeViewPDB(CodeViewPDB &&other)=default
CodeViewPDB()
Definition CodeViewPDB.hpp:40
friend class Parser
Definition CodeViewPDB.hpp:35
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:72
CodeViewPDB & operator=(CodeViewPDB &&other)=default
std::string to_string() const override
void filename(std::string filename)
Definition CodeViewPDB.hpp:89
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:93
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:53
Class which represents a PE section.
Definition PE/Section.hpp:47
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:41
#define LIEF_API
Definition visibility.h:45