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