LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
AndroidIdent.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_ELF_ANDROID_IDENT_H
17#define LIEF_ELF_ANDROID_IDENT_H
18
19#include <ostream>
20#include <memory>
21
22#include "LIEF/visibility.h"
23#include "LIEF/ELF/Note.hpp"
24
25namespace LIEF {
26namespace ELF {
27class LIEF_API AndroidIdent : public Note {
32 public:
33 static constexpr size_t sdk_version_size = sizeof(uint32_t);
34 static constexpr size_t ndk_version_size = 64 * sizeof(char);
35 static constexpr size_t ndk_build_number_size = 64 * sizeof(char);
36
37 public:
38 std::unique_ptr<Note> clone() const override {
39 return std::unique_ptr<AndroidIdent>(new AndroidIdent(*this));
40 }
41 uint32_t sdk_version() const;
44 std::string ndk_version() const;
47 std::string ndk_build_number() const;
50
51 void sdk_version(uint32_t version);
52 void ndk_version(const std::string& ndk_version);
53 void ndk_build_number(const std::string& ndk_build_number);
54
55 void dump(std::ostream& os) const override;
56
57 void accept(Visitor& visitor) const override;
58
59 static bool classof(const Note* note) {
60 return note->type() == Note::TYPE::ANDROID_IDENT;
61 }
62
63 ~AndroidIdent() override = default;
64
65 static constexpr size_t description_size() {
66 return sdk_version_size + ndk_version_size + ndk_build_number_size;
67 }
68
69 LIEF_API friend
70 std::ostream& operator<<(std::ostream& os, const AndroidIdent& note) {
71 note.dump(os);
72 return os;
73 }
74 protected:
75 using Note::Note;
76};
77
78
79} // namepsace ELF
80} // namespace LIEF
81
82#endif
Class representing the ".note.android.ident" section.
Definition AndroidIdent.hpp:31
std::unique_ptr< Note > clone() const override
Clone the current note and keep its polymorphic type.
Definition AndroidIdent.hpp:38
std::string ndk_build_number() const
NDK build number (or an empty string if it can't be parsed)
~AndroidIdent() override=default
std::string ndk_version() const
NDK version used (or an empty string if it can't be parsed)
static constexpr size_t description_size()
Definition AndroidIdent.hpp:65
void ndk_version(const std::string &ndk_version)
friend std::ostream & operator<<(std::ostream &os, const AndroidIdent &note)
Definition AndroidIdent.hpp:70
void dump(std::ostream &os) const override
static bool classof(const Note *note)
Definition AndroidIdent.hpp:59
void accept(Visitor &visitor) const override
void ndk_build_number(const std::string &ndk_build_number)
uint32_t sdk_version() const
Target SDK version (or 0 if it can't be resolved)
void sdk_version(uint32_t version)
Class which represents an ELF note. This class can be instantiated using the static Note::create func...
Definition Note.hpp:39
TYPE type() const
Return the type of the note. This type does not match the NT_ type value. For accessing the original ...
Definition Note.hpp:195
Namespace related to the LIEF's ELF module.
Definition Abstract/Header.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41