LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
OAT/Class.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_OAT_CLASS_H
17#define LIEF_OAT_CLASS_H
18
19#include "LIEF/iterators.hpp"
20#include "LIEF/OAT/enums.hpp"
21#include "LIEF/DEX/deopt.hpp"
22
23#include "LIEF/visibility.h"
24#include "LIEF/Object.hpp"
25
26
27namespace LIEF {
28namespace DEX {
29class Class;
30}
31namespace OAT {
32class Parser;
33class Method;
34
35class LIEF_API Class : public Object {
36 friend class Parser;
37
38 public:
39 using methods_t = std::vector<Method*>;
42
43 public:
44 Class();
45
46 Class(OAT_CLASS_STATUS status, OAT_CLASS_TYPES type,
47 DEX::Class* dex_class, std::vector<uint32_t> bitmap = {});
48
49 Class(const Class&);
50 Class& operator=(const Class&);
51
52 bool has_dex_class() const;
53 const DEX::Class* dex_class() const;
54 DEX::Class* dex_class();
55
56 OAT_CLASS_STATUS status() const;
57 OAT_CLASS_TYPES type() const;
58
59 const std::string& fullname() const;
60 size_t index() const;
61
62 it_methods methods();
63 it_const_methods methods() const;
64
65 const std::vector<uint32_t>& bitmap() const;
66
67 bool is_quickened(const DEX::Method& m) const;
68 bool is_quickened(uint32_t relative_index) const;
69
70 uint32_t method_offsets_index(const DEX::Method& m) const;
71 uint32_t method_offsets_index(uint32_t relative_index) const;
72
73 uint32_t relative_index(const DEX::Method& m) const;
74 uint32_t relative_index(uint32_t method_absolute_index) const;
75
76 DEX::dex2dex_class_info_t dex2dex_info() const;
77
78 void accept(Visitor& visitor) const override;
79
80
81 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Class& cls);
82
83 ~Class() override;
84
85 private:
86
87 DEX::Class* dex_class_ = nullptr;
88
89 OAT_CLASS_STATUS status_ = OAT_CLASS_STATUS::STATUS_NOTREADY;
90 OAT_CLASS_TYPES type_ = OAT_CLASS_TYPES::OAT_CLASS_NONE_COMPILED;
91
92 std::vector<uint32_t> method_bitmap_;
93 methods_t methods_;
94
95};
96
97} // Namespace OAT
98} // Namespace LIEF
99#endif
Class which represents a DEX Class (i.e. a Java/Kotlin class)
Definition DEX/Class.hpp:35
Class which represents a DEX::Method.
Definition DEX/Method.hpp:36
Definition OAT/Class.hpp:35
Class to parse an OAT file to produce an OAT::Binary.
Definition OAT/Parser.hpp:38
Definition Object.hpp:25
Definition Visitor.hpp:219
Iterator which returns reference on container's values.
Definition iterators.hpp:48
LIEF namespace.
Definition Abstract/Binary.hpp:32