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