LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
OAT/Method.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_METHOD_H
17#define LIEF_OAT_METHOD_H
18
19#include <vector>
20#include <string>
21#include <ostream>
22#include "LIEF/visibility.h"
23#include "LIEF/Object.hpp"
24#include "LIEF/DEX/deopt.hpp"
25
26namespace LIEF {
27namespace DEX {
28class Method;
29}
30namespace OAT {
31class Parser;
32class Class;
33
34class LIEF_API Method : public Object {
35 friend class Parser;
36 public:
37
39 using quick_code_t = std::vector<uint8_t>;
40
41 public:
42 Method();
43 Method(DEX::Method* method, Class* oat_class, std::vector<uint8_t> code = {});
44 Method(const Method&);
45 Method& operator=(const Method&);
46
47
49 std::string name() const;
50
52 const Class* oat_class() const;
53 Class* oat_class();
54
57 bool has_dex_method() const;
58
60 const DEX::Method* dex_method() const;
61 DEX::Method* dex_method();
62
65
66 // True if the optimization is native
67 bool is_compiled() const;
68
69 const DEX::dex2dex_method_info_t& dex2dex_info() const;
70
72 const quick_code_t& quick_code() const;
73 void quick_code(const quick_code_t& code);
74
75 void accept(Visitor& visitor) const override;
76
77
78 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Method& meth);
79
80 ~Method() override;
81
82 private:
83 DEX::Method* dex_method_ = nullptr;
84 Class* class_ = nullptr;
85
86 quick_code_t quick_code_;
87};
88
89} // Namespace OAT
90} // Namespace LIEF
91#endif
Class which represents a DEX::Method.
Definition DEX/Method.hpp:36
Definition OAT/Class.hpp:35
Definition OAT/Method.hpp:34
std::vector< uint8_t > quick_code_t
Container for the Quick Code.
Definition OAT/Method.hpp:39
bool has_dex_method() const
Check if a LIEF::DEX::Method is associated with this Method.
const DEX::Method * dex_method() const
LIEF::DEX::Method associated (if any)
bool is_dex2dex_optimized() const
True if the optimization is DEX.
std::string name() const
Method's name.
const Class * oat_class() const
OAT Class associated with this Method.
const quick_code_t & quick_code() const
Quick code associated with the method.
Class to parse an OAT file to produce an OAT::Binary.
Definition OAT/Parser.hpp:38
Definition Object.hpp:25
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32