Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fbe4da5

Browse filesBrowse files
joyeecheungaduh95
authored andcommitted
deps: add LIEF as a dependency
PR-URL: #61167 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 0feab0f commit fbe4da5
Copy full SHA for fbe4da5

1,374 files changed

+480,633Lines changed: 480633 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎deps/LIEF/config/mbedtls/config.h‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include "mbedtls/mbedtls_config.h"
2+
3+
#if defined (MBEDTLS_ARCH_IS_X86)
4+
#undef MBEDTLS_AESNI_C
5+
#endif
Collapse file

‎deps/LIEF/include/LIEF/ART.hpp‎

Copy file name to clipboard
+28Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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_ART_H
17+
#define LIEF_ART_H
18+
19+
#include "LIEF/config.h"
20+
21+
#if defined(LIEF_ART_SUPPORT)
22+
#include "LIEF/ART/Parser.hpp"
23+
#include "LIEF/ART/utils.hpp"
24+
#include "LIEF/ART/File.hpp"
25+
#include "LIEF/ART/EnumToString.hpp"
26+
#endif
27+
28+
#endif
Collapse file
+40Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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_ART_ENUM_TO_STRING_H
17+
#define LIEF_ART_ENUM_TO_STRING_H
18+
#include "LIEF/visibility.h"
19+
#include "LIEF/ART/enums.hpp"
20+
21+
namespace LIEF {
22+
namespace ART {
23+
24+
LIEF_API const char* to_string(STORAGE_MODES e);
25+
26+
LIEF_API const char* to_string(ART_17::IMAGE_SECTIONS e);
27+
LIEF_API const char* to_string(ART_29::IMAGE_SECTIONS e);
28+
LIEF_API const char* to_string(ART_30::IMAGE_SECTIONS e);
29+
30+
LIEF_API const char* to_string(ART_17::IMAGE_METHODS e);
31+
LIEF_API const char* to_string(ART_44::IMAGE_METHODS e);
32+
33+
LIEF_API const char* to_string(ART_17::IMAGE_ROOTS e);
34+
LIEF_API const char* to_string(ART_44::IMAGE_ROOTS e);
35+
36+
} // namespace ART
37+
} // namespace LIEF
38+
39+
#endif
40+
Collapse file
+55Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
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_ART_FILE_H
17+
#define LIEF_ART_FILE_H
18+
#include <ostream>
19+
20+
#include "LIEF/ART/Header.hpp"
21+
22+
#include "LIEF/visibility.h"
23+
#include "LIEF/Object.hpp"
24+
25+
namespace LIEF {
26+
namespace ART {
27+
class Parser;
28+
29+
class LIEF_API File : public Object {
30+
friend class Parser;
31+
32+
public:
33+
File& operator=(const File& copy) = delete;
34+
File(const File& copy) = delete;
35+
36+
const Header& header() const;
37+
Header& header();
38+
39+
void accept(Visitor& visitor) const override;
40+
41+
42+
~File() override;
43+
44+
LIEF_API friend std::ostream& operator<<(std::ostream& os, const File& art_file);
45+
46+
private:
47+
File();
48+
49+
Header header_;
50+
};
51+
52+
}
53+
}
54+
55+
#endif
Collapse file
+130Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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_ART_HEADER_H
17+
#define LIEF_ART_HEADER_H
18+
19+
#include <array>
20+
#include <cstdint>
21+
22+
#include "LIEF/ART/types.hpp"
23+
#include "LIEF/ART/enums.hpp"
24+
25+
#include "LIEF/visibility.h"
26+
#include "LIEF/Object.hpp"
27+
28+
namespace LIEF {
29+
namespace ART {
30+
class Parser;
31+
32+
class LIEF_API Header : public Object {
33+
friend class Parser;
34+
35+
public:
36+
using magic_t = std::array<uint8_t, 4>;
37+
38+
Header();
39+
40+
template<class T>
41+
LIEF_LOCAL Header(const T* header);
42+
43+
Header(const Header&);
44+
Header& operator=(const Header&);
45+
46+
magic_t magic() const;
47+
art_version_t version() const;
48+
49+
uint32_t image_begin() const;
50+
uint32_t image_size() const;
51+
52+
uint32_t oat_checksum() const;
53+
54+
uint32_t oat_file_begin() const;
55+
uint32_t oat_file_end() const;
56+
57+
uint32_t oat_data_begin() const;
58+
uint32_t oat_data_end() const;
59+
60+
int32_t patch_delta() const;
61+
62+
uint32_t image_roots() const;
63+
64+
uint32_t pointer_size() const;
65+
bool compile_pic() const;
66+
67+
uint32_t nb_sections() const;
68+
uint32_t nb_methods() const;
69+
70+
uint32_t boot_image_begin() const;
71+
uint32_t boot_image_size() const;
72+
73+
uint32_t boot_oat_begin() const;
74+
uint32_t boot_oat_size() const;
75+
76+
STORAGE_MODES storage_mode() const;
77+
78+
uint32_t data_size() const;
79+
80+
void accept(Visitor& visitor) const override;
81+
82+
83+
LIEF_API friend std::ostream& operator<<(std::ostream& os, const Header& hdr);
84+
85+
~Header() override;
86+
87+
private:
88+
magic_t magic_;
89+
art_version_t version_;
90+
91+
uint32_t image_begin_;
92+
uint32_t image_size_;
93+
94+
uint32_t oat_checksum_;
95+
96+
uint32_t oat_file_begin_;
97+
uint32_t oat_file_end_;
98+
99+
uint32_t oat_data_begin_;
100+
uint32_t oat_data_end_;
101+
102+
int32_t patch_delta_;
103+
uint32_t image_roots_;
104+
105+
uint32_t pointer_size_;
106+
107+
bool compile_pic_;
108+
109+
uint32_t nb_sections_;
110+
uint32_t nb_methods_;
111+
112+
bool is_pic_;
113+
114+
// From ART 29
115+
// ===========
116+
uint32_t boot_image_begin_;
117+
uint32_t boot_image_size_;
118+
119+
uint32_t boot_oat_begin_;
120+
uint32_t boot_oat_size_;
121+
122+
STORAGE_MODES storage_mode_;
123+
124+
uint32_t data_size_;
125+
};
126+
127+
} // Namespace ART
128+
} // Namespace LIEF
129+
130+
#endif
Collapse file
+107Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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_ART_PARSER_H
17+
#define LIEF_ART_PARSER_H
18+
#include <memory>
19+
#include <vector>
20+
#include <string>
21+
22+
#include "LIEF/ART/types.hpp"
23+
#include "LIEF/visibility.h"
24+
25+
namespace LIEF {
26+
class BinaryStream;
27+
namespace ART {
28+
class File;
29+
30+
31+
/// Class which parses an ART file and transform into a ART::File object
32+
class LIEF_API Parser {
33+
public:
34+
static std::unique_ptr<File> parse(const std::string& file);
35+
static std::unique_ptr<File> parse(std::vector<uint8_t> data, const std::string& name = "");
36+
37+
Parser& operator=(const Parser& copy) = delete;
38+
Parser(const Parser& copy) = delete;
39+
40+
private:
41+
Parser();
42+
Parser(const std::string& file);
43+
Parser(std::vector<uint8_t> data);
44+
virtual ~Parser();
45+
46+
void init(const std::string& name, art_version_t version);
47+
48+
template<typename ART_T>
49+
void parse_file();
50+
51+
template<typename ART_T>
52+
size_t parse_header();
53+
54+
template<typename ART_T, typename PTR_T>
55+
void parse_sections();
56+
57+
template<typename ART_T, typename PTR_T>
58+
void parse_roots();
59+
60+
template<typename ART_T, typename PTR_T>
61+
void parse_methods();
62+
63+
// Section parsing
64+
template<typename ART_T, typename PTR_T>
65+
void parse_objects(size_t offset, size_t size);
66+
67+
template<typename ART_T, typename PTR_T>
68+
void parse_art_fields(size_t offset, size_t size);
69+
70+
template<typename ART_T, typename PTR_T>
71+
void parse_art_methods(size_t offset, size_t size);
72+
73+
template<typename ART_T, typename PTR_T>
74+
void parse_interned_strings(size_t offset, size_t size);
75+
76+
// Parse an **Array** of java.lang.DexCache objects
77+
template<typename ART_T, typename PTR_T>
78+
void parse_dex_caches(size_t offset, size_t size);
79+
80+
// Parse a **Single** java.lang.DexCache object
81+
template<typename ART_T, typename PTR_T>
82+
void parse_dex_cache(size_t object_offset);
83+
84+
// Parse an **Array** of java.lang.Class objects
85+
template<typename ART_T, typename PTR_T>
86+
void parse_class_roots(size_t offset, size_t size);
87+
88+
// Parse java.lang.Class objects
89+
template<typename ART_T, typename PTR_T>
90+
void parse_class(size_t offset);
91+
92+
// Parse java.lang.String objects
93+
template<typename ART_T, typename PTR_T>
94+
void parse_jstring(size_t offset);
95+
96+
97+
//// Parse a **Single** java.lang.DexCache object
98+
//template<typename ART_T, typename PTR_T>
99+
//void parse_class_roots(size_t object_offset);
100+
101+
std::unique_ptr<File> file_;
102+
std::unique_ptr<BinaryStream> stream_;
103+
uint32_t imagebase_ = 0;
104+
};
105+
} // namespace ART
106+
} // namespace LIEF
107+
#endif

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.