LIEF: Library to Instrument Executable Formats Version 0.17.0
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}
31class LIEF_API DataCodeEntry : public LIEF::Object {
34 public:
35 enum class TYPES {
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
53 DataCodeEntry& operator=(const DataCodeEntry&) = default;
54 DataCodeEntry(const DataCodeEntry&) = default;
55 uint32_t offset() const {
58 return offset_;
59 }
60 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
93LIEF_API const char* to_string(DataCodeEntry::TYPES e);
94
95}
96}
97
98#endif
Object.hpp
LIEF::MachO::DataCodeEntry
Interface over an entry in the DataInCode command.
Definition DataCodeEntry.hpp:33
LIEF::MachO::DataCodeEntry::~DataCodeEntry
~DataCodeEntry() override=default
LIEF::MachO::DataCodeEntry::operator<<
friend std::ostream & operator<<(std::ostream &os, const DataCodeEntry &entry)
LIEF::MachO::DataCodeEntry::accept
void accept(Visitor &visitor) const override
LIEF::MachO::DataCodeEntry::DataCodeEntry
DataCodeEntry()=default
LIEF::MachO::DataCodeEntry::DataCodeEntry
DataCodeEntry(const details::data_in_code_entry &entry)
LIEF::MachO::DataCodeEntry::DataCodeEntry
DataCodeEntry(const DataCodeEntry &)=default
LIEF::MachO::DataCodeEntry::offset
void offset(uint32_t off)
Definition DataCodeEntry.hpp:71
LIEF::MachO::DataCodeEntry::type
TYPES type() const
Definition DataCodeEntry.hpp:67
LIEF::MachO::DataCodeEntry::operator=
DataCodeEntry & operator=(const DataCodeEntry &)=default
LIEF::MachO::DataCodeEntry::length
void length(uint16_t length)
Definition DataCodeEntry.hpp:74
LIEF::MachO::DataCodeEntry::offset
uint32_t offset() const
Offset of the data.
Definition DataCodeEntry.hpp:57
LIEF::MachO::DataCodeEntry::DataCodeEntry
DataCodeEntry(uint32_t off, uint16_t length, TYPES type)
Definition DataCodeEntry.hpp:46
LIEF::MachO::DataCodeEntry::type
void type(TYPES type)
Definition DataCodeEntry.hpp:77
LIEF::MachO::DataCodeEntry::TYPES
TYPES
Definition DataCodeEntry.hpp:35
LIEF::MachO::DataCodeEntry::length
uint16_t length() const
Length of the data.
Definition DataCodeEntry.hpp:62
LIEF::MachO::details
Definition endianness_support.hpp:59
LIEF::MachO
Namespace related to the LIEF's Mach-O module.
Definition Abstract/Header.hpp:36
LIEF::MachO::MACHO_TYPES::UNKNOWN
@ UNKNOWN
Definition MachO/enums.hpp:25
LIEF::MachO::to_string
const char * to_string(BuildToolVersion::TOOLS tool)
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41