LIEF: Library to Instrument Executable Formats Version 0.17.0
Loading...
Searching...
No Matches
MapItem.hpp
Go to the documentation of this file.
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_MAP_ITEM_H
17#define LIEF_MAP_ITEM_H
18
19#include <cstdint>
20#include <ostream>
21
22#include "LIEF/visibility.h"
23#include "LIEF/Object.hpp"
24
25namespace LIEF {
26namespace DEX {
27class Parser;
28class Class;
29class LIEF_API MapItem : public Object {
32 friend class Parser;
33
34 public:
35 enum class TYPES : uint16_t {
36 HEADER = 0x0000,
37 STRING_ID = 0x0001,
38 TYPE_ID = 0x0002,
39 PROTO_ID = 0x0003,
40 FIELD_ID = 0x0004,
41 METHOD_ID = 0x0005,
42 CLASS_DEF = 0x0006,
43 CALL_SITE_ID = 0x0007,
44 METHOD_HANDLE = 0x0008,
45 MAP_LIST = 0x1000,
46 TYPE_LIST = 0x1001,
47 ANNOTATION_SET_REF_LIST = 0x1002,
48 ANNOTATION_SET = 0x1003,
49 CLASS_DATA = 0x2000,
50 CODE = 0x2001,
51 STRING_DATA = 0x2002,
52 DEBUG_INFO = 0x2003,
53 ANNOTATION = 0x2004,
54 ENCODED_ARRAY = 0x2005,
55 ANNOTATIONS_DIRECTORY = 0x2006,
56
57 };
58
59 public:
61 MapItem(TYPES type, uint32_t offset, uint32_t size, uint16_t reserved = 0);
62
63 MapItem(const MapItem&);
64 MapItem& operator=(const MapItem&);
65 TYPES type() const;
68 uint16_t reserved() const;
71 uint32_t size() const;
74 uint32_t offset() const;
78
79 void accept(Visitor& visitor) const override;
80
81
82 LIEF_API friend std::ostream& operator<<(std::ostream& os, const MapItem& item);
83
84 ~MapItem() override;
85
86 private:
87 TYPES type_;
88 uint16_t reserved_;
89 uint32_t size_;
90 uint32_t offset_;
91
92};
93
94} // Namespace DEX
95} // Namespace LIEF
96#endif
Class which represents a DEX Class (i.e. a Java/Kotlin class)
Definition DEX/Class.hpp:36
Class which represents an element of the MapList object.
Definition MapItem.hpp:31
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 prupose)
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
void accept(Visitor &visitor) const override
Class which parses a DEX file to produce a DEX::File object.
Definition DEX/Parser.hpp:38
Definition DEX/Class.hpp:30
LIEF namespace.
Definition Abstract/Binary.hpp:36
#define LIEF_API
Definition visibility.h:41