Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
arch_x86.hpp
Go to the documentation of this file.
1#ifndef ARION_ARCH_X86_HPP
2#define ARION_ARCH_X86_HPP
3
6#include <cstdint>
7#include <map>
8#include <string>
9
10namespace arion
11{
12
13class Arion;
14
15};
16
17namespace arion_x86
18{
20inline std::map<uint64_t, std::string> NAME_BY_SYSCALL_NO = {{0, "restart_syscall"},
21 {1, "exit"},
22 {2, "fork"},
23 {3, "read"},
24 {4, "write"},
25 {5, "open"},
26 {6, "close"},
27 {7, "waitpid"},
28 {8, "creat"},
29 {9, "link"},
30 {10, "unlink"},
31 {11, "execve"},
32 {12, "chdir"},
33 {13, "time"},
34 {14, "mknod"},
35 {15, "chmod"},
36 {16, "lchown16"},
37 {18, "stat"},
38 {19, "lseek"},
39 {20, "getpid"},
40 {21, "mount"},
41 {22, "oldumount"},
42 {23, "setuid16"},
43 {24, "getuid16"},
44 {25, "stime"},
45 {26, "ptrace"},
46 {27, "alarm"},
47 {28, "fstat"},
48 {29, "pause"},
49 {30, "utime"},
50 {33, "access"},
51 {34, "nice"},
52 {36, "sync"},
53 {37, "kill"},
54 {38, "rename"},
55 {39, "mkdir"},
56 {40, "rmdir"},
57 {41, "dup"},
58 {42, "pipe"},
59 {43, "times"},
60 {45, "brk"},
61 {46, "setgid16"},
62 {47, "getgid16"},
63 {48, "signal"},
64 {49, "geteuid16"},
65 {50, "getegid16"},
66 {51, "acct"},
67 {52, "umount"},
68 {54, "ioctl"},
69 {55, "fcntl"},
70 {57, "setpgid"},
71 {59, "olduname"},
72 {60, "umask"},
73 {61, "chroot"},
74 {62, "ustat"},
75 {63, "dup2"},
76 {64, "getppid"},
77 {65, "getpgrp"},
78 {66, "setsid"},
79 {67, "sigaction"},
80 {68, "sgetmask"},
81 {69, "ssetmask"},
82 {70, "setreuid16"},
83 {71, "setregid16"},
84 {72, "sigsuspend"},
85 {73, "sigpending"},
86 {74, "sethostname"},
87 {75, "setrlimit"},
88 {76, "old_getrlimit"},
89 {77, "getrusage"},
90 {78, "gettimeofday"},
91 {79, "settimeofday"},
92 {80, "getgroups16"},
93 {81, "setgroups16"},
94 {82, "select"},
95 {83, "symlink"},
96 {84, "lstat"},
97 {85, "readlink"},
98 {86, "uselib"},
99 {87, "swapon"},
100 {88, "reboot"},
101 {89, "readdir"},
102 {90, "mmap"},
103 {91, "munmap"},
104 {92, "truncate"},
105 {93, "ftruncate"},
106 {94, "fchmod"},
107 {95, "fchown16"},
108 {96, "getpriority"},
109 {97, "setpriority"},
110 {99, "statfs"},
111 {100, "fstatfs"},
112 {101, "ioperm"},
113 {102, "socketcall"},
114 {103, "syslog"},
115 {104, "setitimer"},
116 {105, "getitimer"},
117 {106, "newstat"},
118 {107, "newlstat"},
119 {108, "newfstat"},
120 {109, "uname"},
121 {110, "iopl"},
122 {111, "vhangup"},
123 {113, "vm86old"},
124 {114, "wait4"},
125 {115, "swapoff"},
126 {116, "sysinfo"},
127 {117, "ipc"},
128 {118, "fsync"},
129 {119, "sigreturn"},
130 {120, "clone"},
131 {121, "setdomainname"},
132 {122, "newuname"},
133 {123, "modify_ldt"},
134 {124, "adjtimex"},
135 {125, "mprotect"},
136 {126, "sigprocmask"},
137 {128, "init_module"},
138 {129, "delete_module"},
139 {131, "quotactl"},
140 {132, "getpgid"},
141 {133, "fchdir"},
142 {135, "sysfs"},
143 {136, "personality"},
144 {138, "setfsuid16"},
145 {139, "setfsgid16"},
146 {140, "llseek"},
147 {141, "getdents"},
148 {142, "select"},
149 {143, "flock"},
150 {144, "msync"},
151 {145, "readv"},
152 {146, "writev"},
153 {147, "getsid"},
154 {148, "fdatasync"},
155 {150, "mlock"},
156 {151, "munlock"},
157 {152, "mlockall"},
158 {153, "munlockall"},
159 {154, "sched_setparam"},
160 {155, "sched_getparam"},
161 {156, "sched_setscheduler"},
162 {157, "sched_getscheduler"},
163 {158, "sched_yield"},
164 {159, "sched_get_priority_max"},
165 {160, "sched_get_priority_min"},
166 {161, "sched_rr_get_interval"},
167 {162, "nanosleep"},
168 {163, "mremap"},
169 {164, "setresuid16"},
170 {165, "getresuid16"},
171 {166, "vm86"},
172 {168, "poll"},
173 {170, "setresgid16"},
174 {171, "getresgid16"},
175 {172, "prctl"},
176 {173, "rt_sigreturn"},
177 {174, "rt_sigaction"},
178 {175, "rt_sigprocmask"},
179 {176, "rt_sigpending"},
180 {177, "rt_sigtimedwait"},
181 {178, "rt_sigqueueinfo"},
182 {179, "rt_sigsuspend"},
183 {180, "pread64"},
184 {181, "pwrite64"},
185 {182, "chown16"},
186 {183, "getcwd"},
187 {184, "capget"},
188 {185, "capset"},
189 {186, "sigaltstack"},
190 {187, "sendfile"},
191 {190, "vfork"},
192 {191, "getrlimit"},
193 {192, "mmap_pgoff"},
194 {193, "truncate64"},
195 {194, "ftruncate64"},
196 {195, "stat64"},
197 {196, "lstat64"},
198 {197, "fstat64"},
199 {198, "lchown"},
200 {199, "getuid"},
201 {200, "getgid"},
202 {201, "geteuid"},
203 {202, "getegid"},
204 {203, "setreuid"},
205 {204, "setregid"},
206 {205, "getgroups"},
207 {206, "setgroups"},
208 {207, "fchown"},
209 {208, "setresuid"},
210 {209, "getresuid"},
211 {210, "setresgid"},
212 {211, "getresgid"},
213 {212, "chown"},
214 {213, "setuid"},
215 {214, "setgid"},
216 {215, "setfsuid"},
217 {216, "setfsgid"},
218 {217, "pivot_root"},
219 {218, "mincore"},
220 {219, "madvise"},
221 {220, "getdents64"},
222 {221, "fcntl64"},
223 {224, "gettid"},
224 {225, "readahead"},
225 {226, "setxattr"},
226 {227, "lsetxattr"},
227 {228, "fsetxattr"},
228 {229, "getxattr"},
229 {230, "lgetxattr"},
230 {231, "fgetxattr"},
231 {232, "listxattr"},
232 {233, "llistxattr"},
233 {234, "flistxattr"},
234 {235, "removexattr"},
235 {236, "lremovexattr"},
236 {237, "fremovexattr"},
237 {238, "tkill"},
238 {239, "sendfile64"},
239 {240, "futex"},
240 {241, "sched_setaffinity"},
241 {242, "sched_getaffinity"},
242 {243, "set_thread_area"},
243 {244, "get_thread_area"},
244 {245, "io_setup"},
245 {246, "io_destroy"},
246 {247, "io_getevents"},
247 {248, "io_submit"},
248 {249, "io_cancel"},
249 {250, "fadvise64"},
250 {252, "exit_group"},
251 {254, "epoll_create"},
252 {255, "epoll_ctl"},
253 {256, "epoll_wait"},
254 {257, "remap_file_pages"},
255 {258, "set_tid_address"},
256 {259, "timer_create"},
257 {260, "timer_settime"},
258 {261, "timer_gettime"},
259 {262, "timer_getoverrun"},
260 {263, "timer_delete"},
261 {264, "clock_settime"},
262 {265, "clock_gettime"},
263 {266, "clock_getres"},
264 {267, "clock_nanosleep"},
265 {268, "statfs64"},
266 {269, "fstatfs64"},
267 {270, "tgkill"},
268 {271, "utimes"},
269 {272, "fadvise64_64"},
270 {274, "mbind"},
271 {275, "get_mempolicy"},
272 {276, "set_mempolicy"},
273 {277, "mq_open"},
274 {278, "mq_unlink"},
275 {279, "mq_timedsend"},
276 {280, "mq_timedreceive"},
277 {281, "mq_notify"},
278 {282, "mq_getsetattr"},
279 {283, "kexec_load"},
280 {284, "waitid"},
281 {286, "add_key"},
282 {287, "request_key"},
283 {288, "keyctl"},
284 {289, "ioprio_set"},
285 {290, "ioprio_get"},
286 {291, "inotify_init"},
287 {292, "inotify_add_watch"},
288 {293, "inotify_rm_watch"},
289 {294, "migrate_pages"},
290 {295, "openat"},
291 {296, "mkdirat"},
292 {297, "mknodat"},
293 {298, "fchownat"},
294 {299, "futimesat"},
295 {300, "fstatat64"},
296 {301, "unlinkat"},
297 {302, "renameat"},
298 {303, "linkat"},
299 {304, "symlinkat"},
300 {305, "readlinkat"},
301 {306, "fchmodat"},
302 {307, "faccessat"},
303 {308, "pselect6"},
304 {309, "ppoll"},
305 {310, "unshare"},
306 {311, "set_robust_list"},
307 {312, "get_robust_list"},
308 {313, "splice"},
309 {314, "sync_file_range"},
310 {315, "tee"},
311 {316, "vmsplice"},
312 {317, "move_pages"},
313 {318, "getcpu"},
314 {319, "epoll_pwait"},
315 {320, "utimensat"},
316 {321, "signalfd"},
317 {322, "timerfd_create"},
318 {323, "eventfd"},
319 {324, "fallocate"},
320 {325, "timerfd_settime"},
321 {326, "timerfd_gettime"},
322 {327, "signalfd4"},
323 {328, "eventfd2"},
324 {329, "epoll_create1"},
325 {330, "dup3"},
326 {331, "pipe2"},
327 {332, "inotify_init1"},
328 {333, "preadv"},
329 {334, "pwritev"},
330 {335, "rt_tgsigqueueinfo"},
331 {336, "perf_event_open"},
332 {337, "recvmmsg"},
333 {338, "fanotify_init"},
334 {339, "fanotify_mark"},
335 {340, "prlimit64"},
336 {341, "name_to_handle_at"},
337 {342, "open_by_handle_at"},
338 {343, "clock_adjtime"},
339 {344, "syncfs"},
340 {345, "sendmmsg"},
341 {346, "setns"},
342 {347, "process_vm_readv"},
343 {348, "process_vm_writev"},
344 {349, "kcmp"},
345 {350, "finit_module"},
346 {351, "sched_setattr"},
347 {352, "sched_getattr"},
348 {353, "renameat2"},
349 {354, "seccomp"},
350 {355, "getrandom"},
351 {356, "memfd_create"},
352 {357, "bpf"},
353 {358, "execveat"},
354 {359, "socket"},
355 {360, "socketpair"},
356 {361, "bind"},
357 {362, "connect"},
358 {363, "listen"},
359 {364, "accept4"},
360 {365, "getsockopt"},
361 {366, "setsockopt"},
362 {367, "getsockname"},
363 {368, "getpeername"},
364 {369, "sendto"},
365 {370, "sendmsg"},
366 {371, "recvfrom"},
367 {372, "recvmsg"},
368 {373, "shutdown"},
369 {374, "userfaultfd"},
370 {375, "membarrier"},
371 {376, "mlock2"},
372 {377, "copy_file_range"},
373 {378, "preadv2"},
374 {379, "pwritev2"},
375 {383, "statx"},
376 {384, "arch_prctl"},
377 {385, "io_pgetevents"},
378 {386, "rseq"},
379 {393, "semget"},
380 {394, "semctl"},
381 {395, "shmget"},
382 {396, "shmctl"},
383 {397, "shmat"},
384 {398, "shmdt"},
385 {399, "msgget"},
386 {400, "msgsnd"},
387 {401, "msgrcv"},
388 {402, "msgctl"},
389 {403, "clock_gettime"},
390 {404, "clock_settime"},
391 {405, "clock_adjtime"},
392 {406, "clock_getres"},
393 {407, "clock_nanosleep"},
394 {408, "timer_gettime"},
395 {409, "timer_settime"},
396 {410, "timerfd_gettime"},
397 {411, "timerfd_settime"},
398 {412, "utimensat"},
399 {413, "pselect6"},
400 {414, "ppoll"},
401 {416, "io_pgetevents"},
402 {417, "recvmmsg"},
403 {418, "mq_timedsend"},
404 {419, "mq_timedreceive"},
405 {420, "semtimedop"},
406 {421, "rt_sigtimedwait"},
407 {422, "futex_time64"},
408 {423, "sched_rr_get_interval"},
409 {424, "pidfd_send_signal"},
410 {425, "io_uring_setup"},
411 {426, "io_uring_enter"},
412 {427, "io_uring_register"},
413 {428, "open_tree"},
414 {429, "move_mount"},
415 {430, "fsopen"},
416 {431, "fsconfig"},
417 {432, "fsmount"},
418 {433, "fspick"},
419 {434, "pidfd_open"},
420 {435, "clone3"},
421 {436, "close_range"},
422 {437, "openat2"},
423 {438, "pidfd_getfd"},
424 {439, "faccessat2"},
425 {440, "process_madvise"},
426 {441, "epoll_pwait2"},
427 {442, "mount_setattr"},
428 {443, "quotactl_fd"},
429 {444, "landlock_create_ruleset"},
430 {445, "landlock_add_rule"},
431 {446, "landlock_restrict_self"},
432 {447, "memfd_secret"},
433 {448, "process_mrelease"},
434 {449, "futex_waitv"},
435 {450, "set_mempolicy_home_node"},
436 {451, "cachestat"},
437 {452, "fchmodat2"},
438 {454, "futex_wake"},
439 {455, "futex_wait"},
440 {456, "futex_requeue"},
441 {457, "statmount"},
442 {458, "listmount"},
443 {459, "lsm_get_self_attr"},
444 {460, "lsm_set_self_attr"},
445 {461, "lsm_list_modules"},
446 {463, "setxattrat"},
447 {464, "getxattrat"},
448 {465, "listxattrat"},
449 {466, "removexattrat"}};
450
452inline std::map<std::string, arion::REG> ARCH_REGS = {
453 {"AH", UC_X86_REG_AH}, {"AL", UC_X86_REG_AL}, {"AX", UC_X86_REG_AX}, {"BH", UC_X86_REG_BH},
454 {"BL", UC_X86_REG_BL}, {"BP", UC_X86_REG_BP}, {"BPL", UC_X86_REG_BPL}, {"BX", UC_X86_REG_BX},
455 {"CH", UC_X86_REG_CH}, {"CL", UC_X86_REG_CL}, {"CS", UC_X86_REG_CS}, {"CX", UC_X86_REG_CX},
456 {"DH", UC_X86_REG_DH}, {"DI", UC_X86_REG_DI}, {"DIL", UC_X86_REG_DIL}, {"DL", UC_X86_REG_DL},
457 {"DS", UC_X86_REG_DS}, {"DX", UC_X86_REG_DX}, {"EAX", UC_X86_REG_EAX}, {"EBP", UC_X86_REG_EBP},
458 {"EBX", UC_X86_REG_EBX}, {"ECX", UC_X86_REG_ECX}, {"EDI", UC_X86_REG_EDI}, {"EDX", UC_X86_REG_EDX},
459 {"EIP", UC_X86_REG_EIP}, {"ES", UC_X86_REG_ES}, {"ESI", UC_X86_REG_ESI}, {"ESP", UC_X86_REG_ESP},
460 {"FPSW", UC_X86_REG_FPSW}, {"FS", UC_X86_REG_FS}, {"GS", UC_X86_REG_GS}, {"IP", UC_X86_REG_IP},
461 {"SI", UC_X86_REG_SI}, {"SIL", UC_X86_REG_SIL}, {"SP", UC_X86_REG_SP}, {"SPL", UC_X86_REG_SPL},
462 {"SS", UC_X86_REG_SS}, {"CR0", UC_X86_REG_CR0}, {"CR1", UC_X86_REG_CR1}, {"CR2", UC_X86_REG_CR2},
463 {"CR3", UC_X86_REG_CR3}, {"CR4", UC_X86_REG_CR4}, {"CR8", UC_X86_REG_CR8}, {"DR0", UC_X86_REG_DR0},
464 {"DR1", UC_X86_REG_DR1}, {"DR2", UC_X86_REG_DR2}, {"DR3", UC_X86_REG_DR3}, {"DR4", UC_X86_REG_DR4},
465 {"DR5", UC_X86_REG_DR5}, {"DR6", UC_X86_REG_DR6}, {"DR7", UC_X86_REG_DR7}, {"FP0", UC_X86_REG_FP0},
466 {"FP1", UC_X86_REG_FP1}, {"FP2", UC_X86_REG_FP2}, {"FP3", UC_X86_REG_FP3}, {"FP4", UC_X86_REG_FP4},
467 {"FP5", UC_X86_REG_FP5}, {"FP6", UC_X86_REG_FP6}, {"FP7", UC_X86_REG_FP7}, {"R8", UC_X86_REG_R8},
468 {"ST0", UC_X86_REG_ST0}, {"ST1", UC_X86_REG_ST1}, {"ST2", UC_X86_REG_ST2}, {"ST3", UC_X86_REG_ST3},
469 {"ST4", UC_X86_REG_ST4}, {"ST5", UC_X86_REG_ST5}, {"ST6", UC_X86_REG_ST6}, {"ST7", UC_X86_REG_ST7},
470 {"XMM0", UC_X86_REG_XMM0}, {"XMM1", UC_X86_REG_XMM1}, {"XMM2", UC_X86_REG_XMM2}, {"XMM3", UC_X86_REG_XMM3},
471 {"XMM4", UC_X86_REG_XMM4}, {"XMM5", UC_X86_REG_XMM5}, {"XMM6", UC_X86_REG_XMM6}, {"XMM7", UC_X86_REG_XMM7},
472 {"YMM0", UC_X86_REG_YMM0}, {"YMM1", UC_X86_REG_YMM1}, {"YMM2", UC_X86_REG_YMM2}, {"YMM3", UC_X86_REG_YMM3},
473 {"YMM4", UC_X86_REG_YMM4}, {"YMM5", UC_X86_REG_YMM5}, {"YMM6", UC_X86_REG_YMM6}, {"YMM7", UC_X86_REG_YMM7},
474 {"IDTR", UC_X86_REG_IDTR}, {"GDTR", UC_X86_REG_GDTR}, {"LDTR", UC_X86_REG_LDTR}, {"TR", UC_X86_REG_TR},
475 {"FPCW", UC_X86_REG_FPCW}, {"FPTAG", UC_X86_REG_FPTAG}, {"MSR", UC_X86_REG_MSR}, {"MXCSR", UC_X86_REG_MXCSR},
476 {"FLAGS", UC_X86_REG_FLAGS}, {"EFLAGS", UC_X86_REG_EFLAGS}, {"FIP", UC_X86_REG_FIP}, {"FCS", UC_X86_REG_FCS},
477 {"FDP", UC_X86_REG_FDP}, {"FDS", UC_X86_REG_FDS}, {"FOP", UC_X86_REG_FOP}};
478
480inline std::map<arion::REG, uint8_t> ARCH_REGS_SZ = {
481 {UC_X86_REG_AH, 1}, {UC_X86_REG_AL, 1}, {UC_X86_REG_AX, 2}, {UC_X86_REG_BH, 1}, {UC_X86_REG_BL, 1},
482 {UC_X86_REG_BP, 2}, {UC_X86_REG_BPL, 1}, {UC_X86_REG_BX, 2}, {UC_X86_REG_CH, 1}, {UC_X86_REG_CL, 1},
483 {UC_X86_REG_CS, 2}, {UC_X86_REG_CX, 2}, {UC_X86_REG_DH, 1}, {UC_X86_REG_DI, 2}, {UC_X86_REG_DIL, 1},
484 {UC_X86_REG_DL, 1}, {UC_X86_REG_DS, 2}, {UC_X86_REG_DX, 2}, {UC_X86_REG_EAX, 4}, {UC_X86_REG_EBP, 4},
485 {UC_X86_REG_EBX, 4}, {UC_X86_REG_ECX, 4}, {UC_X86_REG_EDI, 4}, {UC_X86_REG_EDX, 4}, {UC_X86_REG_EIP, 4},
486 {UC_X86_REG_ES, 2}, {UC_X86_REG_ESI, 4}, {UC_X86_REG_ESP, 4}, {UC_X86_REG_FPSW, 2}, {UC_X86_REG_FS, 2},
487 {UC_X86_REG_GS, 2}, {UC_X86_REG_IP, 2}, {UC_X86_REG_SI, 2}, {UC_X86_REG_SIL, 1}, {UC_X86_REG_SP, 2},
488 {UC_X86_REG_SPL, 1}, {UC_X86_REG_SS, 2}, {UC_X86_REG_CR0, 8}, {UC_X86_REG_CR1, 8}, {UC_X86_REG_CR2, 8},
489 {UC_X86_REG_CR3, 8}, {UC_X86_REG_CR4, 8}, {UC_X86_REG_CR8, 8}, {UC_X86_REG_DR0, 8}, {UC_X86_REG_DR1, 8},
490 {UC_X86_REG_DR2, 8}, {UC_X86_REG_DR3, 8}, {UC_X86_REG_DR4, 8}, {UC_X86_REG_DR5, 8}, {UC_X86_REG_DR6, 8},
491 {UC_X86_REG_DR7, 8}, {UC_X86_REG_FP0, 10}, {UC_X86_REG_FP1, 10}, {UC_X86_REG_FP2, 10}, {UC_X86_REG_FP3, 10},
492 {UC_X86_REG_FP4, 10}, {UC_X86_REG_FP5, 10}, {UC_X86_REG_FP6, 10}, {UC_X86_REG_FP7, 10}, {UC_X86_REG_ST0, 10},
493 {UC_X86_REG_ST1, 10}, {UC_X86_REG_ST2, 10}, {UC_X86_REG_ST3, 10}, {UC_X86_REG_ST4, 10}, {UC_X86_REG_ST5, 10},
494 {UC_X86_REG_ST6, 10}, {UC_X86_REG_ST7, 10}, {UC_X86_REG_XMM0, 16}, {UC_X86_REG_XMM1, 16}, {UC_X86_REG_XMM2, 16},
495 {UC_X86_REG_XMM3, 16}, {UC_X86_REG_XMM4, 16}, {UC_X86_REG_XMM5, 16}, {UC_X86_REG_XMM6, 16}, {UC_X86_REG_XMM7, 16},
496 {UC_X86_REG_YMM0, 32}, {UC_X86_REG_YMM1, 32}, {UC_X86_REG_YMM2, 32}, {UC_X86_REG_YMM3, 32}, {UC_X86_REG_YMM4, 32},
497 {UC_X86_REG_YMM5, 32}, {UC_X86_REG_YMM6, 32}, {UC_X86_REG_YMM7, 32}, {UC_X86_REG_IDTR, 24}, {UC_X86_REG_GDTR, 24},
498 {UC_X86_REG_LDTR, 24}, {UC_X86_REG_TR, 24}, {UC_X86_REG_FPCW, 2}, {UC_X86_REG_FPTAG, 2}, {UC_X86_REG_MSR, 16},
499 {UC_X86_REG_MXCSR, 4}, {UC_X86_REG_FLAGS, 2}, {UC_X86_REG_EFLAGS, 4}, {UC_X86_REG_FIP, 8}, {UC_X86_REG_FCS, 2},
500 {UC_X86_REG_FDP, 8}, {UC_X86_REG_FDS, 2}, {UC_X86_REG_FOP, 2}};
501
503inline std::vector<arion::REG> CTXT_REGS = {
504 UC_X86_REG_FS, UC_X86_REG_GS, UC_X86_REG_EAX, UC_X86_REG_EBP, UC_X86_REG_EBX, UC_X86_REG_ECX,
505 UC_X86_REG_EDI, UC_X86_REG_EDX, UC_X86_REG_EIP, UC_X86_REG_ESI, UC_X86_REG_ESP, UC_X86_REG_SS,
506 UC_X86_REG_CS, UC_X86_REG_DS, UC_X86_REG_FP0, UC_X86_REG_FP1, UC_X86_REG_FP2, UC_X86_REG_FP3,
507 UC_X86_REG_FP4, UC_X86_REG_FP5, UC_X86_REG_FP6, UC_X86_REG_FP7, UC_X86_REG_ST0, UC_X86_REG_ST1,
508 UC_X86_REG_ST2, UC_X86_REG_ST3, UC_X86_REG_ST4, UC_X86_REG_ST5, UC_X86_REG_ST6, UC_X86_REG_ST7,
509 UC_X86_REG_YMM0, UC_X86_REG_YMM1, UC_X86_REG_YMM2, UC_X86_REG_YMM3, UC_X86_REG_YMM4, UC_X86_REG_YMM5,
510 UC_X86_REG_YMM6, UC_X86_REG_YMM7, UC_X86_REG_EFLAGS};
511
533
535inline arion::ABI_REGISTERS ABI_REGS = arion::ABI_REGISTERS(UC_X86_REG_EIP, UC_X86_REG_ESP);
536
539
542 UC_X86_REG_EAX, UC_X86_REG_EAX,
543 {UC_X86_REG_EBX, UC_X86_REG_ECX, UC_X86_REG_EDX, UC_X86_REG_ESI, UC_X86_REG_EDI, UC_X86_REG_EBP});
544
547
549inline uint32_t HWCAP2 = 2;
550
552inline uint32_t HWCAP = 0xbfebfbff;
553
555inline const size_t PTR_SZ = 4;
556
558inline const uint16_t ARCH_SZ = 32;
559
562
567
570{
571 private:
578 static void int_hook(std::shared_ptr<arion::Arion> arion, uint32_t intno, void *user_data);
582 void setup() override;
583
584 public:
589 : ArchManager(std::make_shared<arion::ARCH_ATTRIBUTES>(arion_x86::ARCH_ATTRS), arion_x86::ARCH_REGS,
591
598 uint16_t new_tls(arion::ADDR udesc_addr);
603 ks_engine *curr_ks() override;
608 csh *curr_cs() override;
619};
620
621}; // namespace arion_x86
622
623#endif // ARION_ARCH_X86_HPP
#define ARION_VVAR_PRESENT
If this flag is set, the loader will map the VVAR segment.
Definition arch_manager.hpp:17
#define ARION_VDSO_PRESENT
If this flag is set, the loader will map the VDSO segment.
Definition arch_manager.hpp:19
Definition arch_manager.hpp:180
ArchManager(std::shared_ptr< ARCH_ATTRIBUTES > attrs, std::map< std::string, REG > arch_regs, std::map< REG, uint8_t > arch_regs_sz, std::vector< REG > ctxt_regs, std::map< uint64_t, CPU_INTR > cpu_idt, bool hooks_intr)
Definition arch_manager.hpp:215
A class responsible for performing architecture specific operations in case of an x86 chip emulation.
Definition arch_x86.hpp:570
static void int_hook(std::shared_ptr< arion::Arion > arion, uint32_t intno, void *user_data)
ArchManagerX86()
Definition arch_x86.hpp:588
uint16_t new_tls(arion::ADDR udesc_addr)
ks_engine * curr_ks() override
void load_tls(arion::ADDR new_tls) override
arion::ADDR dump_tls() override
csh * curr_cs() override
Definition arch_x86.hpp:18
std::map< uint64_t, arion::CPU_INTR > IDT
The x86 Interrupt Descriptor Table.
Definition arch_x86.hpp:513
std::map< std::string, arion::REG > ARCH_REGS
A map identifying a Unicorn x86 register given its name.
Definition arch_x86.hpp:452
uint32_t HWCAP2
Some well working x86 chip HWCAP2 value.
Definition arch_x86.hpp:549
uint32_t HWCAP
Some well working x86 chip HWCAP value.
Definition arch_x86.hpp:552
std::vector< arion::REG > CTXT_REGS
The list of high-level x86 registers that make up the context to be saved and restored.
Definition arch_x86.hpp:503
const uint16_t ARCH_SZ
Size in bits of the x86 general-purpose registers.
Definition arch_x86.hpp:558
arion::ABI_SYSCALLING_CONVENTION ABI_SYSCALLING_CONV
Unicorn x86 registers involved in syscalling convention.
Definition arch_x86.hpp:541
arion::ARCH_ATTRIBUTES ARCH_ATTRS
Multiple architecture specific attributes for x86, grouped in a structure for genericity purpose.
Definition arch_x86.hpp:564
arion::KERNEL_SEG_FLAGS SEG_FLAGS
x86 flags telling the loader which kernel segments should be mapped in memory.
Definition arch_x86.hpp:546
arion::ABI_CALLING_CONVENTION ABI_CALLING_CONV
Unicorn x86 registers involved in calling convention.
Definition arch_x86.hpp:538
const size_t PTR_SZ
Size in bytes of a pointer in a x86 chip.
Definition arch_x86.hpp:555
std::map< arion::REG, uint8_t > ARCH_REGS_SZ
A map identifying a Unicorn x86 register size given the register.
Definition arch_x86.hpp:480
std::map< uint64_t, std::string > NAME_BY_SYSCALL_NO
A map identifying a x86 syscall name given its number.
Definition arch_x86.hpp:20
arion::ABI_REGISTERS ABI_REGS
Unicorn x86 PC and SP registers for genericity.
Definition arch_x86.hpp:535
arion::CPU_ARCH ARCH
Arion CPU_ARCH for x86.
Definition arch_x86.hpp:561
Definition arch_x86-64.hpp:11
uint64_t ADDR
Identifies a memory address.
Definition global_defs.hpp:36
CPU_ARCH
Identifies a CPU architecture.
Definition global_defs.hpp:128
@ X86_ARCH
The x86 CPU architecture.
Definition global_defs.hpp:132
uint8_t KERNEL_SEG_FLAGS
Flags telling the loader which architecture specific segments should stand in memory.
Definition arch_manager.hpp:31
@ X87_FLOATING_POINT_EXCEPTION
x87 Floating-point exception.
Definition arch_manager.hpp:148
@ OVERFLOW
Overflow exception.
Definition arch_manager.hpp:136
@ DOUBLE_FAULT
Double fault.
Definition arch_manager.hpp:140
@ INVALID_OPCODE
Invalid opcode exception.
Definition arch_manager.hpp:138
@ MACHINE_CHECK
Machine check.
Definition arch_manager.hpp:150
@ DEVICE_NOT_AVAILABLE
Device not available.
Definition arch_manager.hpp:139
@ RESERVED
Reserved interrupt vector.
Definition arch_manager.hpp:147
@ BOUND_RANGE_EXCEEDED
Bound range exceeded.
Definition arch_manager.hpp:137
@ PAGE_FAULT
Page fault.
Definition arch_manager.hpp:146
@ SIMD_FLOATING_POINT_ERROR
SIMD Floating-point exception.
Definition arch_manager.hpp:151
@ DIVIDE_ERROR
Divide-by-zero error.
Definition arch_manager.hpp:132
@ ALIGNMENT_CHECK
Alignment check.
Definition arch_manager.hpp:149
@ GENERAL_PROTECTION_FAULT
General protection fault.
Definition arch_manager.hpp:145
@ COPROCESSOR_SEGMENT_OVERRUN
Coprocessor segment overrun.
Definition arch_manager.hpp:141
@ STACK_SEGMENT_FAULT
Stack segment fault.
Definition arch_manager.hpp:144
@ DEBUG_EXCEPTION
Debug exception.
Definition arch_manager.hpp:133
@ BREAKPOINT
Breakpoint exception.
Definition arch_manager.hpp:135
@ INVALID_TSS
Invalid Task State Segment.
Definition arch_manager.hpp:142
@ NON_MASKABLE_INTR
Non-maskable interrupt.
Definition arch_manager.hpp:134
@ SEGMENT_NOT_PRESENT
Segment not present.
Definition arch_manager.hpp:143
Unicorn registers involved in calling convention.
Definition arch_manager.hpp:52
Unicorn PC and SP registers for genericity.
Definition arch_manager.hpp:37
Unicorn registers involved in syscalling convention.
Definition arch_manager.hpp:68
Multiple architecture specific attributes, grouped in a structure for genericity purpose.
Definition arch_manager.hpp:87