LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
ART/Parser.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_ART_PARSER_H
17#define LIEF_ART_PARSER_H
18#include <memory>
19#include <vector>
20
21#include "LIEF/ART/types.hpp"
22#include "LIEF/visibility.h"
23
24namespace LIEF {
25class BinaryStream;
26namespace ART {
27class File;
28
29
32 public:
33 static std::unique_ptr<File> parse(const std::string& file);
34 static std::unique_ptr<File> parse(std::vector<uint8_t> data, const std::string& name = "");
35
36 Parser& operator=(const Parser& copy) = delete;
37 Parser(const Parser& copy) = delete;
38
39 private:
40 Parser();
41 Parser(const std::string& file);
42 Parser(std::vector<uint8_t> data);
43 virtual ~Parser();
44
45 void init(const std::string& name, art_version_t version);
46
47 template<typename ART_T>
48 void parse_file();
49
50 template<typename ART_T>
51 size_t parse_header();
52
53 template<typename ART_T, typename PTR_T>
54 void parse_sections();
55
56 template<typename ART_T, typename PTR_T>
57 void parse_roots();
58
59 template<typename ART_T, typename PTR_T>
60 void parse_methods();
61
62 // Section parsing
63 template<typename ART_T, typename PTR_T>
64 void parse_objects(size_t offset, size_t size);
65
66 template<typename ART_T, typename PTR_T>
67 void parse_art_fields(size_t offset, size_t size);
68
69 template<typename ART_T, typename PTR_T>
70 void parse_art_methods(size_t offset, size_t size);
71
72 template<typename ART_T, typename PTR_T>
73 void parse_interned_strings(size_t offset, size_t size);
74
75 // Parse an **Array** of java.lang.DexCache objects
76 template<typename ART_T, typename PTR_T>
77 void parse_dex_caches(size_t offset, size_t size);
78
79 // Parse a **Single** java.lang.DexCache object
80 template<typename ART_T, typename PTR_T>
81 void parse_dex_cache(size_t object_offset);
82
83 // Parse an **Array** of java.lang.Class objects
84 template<typename ART_T, typename PTR_T>
85 void parse_class_roots(size_t offset, size_t size);
86
87 // Parse java.lang.Class objects
88 template<typename ART_T, typename PTR_T>
89 void parse_class(size_t offset);
90
91 // Parse java.lang.String objects
92 template<typename ART_T, typename PTR_T>
93 void parse_jstring(size_t offset);
94
95
97 //template<typename ART_T, typename PTR_T>
98 //void parse_class_roots(size_t object_offset);
99
100 std::unique_ptr<File> file_;
101 std::unique_ptr<BinaryStream> stream_;
102 uint32_t imagebase_ = 0;
103};
104} // namespace ART
105} // namespace LIEF
106#endif
Class which parses an ART file and transform into a ART::File object.
Definition ART/Parser.hpp:31
static std::unique_ptr< File > parse(std::vector< uint8_t > data, const std::string &name="")
Parser & operator=(const Parser &copy)=delete
static std::unique_ptr< File > parse(const std::string &file)
Parser(const Parser &copy)=delete
uint32_t art_version_t
Definition ART/types.hpp:26
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41