LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
java_structures.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_JAVA_STRUCTURES_H
17#define LIEF_ART_JAVA_STRUCTURES_H
18
19
20#include "LIEF/types.hpp"
21#include <cstdint>
22
23
25
26
28
30
31// ======================
32// Android 6.0.1 - ART 17
33// ======================
34
35
37namespace ART_17::Java {
38
39using heap_reference_t = uint32_t;
40
42 uint32_t x_rb_ptr;
43 uint32_t x_xpadding;
44};
45
46template<class T>
52
53template<>
58template<class T = no_brooks_read_barrier_t>
59struct ALIGNED_(4) jarray_t {
60 jobject_t<T> object;
61 int32_t length;
62 uint32_t* elements;
63};
64
65template<class T = no_brooks_read_barrier_t>
66struct ALIGNED_(4) jclass_t {
67 jobject_t<T> object;
68
69 heap_reference_t class_loader;
70 heap_reference_t component_type;
71 heap_reference_t dex_cache;
72 heap_reference_t dex_cache_strings;
73 heap_reference_t iftable;
75 heap_reference_t super_class;
76 heap_reference_t verify_error_class;
77 heap_reference_t vtable;
78
79 uint32_t access_flags;
80 uint64_t direct_methods;
81 uint64_t ifields;
82 uint64_t sfields;
83 uint64_t virtual_methods;
84 uint32_t class_size;
85 uint32_t clinit_thread_id;
86 int32_t dex_class_def_idx;
87 int32_t dex_type_idx;
88 uint32_t num_direct_methods;
89 uint32_t num_instance_fields;
90 uint32_t num_reference_instance_fields;
91 uint32_t num_reference_static_fields;
92 uint32_t num_static_fields;
93 uint32_t num_virtual_methods;
94 uint32_t object_size;
95 uint32_t primitive_type;
96 uint32_t reference_instance_offsets;
97 int32_t status;
98};
99
100template<class T = no_brooks_read_barrier_t>
101struct ALIGNED_(4) jstring_t {
102 jobject_t<T> object;
103 int32_t count;
104 uint32_t hash_code;
105 uint16_t* value;
106};
107
108template<class T = no_brooks_read_barrier_t>
109struct ALIGNED_(4) jdex_cache_t {
110 jobject_t<T> object;
111
113 heap_reference_t location;
114 heap_reference_t resolved_fields;
115 heap_reference_t resolved_methods;
116 heap_reference_t resolved_types;
117 heap_reference_t strings;
118 uint64_t dex_file;
119};
120
121
122} // Namespace Java
123// Namespace ART_17
124
125// ======================
126// Android 7.0.0 - ART 29
127// ======================
128
129
131namespace ART_29::Java {
134
135template<class T = no_brooks_read_barrier_t>
137
138template<class T = no_brooks_read_barrier_t>
139using jarray_t = ART_17::Java::jarray_t<T>;
140
141template<class T = no_brooks_read_barrier_t>
142struct ALIGNED_(4) jclass_t {
143 jobject_t<T> object;
144
145 heap_reference_t annotation_type; // ADDED in ART 29
146 heap_reference_t class_loader;
147 heap_reference_t component_type;
148 heap_reference_t dex_cache;
149 // heap_reference_t dex_cache_strings; // REMOVED in ART 29
150 heap_reference_t iftable;
151 heap_reference_t name;
152 heap_reference_t super_class;
153 heap_reference_t verify_error; // Type CHANGED from Class to Object
154 heap_reference_t vtable;
155
156 uint32_t access_flags;
157 uint64_t dex_cache_strings; // direct_methods REPLACED with dex_cache_string
158 uint64_t ifields;
159 uint64_t methods; // ADDED in ART 29
160 uint64_t sfields;
161 uint32_t class_flags; // virtual_methods REPLACED with class_flags
162 uint32_t class_size;
163 uint32_t clinit_thread_id;
164 int32_t dex_class_def_idx;
165 int32_t dex_type_idx;
166 // uint32_t num_direct_methods; // REMOVED in ART 29
167 // uint32_t num_instance_fields; // REMOVED in ART 29
168 uint32_t num_reference_instance_fields;
169 uint32_t num_reference_static_fields;
170 // uint32_t num_static_fields; // REMOVED in ART 29
171 // uint32_t num_virtual_methods; // REMOVED in ART 29
172 uint32_t object_size;
173 uint32_t primitive_type;
174 uint32_t reference_instance_offsets;
175 int32_t status;
176
177 uint16_t copied_methods_offset; // ADDED in ART 29
178 uint16_t virtual_methods_offset; // ADDED in ART 29
179};
180
181
182// No changes in jstring structure
183template<class T = no_brooks_read_barrier_t>
184using jstring_t = ART_17::Java::jstring_t<T>;
185
186template<class T = no_brooks_read_barrier_t>
187struct ALIGNED_(4) jdex_cache_t {
188 jobject_t<T> object;
189
191 heap_reference_t location;
192 uint64_t dex_file; // LOCATION CHANGED
193 uint64_t resolved_fields; // TYPE CHANGED from heap_reference_t to uint64_t
194 uint64_t resolved_methods; // TYPE CHANGED from heap_reference_t to uint64_t
195 uint64_t resolved_types; // TYPE CHANGED from heap_reference_t to uint64_t
196 uint64_t strings; // TYPE CHANGED from heap_reference_t to uint64_t
197 uint32_t num_resolved_fields; // ADDED in ART 29
198 uint32_t num_resolved_methods; // ADDED in ART 29
199 uint32_t num_resolved_types; // ADDED in ART 29
200 uint32_t num_strings; // ADDED in ART 29
201};
202
203
204} // Namespace Java
205// Namespace ART_29
206
207
208// ======================
209// Android 7.1.X - ART 30
210// ======================
211
212
214namespace ART_30::Java {
215
218
219template<class T = no_brooks_read_barrier_t>
221
222template<class T = no_brooks_read_barrier_t>
224
225template<class T = no_brooks_read_barrier_t>
226using jclass_t = ART_29::Java::jclass_t<T>;
227
228// No changes in jstring structure
229template<class T = no_brooks_read_barrier_t>
231
232// No changes in jdex_cache structure
233template<class T = no_brooks_read_barrier_t>
234using jdex_cache_t = ART_29::Java::jdex_cache_t<T>;
235
236} // Namespace Java
237// Namespace ART_30
238
239// ======================
240// Android 8.0.0 - ART 44
241// ======================
242
243
245namespace ART_44::Java {
246
247
250
251template<class T = no_brooks_read_barrier_t>
253
254template<class T = no_brooks_read_barrier_t>
256
257template<class T = no_brooks_read_barrier_t>
258struct ALIGNED_(4) jclass_t {
259 jobject_t<T> object;
260
261 // heap_reference_t annotation_type; // REMOVED in ART 44
262 heap_reference_t class_loader;
263 heap_reference_t component_type;
264 heap_reference_t dex_cache;
265 heap_reference_t ext_data; // ADDED in ART 44
266 heap_reference_t iftable;
267 heap_reference_t name;
268 heap_reference_t super_class;
269 // heap_reference_t verify_error; // REMOVED in ART 44
270 heap_reference_t vtable;
271
272 // uint32_t access_flags; // REMOVED in ART 44
273 // uint64_t dex_cache_strings; // REMOVED in ART 44
274 uint64_t ifields;
275 uint64_t methods;
276 uint64_t sfields;
277 uint32_t access_flags; // ADDED in ART 44
278 uint32_t class_flags;
279 uint32_t class_size;
280 uint32_t clinit_thread_id;
281 int32_t dex_class_def_idx;
282 int32_t dex_type_idx;
283 uint32_t num_reference_instance_fields;
284 uint32_t num_reference_static_fields;
285 uint32_t object_size;
286 uint32_t object_size_alloc_fast_path; // ADDED in ART 44
287 uint32_t primitive_type;
288 uint32_t reference_instance_offsets;
289 int32_t status;
290 uint16_t copied_methods_offset;
291 uint16_t virtual_methods_offset;
292};
293
294
295// No changes in jstring structure but string can be
296// encoded as as char16_t or char (compressed)
297// count[0] (LSB) == 1 ----> compressed
298// count[0] (LSB) == 0 ----> chat16_t
299template<class T = no_brooks_read_barrier_t>
301
302template<class T = no_brooks_read_barrier_t>
303struct ALIGNED_(4) jdex_cache_t {
304 jobject_t<T> object;
305
306 // heap_reference_t dex; // REMOVED in ART 44
307 heap_reference_t location;
308 uint32_t num_resolved_call_sites; // ADDED in ART 44 (related to DEX38 format)
309 uint64_t dex_file;
310 uint64_t resolved_call_sites; // ADDED in ART 44 (related to DEX38 format)
311 uint64_t resolved_fields;
312 uint64_t resolved_method_types; // ADDED in ART 44
313 uint64_t resolved_methods;
314 uint64_t resolved_types;
315 uint64_t strings;
316 uint32_t num_resolved_fields;
317 uint32_t num_resolved_methods_types; // ADDED in ART 44
318 uint32_t num_resolved_methods;
319 uint32_t num_resolved_types;
320 uint32_t num_strings;
321};
322
323
324} // Namespace Java
325// Namespace ART_44
326
327
328// ======================
329// Android 8.1.X - ART 46
330// ======================
331
332
334namespace ART_46::Java {
335
338
339template<class T = no_brooks_read_barrier_t>
341
342template<class T = no_brooks_read_barrier_t>
344
345template<class T = no_brooks_read_barrier_t>
346using jclass_t = ART_44::Java::jclass_t<T>;
347
348template<class T = no_brooks_read_barrier_t>
350
351template<class T = no_brooks_read_barrier_t>
352using jdex_cache_t = ART_44::Java::jdex_cache_t<T>;
353
354} // Namespace Java
355// Namespace ART_46
356
357// ======================
358// Android 9.0.0 - ART 66
359// ======================
360
361
363namespace ART_56::Java {
364
367
368template<class T = no_brooks_read_barrier_t>
370
371template<class T = no_brooks_read_barrier_t>
373
374template<class T = no_brooks_read_barrier_t>
376
377template<class T = no_brooks_read_barrier_t>
379
380template<class T = no_brooks_read_barrier_t>
382
383} // Namespace Java
384// Namespace ART_56
385
386}
387// Namespace ART
388// Namespace LIEF
389
390
391#endif
Namespace related to the Java part of ART 17.
Definition java_structures.hpp:37
uint32_t heap_reference_t
Definition java_structures.hpp:39
struct ALIGNED_(4) jarray_t
Definition java_structures.hpp:59
Namespace related to the Java part of ART 29.
Definition java_structures.hpp:131
ART_17::Java::jstring_t< T > jstring_t
Definition java_structures.hpp:184
struct ALIGNED_(4) jclass_t
Definition java_structures.hpp:142
ART_17::Java::jobject_t< T > jobject_t
Definition java_structures.hpp:136
ART_17::Java::jarray_t< T > jarray_t
Definition java_structures.hpp:139
ART_17::Java::brooks_read_barrier_t brooks_read_barrier_t
Definition java_structures.hpp:133
ART_17::Java::heap_reference_t heap_reference_t
Definition java_structures.hpp:132
Namespace related to the Java part of ART 30.
Definition java_structures.hpp:214
ART_29::Java::jstring_t< T > jstring_t
Definition java_structures.hpp:230
ART_29::Java::jdex_cache_t< T > jdex_cache_t
Definition java_structures.hpp:234
ART_29::Java::jarray_t< T > jarray_t
Definition java_structures.hpp:223
ART_29::Java::brooks_read_barrier_t brooks_read_barrier_t
Definition java_structures.hpp:217
ART_29::Java::jobject_t< T > jobject_t
Definition java_structures.hpp:220
ART_29::Java::heap_reference_t heap_reference_t
Definition java_structures.hpp:216
ART_29::Java::jclass_t< T > jclass_t
Definition java_structures.hpp:226
Namespace related to the Java part of ART 44.
Definition java_structures.hpp:245
ART_30::Java::jstring_t< T > jstring_t
Definition java_structures.hpp:300
ART_30::Java::heap_reference_t heap_reference_t
Definition java_structures.hpp:248
struct ALIGNED_(4) jclass_t
Definition java_structures.hpp:258
ART_30::Java::jobject_t< T > jobject_t
Definition java_structures.hpp:252
ART_30::Java::jarray_t< T > jarray_t
Definition java_structures.hpp:255
ART_30::Java::brooks_read_barrier_t brooks_read_barrier_t
Definition java_structures.hpp:249
Namespace related to the Java part of ART 46.
Definition java_structures.hpp:334
ART_44::Java::heap_reference_t heap_reference_t
Definition java_structures.hpp:336
ART_44::Java::jstring_t< T > jstring_t
Definition java_structures.hpp:349
ART_44::Java::jobject_t< T > jobject_t
Definition java_structures.hpp:340
ART_44::Java::jdex_cache_t< T > jdex_cache_t
Definition java_structures.hpp:352
ART_44::Java::jclass_t< T > jclass_t
Definition java_structures.hpp:346
ART_44::Java::brooks_read_barrier_t brooks_read_barrier_t
Definition java_structures.hpp:337
ART_44::Java::jarray_t< T > jarray_t
Definition java_structures.hpp:343
Namespace related to the Java part of ART 46.
Definition java_structures.hpp:363
ART_46::Java::jstring_t< T > jstring_t
Definition java_structures.hpp:378
ART_46::Java::jclass_t< T > jclass_t
Definition java_structures.hpp:375
ART_46::Java::jdex_cache_t< T > jdex_cache_t
Definition java_structures.hpp:381
ART_46::Java::jobject_t< T > jobject_t
Definition java_structures.hpp:369
ART_46::Java::jarray_t< T > jarray_t
Definition java_structures.hpp:372
ART_46::Java::brooks_read_barrier_t brooks_read_barrier_t
Definition java_structures.hpp:366
ART_46::Java::heap_reference_t heap_reference_t
Definition java_structures.hpp:365
Namespace related to the LIEF's ART module.
Definition java_structures.hpp:27
uint32_t x_rb_ptr
Definition java_structures.hpp:42
uint32_t x_xpadding
Definition java_structures.hpp:43
heap_reference_t klass
Definition java_structures.hpp:55
Definition java_structures.hpp:47
heap_reference_t klass
Definition java_structures.hpp:48
uint32_t monitor
Definition java_structures.hpp:49
T brooks_read_barrier
Definition java_structures.hpp:50
Definition java_structures.hpp:29