LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
BuildVersion.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 * Copyright 2017 - 2026 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 <array>
19#include <memory>
20#include <ostream>
21#include <vector>
22
23#include "LIEF/visibility.h"
24
27
28
29namespace LIEF::MachO {
30
31namespace details {
32struct build_version_command;
33}
34
36 friend class BinaryParser;
37
38 public:
40 using version_t = std::array<uint32_t, 3>;
41
42 using tools_list_t = std::vector<BuildToolVersion>;
43
44 public:
45 enum class PLATFORMS : uint32_t {
47 MACOS = 1,
48 IOS = 2,
49 TVOS = 3,
50 WATCHOS = 4,
51 BRIDGEOS = 5,
52 MAC_CATALYST = 6,
53 IOS_SIMULATOR = 7,
54 TVOS_SIMULATOR = 8,
55 WATCHOS_SIMULATOR = 9,
56 DRIVERKIT = 10,
57 VISIONOS = 11,
58 VISIONOS_SIMULATOR = 12,
59 FIRMWARE = 13,
60 SEPOS = 14,
61 MACOS_EXCLAVE_CORE = 15,
62 MACOS_EXCLAVE_KIT = 16,
63 IOS_EXCLAVE_CORE = 17,
64 IOS_EXCLAVE_KIT = 18,
65 TVOS_EXCLAVE_CORE = 19,
66 TVOS_EXCLAVE_KIT = 20,
67 WATCHOS_EXCLAVE_CORE = 21,
68 WATCHOS_EXCLAVE_KIT = 22,
69 VISIONOS_EXCLAVE_CORE = 23,
70 VISIONOS_EXCLAVE_KIT = 24,
71
72 ANY = 0xFFFFFFFF,
73 };
74
75 public:
76 BuildVersion() = default;
77 BuildVersion(const details::build_version_command& version_cmd);
79 const version_t& sdk, const tools_list_t& tools);
80
81 BuildVersion& operator=(const BuildVersion& copy) = default;
82 BuildVersion(const BuildVersion& copy) = default;
83
84 std::unique_ptr<LoadCommand> clone() const override {
85 return std::make_unique<BuildVersion>(*this);
86 }
87
88 version_t minos() const {
89 return minos_;
90 }
91
93 minos_ = version;
94 }
95
96 version_t sdk() const {
97 return sdk_;
98 }
100 sdk_ = version;
101 }
102
104 return platform_;
105 }
106 void platform(PLATFORMS plat) {
107 platform_ = plat;
108 }
109
110 const tools_list_t& tools() const {
111 return tools_;
112 }
113
114 ~BuildVersion() override = default;
115
116 void accept(Visitor& visitor) const override;
117
118 std::ostream& print(std::ostream& os) const override;
119
120 static bool classof(const LoadCommand* cmd) {
122 }
123
124 private:
125 PLATFORMS platform_ = PLATFORMS::UNKNOWN;
126 version_t minos_;
127 version_t sdk_;
128 tools_list_t tools_;
129};
130
132
133}
134
135#endif
void minos(version_t version)
Definition BuildVersion.hpp:92
const tools_list_t & tools() const
Definition BuildVersion.hpp:110
BuildVersion & operator=(const BuildVersion &copy)=default
BuildVersion(const details::build_version_command &version_cmd)
std::vector< BuildToolVersion > tools_list_t
Definition BuildVersion.hpp:42
PLATFORMS platform() const
Definition BuildVersion.hpp:103
std::ostream & print(std::ostream &os) const override
friend class BinaryParser
Definition BuildVersion.hpp:36
static bool classof(const LoadCommand *cmd)
Definition BuildVersion.hpp:120
std::array< uint32_t, 3 > version_t
Version is an array of 3 integers.
Definition BuildVersion.hpp:40
void accept(Visitor &visitor) const override
~BuildVersion() override=default
version_t sdk() const
Definition BuildVersion.hpp:96
version_t minos() const
Definition BuildVersion.hpp:88
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:99
BuildVersion(const BuildVersion &copy)=default
std::unique_ptr< LoadCommand > clone() const override
Definition BuildVersion.hpp:84
PLATFORMS
Definition BuildVersion.hpp:45
void platform(PLATFORMS plat)
Definition BuildVersion.hpp:106
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:132
@ BUILD_VERSION
Definition LoadCommand.hpp:99
Definition Visitor.hpp:212
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_version_t version()
Return the current version.
PLATFORMS
Definition platforms.hpp:35
#define LIEF_API
Definition visibility.h:45