LIEF: Library to Instrument Executable Formats
Version 0.17.4
Toggle main menu visibility
Loading...
Searching...
No Matches
install
linux
x86_64
sdk
static
include
LIEF
DEX
DEX/Parser.hpp
Go to the documentation of this file.
1
/* Copyright 2017 - 2025 R. Thomas
2
* Copyright 2017 - 2025 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_DEX_PARSER_H
17
#define LIEF_DEX_PARSER_H
18
19
#include <memory>
20
#include <vector>
21
#include <string>
22
#include <unordered_map>
23
24
#include "
LIEF/visibility.h
"
25
#include "
LIEF/DEX/types.hpp
"
26
27
namespace
LIEF
{
28
class
VectorStream
;
29
30
namespace
DEX
{
31
class
Class
;
32
class
Method
;
33
class
Field
;
34
class
File
;
35
class
Type
;
36
38
class
LIEF_API
Parser
{
39
public
:
40
42
static
std::unique_ptr<File>
parse
(
const
std::string& file);
43
static
std::unique_ptr<File>
parse
(std::vector<uint8_t> data,
const
std::string& name =
""
);
44
45
Parser
&
operator=
(
const
Parser
& copy) =
delete
;
46
Parser
(
const
Parser
& copy) =
delete
;
47
48
private
:
49
Parser
();
50
Parser
(
const
std::string& file);
51
Parser
(std::vector<uint8_t> data);
52
~Parser
();
53
54
void
init(
const
std::string& name,
dex_version_t
version
);
55
56
template
<
typename
DEX_T>
57
void
parse_file();
58
59
template
<
typename
DEX_T>
60
void
parse_header();
61
62
template
<
typename
DEX_T>
63
void
parse_map();
64
65
template
<
typename
DEX_T>
66
void
parse_strings();
67
68
template
<
typename
DEX_T>
69
void
parse_types();
70
71
template
<
typename
DEX_T>
72
void
parse_fields();
73
74
template
<
typename
DEX_T>
75
void
parse_prototypes();
76
77
template
<
typename
DEX_T>
78
void
parse_methods();
79
80
template
<
typename
DEX_T>
81
void
parse_classes();
82
83
template
<
typename
DEX_T>
84
void
parse_class_data(uint32_t offset,
Class
& cls);
85
86
template
<
typename
DEX_T>
87
void
parse_field(
size_t
index,
Class
& cls,
bool
is_static);
88
89
template
<
typename
DEX_T>
90
void
parse_method(
size_t
index,
Class
& cls,
bool
is_virtual);
91
92
template
<
typename
DEX_T>
93
void
parse_code_info(uint32_t offset,
Method
& method);
94
95
void
resolve_inheritance();
96
97
void
resolve_external_methods();
98
99
void
resolve_external_fields();
100
101
void
resolve_types();
102
103
std::unique_ptr<File> file_;
104
105
// Map of inheritance relationship when parsing classes ('parse_classes')
106
// The key is the parent class name of the value
107
std::unordered_multimap<std::string, Class*> inheritance_;
108
109
// Map of method/class relationship when parsing methods ('parse_methods')
110
// The key is the Class name in which the method is defined
111
std::unordered_multimap<std::string, Method*> class_method_map_;
112
113
// Map of field/class relationship when parsing fields ('parse_fields')
114
// The key is the Class name in which the field is defined
115
std::unordered_multimap<std::string, Field*> class_field_map_;
116
117
std::unordered_multimap<std::string, Type*> class_type_map_;
118
119
std::unique_ptr<VectorStream> stream_;
120
};
121
122
}
// namespace DEX
123
}
// namespace LIEF
124
#endif
types.hpp
LIEF::DEX::Class
Class which represents a DEX Class (i.e. a Java/Kotlin class).
Definition
DEX/Class.hpp:36
LIEF::DEX::Field
Class which represent a DEX Field.
Definition
Field.hpp:34
LIEF::DEX::File
Class that represents a DEX file.
Definition
DEX/File.hpp:39
LIEF::DEX::Method
Class which represents a DEX::Method.
Definition
DEX/Method.hpp:36
LIEF::DEX::Parser::parse
static std::unique_ptr< File > parse(std::vector< uint8_t > data, const std::string &name="")
LIEF::DEX::Parser::parse
static std::unique_ptr< File > parse(const std::string &file)
Parse the DEX file from the file path given in parameter.
LIEF::DEX::Parser::Parser
Parser(const Parser ©)=delete
LIEF::DEX::Parser::operator=
Parser & operator=(const Parser ©)=delete
LIEF::DEX::Type
Class which represents a DEX type as described in the format specifications: https://source....
Definition
DEX/Type.hpp:33
LIEF::VectorStream
Definition
VectorStream.hpp:29
LIEF::DEX
Definition
DEX/Class.hpp:30
LIEF::DEX::version
dex_version_t version(const std::string &file)
Return the DEX version of the given file.
LIEF::DEX::dex_version_t
uint32_t dex_version_t
Definition
DEX/types.hpp:23
LIEF
LIEF namespace.
Definition
Abstract/Binary.hpp:40
visibility.h
LIEF_API
#define LIEF_API
Definition
visibility.h:41
Generated by
1.17.0