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