Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
global_defs.hpp
Go to the documentation of this file.
1#ifndef ARION_GLOBAL_DEFS_HPP
2#define ARION_GLOBAL_DEFS_HPP
3
4#include <array>
5#include <cstdint>
6#include <cstring>
7#include <map>
8#include <stddef.h>
9#include <string>
10#include <sys/types.h>
11
13#define ARION_EXPORT __attribute__((visibility("default")))
15#define ARION_BUF_SZ 0x1000
17#define ARION_UUID_SZ 0x24
19#define ARION_SYSTEM_PAGE_SZ 0x1000
21#define ARION_FD_SZ 0x4
23#define ARION_UNIX_PATH_MAX 0x6C
25#define ARION_MAX_U32 0xFFFFFFFF
27#define ARION_MAX_U64 0xFFFFFFFFFFFFFFFF
29#define ARION_PROCESS_PID 0x1
31#define ARION_CYCLES_PER_THREAD 0x1000
32
33namespace arion
34{
36using ADDR = uint64_t;
38using PROT_FLAGS = uint8_t;
40using BYTE = uint8_t;
42using REG = uint64_t;
44using RVAL8 = uint8_t;
46using RVAL16 = uint16_t;
48using RVAL32 = uint32_t;
50using RVAL64 = uint64_t;
52using RVAL128 = std::array<BYTE, 16>;
54using RVAL256 = std::array<BYTE, 32>;
56using RVAL512 = std::array<BYTE, 64>;
58using SYS_PARAM = uint64_t;
59
61const size_t EMPTY = 0;
62
80
82struct SEGMENT
83{
85 std::string info;
91 size_t align;
93 size_t virt_sz;
95 size_t phy_sz;
98};
99
101struct SIGNAL
102{
106 int signo;
113};
114
125
140
153
172
174inline std::map<std::string, CPU_ARCH> ARCH_FROM_NAME{{"UNKNOWN", CPU_ARCH::UNKNOWN_ARCH},
175 {"X86", CPU_ARCH::X86_ARCH},
176 {"X86-64", CPU_ARCH::X8664_ARCH},
177 {"ARM", CPU_ARCH::ARM_ARCH},
178 {"ARM64", CPU_ARCH::ARM64_ARCH}};
179
181inline std::map<CPU_ARCH, std::string> NAME_FROM_ARCH{{CPU_ARCH::UNKNOWN_ARCH, "UNKNOWN"},
182 {CPU_ARCH::X86_ARCH, "X86"},
183 {CPU_ARCH::X8664_ARCH, "X86-64"},
184 {CPU_ARCH::ARM_ARCH, "ARM"},
185 {CPU_ARCH::ARM64_ARCH, "ARM64"}};
186
187} // namespace arion
188
189#endif // ARION_GLOBAL_DEFS_HPP
#define ARION_EXPORT
Defines which symbols should be exported from the library.
Definition global_defs.hpp:13
Definition arch_x86-64.hpp:11
uint64_t SYS_PARAM
Identifies a syscall parameter.
Definition global_defs.hpp:58
uint64_t REG
Identifies a Unicorn register.
Definition global_defs.hpp:42
std::map< CPU_ARCH, std::string > NAME_FROM_ARCH
A map identifying a name corresponding a given CPU architecture.
Definition global_defs.hpp:181
std::map< std::string, CPU_ARCH > ARCH_FROM_NAME
A map identifying a CPU architecture given its name.
Definition global_defs.hpp:174
LINKAGE_TYPE
Identifies the method used to link an executable.
Definition global_defs.hpp:117
@ STATIC_LINKAGE
The executable was statically linked.
Definition global_defs.hpp:123
@ DYNAMIC_LINKAGE
The executable was dynamically linked.
Definition global_defs.hpp:121
@ UNKNOWN_LINKAGE
Unknown linkage method.
Definition global_defs.hpp:119
uint8_t RVAL8
Identifies a 8-bit register value.
Definition global_defs.hpp:44
uint32_t RVAL32
Identifies a 32-bit register value.
Definition global_defs.hpp:48
std::array< BYTE, 32 > RVAL256
Identifies a 256-bit register value.
Definition global_defs.hpp:54
uint64_t ADDR
Identifies a memory address.
Definition global_defs.hpp:36
uint16_t RVAL16
Identifies a 16-bit register value.
Definition global_defs.hpp:46
CPU_ARCH
Identifies a CPU architecture.
Definition global_defs.hpp:128
@ X8664_ARCH
The x86-64 CPU architecture.
Definition global_defs.hpp:134
@ UNKNOWN_ARCH
Unknown CPU architecture.
Definition global_defs.hpp:130
@ X86_ARCH
The x86 CPU architecture.
Definition global_defs.hpp:132
@ ARM64_ARCH
The ARM64 CPU architecture.
Definition global_defs.hpp:138
@ ARM_ARCH
The ARM CPU architecture.
Definition global_defs.hpp:136
std::array< BYTE, 64 > RVAL512
Identifies a 512-bit register value.
Definition global_defs.hpp:56
uint8_t BYTE
Identifies an 8-bit integer.
Definition global_defs.hpp:40
LOG_LEVEL
Identifies a logging level.
Definition global_defs.hpp:156
@ WARN
Potentially harmful situations or warnings.
Definition global_defs.hpp:164
@ OFF
Disables all logging output.
Definition global_defs.hpp:170
@ INFO
General informational messages about application progress.
Definition global_defs.hpp:162
@ TRACE
Fine-grained informational events, typically for debugging.
Definition global_defs.hpp:158
@ ERROR
Error events that might allow the application to continue running.
Definition global_defs.hpp:166
@ DEBUG
Debug-level messages, useful for development and troubleshooting.
Definition global_defs.hpp:160
@ CRITICAL
Severe error events that will likely lead to application termination.
Definition global_defs.hpp:168
const size_t EMPTY
A 64-bit zero-initialized value for various purposes.
Definition global_defs.hpp:61
uint8_t PROT_FLAGS
Identifies memory protection rights.
Definition global_defs.hpp:38
uint64_t RVAL64
Identifies a 64-bit register value.
Definition global_defs.hpp:50
std::array< BYTE, 16 > RVAL128
Identifies a 128-bit register value.
Definition global_defs.hpp:52
PLATFORM
Identifies an Operating System (OS).
Definition global_defs.hpp:143
@ UNKNOWN_PLATFORM
Unknown OS.
Definition global_defs.hpp:145
@ MACOS
macOS.
Definition global_defs.hpp:151
@ LINUX
Linux.
Definition global_defs.hpp:147
@ WINDOWS
Windows.
Definition global_defs.hpp:149
Identifies an OS memory segment.
Definition global_defs.hpp:83
std::string info
A string associated to this memory segment, for identification purpose.
Definition global_defs.hpp:85
PROT_FLAGS flags
Memory protection rights for this segment.
Definition global_defs.hpp:97
size_t align
The byte alignment value that this segment must respect when being mapped in memory.
Definition global_defs.hpp:91
ADDR virt_addr
The address where this segment should stand in memory.
Definition global_defs.hpp:87
size_t virt_sz
The size of this segment when allocated in memory.
Definition global_defs.hpp:93
ADDR file_addr
The offset where data for this segment holds in its associated file.
Definition global_defs.hpp:89
size_t phy_sz
The size of this segment in the file that describes it.
Definition global_defs.hpp:95
Identifies an OS signal.
Definition global_defs.hpp:102
SIGNAL(pid_t source_pid, int signo)
Definition global_defs.hpp:112
pid_t source_pid
PID of the process responsible for triggering this signal.
Definition global_defs.hpp:104
int signo
The signal number.
Definition global_defs.hpp:106
Identifies a size-agnostic register value.
Definition global_defs.hpp:64
RVAL8 r8
Used to store 8-bit register values.
Definition global_defs.hpp:66
RVAL64 r64
Used to store 64-bit register values.
Definition global_defs.hpp:72
RVAL512 r512
Used to store 512-bit register values.
Definition global_defs.hpp:78
RVAL256 r256
Used to store 256-bit register values.
Definition global_defs.hpp:76
RVAL16 r16
Used to store 16-bit register values.
Definition global_defs.hpp:68
RVAL128 r128
Used to store 128-bit register values.
Definition global_defs.hpp:74
RVAL32 r32
Used to store 32-bit register values.
Definition global_defs.hpp:70