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
ART
ART/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_ART_PARSER_H
17
#define LIEF_ART_PARSER_H
18
#include <string_view>
19
#include <memory>
20
#include <vector>
21
22
#include "
LIEF/ART/types.hpp
"
23
#include "
LIEF/path.hpp
"
24
#include "
LIEF/visibility.h
"
25
26
namespace
LIEF
{
27
class
BinaryStream
;
28
namespace
ART
{
29
class
File
;
30
31
33
class
LIEF_API
Parser
{
34
public
:
35
static
std::unique_ptr<File>
parse
(std::string_view file);
36
39
template
<
class
PathT, enable_if_path_t<PathT> = 0>
40
static
std::unique_ptr<File>
parse
(
const
PathT& file) {
41
return
parse
(file.string());
42
}
43
44
static
std::unique_ptr<File>
parse
(std::vector<uint8_t> data,
45
std::string_view name =
""
);
46
47
Parser
&
operator=
(
const
Parser
& copy) =
delete
;
48
Parser
(
const
Parser
& copy) =
delete
;
49
50
private
:
51
Parser
();
52
Parser
(std::string_view file);
53
Parser
(std::vector<uint8_t> data);
54
~Parser
();
55
56
void
init(std::string_view name,
art_version_t
version
);
57
58
template
<
typename
ART_T>
59
void
parse_file();
60
61
template
<
typename
ART_T>
62
size_t
parse_header();
63
64
template
<
typename
ART_T,
typename
PTR_T>
65
void
parse_sections();
66
67
template
<
typename
ART_T,
typename
PTR_T>
68
void
parse_roots();
69
70
template
<
typename
ART_T,
typename
PTR_T>
71
void
parse_methods();
72
73
// Section parsing
74
template
<
typename
ART_T,
typename
PTR_T>
75
void
parse_objects(
size_t
offset,
size_t
size);
76
77
template
<
typename
ART_T,
typename
PTR_T>
78
void
parse_art_fields(
size_t
offset,
size_t
size);
79
80
template
<
typename
ART_T,
typename
PTR_T>
81
void
parse_art_methods(
size_t
offset,
size_t
size);
82
83
template
<
typename
ART_T,
typename
PTR_T>
84
void
parse_interned_strings(
size_t
offset,
size_t
size);
85
86
// Parse an **Array** of java.lang.DexCache objects
87
template
<
typename
ART_T,
typename
PTR_T>
88
void
parse_dex_caches(
size_t
offset,
size_t
size);
89
90
// Parse a **Single** java.lang.DexCache object
91
template
<
typename
ART_T,
typename
PTR_T>
92
void
parse_dex_cache(
size_t
object_offset);
93
94
// Parse an **Array** of java.lang.Class objects
95
template
<
typename
ART_T,
typename
PTR_T>
96
void
parse_class_roots(
size_t
offset,
size_t
size);
97
98
// Parse java.lang.Class objects
99
template
<
typename
ART_T,
typename
PTR_T>
100
void
parse_class(
size_t
offset);
101
102
// Parse java.lang.String objects
103
template
<
typename
ART_T,
typename
PTR_T>
104
void
parse_jstring(
size_t
offset);
105
106
108
// template<typename ART_T, typename PTR_T>
109
// void parse_class_roots(size_t object_offset);
110
111
std::unique_ptr<File> file_;
112
std::unique_ptr<BinaryStream> stream_;
113
uint32_t imagebase_ = 0;
114
};
115
}
116
}
117
#endif
types.hpp
LIEF::ART::File
Definition
ART/File.hpp:29
LIEF::ART::Parser::parse
static std::unique_ptr< File > parse(std::string_view file)
LIEF::ART::Parser::parse
static std::unique_ptr< File > parse(const PathT &file)
Same as parse(std::string_view) but the file is given as a std::filesystem::path.
Definition
ART/Parser.hpp:40
LIEF::ART::Parser::operator=
Parser & operator=(const Parser ©)=delete
LIEF::ART::Parser::Parser
Parser(const Parser ©)=delete
LIEF::ART::Parser::parse
static std::unique_ptr< File > parse(std::vector< uint8_t > data, std::string_view name="")
LIEF::BinaryStream
Class that is used to a read stream of data from different sources.
Definition
BinaryStream.hpp:35
LIEF::ART
Definition
ART/enums.hpp:21
LIEF::ART::version
art_version_t version(std::string_view file)
Return the ART version of the given file.
LIEF::ART::art_version_t
uint32_t art_version_t
Definition
ART/types.hpp:24
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