LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
PDBChecksum.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_PDBCHECKSUM_H
17#define LIEF_PE_PDBCHECKSUM_H
18#include <vector>
19
20#include "LIEF/visibility.h"
22
23namespace LIEF {
24namespace PE {
25
28class LIEF_API PDBChecksum : public Debug {
29 public:
30 static std::unique_ptr<PDBChecksum>
31 parse(const details::pe_debug& hdr, Section* section, span<uint8_t> payload);
32
33 enum class HASH_ALGO : uint32_t {
36 };
37
38 PDBChecksum(HASH_ALGO algo, std::vector<uint8_t> hash) :
40 algo_(algo),
41 hash_(std::move(hash))
42 {}
43
44 PDBChecksum(const details::pe_debug& dbg, Section* sec,
45 HASH_ALGO algo, std::vector<uint8_t> hash) :
46 Debug(dbg, sec),
47 algo_(algo),
48 hash_(std::move(hash))
49 {}
50
51 PDBChecksum(const PDBChecksum& other) = default;
52 PDBChecksum& operator=(const PDBChecksum& other) = default;
53
55 PDBChecksum& operator=(PDBChecksum&& other) = default;
56
57 std::unique_ptr<Debug> clone() const override {
58 return std::unique_ptr<Debug>(new PDBChecksum(*this));
59 }
60
63 return hash_;
64 }
65
67 return hash_;
68 }
69
70 void hash(std::vector<uint8_t> h) {
71 hash_ = std::move(h);
72 }
73
76 return algo_;
77 }
78
79 void algorithm(HASH_ALGO algo) {
80 algo_ = algo;
81 }
82
83 static bool classof(const Debug* debug) {
84 return debug->type() == Debug::TYPES::PDBCHECKSUM;
85 }
86
87 ~PDBChecksum() override = default;
88
89 std::string to_string() const override;
90
91 private:
93 std::vector<uint8_t> hash_;
94};
95
97
98}
99}
100
101#endif
span< uint8_t > payload()
Debug data associated with this entry.
Debug()=default
const Section * section() const
The section where debug data is located.
Definition debug/Debug.hpp:170
TYPES
The entry types.
Definition debug/Debug.hpp:46
@ PDBCHECKSUM
Checksum of the PDB file.
Definition debug/Debug.hpp:97
PDBChecksum(HASH_ALGO algo, std::vector< uint8_t > hash)
Definition PDBChecksum.hpp:38
PDBChecksum & operator=(const PDBChecksum &other)=default
PDBChecksum & operator=(PDBChecksum &&other)=default
HASH_ALGO algorithm() const
Algorithm used for hashing the PDB content.
Definition PDBChecksum.hpp:75
std::unique_ptr< Debug > clone() const override
Definition PDBChecksum.hpp:57
std::string to_string() const override
void algorithm(HASH_ALGO algo)
Definition PDBChecksum.hpp:79
span< uint8_t > hash()
Definition PDBChecksum.hpp:66
PDBChecksum(PDBChecksum &&)=default
PDBChecksum(const details::pe_debug &dbg, Section *sec, HASH_ALGO algo, std::vector< uint8_t > hash)
Definition PDBChecksum.hpp:44
span< const uint8_t > hash() const
Hash of the PDB content.
Definition PDBChecksum.hpp:62
~PDBChecksum() override=default
static bool classof(const Debug *debug)
Definition PDBChecksum.hpp:83
void hash(std::vector< uint8_t > h)
Definition PDBChecksum.hpp:70
HASH_ALGO
Definition PDBChecksum.hpp:33
@ UNKNOWN
Definition PDBChecksum.hpp:34
@ SHA256
Definition PDBChecksum.hpp:35
PDBChecksum(const PDBChecksum &other)=default
static std::unique_ptr< PDBChecksum > parse(const details::pe_debug &hdr, Section *section, span< uint8_t > payload)
Class which represents a PE section.
Definition PE/Section.hpp:46
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
const char * to_string(CODE_PAGES e)
LIEF namespace.
Definition Abstract/Binary.hpp:40
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:41