LIEF: Library to Instrument Executable Formats Version 0.15.0
Loading...
Searching...
No Matches
DexFile.hpp
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_OAT_DEXFILE_H
17#define LIEF_OAT_DEXFILE_H
18
19#include <cstdint>
20#include <string>
21#include <vector>
22
23#include "LIEF/visibility.h"
24#include "LIEF/Object.hpp"
25
26namespace LIEF {
27class Visitor;
28
29namespace DEX {
30class File;
31}
32
33namespace OAT {
34class Parser;
35
36class LIEF_API DexFile : public Object {
37 friend class Parser;
38
39 public:
40 DexFile();
41 DexFile(const DexFile&);
42 DexFile& operator=(const DexFile&);
43
44 const std::string& location() const;
45
46 uint32_t checksum() const;
47 uint32_t dex_offset() const;
48
49 bool has_dex_file() const;
50
51 const DEX::File* dex_file() const;
52 DEX::File* dex_file();
53
54 void location(const std::string& location);
55 void checksum(uint32_t checksum);
56 void dex_offset(uint32_t dex_offset);
57
58 const std::vector<uint32_t>& classes_offsets() const;
59
60 // Android 7.X.X and Android 8.0.0
61 // ===============================
62 uint32_t lookup_table_offset() const;
63
64 void class_offsets_offset(uint32_t offset);
65 void lookup_table_offset(uint32_t offset);
66 // ===============================
67
68 void accept(Visitor& visitor) const override;
69
70
71 ~DexFile() override;
72
73 LIEF_API friend std::ostream& operator<<(std::ostream& os, const DexFile& dex_file);
74
75 private:
76 std::string location_;
77 uint32_t checksum_ = 0;
78 uint32_t dex_offset_ = 0;
79
80 DEX::File* dex_file_ = nullptr;
81
82 // OAT 64 (Android 6.X.X)
83 std::vector<uint32_t> classes_offsets_;
84
85 // OAT 79 / 88 (Android 7.X.X)
86 uint32_t lookup_table_offset_ = 0;
87
88 // OAT 131 (Android 8.1.0)
89 uint32_t method_bss_mapping_offset_ = 0;
90 uint32_t dex_sections_layout_offset_ = 0;
91};
92
93} // Namespace OAT
94} // Namespace LIEF
95#endif
Class that represents a DEX file.
Definition DEX/File.hpp:39
Definition DexFile.hpp:36
Class to parse an OAT file to produce an OAT::Binary.
Definition OAT/Parser.hpp:38
Definition Object.hpp:25
Definition Visitor.hpp:219
LIEF namespace.
Definition Abstract/Binary.hpp:32