LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
BigObjHeader.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_COFF_BIGOBJ_HEADER_H
16#define LIEF_COFF_BIGOBJ_HEADER_H
17#include <array>
18#include <cstdint>
19
20#include "LIEF/COFF/Header.hpp"
21
23#include "LIEF/span.hpp"
24#include "LIEF/visibility.h"
25
26
27namespace LIEF::COFF {
28
35 public:
36 static constexpr auto UUID_SZ = 16;
38 Header(KIND::BIGOBJ) {}
39
40 static std::unique_ptr<BigObjHeader> create(BinaryStream& stream);
41
43 BigObjHeader(const BigObjHeader&) = default;
44
47
48 std::unique_ptr<Header> clone() const override {
49 return std::unique_ptr<Header>(new BigObjHeader(*this));
50 }
51
53 uint16_t version() const {
54 return version_;
55 }
56
60 return uuid_;
61 }
62
64 uint32_t sizeof_data() const {
65 return sizeof_data_;
66 }
67
69 uint32_t flags() const {
70 return flags_;
71 }
72
74 uint32_t metadata_size() const {
75 return metadata_size_;
76 }
77
79 uint32_t metadata_offset() const {
80 return metadata_offset_;
81 }
82
83 void version(uint16_t value) {
84 version_ = value;
85 }
86
87 void sizeof_data(uint32_t value) {
88 sizeof_data_ = value;
89 }
90
91 void flags(uint32_t value) {
92 flags_ = value;
93 }
94
95 void metadata_size(uint32_t value) {
96 metadata_size_ = value;
97 }
98
99 void metadata_offset(uint32_t value) {
100 metadata_offset_ = value;
101 }
102
103 static bool classof(const Header* header) {
104 return header->kind() == Header::KIND::BIGOBJ;
105 }
106
107 ~BigObjHeader() override = default;
108
109 std::string to_string() const override;
110
111 protected:
112 uint16_t version_ = 0;
113 std::array<uint8_t, UUID_SZ> uuid_ = {};
114
115 uint32_t sizeof_data_ = 0;
116 uint32_t flags_ = 0;
117 uint32_t metadata_size_ = 0;
118 uint32_t metadata_offset_ = 0;
119};
120
121}
122
123#endif
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:34
uint32_t metadata_size() const
Size of CLR metadata.
Definition BigObjHeader.hpp:74
void flags(uint32_t value)
Definition BigObjHeader.hpp:91
uint32_t flags() const
1 means that it contains metadata
Definition BigObjHeader.hpp:69
static std::unique_ptr< BigObjHeader > create(BinaryStream &stream)
uint32_t sizeof_data() const
Size of data that follows the header.
Definition BigObjHeader.hpp:64
BigObjHeader()
Definition BigObjHeader.hpp:37
void version(uint16_t value)
Definition BigObjHeader.hpp:83
std::string to_string() const override
std::unique_ptr< Header > clone() const override
Definition BigObjHeader.hpp:48
static constexpr auto UUID_SZ
Definition BigObjHeader.hpp:36
void sizeof_data(uint32_t value)
Definition BigObjHeader.hpp:87
void metadata_size(uint32_t value)
Definition BigObjHeader.hpp:95
static bool classof(const Header *header)
Definition BigObjHeader.hpp:103
span< const uint8_t > uuid() const
Originally named ClassID, this uuid should match: {D1BAA1C7-BAEE-4ba9-AF20-FAF66AA4DCB8}...
Definition BigObjHeader.hpp:59
void metadata_offset(uint32_t value)
Definition BigObjHeader.hpp:99
BigObjHeader & operator=(BigObjHeader &&)=default
BigObjHeader & operator=(const BigObjHeader &)=default
BigObjHeader(BigObjHeader &&)=default
BigObjHeader(const BigObjHeader &)=default
uint32_t metadata_offset() const
Offset of CLR metadata.
Definition BigObjHeader.hpp:79
~BigObjHeader() override=default
uint16_t version() const
The version of this header which must be >= 2.
Definition BigObjHeader.hpp:53
KIND kind() const
The type of this header: whether it is regular or using the /bigobj format.
Definition COFF/Header.hpp:61
KIND
Definition COFF/Header.hpp:34
@ BIGOBJ
Definition COFF/Header.hpp:37
#define LIEF_LIFETIMEBOUND
Definition compiler_attributes.hpp:72
Definition AuxiliarySymbol.hpp:29
tcb::span< ElementType, Extent > span
Definition span.hpp:22
#define LIEF_API
Definition visibility.h:44