LIEF: Library to Instrument Executable Formats
Version 2.0.0
Toggle main menu visibility
Loading...
Searching...
No Matches
lief-install
x86_64
static
include
LIEF
OAT
OAT/Parser.hpp
Go to the documentation of this file.
1
/* Copyright 2017 - 2026 R. Thomas
2
* Copyright 2017 - 2026 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_PARSER_H
17
#define LIEF_OAT_PARSER_H
18
#include <string_view>
19
#include <cstdint>
20
#include <memory>
21
22
#include "
LIEF/ELF/Parser.hpp
"
23
#include "
LIEF/errors.hpp
"
24
#include "
LIEF/path.hpp
"
25
#include "
LIEF/visibility.h
"
26
27
namespace
LIEF
{
28
29
namespace
VDEX
{
30
class
File
;
31
}
32
33
namespace
DEX
{
34
class
Class
;
35
}
36
37
namespace
OAT
{
38
class
Binary
;
39
class
Class
;
40
42
class
LIEF_API
Parser
:
public
ELF::Parser
{
43
public
:
45
static
std::unique_ptr<Binary>
parse
(std::string_view oat_file);
46
static
std::unique_ptr<Binary>
parse
(std::string_view oat_file,
47
std::string_view vdex_file);
48
51
template
<
class
PathT, enable_if_path_t<PathT> = 0>
52
static
std::unique_ptr<Binary>
parse
(
const
PathT& oat_file) {
53
return
parse
(oat_file.string());
54
}
55
58
template
<
class
OatT,
class
VdexT, enable_if_path_t<OatT, VdexT> = 0>
59
static
std::unique_ptr<Binary>
parse
(
const
OatT& oat_file,
60
const
VdexT& vdex_file) {
61
return
parse
(std::filesystem::path(oat_file).
string
(),
62
std::filesystem::path(vdex_file).
string
());
63
}
64
65
static
std::unique_ptr<Binary>
parse
(std::vector<uint8_t> data);
66
67
Parser
&
operator=
(
const
Parser
& copy) =
delete
;
68
Parser
(
const
Parser
& copy) =
delete
;
69
70
protected
:
71
Parser
();
72
Parser
(std::string_view oat_file);
73
Parser
(std::vector<uint8_t> data);
74
~Parser
();
75
76
Binary
& oat_binary() {
77
// The type of the parent binary_ is guaranteed by the constructor
78
return
*
reinterpret_cast<
Binary
*
>
(binary_.get());
79
}
80
81
bool
has_vdex()
const
;
82
void
set_vdex(std::unique_ptr<VDEX::File> file);
83
84
template
<
typename
OAT_T>
85
void
parse_binary();
86
87
template
<
typename
OAT_T>
88
void
parse_header();
89
90
template
<
typename
OAT_T>
91
void
parse_header_keys();
92
93
template
<
typename
OAT_T>
94
void
parse_dex_files();
95
96
template
<
typename
OAT_T>
97
void
parse_type_lookup_table();
98
99
template
<
typename
OAT_T>
100
void
parse_oat_classes();
101
102
template
<
typename
OAT_T>
103
void
parse_oat_methods(uint64_t methods_offsets,
Class
& clazz,
104
const
DEX::Class
& dex_class);
105
106
void
init();
107
108
result<uint64_t>
oat_data_exec_gap()
const
;
109
110
std::unique_ptr<LIEF::VDEX::File> vdex_file_;
111
112
uint64_t data_address_ = 0;
113
uint64_t data_size_ = 0;
114
115
uint64_t exec_start_ = 0;
116
uint64_t exec_size_ = 0;
117
};
118
119
}
120
}
121
#endif
Parser.hpp
LIEF::DEX::Class
Class which represents a DEX Class (i.e. a Java/Kotlin class).
Definition
DEX/Class.hpp:37
LIEF::ELF::Parser
Class which parses and transforms an ELF file into a ELF::Binary object.
Definition
ELF/Parser.hpp:47
LIEF::OAT::Binary
Definition
OAT/Binary.hpp:41
LIEF::OAT::Class
Definition
OAT/Class.hpp:36
LIEF::OAT::Parser::parse
static std::unique_ptr< Binary > parse(std::string_view oat_file)
Parse an OAT file.
LIEF::OAT::Parser::parse
static std::unique_ptr< Binary > parse(const OatT &oat_file, const VdexT &vdex_file)
Same as parse(std::string_view, std::string_view) but at least one of the files is given as a std::fi...
Definition
OAT/Parser.hpp:59
LIEF::OAT::Parser::parse
static std::unique_ptr< Binary > parse(std::vector< uint8_t > data)
LIEF::OAT::Parser::operator=
Parser & operator=(const Parser ©)=delete
LIEF::OAT::Parser::parse
static std::unique_ptr< Binary > parse(const PathT &oat_file)
Same as parse(std::string_view) but the file is given as a std::filesystem::path.
Definition
OAT/Parser.hpp:52
LIEF::OAT::Parser::Parser
Parser(const Parser ©)=delete
LIEF::OAT::Parser::parse
static std::unique_ptr< Binary > parse(std::string_view oat_file, std::string_view vdex_file)
LIEF::VDEX::File
Main class for the VDEX module which represents a VDEX file.
Definition
VDEX/File.hpp:42
LIEF::result
Wrapper that contains an Object (T) or an error.
Definition
errors.hpp:79
errors.hpp
LIEF::DEX
Definition
DEX/Class.hpp:31
LIEF::OAT
Definition
ELF/Parser.hpp:34
LIEF::VDEX
Definition
OAT/Binary.hpp:31
LIEF
LIEF namespace.
Definition
Abstract/Binary.hpp:41
path.hpp
visibility.h
LIEF_API
#define LIEF_API
Definition
visibility.h:45
Generated by
1.18.0