LIEF: Library to Instrument Executable Formats Version 0.17.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 MACOS_EXCLAVE_CORE = 15,
61 MACOS_EXCLAVE_KIT = 16,
62 IOS_EXCLAVE_CORE = 17,
63 IOS_EXCLAVE_KIT = 18,
64 TVOS_EXCLAVE_CORE = 19,
65 TVOS_EXCLAVE_KIT = 20,
66
67 ANY = 0xFFFFFFFF
68 };
69
70 public:
71 BuildVersion() = default;
72 BuildVersion(const details::build_version_command& version_cmd);
73 BuildVersion(const PLATFORMS platform,
74 const version_t &minos,
75 const version_t &sdk,
76 const tools_list_t &tools);
77
78 BuildVersion& operator=(const BuildVersion& copy) = default;
79 BuildVersion(const BuildVersion& copy) = default;
80
81 std::unique_ptr<LoadCommand> clone() const override {
82 return std::unique_ptr<BuildVersion>(new BuildVersion(*this));
83 }
84
85 version_t minos() const {
86 return minos_;
87 }
88
89 void minos(version_t version) {
90 minos_ = version;
91 }
92
93 version_t sdk() const {
94 return sdk_;
95 }
96 void sdk(version_t version) {
97 sdk_ = version;
98 }
99
101 return platform_;
102 }
103 void platform(PLATFORMS plat) {
104 platform_ = plat;
105 }
106
107 const tools_list_t& tools() const {
108 return tools_;
109 }
110
111 ~BuildVersion() override = default;
112
113 void accept(Visitor& visitor) const override;
114
115 std::ostream& print(std::ostream& os) const override;
116
117 static bool classof(const LoadCommand* cmd) {
118 return cmd->command() == LoadCommand::TYPE::BUILD_VERSION;
119 }
120
121 private:
122 PLATFORMS platform_ = PLATFORMS::UNKNOWN;
123 version_t minos_;
124 version_t sdk_;
125 tools_list_t tools_;
126};
127
129
130}
131}
132#endif
Definition BuildVersion.hpp:34
void minos(version_t version)
Definition BuildVersion.hpp:89
const tools_list_t & tools() const
Definition BuildVersion.hpp:107
BuildVersion & operator=(const BuildVersion &copy)=default
BuildVersion(const details::build_version_command &version_cmd)
PLATFORMS platform() const
Definition BuildVersion.hpp:100
std::ostream & print(std::ostream &os) const override
static bool classof(const LoadCommand *cmd)
Definition BuildVersion.hpp:117
void accept(Visitor &visitor) const override
~BuildVersion() override=default
version_t sdk() const
Definition BuildVersion.hpp:93
version_t minos() const
Definition BuildVersion.hpp:85
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:96
BuildVersion(const BuildVersion &copy)=default
std::unique_ptr< LoadCommand > clone() const override
Definition BuildVersion.hpp:81
PLATFORMS
Definition BuildVersion.hpp:44
void platform(PLATFORMS plat)
Definition BuildVersion.hpp:103
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:37
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:125
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