LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
DEX/Header.hpp
Go to the documentation of this file.
1
2/* Copyright 2017 - 2024 R. Thomas
3 * Copyright 2017 - 2024 Quarkslab
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#ifndef LIEF_DEX_HEADER_H
18#define LIEF_DEX_HEADER_H
19
20#include <array>
21#include <utility>
22#include <cstdint>
23#include <ostream>
24
25#include "LIEF/visibility.h"
26#include "LIEF/Object.hpp"
27
28namespace LIEF {
29class Visitor;
30
31namespace DEX {
32class Parser;
33
39class LIEF_API Header : public Object {
40 friend class Parser;
41
42 public:
43 using location_t = std::pair<uint32_t, uint32_t>;
44
45 using magic_t = std::array<uint8_t, 8>;
46 using signature_t = std::array<uint8_t, 20>;
47
49 Header(const Header&);
51
52 template<class T>
53 LIEF_LOCAL Header(const T& header);
54
56 magic_t magic() const;
57
59 uint32_t checksum() const;
60
63
65 uint32_t file_size() const;
66
68 uint32_t header_size() const;
69
71 uint32_t endian_tag() const;
72
74 uint32_t map() const;
75
85
86 uint32_t nb_classes() const;
87
88 uint32_t nb_methods() const;
89
90 void accept(Visitor& visitor) const override;
91
92
93 LIEF_API friend std::ostream& operator<<(std::ostream& os, const Header& hdr);
94
95 ~Header() override;
96
97 private:
98 magic_t magic_;
99 uint32_t checksum_;
100 signature_t signature_;
101 uint32_t file_size_;
102
103 uint32_t header_size_;
104 uint32_t endian_tag_;
105
106 uint32_t link_size_;
107 uint32_t link_off_;
108
109 uint32_t map_off_;
110
111 uint32_t string_ids_size_;
112 uint32_t string_ids_off_;
113
114 uint32_t type_ids_size_;
115 uint32_t type_ids_off_;
116
117 uint32_t proto_ids_size_;
118 uint32_t proto_ids_off_;
119
120 uint32_t field_ids_size_;
121 uint32_t field_ids_off_;
122
123 uint32_t method_ids_size_;
124 uint32_t method_ids_off_;
125
126 uint32_t class_defs_size_;
127 uint32_t class_defs_off_;
128
129 uint32_t data_size_;
130 uint32_t data_off_;
131};
132
133} // Namespace DEX
134} // Namespace LIEF
135
136#endif
Class which represents the DEX header. This is the first structure that begins the DEX format.
Definition DEX/Header.hpp:39
location_t strings() const
Offset and size of the string pool.
location_t types() const
location_t methods() const
location_t data() const
location_t prototypes() const
Header(const T &header)
friend std::ostream & operator<<(std::ostream &os, const Header &hdr)
std::pair< uint32_t, uint32_t > location_t
Definition DEX/Header.hpp:43
magic_t magic() const
The DEX magic bytes (DEX\n followed by the DEX version)
signature_t signature() const
SHA-1 DEX signature (which is not really used as a signature)
~Header() override
uint32_t endian_tag() const
File endianess of the file.
location_t fields() const
std::array< uint8_t, 8 > magic_t
Definition DEX/Header.hpp:45
uint32_t nb_methods() const
uint32_t header_size() const
Size of this header. It should be 0x70.
uint32_t checksum() const
The file checksum.
location_t classes() const
Header & operator=(const Header &)
location_t link() const
std::array< uint8_t, 20 > signature_t
Definition DEX/Header.hpp:46
void accept(Visitor &visitor) const override
Header(const Header &)
uint32_t map() const
Offset from the start of the file to the map list (see: DEX::MapList)
uint32_t file_size() const
Size of the entire file (including the current the header)
uint32_t nb_classes() const
Class which parses a DEX file to produce a DEX::File object.
Definition DEX/Parser.hpp:38
Definition Object.hpp:25
Definition Visitor.hpp:224
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41
#define LIEF_LOCAL
Definition visibility.h:42