LIEF: Library to Instrument Executable Formats Version 0.15.1
Loading...
Searching...
No Matches
DataCodeEntry.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_MACHO_DATA_CODE_ENTRY_H
17#define LIEF_MACHO_DATA_CODE_ENTRY_H
18#include <ostream>
19#include <cstdint>
20
21#include "LIEF/visibility.h"
22
23#include "LIEF/Object.hpp"
24
25namespace LIEF {
26namespace MachO {
27
28namespace details {
29struct data_in_code_entry;
30}
31
34 public:
35 enum class TYPES {
36 UNKNOWN = 0,
37 DATA = 1,
38 JUMP_TABLE_8 = 2,
39 JUMP_TABLE_16 = 3,
40 JUMP_TABLE_32 = 4,
41 ABS_JUMP_TABLE_32 = 5,
42 };
43
44 public:
45 DataCodeEntry() = default;
46 DataCodeEntry(uint32_t off, uint16_t length, TYPES type) :
47 offset_(off),
48 length_(length),
49 type_(type)
50 {}
51 DataCodeEntry(const details::data_in_code_entry& entry);
52
54 DataCodeEntry(const DataCodeEntry&) = default;
55
57 uint32_t offset() const {
58 return offset_;
59 }
60
62 uint16_t length() const {
63 return length_;
64 }
65
66 // Type of the data
67 TYPES type() const {
68 return type_;
69 }
70
71 void offset(uint32_t off) {
72 offset_ = off;
73 }
74 void length(uint16_t length) {
75 length_ = length;
76 }
77 void type(TYPES type) {
78 type_ = type;
79 }
80
81 ~DataCodeEntry() override = default;
82
83 void accept(Visitor& visitor) const override;
84
85 LIEF_API friend std::ostream& operator<<(std::ostream& os, const DataCodeEntry& entry);
86
87 private:
88 uint32_t offset_ = 0;
89 uint16_t length_ = 0;
90 TYPES type_ = TYPES::UNKNOWN;
91};
92
94
95}
96}
97
98#endif
Interface over an entry in the DataInCode command.
Definition DataCodeEntry.hpp:33
~DataCodeEntry() override=default
friend std::ostream & operator<<(std::ostream &os, const DataCodeEntry &entry)
void accept(Visitor &visitor) const override
DataCodeEntry(const details::data_in_code_entry &entry)
DataCodeEntry(const DataCodeEntry &)=default
void offset(uint32_t off)
Definition DataCodeEntry.hpp:71
TYPES type() const
Definition DataCodeEntry.hpp:67
DataCodeEntry & operator=(const DataCodeEntry &)=default
void length(uint16_t length)
Definition DataCodeEntry.hpp:74
uint32_t offset() const
Offset of the data.
Definition DataCodeEntry.hpp:57
DataCodeEntry(uint32_t off, uint16_t length, TYPES type)
Definition DataCodeEntry.hpp:46
void type(TYPES type)
Definition DataCodeEntry.hpp:77
TYPES
Definition DataCodeEntry.hpp:35
uint16_t length() const
Length of the data.
Definition DataCodeEntry.hpp:62
Definition Object.hpp:25
Definition Visitor.hpp:224
const char * to_string(BuildToolVersion::TOOLS tool)
LIEF namespace.
Definition Abstract/Binary.hpp:32
#define LIEF_API
Definition visibility.h:41