LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
ResourceIcon.hpp
Go to the documentation of this file.
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_RESOURCE_ICON_H
17#define LIEF_PE_RESOURCE_ICON_H
18#include <ostream>
19#include <sstream>
20#include <climits>
21#include <vector>
22
23#include "LIEF/visibility.h"
24
25#include "LIEF/span.hpp"
26#include "LIEF/Object.hpp"
27
28#include "LIEF/PE/enums.hpp"
29
30namespace LIEF {
31namespace PE {
33
34namespace details {
35struct pe_resource_icon_group;
36struct pe_icon_header;
37}
38
39class LIEF_API ResourceIcon : public Object {
40
41 friend class ResourcesManager;
42
43 public:
45 ResourceIcon(const details::pe_resource_icon_group& header);
46 ResourceIcon(const details::pe_icon_header& header);
47
48 ResourceIcon(const ResourceIcon&);
49 ResourceIcon& operator=(const ResourceIcon&);
50
51 ~ResourceIcon() override;
52 uint32_t id() const;
55 uint32_t lang() const;
58 uint32_t sublang() const;
61 uint8_t width() const;
64 uint8_t height() const;
67 uint8_t color_count() const;
70 uint8_t reserved() const;
73 uint16_t planes() const;
76 uint16_t bit_count() const;
79 uint32_t size() const;
82 span<const uint8_t> pixels() const;
85
86 void id(uint32_t id);
87 void lang(uint32_t lang);
88 void sublang(uint32_t sublang);
89 void width(uint8_t width);
90 void height(uint8_t height);
91 void color_count(uint8_t color_count);
92 void reserved(uint8_t reserved);
93 void planes(uint16_t planes);
94 void bit_count(uint16_t bit_count);
95 void pixels(const std::vector<uint8_t>& pixels);
96 void save(const std::string& filename) const;
101
102 void accept(Visitor& visitor) const override;
103
104
105 LIEF_API friend std::ostream& operator<<(std::ostream& os, const ResourceIcon& entry);
106
107 private:
108 uint8_t width_ = 0;
109 uint8_t height_ = 0;
110 uint8_t color_count_ = 0;
111 uint8_t reserved_ = 0;
112 uint16_t planes_ = 0;
113 uint16_t bit_count_ = 0;
114 uint32_t id_ = UINT_MAX;
115 uint32_t lang_ = /* LANG_NEUTRAL */0;
116 uint32_t sublang_ = 0 /* SUBLANG_NEUTRAL */;
117 std::vector<uint8_t> pixels_;
118};
119
120}
121}
122
123
124#endif
Definition ResourceIcon.hpp:39
ResourceIcon(const details::pe_resource_icon_group &header)
void height(uint8_t height)
uint32_t lang() const
Language associated with the icon.
void id(uint32_t id)
uint32_t sublang() const
Sub language associated with the icon.
void width(uint8_t width)
friend std::ostream & operator<<(std::ostream &os, const ResourceIcon &entry)
ResourceIcon(const ResourceIcon &)
void pixels(const std::vector< uint8_t > &pixels)
void bit_count(uint16_t bit_count)
uint8_t height() const
Height in pixels of the image.
uint16_t planes() const
Color Planes.
void color_count(uint8_t color_count)
void planes(uint16_t planes)
uint32_t id() const
Id associated with the icon.
span< const uint8_t > pixels() const
Pixels of the image (as bytes)
ResourceIcon(const details::pe_icon_header &header)
void sublang(uint32_t sublang)
uint8_t reserved() const
Reserved (must be 0)
uint8_t color_count() const
Number of colors in image (0 if >=8bpp)
ResourceIcon & operator=(const ResourceIcon &)
void accept(Visitor &visitor) const override
uint32_t size() const
Size in bytes of the image.
uint16_t bit_count() const
Bits per pixel.
void save(const std::string &filename) const
Save the icon to the given filename.
void lang(uint32_t lang)
void reserved(uint8_t reserved)
uint8_t width() const
Width in pixels of the image.
The Resource Manager provides an enhanced API to manipulate the resource tree.
Definition ResourcesManager.hpp:38
Definition CodeIntegrity.hpp:26
Namespace related to the LIEF's PE module.
Definition Abstract/Header.hpp:32
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41