Arion 1.0.2-alpha
A high-performance C++ framework for emulating executable binaries.
 
Loading...
Searching...
No Matches
lnx_kernel_utils.hpp
Go to the documentation of this file.
1#ifndef ARION_LNX_KERNEL_UTILS_HPP
2#define ARION_LNX_KERNEL_UTILS_HPP
3
8#include <fcntl.h>
9#include <linux/futex.h>
10#include <linux/sched.h>
11#include <sys/mman.h>
12#include <sys/stat.h>
13#include <sys/un.h>
14
16{
17
18// Defined in https://elixir.bootlin.com/linux/v6.12.6/source/arch/x86/include/uapi/asm/signal.h#L93
21{
23 void *handler;
25 unsigned long flags;
27 void *restorer;
29 sigset_t mask;
30};
31
34{
36 uint32_t rlim_cur;
38 uint32_t rlim_max;
39};
40
42struct iovec32
43{
45 uint32_t iov_base;
47 uint32_t iov_len;
48};
49
52{
54 __kernel_long_t tv_sec;
56 __kernel_long_t tv_usec;
57};
58
61{
68};
69
98
100typedef unsigned long elf_greg_t;
102typedef unsigned long elf_freg_t[3];
103
110
113{
114 public:
118 ErrCodeType() : arion_type::KernelType("Error code", arion::LOG_COLOR::MAGENTA) {};
125 std::string str(std::shared_ptr<arion::Arion> arion, uint64_t val) override;
126};
128extern std::shared_ptr<ErrCodeType> ERR_CODE_TYPE;
129
132{
133 public:
137 FileDescriptorType() : arion_type::KernelType("File descriptor", arion::LOG_COLOR::MAGENTA) {};
144 std::string str(std::shared_ptr<arion::Arion> arion, uint64_t val) override;
145};
147extern std::shared_ptr<FileDescriptorType> FILE_DESCRIPTOR_TYPE;
148
151{
152 public:
156 InAddrTType() : arion_type::KernelType("Type in_addr_t", arion::LOG_COLOR::CYAN) {};
163 std::string str(std::shared_ptr<arion::Arion> arion, uint64_t val) override;
164};
166extern std::shared_ptr<InAddrTType> IN_ADDR_T_TYPE;
167
170{
171 public:
175 In6AddrTType() : arion_type::KernelType("Type in6_addr_t", arion::LOG_COLOR::CYAN) {};
182 std::string str(std::shared_ptr<arion::Arion> arion, uint64_t val) override;
183};
185extern std::shared_ptr<In6AddrTType> IN6_ADDR_T_TYPE;
186
189{
190 public:
194 AccessModeType() : arion_type::FlagType("Access mode", {{0, "F_OK"}, {1, "X_OK"}, {2, "W_OK"}, {4, "R_OK"}}) {};
195};
197extern std::shared_ptr<AccessModeType> ACCESS_MODE_TYPE;
198
201{
202 public:
207 : arion_type::FlagType("Open mode", {{0, "O_RDONLY"},
208 {1, "O_WRONLY"},
209 {2, "O_RDWR"},
210 {0100, "O_CREAT"},
211 {0200, "O_EXCL"},
212 {0400, "O_NOCTTY"},
213 {01000, "O_TRUNC"},
214 {02000, "O_APPEND"},
215 {04000, "O_NONBLOCK"},
216 {04010000, "O_SYNC"},
217 {020000, "O_ASYNC"},
218 {0100000, "O_LARGEFILE"},
219 {0200000, "O_DIRECTORY"},
220 {0400000, "O_NOFOLLOW"},
221 {02000000, "O_CLOEXEC"},
222 {040000, "O_DIRECT"},
223 {01000000, "O_NOATIME"},
224 {010000000, "O_PATH"},
225 {010000, "O_DSYNC"},
226 {020000000 | 0200000, "__O_TMPFILE"}}) {};
227};
229extern std::shared_ptr<OpenModeType> OPEN_MODE_TYPE;
230
233{
234 public:
239 : arion_type::FlagType("File AT flag", {{-100, "AT_FDCWD"},
240 {0x100, "AT_SYMLINK_NOFOLLOW"},
241 {0x200, "AT_REMOVEDIR"},
242 {0x400, "AT_SYMLINK_FOLLOW"},
243 {0x800, "AT_NO_AUTOMOUNT"},
244 {0x1000, "AT_EMPTY_PATH"},
245 {0x6000, "AT_STATX_SYNC_TYPE"},
246 {0x0000, "AT_STATX_SYNC_AS_STAT"},
247 {0x2000, "AT_STATX_FORCE_SYNC"},
248 {0x4000, "AT_STATX_DONT_SYNC"},
249 {0x8000, "AT_RECURSIVE"}}) {};
250};
252extern std::shared_ptr<FileATFlagType> FILE_AT_FLAG_TYPE;
253
256{
257 public:
262 : arion_type::FlagType("Statx mask", {{0x00000001U, "STATX_TYPE"},
263 {0x00000002U, "STATX_MODE"},
264 {0x00000004U, "STATX_NLINK"},
265 {0x00000008U, "STATX_UID"},
266 {0x00000010U, "STATX_GID"},
267 {0x00000020U, "STATX_ATIME"},
268 {0x00000040U, "STATX_MTIME"},
269 {0x00000080U, "STATX_CTIME"},
270 {0x00000100U, "STATX_INO"},
271 {0x00000200U, "STATX_SIZE"},
272 {0x00000400U, "STATX_BLOCKS"},
273 {0x000007ffU, "STATX_BASIC_STATS"},
274 {0x00000800U, "STATX_BTIME"},
275 {0x00001000U, "STATX_MNT_ID"},
276 {0x00002000U, "STATX_DIOALIGN"},
277 {0x00004000U, "STATX_MNT_ID_UNIQUE"},
278 {0x00008000U, "STATX_SUBVOL"},
279 {0x10000, "STATX_WRITE_ATOMIC"}}) {};
280};
282extern std::shared_ptr<StatxMaskType> STATX_MASK_TYPE;
283
286{
287 public:
292 : arion_type::FlagType("Statx attributes", {{0x4, "STATX_ATTR_COMPRESSED"},
293 {0x10, "STATX_ATTR_IMMUTABLE"},
294 {0x20, "STATX_ATTR_APPEND"},
295 {0x40, "STATX_ATTR_NODUMP"},
296 {0x800, "STATX_ATTR_ENCRYPTED"},
297 {0x1000, "STATX_ATTR_VERITY"},
298 {0x2000, "STATX_ATTR_MOUNT_ROOT"},
299 {0x200000, "STATX_ATTR_DAX"},
300 {0x400000, "STATX_ATTR_WRITE_ATOMIC"}}) {};
301};
303extern std::shared_ptr<StatxAttrsType> STATX_ATTRS_TYPE;
304
307{
308 public:
312 ProtFlagType() : arion_type::KernelType("Protection flag", arion::LOG_COLOR::ORANGE) {};
319 std::string str(std::shared_ptr<arion::Arion> arion, uint64_t val) override;
320};
322extern std::shared_ptr<ProtFlagType> PROT_FLAG_TYPE;
323
326{
327 public:
332 : arion_type::FlagType("Mmap flag", {{0x0, "MAP_FILE"},
333 {0x1, "MAP_SHARED"},
334 {0x2, "MAP_PRIVATE"},
335 {0x3, "MAP_SHARED_VALIDATE"},
336 {0x10, "MAP_FIXED"},
337 {0x20, "MAP_ANONYMOUS"},
338 {0x40, "MAP_32BIT"},
339 {0x100, "MAP_GROWSDOWN"},
340 {0x800, "MAP_DENYWRITE"},
341 {0x1000, "MAP_EXECUTABLE"},
342 {0x2000, "MAP_LOCKED"},
343 {0x4000, "MAP_NORESERVE"},
344 {0x8000, "MAP_POPULATE"},
345 {0x10000, "MAP_NONBLOCK"},
346 {0x20000, "MAP_STACK"},
347 {0x40000, "MAP_HUGETLB"},
348 {0x80000, "MAP_SYNC"},
349 {0x100000, "MAP_FIXED_NOREPLACE"}}) {};
350};
352extern std::shared_ptr<MmapFlagType> MMAP_FLAG_TYPE;
353
356{
357 public:
363 "Seek whence", {{0, "SEEK_SET"}, {1, "SEEK_CUR"}, {2, "SEEK_END"}, {3, "SEEK_DATA"}, {4, "SEEK_HOLE"}}) {
364 };
365};
367extern std::shared_ptr<SeekWhenceType> SEEK_WHENCE_TYPE;
368
371{
372 public:
377 : arion_type::FlagType("Futex operation", {{0, "FUTEX_WAIT"},
378 {1, "FUTEX_WAKE"},
379 {2, "FUTEX_FD"},
380 {3, "FUTEX_REQUEUE"},
381 {4, "FUTEX_CMP_REQUEUE"},
382 {5, "FUTEX_WAKE_OP"},
383 {6, "FUTEX_LOCK_PI"},
384 {7, "FUTEX_UNLOCK_PI"},
385 {8, "FUTEX_TRYLOCK_PI"},
386 {9, "FUTEX_WAIT_BITSET"},
387 {10, "FUTEX_WAKE_BITSET"},
388 {11, "FUTEX_WAIT_REQUEUE_PI"},
389 {12, "FUTEX_CMP_REQUEUE_PI"},
390 {13, "FUTEX_LOCK_PI2"},
391 {128, "FUTEX_PRIVATE_FLAG"},
392 {256, "FUTEX_CLOCK_REALTIME"},
393 // Private variants (base + FUTEX_PRIVATE_FLAG = +128)
394 {0 + 128, "FUTEX_WAIT_PRIVATE"},
395 {1 + 128, "FUTEX_WAKE_PRIVATE"},
396 {3 + 128, "FUTEX_REQUEUE_PRIVATE"},
397 {4 + 128, "FUTEX_CMP_REQUEUE_PRIVATE"},
398 {5 + 128, "FUTEX_WAKE_OP_PRIVATE"},
399 {6 + 128, "FUTEX_LOCK_PI_PRIVATE"},
400 {13 + 128, "FUTEX_LOCK_PI2_PRIVATE"},
401 {7 + 128, "FUTEX_UNLOCK_PI_PRIVATE"},
402 {8 + 128, "FUTEX_TRYLOCK_PI_PRIVATE"},
403 {9 + 128, "FUTEX_WAIT_BITSET_PRIVATE"},
404 {10 + 128, "FUTEX_WAKE_BITSET_PRIVATE"},
405 {11 + 128, "FUTEX_WAIT_REQUEUE_PI_PRIVATE"},
406 {12 + 128, "FUTEX_CMP_REQUEUE_PI_PRIVATE"}}) {};
407};
409extern std::shared_ptr<FutexOpType> FUTEX_OP_TYPE;
410
413{
414 public:
419 : arion_type::FlagType("Clone flag", {{0x000000ff, "CSIGNAL"},
420 {0x00000100, "CLONE_VM"},
421 {0x00000200, "CLONE_FS"},
422 {0x00000400, "CLONE_FILES"},
423 {0x00000800, "CLONE_SIGHAND"},
424 {0x00001000, "CLONE_PIDFD"},
425 {0x00002000, "CLONE_PTRACE"},
426 {0x00004000, "CLONE_VFORK"},
427 {0x00008000, "CLONE_PARENT"},
428 {0x00010000, "CLONE_THREAD"},
429 {0x00020000, "CLONE_NEWNS"},
430 {0x00040000, "CLONE_SYSVSEM"},
431 {0x00080000, "CLONE_SETTLS"},
432 {0x00100000, "CLONE_PARENT_SETTID"},
433 {0x00200000, "CLONE_CHILD_CLEARTID"},
434 {0x00400000, "CLONE_DETACHED"},
435 {0x00800000, "CLONE_UNTRACED"},
436 {0x01000000, "CLONE_CHILD_SETTID"},
437 {0x02000000, "CLONE_NEWCGROUP"},
438 {0x04000000, "CLONE_NEWUTS"},
439 {0x08000000, "CLONE_NEWIPC"},
440 {0x10000000, "CLONE_NEWUSER"},
441 {0x20000000, "CLONE_NEWPID"},
442 {0x40000000, "CLONE_NEWNET"},
443 {0x80000000, "CLONE_IO"},
444 {0x100000000ULL, "CLONE_CLEAR_SIGHAND"},
445 {0x200000000ULL, "CLONE_INTO_CGROUP"},
446 {0x00000080, "CLONE_NEWTIME"}}) {};
447};
449extern std::shared_ptr<CloneFlagType> CLONE_FLAG_TYPE;
450
453{
454 public:
459 : arion_type::FlagType("Signal",
460 {{1, "SIGHUP"}, {2, "SIGINT"}, {3, "SIGQUIT"}, {4, "SIGILL"}, {5, "SIGTRAP"},
461 {6, "SIGABRT"}, {6, "SIGIOT"}, {7, "SIGBUS"}, {8, "SIGFPE"}, {9, "SIGKILL"},
462 {10, "SIGUSR1"}, {11, "SIGSEGV"}, {12, "SIGUSR2"}, {13, "SIGPIPE"}, {14, "SIGALRM"},
463 {15, "SIGTERM"}, {16, "SIGSTKFLT"}, {17, "SIGCHLD"}, {18, "SIGCONT"}, {19, "SIGSTOP"},
464 {20, "SIGTSTP"}, {21, "SIGTTIN"}, {22, "SIGTTOU"}, {23, "SIGURG"}, {24, "SIGXCPU"},
465 {25, "SIGXFSZ"}, {26, "SIGVTALRM"}, {27, "SIGPROF"}, {28, "SIGWINCH"}, {29, "SIGIO"},
466 {30, "SIGPWR"}, {31, "SIGSYS"}}) {};
467};
469extern std::shared_ptr<SignalType> SIGNAL_TYPE;
470
473{
474 public:
479 : arion_type::FlagType("File mode",
480 {{00170000, "S_IFMT"}, {0140000, "S_IFSOCK"}, {0120000, "S_IFLNK"}, {0100000, "S_IFREG"},
481 {0060000, "S_IFBLK"}, {0040000, "S_IFDIR"}, {0020000, "S_IFCHR"}, {0010000, "S_IFIFO"},
482 {0004000, "S_ISUID"}, {0002000, "S_ISGID"}, {0001000, "S_ISVTX"}, {00700, "S_IRWXU"},
483 {00400, "S_IRUSR"}, {00200, "S_IWUSR"}, {00100, "S_IXUSR"}, {00070, "S_IRWXG"},
484 {00040, "S_IRGRP"}, {00020, "S_IWGRP"}, {00010, "S_IXGRP"}, {00007, "S_IRWXO"},
485 {00004, "S_IROTH"}, {00002, "S_IWOTH"}, {00001, "S_IXOTH"}}) {};
486};
488extern std::shared_ptr<FileModeType> FILE_MODE_TYPE;
489
492{
493 public:
499 "Socket domain",
500 {{0, "AF_UNSPEC"}, {1, "AF_LOCAL"}, {2, "AF_INET"}, {3, "AF_AX25"}, {4, "AF_IPX"},
501 {5, "AF_APPLETALK"}, {6, "AF_NETROM"}, {7, "AF_BRIDGE"}, {8, "AF_ATMPVC"}, {9, "AF_X25"},
502 {10, "AF_INET6"}, {11, "AF_ROSE"}, {12, "AF_DECnet"}, {13, "AF_NETBEUI"}, {14, "AF_SECURITY"},
503 {15, "AF_KEY"}, {16, "AF_ROUTE"}, {17, "AF_PACKET"}, {18, "AF_ASH"}, {19, "AF_ECONET"},
504 {20, "AF_ATMSVC"}, {21, "AF_RDS"}, {22, "AF_SNA"}, {23, "AF_IRDA"}, {24, "AF_PPPOX"},
505 {25, "AF_WANPIPE"}, {26, "AF_LLC"}, {27, "AF_IB"}, {28, "AF_MPLS"}, {29, "AF_CAN"},
506 {30, "AF_TIPC"}, {31, "AF_BLUETOOTH"}, {32, "AF_IUCV"}, {33, "AF_RXRPC"}, {34, "AF_ISDN"},
507 {35, "AF_PHONET"}, {36, "AF_IEEE802154"}, {37, "AF_CAIF"}, {38, "AF_ALG"}, {39, "AF_NFC"},
508 {40, "AF_VSOCK"}, {41, "AF_KCM"}, {42, "AF_QIPCRTR"}, {43, "AF_SMC"}, {44, "AF_XDP"},
509 {45, "AF_MCTP"}}) {};
510};
512extern std::shared_ptr<SocketDomainType> SOCKET_DOMAIN_TYPE;
513
516{
517 public:
522 : arion_type::FlagType("Socket domain", {{1, "SOCK_STREAM"},
523 {2, "SOCK_DGRAM"},
524 {3, "SOCK_RAW"},
525 {4, "SOCK_RDM"},
526 {5, "SOCK_SEQPACKET"},
527 {6, "SOCK_DCCP"},
528 {10, "SOCK_PACKET"},
529 {00004000, "SOCK_NONBLOCK"},
530 {02000000, "SOCK_CLOEXEC"}}) {};
531};
533extern std::shared_ptr<SocketTypeType> SOCKET_TYPE_TYPE;
534
537{
538 public:
544 {{ftype::PTR_SZ, arion_type::INT_TYPE, "st_dev"},
545 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_ino"},
546 {{32}, ftype::V16, arion_lnx_type::FILE_MODE_TYPE, "st_mode"},
548 {{32}, ftype::V16, arion_type::INT_TYPE, "st_nlink"},
549 {{arion::CPU_ARCH::X8664_ARCH}, ftype::V64, arion_type::INT_TYPE, "st_nlink"},
550 {{arion::CPU_ARCH::ARM64_ARCH}, ftype::V32, arion_type::INT_TYPE, "st_nlink"},
552 {{32}, ftype::V16, arion_type::INT_TYPE, "st_uid"},
553 {{64}, ftype::V32, arion_type::INT_TYPE, "st_uid"},
554 {{32}, ftype::V16, arion_type::INT_TYPE, "st_gid"},
555 {{64}, ftype::V32, arion_type::INT_TYPE, "st_gid"},
556 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_rdev"},
557 {{arion::CPU_ARCH::ARM64_ARCH}, ftype::PTR_SZ, arion_type::INT_TYPE, "__pad1"},
558 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_size"},
559 {{32}, ftype::PTR_SZ, arion_type::INT_TYPE, "st_blksize"},
560 {{arion::CPU_ARCH::X8664_ARCH}, ftype::PTR_SZ, arion_type::INT_TYPE, "st_blksize"},
561 {{arion::CPU_ARCH::ARM64_ARCH}, ftype::V32, arion_type::INT_TYPE, "st_blksize"},
562 {{arion::CPU_ARCH::ARM64_ARCH}, ftype::V32, arion_type::INT_TYPE, "__pad2"},
563 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_blocks"},
564 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_atime"},
565 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_atime_ns"},
566 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_mtime"},
567 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_mtime_ns"},
568 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_ctime"},
569 {ftype::PTR_SZ, arion_type::INT_TYPE, "st_ctime_ns"},
570 {{32}, ftype::PTR_SZ, arion_type::INT_TYPE, "__unused1"},
571 {{arion::CPU_ARCH::X8664_ARCH}, ftype::PTR_SZ, arion_type::INT_TYPE, "__unused1"},
572 {{arion::CPU_ARCH::ARM64_ARCH}, ftype::V32, arion_type::INT_TYPE, "__unused1"},
573 {{32}, ftype::PTR_SZ, arion_type::INT_TYPE, "__unused2"},
574 {{arion::CPU_ARCH::X8664_ARCH}, ftype::PTR_SZ, arion_type::INT_TYPE, "__unused2"},
575 {{arion::CPU_ARCH::ARM64_ARCH}, ftype::V32, arion_type::INT_TYPE, "__unused2"},
576 {{arion::CPU_ARCH::X8664_ARCH}, ftype::PTR_SZ, arion_type::INT_TYPE, "__unused3"}}) {};
577};
579extern std::shared_ptr<StatStructFactory> STAT_STRUCT_FACTORY;
580
583{
584 public:
589};
591extern std::shared_ptr<StructStatType> STRUCT_STAT_TYPE;
592
595{
596 public:
602 {ftype::V32, arion_lnx_type::STATX_MASK_TYPE, "stx_mask"},
603 {ftype::V32, arion_type::INT_TYPE, "stx_blksize"},
604 {ftype::V64, arion_lnx_type::STATX_ATTRS_TYPE, "stx_attributes"},
605 {ftype::V32, arion_type::INT_TYPE, "stx_nlink"},
606 {ftype::V32, arion_type::INT_TYPE, "stx_uid"},
607 {ftype::V32, arion_type::INT_TYPE, "stx_gid"},
608 {ftype::V16, arion_lnx_type::FILE_MODE_TYPE, "stx_mode"},
609 {ftype::V16, arion_type::INT_TYPE, "__unused1"},
610 {ftype::V64, arion_type::INT_TYPE, "stx_ino"},
611 {ftype::V64, arion_type::INT_TYPE, "stx_size"},
612 {ftype::V64, arion_type::INT_TYPE, "stx_blocks"},
613 {ftype::V64, arion_lnx_type::STATX_ATTRS_TYPE, "stx_attributes_mask"},
614 {ftype::V64, arion_type::INT_TYPE, "stx_atime_tv_sec"},
615 {ftype::V32, arion_type::INT_TYPE, "stx_atime_tv_nsec"},
616 {ftype::V32, arion_type::INT_TYPE, "stx_atime_unused1"},
617 {ftype::V64, arion_type::INT_TYPE, "stx_btime_tv_sec"},
618 {ftype::V32, arion_type::INT_TYPE, "stx_btime_tv_nsec"},
619 {ftype::V32, arion_type::INT_TYPE, "stx_btime_unused1"},
620 {ftype::V64, arion_type::INT_TYPE, "stx_ctime_tv_sec"},
621 {ftype::V32, arion_type::INT_TYPE, "stx_ctime_tv_nsec"},
622 {ftype::V32, arion_type::INT_TYPE, "stx_ctime_unused1"},
623 {ftype::V64, arion_type::INT_TYPE, "stx_mtime_tv_sec"},
624 {ftype::V32, arion_type::INT_TYPE, "stx_mtime_tv_nsec"},
625 {ftype::V32, arion_type::INT_TYPE, "stx_mtime_unused1"},
626 {ftype::V32, arion_type::INT_TYPE, "stx_rdev_major"},
627 {ftype::V32, arion_type::INT_TYPE, "stx_rdev_minor"},
628 {ftype::V32, arion_type::INT_TYPE, "stx_dev_major"},
629 {ftype::V32, arion_type::INT_TYPE, "stx_dev_minor"},
630 {ftype::A64, arion_type::INT_TYPE, "unused2", 14},
631 }) {};
632};
634extern std::shared_ptr<StatxStructFactory> STATX_STRUCT_FACTORY;
635
638{
639 public:
644};
646extern std::shared_ptr<StructStatxType> STRUCT_STATX_TYPE;
647
650{
651 public:
657 {{ftype::V64, arion_type::INT_TYPE, "tv_sec"}, {ftype::V64, arion_type::INT_TYPE, "tv_nsec"}}) {};
658};
660extern std::shared_ptr<TimespecStructFactory> TIMESPEC_STRUCT_FACTORY;
661
664{
665 public:
670};
672extern std::shared_ptr<StructTimespecType> STRUCT_TIMESPEC_TYPE;
673
676{
677 public:
683 {ftype::V64, arion_type::INT_TYPE, "pidfd"},
684 {ftype::V64, arion_type::INT_TYPE, "child_tid"},
685 {ftype::V64, arion_type::INT_TYPE, "parent_tid"},
686 {ftype::V64, arion_lnx_type::SIGNAL_TYPE, "exit_signal"},
687 {ftype::V64, arion_type::INT_TYPE, "stack"},
688 {ftype::V64, arion_type::INT_TYPE, "stack_size"},
689 {ftype::V64, arion_type::INT_TYPE, "tls"},
690 {ftype::V64, arion_type::INT_TYPE, "set_tid"},
691 {ftype::V64, arion_type::INT_TYPE, "set_tid_size"},
692 {ftype::V64, arion_lnx_type::FILE_DESCRIPTOR_TYPE, "cgroup"}}) {};
693};
695extern std::shared_ptr<CloneArgsStructFactory> CLONE_ARGS_STRUCT_FACTORY;
696
699{
700 public:
705};
707extern std::shared_ptr<StructCloneArgsType> STRUCT_CLONE_ARGS_TYPE;
708
711{
712 public:
718 {ftype::V16, arion_type::INT_TYPE, "sin_port"},
719 {ftype::V32, arion_lnx_type::IN_ADDR_T_TYPE, "sin_addr"}}) {};
720};
722extern std::shared_ptr<SockaddrInStructFactory> SOCKADDR_IN_STRUCT_FACTORY;
723
726{
727 public:
732};
734extern std::shared_ptr<StructSockaddrInType> STRUCT_SOCKADDR_IN_TYPE;
735
738{
739 public:
745 {ftype::V16, arion_lnx_type::SOCKET_DOMAIN_TYPE, "sin6_family"},
746 {ftype::V16, arion_type::INT_TYPE, "sin6_port"},
747 {ftype::V32, arion_type::INT_TYPE, "sin6_flowinfo"},
748 {ftype::A8, arion_lnx_type::IN6_ADDR_T_TYPE, "sin6_addr", 16},
749 {ftype::V32, arion_type::INT_TYPE, "sin6_scope_id"},
750 }) {};
751};
753extern std::shared_ptr<SockaddrIn6StructFactory> SOCKADDR_IN6_STRUCT_FACTORY;
754
757{
758 public:
763};
765extern std::shared_ptr<StructSockaddrIn6Type> STRUCT_SOCKADDR_IN6_TYPE;
766
769{
770 public:
776};
778extern std::shared_ptr<SockaddrUnStructFactory> SOCKADDR_UN_STRUCT_FACTORY;
779
782{
783 public:
795 std::string str(std::shared_ptr<arion::Arion> arion, uint64_t val) override;
796};
798extern std::shared_ptr<StructSockaddrUnType> STRUCT_SOCKADDR_UN_TYPE;
799
803{
804 private:
812 std::shared_ptr<arion_poly_struct::AbsArionStructType> process(std::shared_ptr<arion::Arion> arion,
813 uint64_t val) override;
814
815 public:
820};
822extern std::shared_ptr<StructSockaddrType> STRUCT_SOCKADDR_TYPE;
823
824} // namespace arion_lnx_type
825
826#endif // ARION_LNX_KERNEL_UTILS_HPP
Type representing the access modes for the access() syscall (R_OK, W_OK, X_OK, F_OK).
Definition lnx_kernel_utils.hpp:189
AccessModeType()
Definition lnx_kernel_utils.hpp:194
Polymorphic structure factory for the Linux struct clone_args structure.
Definition lnx_kernel_utils.hpp:676
CloneArgsStructFactory()
Definition lnx_kernel_utils.hpp:681
Type representing the flags for the clone() syscall (CLONE_VM, CLONE_THREAD, etc.).
Definition lnx_kernel_utils.hpp:413
CloneFlagType()
Definition lnx_kernel_utils.hpp:418
Type used for syscall return error codes (negative values).
Definition lnx_kernel_utils.hpp:113
std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val) override
ErrCodeType()
Definition lnx_kernel_utils.hpp:118
Type representing the flags used by the *at file syscalls (openat, faccessat, etc....
Definition lnx_kernel_utils.hpp:233
FileATFlagType()
Definition lnx_kernel_utils.hpp:238
Type used for file descriptor values.
Definition lnx_kernel_utils.hpp:132
std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val) override
FileDescriptorType()
Definition lnx_kernel_utils.hpp:137
Type representing Unix file modes (permissions and file type).
Definition lnx_kernel_utils.hpp:473
FileModeType()
Definition lnx_kernel_utils.hpp:478
Type representing the operation codes for the futex() syscall.
Definition lnx_kernel_utils.hpp:371
FutexOpType()
Definition lnx_kernel_utils.hpp:376
Type used for 128-bit IPv6 address values (in6_addr_t).
Definition lnx_kernel_utils.hpp:170
std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val) override
In6AddrTType()
Definition lnx_kernel_utils.hpp:175
Type used for 32-bit IPv4 address values (in_addr_t).
Definition lnx_kernel_utils.hpp:151
InAddrTType()
Definition lnx_kernel_utils.hpp:156
std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val) override
Type representing the flags for the mmap() syscall (MAP_SHARED, MAP_ANONYMOUS, etc....
Definition lnx_kernel_utils.hpp:326
MmapFlagType()
Definition lnx_kernel_utils.hpp:331
Type representing the open modes for the open() syscall (O_RDONLY, O_CREAT, etc.).
Definition lnx_kernel_utils.hpp:201
OpenModeType()
Definition lnx_kernel_utils.hpp:206
Type representing the memory protection flags for mmap/mprotect (PROT_READ, PROT_WRITE,...
Definition lnx_kernel_utils.hpp:307
std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val) override
ProtFlagType()
Definition lnx_kernel_utils.hpp:312
Type representing the seek origin flags for lseek (SEEK_SET, SEEK_CUR, SEEK_END).
Definition lnx_kernel_utils.hpp:356
SeekWhenceType()
Definition lnx_kernel_utils.hpp:361
Type representing Linux signals (SIGHUP, SIGINT, SIGSEGV, etc.).
Definition lnx_kernel_utils.hpp:453
SignalType()
Definition lnx_kernel_utils.hpp:458
Polymorphic structure factory for the IPv6 socket address struct sockaddr_in6.
Definition lnx_kernel_utils.hpp:738
SockaddrIn6StructFactory()
Definition lnx_kernel_utils.hpp:743
Polymorphic structure factory for the IPv4 socket address struct sockaddr_in.
Definition lnx_kernel_utils.hpp:711
SockaddrInStructFactory()
Definition lnx_kernel_utils.hpp:716
Polymorphic structure factory for the Unix domain socket address struct sockaddr_un.
Definition lnx_kernel_utils.hpp:769
SockaddrUnStructFactory()
Definition lnx_kernel_utils.hpp:774
Type representing the socket address families (domains) (AF_INET, AF_LOCAL, etc.).
Definition lnx_kernel_utils.hpp:492
SocketDomainType()
Definition lnx_kernel_utils.hpp:497
Type representing the socket types (SOCK_STREAM, SOCK_DGRAM, etc.).
Definition lnx_kernel_utils.hpp:516
SocketTypeType()
Definition lnx_kernel_utils.hpp:521
Polymorphic structure factory for the Unix struct stat (file status) structure.
Definition lnx_kernel_utils.hpp:537
StatStructFactory()
Definition lnx_kernel_utils.hpp:542
Type representing the file attributes flags returned by the statx() syscall.
Definition lnx_kernel_utils.hpp:286
StatxAttrsType()
Definition lnx_kernel_utils.hpp:291
Type representing the mask of requested fields for the statx() syscall.
Definition lnx_kernel_utils.hpp:256
StatxMaskType()
Definition lnx_kernel_utils.hpp:261
Polymorphic structure factory for the Linux struct statx (extended file status) structure.
Definition lnx_kernel_utils.hpp:595
StatxStructFactory()
Definition lnx_kernel_utils.hpp:600
Arion structure type wrapper for struct clone_args.
Definition lnx_kernel_utils.hpp:699
StructCloneArgsType()
Definition lnx_kernel_utils.hpp:704
Arion structure type wrapper for struct sockaddr_in6.
Definition lnx_kernel_utils.hpp:757
StructSockaddrIn6Type()
Definition lnx_kernel_utils.hpp:762
Arion structure type wrapper for struct sockaddr_in.
Definition lnx_kernel_utils.hpp:726
StructSockaddrInType()
Definition lnx_kernel_utils.hpp:731
Definition lnx_kernel_utils.hpp:803
StructSockaddrType()
Definition lnx_kernel_utils.hpp:819
std::shared_ptr< arion_poly_struct::AbsArionStructType > process(std::shared_ptr< arion::Arion > arion, uint64_t val) override
Arion structure type wrapper for struct sockaddr_un.
Definition lnx_kernel_utils.hpp:782
std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val) override
StructSockaddrUnType()
Definition lnx_kernel_utils.hpp:787
Arion structure type wrapper for struct stat.
Definition lnx_kernel_utils.hpp:583
StructStatType()
Definition lnx_kernel_utils.hpp:588
Arion structure type wrapper for struct statx.
Definition lnx_kernel_utils.hpp:638
StructStatxType()
Definition lnx_kernel_utils.hpp:643
Arion structure type wrapper for struct timespec.
Definition lnx_kernel_utils.hpp:664
StructTimespecType()
Definition lnx_kernel_utils.hpp:669
Polymorphic structure factory for the POSIX struct timespec structure.
Definition lnx_kernel_utils.hpp:650
TimespecStructFactory()
Definition lnx_kernel_utils.hpp:655
Definition struct_utils.hpp:946
ArionStructType(std::string name, std::shared_ptr< arion_poly_struct::PolymorphicStructFactory< struct stat > > factory)
Definition struct_utils.hpp:957
Definition struct_utils.hpp:988
ArionVariableStructType(std::string name)
Definition struct_utils.hpp:1005
Definition struct_utils.hpp:200
PolymorphicStructFactory(std::vector< POLYMORPHIC_STRUCT_FIELD > fields)
Definition struct_utils.hpp:288
Class for data types represented as a set of bit flags or discrete symbolic constants.
Definition type_utils.hpp:134
FlagType(std::string name, std::map< uint64_t, std::string > flag_map)
Definition type_utils.hpp:145
Abstract base class for all kernel-related data types used for visualization/logging.
Definition type_utils.hpp:27
KernelType(std::string name, arion::LOG_COLOR color=arion::LOG_COLOR::DEFAULT)
Definition type_utils.hpp:40
Definition lnx_kernel_utils.hpp:16
std::shared_ptr< StructStatxType > STRUCT_STATX_TYPE
Shared pointer to the singleton instance of StructStatxType.
std::shared_ptr< StatxAttrsType > STATX_ATTRS_TYPE
Shared pointer to the singleton instance of StatxAttrsType.
std::shared_ptr< ErrCodeType > ERR_CODE_TYPE
Shared pointer to the singleton instance of ErrCodeType.
std::shared_ptr< CloneArgsStructFactory > CLONE_ARGS_STRUCT_FACTORY
Shared pointer to the singleton instance of CloneArgsStructFactory.
std::shared_ptr< CloneFlagType > CLONE_FLAG_TYPE
Shared pointer to the singleton instance of CloneFlagType.
std::shared_ptr< AccessModeType > ACCESS_MODE_TYPE
Shared pointer to the singleton instance of AccessModeType.
std::shared_ptr< StructCloneArgsType > STRUCT_CLONE_ARGS_TYPE
Shared pointer to the singleton instance of StructCloneArgsType.
std::shared_ptr< ProtFlagType > PROT_FLAG_TYPE
Shared pointer to the singleton instance of ProtFlagType.
std::shared_ptr< StatStructFactory > STAT_STRUCT_FACTORY
Shared pointer to the singleton instance of StatStructFactory.
std::shared_ptr< StatxStructFactory > STATX_STRUCT_FACTORY
Shared pointer to the singleton instance of StatxStructFactory.
std::shared_ptr< StructSockaddrInType > STRUCT_SOCKADDR_IN_TYPE
Shared pointer to the singleton instance of StructSockaddrInType.
std::shared_ptr< SignalType > SIGNAL_TYPE
Shared pointer to the singleton instance of SignalType.
std::shared_ptr< SockaddrUnStructFactory > SOCKADDR_UN_STRUCT_FACTORY
Shared pointer to the singleton instance of SockaddrUnStructFactory.
std::shared_ptr< MmapFlagType > MMAP_FLAG_TYPE
Shared pointer to the singleton instance of MmapFlagType.
std::shared_ptr< FileModeType > FILE_MODE_TYPE
Shared pointer to the singleton instance of FileModeType.
std::shared_ptr< In6AddrTType > IN6_ADDR_T_TYPE
Shared pointer to the singleton instance of In6AddrTType.
std::shared_ptr< StructSockaddrUnType > STRUCT_SOCKADDR_UN_TYPE
Shared pointer to the singleton instance of StructSockaddrUnType.
std::shared_ptr< StructSockaddrType > STRUCT_SOCKADDR_TYPE
Shared pointer to the singleton instance of StructSockaddrType.
std::shared_ptr< StructTimespecType > STRUCT_TIMESPEC_TYPE
Shared pointer to the singleton instance of StructTimespecType.
std::shared_ptr< StructSockaddrIn6Type > STRUCT_SOCKADDR_IN6_TYPE
Shared pointer to the singleton instance of StructSockaddrIn6Type.
std::shared_ptr< OpenModeType > OPEN_MODE_TYPE
Shared pointer to the singleton instance of OpenModeType.
std::shared_ptr< TimespecStructFactory > TIMESPEC_STRUCT_FACTORY
Shared pointer to the singleton instance of TimespecStructFactory.
std::shared_ptr< StatxMaskType > STATX_MASK_TYPE
Shared pointer to the singleton instance of StatxMaskType.
std::shared_ptr< StructStatType > STRUCT_STAT_TYPE
Shared pointer to the singleton instance of StructStatType.
std::shared_ptr< SocketTypeType > SOCKET_TYPE_TYPE
Shared pointer to the singleton instance of SocketTypeType.
std::shared_ptr< SockaddrIn6StructFactory > SOCKADDR_IN6_STRUCT_FACTORY
Shared pointer to the singleton instance of SockaddrIn6StructFactory.
std::shared_ptr< InAddrTType > IN_ADDR_T_TYPE
Shared pointer to the singleton instance of InAddrTType.
unsigned long elf_greg_t
Type definition for a single general-purpose register value in an ELF core dump.
Definition lnx_kernel_utils.hpp:100
std::shared_ptr< FutexOpType > FUTEX_OP_TYPE
Shared pointer to the singleton instance of FutexOpType.
std::shared_ptr< SockaddrInStructFactory > SOCKADDR_IN_STRUCT_FACTORY
Shared pointer to the singleton instance of SockaddrInStructFactory.
std::shared_ptr< FileDescriptorType > FILE_DESCRIPTOR_TYPE
Shared pointer to the singleton instance of FileDescriptorType.
arion::PROT_FLAGS kernel_prot_to_arion_prot(int kflags)
std::shared_ptr< FileATFlagType > FILE_AT_FLAG_TYPE
Shared pointer to the singleton instance of FileATFlagType.
std::shared_ptr< SeekWhenceType > SEEK_WHENCE_TYPE
Shared pointer to the singleton instance of SeekWhenceType.
std::shared_ptr< SocketDomainType > SOCKET_DOMAIN_TYPE
Shared pointer to the singleton instance of SocketDomainType.
unsigned long elf_freg_t[3]
Type definition for an FPU register value in an ELF core dump (typically for legacy 32-bit x86).
Definition lnx_kernel_utils.hpp:102
Definition type_utils.hpp:23
std::shared_ptr< IntType > INT_TYPE
Shared pointer to the singleton instance of IntType.
Definition arch_x86-64.hpp:11
@ X8664_ARCH
The x86-64 CPU architecture.
Definition global_defs.hpp:134
@ ARM64_ARCH
The ARM64 CPU architecture.
Definition global_defs.hpp:138
uint8_t PROT_FLAGS
Identifies memory protection rights.
Definition global_defs.hpp:38
Kernel structure for time value used in older syscalls (gettimeofday, ELF notes).
Definition lnx_kernel_utils.hpp:52
__kernel_long_t tv_sec
Seconds component of the time value.
Definition lnx_kernel_utils.hpp:54
__kernel_long_t tv_usec
Microseconds component of the time value.
Definition lnx_kernel_utils.hpp:56
Common fields shared across architecture-specific elf_prstatus structures in core dumps.
Definition lnx_kernel_utils.hpp:72
struct __kernel_old_timeval pr_cstime
System CPU time consumed by waited-for children (obsolete field).
Definition lnx_kernel_utils.hpp:96
short pr_cursig
Current signal.
Definition lnx_kernel_utils.hpp:76
pid_t pr_pgrp
Process Group ID.
Definition lnx_kernel_utils.hpp:86
pid_t pr_pid
Process ID.
Definition lnx_kernel_utils.hpp:82
struct __kernel_old_timeval pr_utime
User CPU time consumed (obsolete field).
Definition lnx_kernel_utils.hpp:90
struct elf_siginfo pr_info
Signal information structure.
Definition lnx_kernel_utils.hpp:74
pid_t pr_ppid
Parent Process ID.
Definition lnx_kernel_utils.hpp:84
struct __kernel_old_timeval pr_stime
System CPU time consumed (obsolete field).
Definition lnx_kernel_utils.hpp:92
unsigned long pr_sigpend
Pending signals.
Definition lnx_kernel_utils.hpp:78
struct __kernel_old_timeval pr_cutime
User CPU time consumed by waited-for children (obsolete field).
Definition lnx_kernel_utils.hpp:94
unsigned long pr_sighold
Held signals.
Definition lnx_kernel_utils.hpp:80
pid_t pr_sid
Session ID.
Definition lnx_kernel_utils.hpp:88
Kernel structure for signal information used in ELF core dump notes.
Definition lnx_kernel_utils.hpp:61
int si_signo
Signal number.
Definition lnx_kernel_utils.hpp:63
int si_errno
Error number.
Definition lnx_kernel_utils.hpp:67
int si_code
Signal code.
Definition lnx_kernel_utils.hpp:65
Structure for a scatter/gather vector entry in 32-bit systems.
Definition lnx_kernel_utils.hpp:43
uint32_t iov_len
Length of the buffer.
Definition lnx_kernel_utils.hpp:47
uint32_t iov_base
Base address of the buffer.
Definition lnx_kernel_utils.hpp:45
Linux kernel structure representing the signal action data for rt_sigaction.
Definition lnx_kernel_utils.hpp:21
unsigned long flags
Signal flags (e.g., SA_SIGINFO).
Definition lnx_kernel_utils.hpp:25
void * handler
Signal handler function pointer.
Definition lnx_kernel_utils.hpp:23
sigset_t mask
Signals blocked during handler execution.
Definition lnx_kernel_utils.hpp:29
void * restorer
Signal trampoline/restorer function pointer.
Definition lnx_kernel_utils.hpp:27
Structure for resource limits in 32-bit systems (two 32-bit values).
Definition lnx_kernel_utils.hpp:34
uint32_t rlim_cur
Current (soft) limit.
Definition lnx_kernel_utils.hpp:36
uint32_t rlim_max
Maximum (hard) limit.
Definition lnx_kernel_utils.hpp:38