LIEF: Library to Instrument Executable Formats Version 2.0.0
Loading...
Searching...
No Matches
MapItem.hpp
Go to the documentation of this file.
1/* Copyright 2017 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_MAP_ITEM_H
16#define LIEF_MAP_ITEM_H
17
18#include <cstdint>
19#include <ostream>
20
21#include "LIEF/Object.hpp"
22#include "LIEF/visibility.h"
23
24
25namespace LIEF::DEX {
26class Parser;
27class Class;
28
30class LIEF_API MapItem : public Object {
31 friend class Parser;
32
33 public:
34 enum class TYPES : uint16_t {
35 HEADER = 0x0000,
36 STRING_ID = 0x0001,
37 TYPE_ID = 0x0002,
38 PROTO_ID = 0x0003,
39 FIELD_ID = 0x0004,
40 METHOD_ID = 0x0005,
41 CLASS_DEF = 0x0006,
42 CALL_SITE_ID = 0x0007,
43 METHOD_HANDLE = 0x0008,
44 MAP_LIST = 0x1000,
45 TYPE_LIST = 0x1001,
46 ANNOTATION_SET_REF_LIST = 0x1002,
47 ANNOTATION_SET = 0x1003,
48 CLASS_DATA = 0x2000,
49 CODE = 0x2001,
50 STRING_DATA = 0x2002,
51 DEBUG_INFO = 0x2003,
52 ANNOTATION = 0x2004,
53 ENCODED_ARRAY = 0x2005,
54 ANNOTATIONS_DIRECTORY = 0x2006,
55
56 };
57
58 public:
60 MapItem(TYPES type, uint32_t offset, uint32_t size, uint16_t reserved = 0);
61
64
66 TYPES type() const;
67
69 uint16_t reserved() const;
70
72 uint32_t size() const;
73
76 uint32_t offset() const;
77
78 void accept(Visitor& visitor) const override;
79
80
81 LIEF_API friend std::ostream& operator<<(std::ostream& os, const MapItem& item);
82
83 ~MapItem() override;
84
85 private:
86 TYPES type_ = TYPES::HEADER;
87 uint16_t reserved_ = 0;
88 uint32_t size_ = 0;
89 uint32_t offset_ = 0;
90};
91
92} // Namespace DEX
93// Namespace LIEF
94#endif
Class which represents a DEX Class (i.e. a Java/Kotlin class).
Definition DEX/Class.hpp:36
MapItem(const MapItem &)
MapItem & operator=(const MapItem &)
uint32_t offset() const
Offset from the start of the DEX file to the items associated with the underlying TYPES.
uint16_t reserved() const
Reserved value (likely for alignment purpose).
MapItem(TYPES type, uint32_t offset, uint32_t size, uint16_t reserved=0)
uint32_t size() const
The number of elements (the real meaning depends on the type).
TYPES type() const
The type of the item.
friend std::ostream & operator<<(std::ostream &os, const MapItem &item)
~MapItem() override
friend class Parser
Definition MapItem.hpp:31
TYPES
Definition MapItem.hpp:34
@ HEADER
Definition MapItem.hpp:35
void accept(Visitor &visitor) const override
Class which parses a DEX file to produce a DEX::File object.
Definition DEX/Parser.hpp:39
Definition Visitor.hpp:211
Definition DEX/Class.hpp:30
#define LIEF_API
Definition visibility.h:44