LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
BuildVersion.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_MACHO_BUILD_VERSION_COMMAND_H
17#define LIEF_MACHO_BUILD_VERSION_COMMAND_H
18#include <vector>
19#include <ostream>
20#include <array>
21
22#include "LIEF/visibility.h"
23
26
27namespace LIEF {
28namespace MachO {
29
30namespace details {
31struct build_version_command;
32}
33
35 friend class BinaryParser;
36
37 public: using version_t = std::array<uint32_t, 3>;
40
41 using tools_list_t = std::vector<BuildToolVersion>;
42
43 public:
44 enum class PLATFORMS : uint32_t {
46 MACOS = 1,
47 IOS = 2,
48 TVOS = 3,
49 WATCHOS = 4,
50 BRIDGEOS = 5,
51 MAC_CATALYST = 6,
52 IOS_SIMULATOR = 7,
53 TVOS_SIMULATOR = 8,
54 WATCHOS_SIMULATOR = 9,
55 DRIVERKIT = 10,
56 VISIONOS = 11,
57 VISIONOS_SIMULATOR = 12,
58 FIRMWARE = 13,
59 SEPOS = 14,
60
61 ANY = 0xFFFFFFFF
62 };
63
64 public:
65 BuildVersion() = default;
66 BuildVersion(const details::build_version_command& version_cmd);
67 BuildVersion(const PLATFORMS platform,
68 const version_t &minos,
69 const version_t &sdk,
70 const tools_list_t &tools);
71
72 BuildVersion& operator=(const BuildVersion& copy) = default;
73 BuildVersion(const BuildVersion& copy) = default;
74
75 std::unique_ptr<LoadCommand> clone() const override {
76 return std::unique_ptr<BuildVersion>(new BuildVersion(*this));
77 }
78
79 version_t minos() const {
80 return minos_;
81 }
82
83 void minos(version_t version) {
84 minos_ = version;
85 }
86
87 version_t sdk() const {
88 return sdk_;
89 }
90 void sdk(version_t version) {
91 sdk_ = version;
92 }
93
95 return platform_;
96 }
97 void platform(PLATFORMS plat) {
98 platform_ = plat;
99 }
100
101 const tools_list_t& tools() const {
102 return tools_;
103 }
104
105 ~BuildVersion() override = default;
106
107 void accept(Visitor& visitor) const override;
108
109 std::ostream& print(std::ostream& os) const override;
110
111 static bool classof(const LoadCommand* cmd) {
112 return cmd->command() == LoadCommand::TYPE::BUILD_VERSION;
113 }
114
115 private:
116 PLATFORMS platform_ = PLATFORMS::UNKNOWN;
117 version_t minos_;
118 version_t sdk_;
119 tools_list_t tools_;
120};
121
123
124}
125}
126#endif
Definition BuildVersion.hpp:34
void minos(version_t version)
Definition BuildVersion.hpp:83
const tools_list_t & tools() const
Definition BuildVersion.hpp:101
BuildVersion & operator=(const BuildVersion &copy)=default
BuildVersion(const details::build_version_command &version_cmd)
PLATFORMS platform() const
Definition BuildVersion.hpp:94
std::ostream & print(std::ostream &os) const override
static bool classof(const LoadCommand *cmd)
Definition BuildVersion.hpp:111
void accept(Visitor &visitor) const override
~BuildVersion() override=default
version_t sdk() const
Definition BuildVersion.hpp:87
version_t minos() const
Definition BuildVersion.hpp:79
BuildVersion(const PLATFORMS platform, const version_t &minos, const version_t &sdk, const tools_list_t &tools)
void sdk(version_t version)
Definition BuildVersion.hpp:90
BuildVersion(const BuildVersion &copy)=default
std::unique_ptr< LoadCommand > clone() const override
Definition BuildVersion.hpp:75
PLATFORMS
Definition BuildVersion.hpp:44
void platform(PLATFORMS plat)
Definition BuildVersion.hpp:97
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:124
Definition endianness_support.hpp:59
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
@ UNKNOWN
Definition MachO/enums.hpp:25
const char * to_string(BuildToolVersion::TOOLS tool)
LIEF namespace.
Definition Abstract/Binary.hpp:36
PLATFORMS
Definition platforms.hpp:26
#define LIEF_API
Definition visibility.h:41