LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
CodeViewPDB.hpp
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_DEBUG_CODE_VIEW_PDB_H
17#define LIEF_PE_DEBUG_CODE_VIEW_PDB_H
18#include "LIEF/PE/debug/CodeView.hpp"
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;
31}
32
34class LIEF_API CodeViewPDB : public CodeView {
35 friend class Parser;
36 friend class Builder;
37
38 public:
39 using signature_t = std::array<uint8_t, 16>;
41 CodeViewPDB(const details::pe_debug& debug_info,
42 const details::pe_pdb_70& pdb_70);
43 CodeViewPDB(const CodeViewPDB& other);
44 CodeViewPDB& operator=(const CodeViewPDB& other);
45
46 std::string guid() const;
47
48 uint32_t age() const {
49 return age_;
50 }
51
52 const signature_t& signature() const {
53 return signature_;
54 }
55
56 const std::string& filename() const {
57 return filename_;
58 }
59
60 void age(uint32_t age) {
61 age_ = age;
62 }
63
64 void signature(const signature_t& sig) {
65 signature_ = sig;
66 }
67
68 void filename(std::string filename) {
69 filename_ = std::move(filename);
70 }
71
72 std::unique_ptr<Debug> clone() const override {
73 return std::unique_ptr<Debug>(new CodeViewPDB(*this));
74 }
75
76 static bool classof(const Debug* debug) {
77 if (!CodeView::classof(debug)) {
78 return false;
79 }
80 const auto& cv = static_cast<const CodeView&>(*debug);
81
82 return cv.signature() == SIGNATURES::PDB_20 ||
83 cv.signature() == SIGNATURES::PDB_70;
84 }
85
86 void accept(Visitor& visitor) const override;
87 LIEF_API friend std::ostream& operator<<(std::ostream& os, const CodeViewPDB& entry);
88
89 ~CodeViewPDB() override;
90
91 protected:
92 uint32_t age_ = 0;
93 signature_t signature_;
94 std::string filename_;
95};
96
97} // namespace PE
98} // namespace LIEF
99#endif
Class that is used to rebuild a raw PE binary from a PE::Binary object.
Definition PE/Builder.hpp:45
CodeView PDB specialization.
Definition CodeViewPDB.hpp:34
Interface for the (Generic) Debug CodeView (IMAGE_DEBUG_TYPE_CODEVIEW)
Definition CodeView.hpp:26
SIGNATURES signature() const
The signature that defines the underlying type of the payload.
Definition CodeView.hpp:56
This class represents a generic entry in the debug data directory. For known types,...
Definition debug/Debug.hpp:38
Main interface to parse PE binaries. In particular the static functions: Parser::parse should be used...
Definition PE/Parser.hpp:47
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32