LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
ART/Header.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_HEADER_H
17#define LIEF_ART_HEADER_H
18
19#include <array>
20#include <cstdint>
21#include <ostream>
22
23#include "LIEF/ART/enums.hpp"
24#include "LIEF/ART/types.hpp"
25
26#include "LIEF/Object.hpp"
27#include "LIEF/visibility.h"
28
29
30namespace LIEF::ART {
31class Parser;
32
33class LIEF_API Header : public Object {
34 friend class Parser;
35
36 public:
37 using magic_t = std::array<uint8_t, 4>;
38
40
41 template<class T>
42 LIEF_LOCAL Header(const T* header);
43
44 Header(const Header&);
46
47 magic_t magic() const;
49
50 uint32_t image_begin() const;
51 uint32_t image_size() const;
52
53 uint32_t oat_checksum() const;
54
55 uint32_t oat_file_begin() const;
56 uint32_t oat_file_end() const;
57
58 uint32_t oat_data_begin() const;
59 uint32_t oat_data_end() const;
60
61 int32_t patch_delta() const;
62
63 uint32_t image_roots() const;
64
65 uint32_t pointer_size() const;
66 bool compile_pic() const;
67
68 uint32_t nb_sections() const;
69 uint32_t nb_methods() const;
70
71 uint32_t boot_image_begin() const;
72 uint32_t boot_image_size() const;
73
74 uint32_t boot_oat_begin() const;
75 uint32_t boot_oat_size() const;
76
78
79 uint32_t data_size() const;
80
81 void accept(Visitor& visitor) const override;
82
83
84 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Header& hdr);
85
86 ~Header() override;
87
88 private:
89 magic_t magic_{};
90 art_version_t version_ = 0;
91
92 uint32_t image_begin_ = 0;
93 uint32_t image_size_ = 0;
94
95 uint32_t oat_checksum_ = 0;
96
97 uint32_t oat_file_begin_ = 0;
98 uint32_t oat_file_end_ = 0;
99
100 uint32_t oat_data_begin_ = 0;
101 uint32_t oat_data_end_ = 0;
102
103 int32_t patch_delta_ = 0;
104 uint32_t image_roots_ = 0;
105
106 uint32_t pointer_size_ = 0;
107
108 bool compile_pic_ = false;
109
110 uint32_t nb_sections_ = 0;
111 uint32_t nb_methods_ = 0;
112
113 bool is_pic_ = false;
114
115 // From ART 29
116 // ===========
117 uint32_t boot_image_begin_ = 0;
118 uint32_t boot_image_size_ = 0;
119
120 uint32_t boot_oat_begin_ = 0;
121 uint32_t boot_oat_size_ = 0;
122
124
125 uint32_t data_size_ = 0;
126};
127
128} // Namespace ART
129// Namespace LIEF
130
131#endif
Header & operator=(const Header &)
bool compile_pic() const
uint32_t boot_image_begin() const
uint32_t nb_sections() const
uint32_t image_size() const
uint32_t data_size() const
STORAGE_MODES storage_mode() const
friend std::ostream & operator<<(std::ostream &os, const Header &hdr)
uint32_t pointer_size() const
std::array< uint8_t, 4 > magic_t
Definition ART/Header.hpp:37
~Header() override
Header(const T *header)
magic_t magic() const
uint32_t oat_file_end() const
uint32_t nb_methods() const
uint32_t image_begin() const
art_version_t version() const
void accept(Visitor &visitor) const override
uint32_t boot_oat_begin() const
int32_t patch_delta() const
uint32_t oat_data_end() const
friend class Parser
Definition ART/Header.hpp:34
Header(const Header &)
uint32_t oat_file_begin() const
uint32_t boot_image_size() const
uint32_t boot_oat_size() const
uint32_t oat_data_begin() const
uint32_t oat_checksum() const
uint32_t image_roots() const
Class which parses an ART file and transforms it into an ART::File object.
Definition ART/Parser.hpp:32
Definition Visitor.hpp:212
Definition ART/enums.hpp:20
STORAGE_MODES
Definition ART/enums.hpp:22
@ STORAGE_UNCOMPRESSED
Definition ART/enums.hpp:23
uint32_t art_version_t
Definition ART/types.hpp:24
#define LIEF_API
Definition visibility.h:45
#define LIEF_LOCAL
Definition visibility.h:46