LIEF: Library to Instrument Executable Formats Version 0.15.1
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:
39 using version_t = std::array<uint32_t, 3>;
40
41 using tools_list_t = std::vector<BuildToolVersion>;
42
43 public:
44 enum class PLATFORMS {
45 UNKNOWN = 0,
46 MACOS = 1,
47 IOS = 2,
48 TVOS = 3,
49 WATCHOS = 4,
50 };
51
52 public:
53 BuildVersion() = default;
54 BuildVersion(const details::build_version_command& version_cmd);
55 BuildVersion(const PLATFORMS platform,
56 const version_t &minos,
57 const version_t &sdk,
58 const tools_list_t &tools);
59
60 BuildVersion& operator=(const BuildVersion& copy) = default;
61 BuildVersion(const BuildVersion& copy) = default;
62
63 std::unique_ptr<LoadCommand> clone() const override {
64 return std::unique_ptr<BuildVersion>(new BuildVersion(*this));
65 }
66
67 version_t minos() const {
68 return minos_;
69 }
70
71 void minos(version_t version) {
72 minos_ = version;
73 }
74
75 version_t sdk() const {
76 return sdk_;
77 }
78 void sdk(version_t version) {
79 sdk_ = version;
80 }
81
83 return platform_;
84 }
85 void platform(PLATFORMS plat) {
86 platform_ = plat;
87 }
88
89 const tools_list_t& tools() const {
90 return tools_;
91 }
92
93 ~BuildVersion() override = default;
94
95 void accept(Visitor& visitor) const override;
96
97 std::ostream& print(std::ostream& os) const override;
98
99 static bool classof(const LoadCommand* cmd) {
100 return cmd->command() == LoadCommand::TYPE::BUILD_VERSION;
101 }
102
103 private:
104 PLATFORMS platform_ = PLATFORMS::UNKNOWN;
105 version_t minos_;
106 version_t sdk_;
107 tools_list_t tools_;
108};
109
111
112}
113}
114#endif
Class used to parse a single binary (i.e. non-FAT)
Definition BinaryParser.hpp:74
Definition BuildVersion.hpp:34
void minos(version_t version)
Definition BuildVersion.hpp:71
const tools_list_t & tools() const
Definition BuildVersion.hpp:89
BuildVersion & operator=(const BuildVersion &copy)=default
BuildVersion(const details::build_version_command &version_cmd)
std::vector< BuildToolVersion > tools_list_t
Definition BuildVersion.hpp:41
PLATFORMS platform() const
Definition BuildVersion.hpp:82
std::ostream & print(std::ostream &os) const override
static bool classof(const LoadCommand *cmd)
Definition BuildVersion.hpp:99
PLATFORMS
Definition BuildVersion.hpp:44
std::array< uint32_t, 3 > version_t
Version is an array of 3 integers.
Definition BuildVersion.hpp:39
void accept(Visitor &visitor) const override
~BuildVersion() override=default
version_t sdk() const
Definition BuildVersion.hpp:75
version_t minos() const
Definition BuildVersion.hpp:67
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:78
BuildVersion(const BuildVersion &copy)=default
std::unique_ptr< LoadCommand > clone() const override
Definition BuildVersion.hpp:63
void platform(PLATFORMS plat)
Definition BuildVersion.hpp:85
Based class for the Mach-O load commands.
Definition LoadCommand.hpp:36
LoadCommand::TYPE command() const
Command type.
Definition LoadCommand.hpp:122
Definition Visitor.hpp:224
const char * to_string(BuildToolVersion::TOOLS tool)
LIEF namespace.
Definition Abstract/Binary.hpp:32
PLATFORMS
Definition platforms.hpp:26
#define LIEF_API
Definition visibility.h:41