diff options
author | Santo Cariotti <santo@dcariotti.me> | 2023-10-20 17:16:06 +0200 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2023-10-20 17:16:06 +0200 |
commit | 16f0a9e8f933e34e5b80901c6ccb66864f251055 (patch) | |
tree | 5d1e6dbc9e7eb5a88bc0434f33f3146cabde8adb | |
parent | cd4920a2903656a9fdda6ebc99ac6a0663095d83 (diff) |
Add params for sys calls
-rw-r--r-- | src/arch/linux/x86_64.rs | 2718 | ||||
-rw-r--r-- | src/registers.rs | 103 |
2 files changed, 2248 insertions, 573 deletions
diff --git a/src/arch/linux/x86_64.rs b/src/arch/linux/x86_64.rs index 0d378ca..ab9172a 100644 --- a/src/arch/linux/x86_64.rs +++ b/src/arch/linux/x86_64.rs @@ -1,559 +1,2173 @@ +pub const SYSCALLS_NRO: usize = 333; /// Sys call table as shown at https://chromium.googlesource.com/chromiumos/docs/+/master/constants/syscalls.md#x86_64-64_bit /// and https://github.com/torvalds/linux/blob/master/arch/x86/entry/syscalls/syscall_64.tbl -pub const TABLE: [&str; 550] = [ - "read", - "write", - "open", - "close", - "stat", - "fstat", - "lstat", - "poll", - "lseek", - "mmap", - "mprotect", - "munmap", - "brk", - "rt_sigaction", - "rt_sigprocmask", - "rt_sigreturn", - "ioctl", - "pread64", - "pwrite64", - "readv", - "writev", - "access", - "pipe", - "select", - "sched_yield", - "mremap", - "msync", - "mincore", - "madvise", - "shmget", - "shmat", - "shmctl", - "dup", - "dup2", - "pause", - "nanosleep", - "getitimer", - "alarm", - "setitimer", - "getpid", - "sendfile", - "socket", - "connect", - "accept", - "sendto", - "recvfrom", - "sendmsg", - "recvmsg", - "shutdown", - "bind", - "listen", - "getsockname", - "getpeername", - "socketpair", - "setsockopt", - "getsockopt", - "clone", - "fork", - "vfork", - "execve", - "exit", - "wait4", - "kill", - "uname", - "semget", - "semop", - "semctl", - "shmdt", - "msgget", - "msgsnd", - "msgrcv", - "msgctl", - "fcntl", - "flock", - "fsync", - "fdatasync", - "truncate", - "ftruncate", - "getdents", - "getcwd", - "chdir", - "fchdir", - "rename", - "mkdir", - "rmdir", - "creat", - "link", - "unlink", - "symlink", - "readlink", - "chmod", - "fchmod", - "chown", - "fchown", - "lchown", - "umask", - "gettimeofday", - "getrlimit", - "getrusage", - "sysinfo", - "times", - "ptrace", - "getuid", - "syslog", - "getgid", - "setuid", - "setgid", - "geteuid", - "getegid", - "setpgid", - "getppid", - "getpgrp", - "setsid", - "setreuid", - "setregid", - "getgroups", - "setgroups", - "setresuid", - "getresuid", - "setresgid", - "getresgid", - "getpgid", - "setfsuid", - "setfsgid", - "getsid", - "capget", - "capset", - "rt_sigpending", - "rt_sigtimedwait", - "rt_sigqueueinfo", - "rt_sigsuspend", - "sigaltstack", - "utime", - "mknod", - "uselib", - "personality", - "ustat", - "statfs", - "fstatfs", - "sysfs", - "getpriority", - "setpriority", - "sched_setparam", - "sched_getparam", - "sched_setscheduler", - "sched_getscheduler", - "sched_get_priority_max", - "sched_get_priority_min", - "sched_rr_get_interval", - "mlock", - "munlock", - "mlockall", - "munlockall", - "vhangup", - "modify_ldt", - "pivot_root", - "_sysctl", - "prctl", - "arch_prctl", - "adjtimex", - "setrlimit", - "chroot", - "sync", - "acct", - "settimeofday", - "mount", - "umount2", - "swapon", - "swapoff", - "reboot", - "sethostname", - "setdomainname", - "iopl", - "ioperm", - "create_module", - "init_module", - "delete_module", - "get_kernel_syms", - "query_module", - "quotactl", - "nfsservctl", - "getpmsg", - "putpmsg", - "afs_syscall", - "tuxcall", - "security", - "gettid", - "readahead", - "setxattr", - "lsetxattr", - "fsetxattr", - "getxattr", - "lgetxattr", - "fgetxattr", - "listxattr", - "llistxattr", - "flistxattr", - "removexattr", - "lremovexattr", - "fremovexattr", - "tkill", - "time", - "futex", - "sched_setaffinity", - "sched_getaffinity", - "set_thread_area", - "io_setup", - "io_destroy", - "io_getevents", - "io_submit", - "io_cancel", - "get_thread_area", - "lookup_dcookie", - "epoll_create", - "epoll_ctl_old", - "epoll_wait_old", - "remap_file_pages", - "getdents64", - "set_tid_address", - "restart_syscall", - "semtimedop", - "fadvise64", - "timer_create", - "timer_settime", - "timer_gettime", - "timer_getoverrun", - "timer_delete", - "clock_settime", - "clock_gettime", - "clock_getres", - "clock_nanosleep", - "exit_group", - "epoll_wait", - "epoll_ctl", - "tgkill", - "utimes", - "vserver", - "mbind", - "set_mempolicy", - "get_mempolicy", - "mq_open", - "mq_unlink", - "mq_timedsend", - "mq_timedreceive", - "mq_notify", - "mq_getsetattr", - "kexec_load", - "waitid", - "add_key", - "request_key", - "keyctl", - "ioprio_set", - "ioprio_get", - "inotify_init", - "inotify_add_watch", - "inotify_rm_watch", - "migrate_pages", - "openat", - "mkdirat", - "mknodat", - "fchownat", - "futimesat", - "newfstatat", - "unlinkat", - "renameat", - "linkat", - "symlinkat", - "readlinkat", - "fchmodat", - "faccessat", - "pselect6", - "ppoll", - "unshare", - "set_robust_list", - "get_robust_list", - "splice", - "tee", - "sync_file_range", - "vmsplice", - "move_pages", - "utimensat", - "epoll_pwait", - "signalfd", - "timerfd_create", - "eventfd", - "fallocate", - "timerfd_settime", - "timerfd_gettime", - "accept4", - "signalfd4", - "eventfd2", - "epoll_create1", - "dup3", - "pipe2", - "inotify_init1", - "preadv", - "pwritev", - "rt_tgsigqueueinfo", - "perf_event_open", - "recvmmsg", - "fanotify_init", - "fanotify_mark", - "prlimit64", - "name_to_handle_at", - "open_by_handle_at", - "clock_adjtime", - "syncfs", - "sendmmsg", - "setns", - "getcpu", - "process_vm_readv", - "process_vm_writev", - "kcmp", - "finit_module", - "sched_setattr", - "sched_getattr", - "renameat2", - "seccomp", - "getrandom", - "memfd_create", - "kexec_file_load", - "bpf", - "execveat", - "userfaultfd", - "membarrier", - "mlock2", - "copy_file_range", - "preadv2", - "pwritev2", - "pkey_mprotect", - "pkey_alloc", - "pkey_free", - "statx", - "io_pgetevents", - "rseq", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "pidfd_send_signal", - "io_uring_setup", - "io_uring_enter", - "io_uring_register", - "open_tree", - "move_mount", - "fsopen", - "fsconfig", - "fsmount", - "fspick", - "pidfd_open", - "clone3", - "close_range", - "openat2", - "pidfd_getfd", - "faccessat2", - "process_madvise", - "epoll_pwait2", - "mount_setattr", - "quotactl_fd", - "landlock_create_ruleset", - "landlock_add_rule", - "landlock_restrict_self", - "memfd_secret", - "process_mrelease", - "futex_waitv", - "set_mempolicy_home_node", - "cachestat", - "fchmodat2", - "map_shadow_stack", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "", - "rt_sigaction", - "rt_sigreturn", - "ioctl", - "readv", - "writev", - "recvfrom", - "sendmsg", - "recvmsg", - "execve", - "ptrace", - "rt_sigpending", - "rt_sigtimedwait", - "rt_sigqueueinfo", - "sigaltstack", - "timer_create", - "mq_notify", - "kexec_load", - "waitid", - "set_robust_list", - "get_robust_list", - "vmsplice", - "move_pages", - "preadv", - "pwritev", - "rt_tgsigqueueinfo", - "recvmmsg", - "sendmmsg", - "process_vm_readv", - "process_vm_writev", - "setsockopt", - "getsockopt", - "io_setup", - "io_submit", - "execveat", - "preadv2", - "pwritev2", +/// The row is formatted like: +/// | syscall_name | rdi | rsi | rdx | r10 | r8 | r9 | +pub const TABLE: [[&str; 7]; SYSCALLS_NRO] = [ + [ + "read", + "unsigned int fd", + "char *buf", + "size_t count", + "", + "", + "", + ], + [ + "write", + "unsigned int fd", + "const char *buf", + "size_t count", + "", + "", + "", + ], + [ + "open", + "const char *filename", + "int flags", + "umode_t mode", + "", + "", + "", + ], + ["close", "unsigned int fd", "", "", "", "", ""], + [ + "stat", + "const char *filename", + "struct __old_kernel_stat *statbuf", + "", + "", + "", + "", + ], + [ + "fstat", + "unsigned int fd", + "struct __old_kernel_stat *statbuf", + "", + "", + "", + "", + ], + [ + "lstat", + "const char *filename", + "struct __old_kernel_stat *statbuf", + "", + "", + "", + "", + ], + [ + "poll", + "struct pollfd *ufds", + "unsigned int nfds", + "int timeout", + "", + "", + "", + ], + [ + "lseek", + "unsigned int fd", + "off_t offset", + "unsigned int whence", + "", + "", + "", + ], + [ + "mmap", + "void addr[.length]", + "size_t length", + "int prot", + "int flags", + "int fd", + "off_t offset", + ], + [ + "mprotect", + "unsigned long start", + "size_t len", + "unsigned long prot", + "", + "", + "", + ], + ["munmap", "unsigned long addr", "size_t len", "", "", "", ""], + ["brk", "unsigned long brk", "", "", "", "", ""], + [ + "rt_sigaction", + "int", + "const struct sigaction *", + "struct sigaction *", + "size_t", + "", + "", + ], + [ + "rt_sigprocmask", + "int how", + "sigset_t *set", + "sigset_t *oset", + "size_t sigsetsize", + "", + "", + ], + ["rt_sigreturn", "...", "", "", "", "", ""], + [ + "ioctl", + "unsigned int fd", + "unsigned int cmd", + "unsigned long arg", + "", + "", + "", + ], + [ + "pread64", + "unsigned int fd", + "char *buf", + "size_t count", + "loff_t pos", + "", + "", + ], + [ + "pwrite64", + "unsigned int fd", + "const char *buf", + "size_t count", + "loff_t pos", + "", + "", + ], + [ + "readv", + "unsigned long fd", + "const struct iovec *vec", + "unsigned long vlen", + "", + "", + "", + ], + [ + "writev", + "unsigned long fd", + "const struct iovec *vec", + "unsigned long vlen", + "", + "", + "", + ], + ["access", "const char *filename", "int mode", "", "", "", ""], + ["pipe", "int *fildes", "", "", "", "", ""], + [ + "select", + "int n", + "fd_set *inp", + "fd_set *outp", + "fd_set *exp", + "struct timeval *tvp", + "", + ], + ["sched_yield", "", "", "", "", "", ""], + [ + "mremap", + "unsigned long addr", + "unsigned long old_len", + "unsigned long new_len", + "unsigned long flags", + "unsigned long new_addr", + "", + ], + [ + "msync", + "unsigned long start", + "size_t len", + "int flags", + "", + "", + "", + ], + [ + "mincore", + "unsigned long start", + "size_t len", + "unsigned char * vec", + "", + "", + "", + ], + [ + "madvise", + "unsigned long start", + "size_t len", + "int behavior", + "", + "", + "", + ], + ["shmget", "key_t key", "size_t size", "int flag", "", "", ""], + [ + "shmat", + "int shmid", + "char *shmaddr", + "int shmflg", + "", + "", + "", + ], + [ + "shmctl", + "int shmid", + "int cmd", + "struct shmid_ds *buf", + "", + "", + "", + ], + ["dup", "unsigned int fildes", "", "", "", "", ""], + [ + "dup2", + "unsigned int oldfd", + "unsigned int newfd", + "", + "", + "", + "", + ], + ["pause", "", "", "", "", "", ""], + [ + "nanosleep", + "struct __kernel_timespec *rqtp", + "struct __kernel_timespec *rmtp", + "", + "", + "", + "", + ], + [ + "getitimer", + "int which", + "struct itimerval *value", + "", + "", + "", + "", + ], + ["alarm", "unsigned int seconds", "", "", "", "", ""], + [ + "setitimer", + "int which", + "struct itimerval *value", + "struct itimerval *ovalue", + "", + "", + "", + ], + ["getpid", "", "", "", "", "", ""], + [ + "sendfile", + "int out_fd", + "int in_fd", + "off_t *offset", + "size_t count", + "", + "", + ], + ["socket", "int", "int", "int", "", "", ""], + ["connect", "int", "struct sockaddr *", "int", "", "", ""], + ["accept", "int", "struct sockaddr *", "int *", "", "", ""], + [ + "sendto", + "int", + "void *", + "size_t", + "unsigned", + "struct sockaddr *", + "int", + ], + [ + "recvfrom", + "int", + "void *", + "size_t", + "unsigned", + "struct sockaddr *", + "int *", + ], + [ + "sendmsg", + "int fd", + "struct user_msghdr *msg", + "unsigned flags", + "", + "", + "", + ], + [ + "recvmsg", + "int fd", + "struct user_msghdr *msg", + "unsigned flags", + "", + "", + "", + ], + ["shutdown", "int", "int", "", "", "", ""], + ["bind", "int", "struct sockaddr *", "int", "", "", ""], + ["listen", "int", "int", "", "", "", ""], + [ + "getsockname", + "int", + "struct sockaddr *", + "int *", + "", + "", + "", + ], + [ + "getpeername", + "int", + "struct sockaddr *", + "int *", + "", + "", + "", + ], + ["socketpair", "int", "int", "int", "int *", "", ""], + [ + "setsockopt", + "int fd", + "int level", + "int optname", + "char *optval", + "int optlen", + "", + ], + [ + "getsockopt", + "int fd", + "int level", + "int optname", + "char *optval", + "int *optlen", + "", + ], + [ + "clone", + "unsigned long", + "unsigned long", + "int *", + "int *", + "unsigned long", + "", + ], + ["fork", "", "", "", "", "", ""], + ["vfork", "", "", "", "", "", ""], + [ + "execve", + "const char *filename", + "const char *const *argv", + "const char *const *envp", + "", + "", + "", + ], + ["exit", "int error_code", "", "", "", "", ""], + [ + "wait4", + "pid_t pid", + "int *stat_addr", + "int options", + "struct rusage *ru", + "", + "", + ], + ["kill", "pid_t pid", "int sig", "", "", "", ""], + ["uname", "struct old_utsname *", "", "", "", "", ""], + ["semget", "key_t key", "int nsems", "int semflg", "", "", ""], + [ + "semop", + "int semid", + "struct sembuf *sops", + "unsigned nsops", + "", + "", + "", + ], + [ + "semctl", + "int semid", + "int semnum", + "int cmd", + "unsigned long arg", + "", + "", + ], + ["shmdt", "char *shmaddr", "", "", "", "", ""], + ["msgget", "key_t key", "int msgflg", "", "", "", ""], + [ + "msgsnd", + "int msqid", + "struct msgbuf *msgp", + "size_t msgsz", + "int msgflg", + "", + "", + ], + [ + "msgrcv", + "int msqid", + "struct msgbuf *msgp", + "size_t msgsz", + "long msgtyp", + "int msgflg", + "", + ], + [ + "msgctl", + "int msqid", + "int cmd", + "struct msqid_ds *buf", + "", + "", + "", + ], + [ + "fcntl", + "unsigned int fd", + "unsigned int cmd", + "unsigned long arg", + "", + "", + "", + ], + [ + "flock", + "unsigned int fd", + "unsigned int cmd", + "", + "", + "", + "", + ], + ["fsync", "unsigned int fd", "", "", "", "", ""], + ["fdatasync", "unsigned int fd", "", "", "", "", ""], + [ + "truncate", + "const char *path", + "long length", + "", + "", + "", + "", + ], + [ + "ftruncate", + "unsigned int fd", + "unsigned long length", + "", + "", + "", + "", + ], + [ + "getdents", + "unsigned int fd", + "struct linux_dirent *dirent", + "unsigned int count", + "", + "", + "", + ], + ["getcwd", "char *buf", "unsigned long size", "", "", "", ""], + ["chdir", "const char *filename", "", "", "", "", ""], + ["fchdir", "unsigned int fd", "", "", "", "", ""], + [ + "rename", + "const char *oldname", + "const char *newname", + "", + "", + "", + "", + ], + [ + "mkdir", + "const char *pathname", + "umode_t mode", + "", + "", + "", + "", + ], + ["rmdir", "const char *pathname", "", "", "", "", ""], + [ + "creat", + "const char *pathname", + "umode_t mode", + "", + "", + "", + "", + ], + [ + "link", + "const char *oldname", + "const char *newname", + "", + "", + "", + "", + ], + ["unlink", "const char *pathname", "", "", "", "", ""], + [ + "symlink", + "const char *old", + "const char *new", + "", + "", + "", + "", + ], + [ + "readlink", + "const char *path", + "char *buf", + "int bufsiz", + "", + "", + "", + ], + [ + "chmod", + "const char *filename", + "umode_t mode", + "", + "", + "", + "", + ], + ["fchmod", "unsigned int fd", "umode_t mode", "", "", "", ""], + [ + "chown", + "const char *filename", + "uid_t user", + "gid_t group", + "", + "", + "", + ], + [ + "fchown", + "unsigned int fd", + "uid_t user", + "gid_t group", + "", + "", + "", + ], + [ + "lchown", + "const char *filename", + "uid_t user", + "gid_t group", + "", + "", + "", + ], + ["umask", "int mask", "", "", "", "", ""], + [ + "gettimeofday", + "struct timeval *tv", + "struct timezone *tz", + "", + "", + "", + "", + ], + [ + "getrlimit", + "unsigned int resource", + "struct rlimit *rlim", + "", + "", + "", + "", + ], + ["getrusage", "int who", "struct rusage *ru", "", "", "", ""], + ["sysinfo", "struct sysinfo *info", "", "", "", "", ""], + ["times", "struct tms *tbuf", "", "", "", "", ""], + [ + "ptrace", + "long request", + "long pid", + "unsigned long addr", + "unsigned long data", + "", + "", + ], + ["getuid", "", "", "", "", "", ""], + ["syslog", "int type", "char *buf", "int len", "", "", ""], + ["getgid", "", "", "", "", "", ""], + ["setuid", "uid_t uid", "", "", "", "", ""], + ["setgid", "gid_t gid", "", "", "", "", ""], + ["geteuid", "", "", "", "", "", ""], + ["getegid", "", "", "", "", "", ""], + ["setpgid", "pid_t pid", "pid_t pgid", "", "", "", ""], + ["getppid", "", "", "", "", "", ""], + ["getpgrp", "", "", "", "", "", ""], + ["setsid", "", "", "", "", "", ""], + ["setreuid", "uid_t ruid", "uid_t euid", "", "", "", ""], + ["setregid", "gid_t rgid", "gid_t egid", "", "", "", ""], + [ + "getgroups", + "int gidsetsize", + "gid_t *grouplist", + "", + "", + "", + "", + ], + [ + "setgroups", + "int gidsetsize", + "gid_t *grouplist", + "", + "", + "", + "", + ], + [ + "setresuid", + "uid_t ruid", + "uid_t euid", + "uid_t suid", + "", + "", + "", + ], + [ + "getresuid", + "uid_t *ruid", + "uid_t *euid", + "uid_t *suid", + "", + "", + "", + ], + [ + "setresgid", + "gid_t rgid", + "gid_t egid", + "gid_t sgid", + "", + "", + "", + ], + [ + "getresgid", + "gid_t *rgid", + "gid_t *egid", + "gid_t *sgid", + "", + "", + "", + ], + ["getpgid", "pid_t pid", "", "", "", "", ""], + ["setfsuid", "uid_t uid", "", "", "", "", ""], + ["setfsgid", "gid_t gid", "", "", "", "", ""], + ["getsid", "pid_t pid", "", "", "", "", ""], + [ + "capget", + "cap_user_header_t header", + "cap_user_data_t dataptr", + "", + "", + "", + "", + ], + [ + "capset", + "cap_user_header_t header", + "const cap_user_data_t data", + "", + "", + "", + "", + ], + [ + "rt_sigpending", + "sigset_t *set", + "size_t sigsetsize", + "", + "", + "", + "", + ], + [ + "rt_sigtimedwait", + "const sigset_t *uthese", + "siginfo_t *uinfo", + "const struct __kernel_timespec *uts", + "size_t sigsetsize", + "", + "", + ], + [ + "rt_sigqueueinfo", + "pid_t pid", + "int sig", + "siginfo_t *uinfo", + "", + "", + "", + ], + [ + "rt_sigsuspend", + "sigset_t *unewset", + "size_t sigsetsize", + "", + "", + "", + "", + ], + [ + "sigaltstack", + "const struct sigaltstack *uss", + "struct sigaltstack *uoss", + "", + "", + "", + "", + ], + [ + "utime", + "char *filename", + "struct utimbuf *times", + "", + "", + "", + "", + ], + [ + "mknod", + "const char *filename", + "umode_t mode", + "unsigned dev", + "", + "", + "", + ], + ["uselib", "const char *library", "", "", "", "", ""], + [ + "personality", + "unsigned int personality", + "", + "", + "", + "", + "", + ], + [ + "ustat", + "unsigned dev", + "struct ustat *ubuf", + "", + "", + "", + "", + ], + [ + "statfs", + "const char * path", + "struct statfs *buf", + "", + "", + "", + "", + ], + [ + "fstatfs", + "unsigned int fd", + "struct statfs *buf", + "", + "", + "", + "", + ], + [ + "sysfs", + "int option", + "unsigned long arg1", + "unsigned long arg2", + "", + "", + "", + ], + ["getpriority", "int which", "int who", "", "", "", ""], + [ + "setpriority", + "int which", + "int who", + "int niceval", + "", + "", + "", + ], + [ + "sched_setparam", + "pid_t pid", + "struct sched_param *param", + "", + "", + "", + "", + ], + [ + "sched_getparam", + "pid_t pid", + "struct sched_param *param", + "", + "", + "", + "", + ], + [ + "sched_setscheduler", + "pid_t pid", + "int policy", + "struct sched_param *param", + "", + "", + "", + ], + ["sched_getscheduler", "pid_t pid", "", "", "", "", ""], + ["sched_get_priority_max", "int policy", "", "", "", "", ""], + ["sched_get_priority_min", "int policy", "", "", "", "", ""], + [ + "sched_rr_get_interval", + "pid_t pid", + "struct __kernel_timespec *interval", + "", + "", + "", + "", + ], + ["mlock", "unsigned long start", "size_t len", "", "", "", ""], + [ + "munlock", + "unsigned long start", + "size_t len", + "", + "", + "", + "", + ], + ["mlockall", "int flags", "", "", "", "", ""], + ["munlockall", "", "", "", "", "", ""], + ["vhangup", "", "", "", "", "", ""], + [ + "modify_ldt", + "SYS_modify_ldt", + "int func", + "void ptr[.bytecount]", + "unsigned long bytecount", + "", + "", + ], + [ + "pivot_root", + "const char *new_root", + "const char *put_old", + "", + "", + "", + "", + ], + ["_sysctl", "struct __sysctl_args *args", "", "", "", "", ""], + [ + "prctl", + "int option", + "unsigned long arg2", + "unsigned long arg3", + "unsigned long arg4", + "unsigned long arg5", + "", + ], + [ + "arch_prctl", + "SYS_arch_prctl", + "int code", + "unsigned long addr", + " ", + " ", + " ", + ], + [ + "adjtimex", + "struct __kernel_timex *txc_p", + "", + "", + "", + "", + "", + ], + [ + "setrlimit", + "unsigned int resource", + "struct rlimit *rlim", + "", + "", + "", + "", + ], + ["chroot", "const char *filename", "", "", "", "", ""], + ["sync", "", "", "", "", "", ""], + ["acct", "const char *name", "", "", "", "", ""], + [ + "settimeofday", + "struct timeval *tv", + "struct timezone *tz", + "", + "", + "", + "", + ], + [ + "mount", + "char *dev_name", + "char *dir_name", + "char *type", + "unsigned long flags", + "void *data", + "", + ], + ["umount2", "const char *target", "int flags", "", "", "", ""], + [ + "swapon", + "const char *specialfile", + "int swap_flags", + "", + "", + "", + "", + ], + ["swapoff", "const char *specialfile", "", "", "", "", ""], + [ + "reboot", + "int magic1", + "int magic2", + "unsigned int cmd", + "void *arg", + "", + "", + ], + ["sethostname", "char *name", "int len", "", "", "", ""], + ["setdomainname", "char *name", "int len", "", "", "", ""], + ["iopl", "int level", "", "", "", "", ""], + [ + "ioperm", + "unsigned long from", + "unsigned long num", + "int on", + "", + "", + "", + ], + [ + "create_module", + "const char *name", + "size_t size", + "", + "", + "", + "", + ], + [ + "init_module", + "void *umod", + "unsigned long len", + "const char *uargs", + "", + "", + "", + ], + [ + "delete_module", + "const char *name_user", + "unsigned int flags", + "", + "", + "", + "", + ], + [ + "get_kernel_syms", + "struct kernel_sym *table", + "", + "", + "", + "", + "", + ], + [ + "query_module", + "const char *name", + "int which", + "void buf[.bufsize]", + "size_t bufsize", + "size_t *ret", + "", + ], + [ + "quotactl", + "unsigned int cmd", + "const char *special", + "qid_t id", + "void *addr", + "", + "", + ], + [ + "nfsservctl", + "int cmd", + "struct nfsctl_arg *argp", + "union nfsctl_res *res", + "", + "", + "", + ], + ["getpmsg", "", "", "", "", "", ""], + ["putpmsg", "", "", "", "", "", ""], + ["afs_syscall", "", "", "", "", "", ""], + ["tuxcall", "", "", "", "", "", ""], + ["security", "", "", "", "", "", ""], + ["gettid", "", "", "", "", "", ""], + [ + "readahead", + "int fd", + "loff_t offset", + "size_t count", + "", + "", + "", + ], + [ + "setxattr", + "const char *path", + "const char *name", + "const void *value", + "size_t size", + "int flags", + "", + ], + [ + "lsetxattr", + "const char *path", + "const char *name", + "const void *value", + "size_t size", + "int flags", + "", + ], + [ + "fsetxattr", + "int fd", + "const char *name", + "const void *value", + "size_t size", + "int flags", + "", + ], + [ + "getxattr", + "const char *path", + "const char *name", + "void *value", + "size_t size", + "", + "", + ], + [ + "lgetxattr", + "const char *path", + "const char *name", + "void *value", + "size_t size", + "", + "", + ], + [ + "fgetxattr", + "int fd", + "const char *name", + "void *value", + "size_t size", + "", + "", + ], + [ + "listxattr", + "const char *path", + "char *list", + "size_t size", + "", + "", + "", + ], + [ + "llistxattr", + "const char *path", + "char *list", + "size_t size", + "", + "", + "", + ], + [ + "flistxattr", + "int fd", + "char *list", + "size_t size", + "", + "", + "", + ], + [ + "removexattr", + "const char *path", + "const char *name", + "", + "", + "", + "", + ], + [ + "lremovexattr", + "const char *path", + "const char *name", + "", + "", + "", + "", + ], + ["fremovexattr", "int fd", "const char *name", "", "", "", ""], + ["tkill", "pid_t pid", "int sig", "", "", "", ""], + ["time", "time_t *tloc", "", "", "", "", ""], + [ + "futex", + "u32 *uaddr", + "int op", + "u32 val", + "struct __kernel_timespec *utime", + "u32 *uaddr2", + "u32 val3", + ], + [ + "sched_setaffinity", + "pid_t pid", + "unsigned int len", + "unsigned long *user_mask_ptr", + "", + "", + "", + ], + [ + "sched_getaffinity", + "pid_t pid", + "unsigned int len", + "unsigned long *user_mask_ptr", + "", + "", + "", + ], + ["set_thread_area", "", "", "", "", "", ""], + [ + "io_setup", + "unsigned nr_reqs", + "aio_context_t *ctx", + "", + "", + "", + "", + ], + ["io_destroy", "aio_context_t ctx", "", "", "", "", ""], + [ + "io_getevents", + "aio_context_t ctx_id", + "long min_nr", + "long nr", + "struct io_event *events", + "struct __kernel_timespec *timeout", + "", + ], + [ + "io_submit", + "aio_context_t", + "long", + "struct iocb * *", + "", + "", + "", + ], + [ + "io_cancel", + "aio_context_t ctx_id", + "struct iocb *iocb", + "struct io_event *result", + "", + "", + "", + ], + ["get_thread_area", "", "", "", "", "", ""], + [ + "lookup_dcookie", + "u64 cookie64", + "char *buf", + "size_t len", + "", + "", + "", + ], + ["epoll_create", "int size", "", "", "", "", ""], + ["epoll_ctl_old", "", "", "", "", "", ""], + ["epoll_wait_old", "", "", "", "", "", ""], + [ + "remap_file_pages", + "unsigned long start", + "unsigned long size", + "unsigned long prot", + "unsigned long pgoff", + "unsigned long flags", + "", + ], + [ + "getdents64", + "unsigned int fd", + "struct linux_dirent64 *dirent", + "unsigned int count", + "", + "", + "", + ], + ["set_tid_address", "int *tidptr", "", "", "", "", ""], + ["restart_syscall", "", "", "", "", "", ""], + [ + "semtimedop", + "int semid", + "struct sembuf *sops", + "unsigned nsops", + "const struct __kernel_timespec *timeout", + "", + "", + ], + [ + "fadvise64", + "int fd", + "loff_t offset", + "size_t len", + "int advice", + "", + "", + ], + [ + "timer_create", + "clockid_t which_clock", + "struct sigevent *timer_event_spec", + "timer_t * created_timer_id", + "", + "", + "", + ], + [ + "timer_settime", + "timer_t timer_id", + "int flags", + "const struct __kernel_itimerspec *new_setting", + "struct __kernel_itimerspec *old_setting", + "", + "", + ], + [ + "timer_gettime", + "timer_t timer_id", + "struct __kernel_itimerspec *setting", + "", + "", + "", + "", + ], + ["timer_getoverrun", "timer_t timer_id", "", "", "", "", ""], + ["timer_delete", "timer_t timer_id", "", "", "", "", ""], + [ + "clock_settime", + "clockid_t which_clock", + "const struct __kernel_timespec *tp", + "", + "", + "", + "", + ], + [ + "clock_gettime", + "clockid_t which_clock", + "struct __kernel_timespec *tp", + "", + "", + "", + "", + ], + [ + "clock_getres", + "clockid_t which_clock", + "struct __kernel_timespec *tp", + "", + "", + "", + "", + ], + [ + "clock_nanosleep", + "clockid_t which_clock", + "int flags", + "const struct __kernel_timespec *rqtp", + "struct __kernel_timespec *rmtp", + "", + "", + ], + ["exit_group", "int error_code", "", "", "", "", ""], + [ + "epoll_wait", + "int epfd", + "struct epoll_event *events", + "int maxevents", + "int timeout", + "", + "", + ], + [ + "epoll_ctl", + "int epfd", + "int op", + "int fd", + "struct epoll_event *event", + "", + "", + ], + ["tgkill", "pid_t tgid", "pid_t pid", "int sig", "", "", ""], + [ + "utimes", + "char *filename", + "struct timeval *utimes", + "", + "", + "", + "", + ], + ["vserver", "", "", "", "", "", ""], + [ + "mbind", + "unsigned long start", + "unsigned long len", + "unsigned long mode", + "const unsigned long *nmask", + "unsigned long maxnode", + "unsigned flags", + ], + [ + "set_mempolicy", + "int mode", + "const unsigned long *nmask", + "unsigned long maxnode", + "", + "", + "", + ], + [ + "get_mempolicy", + "int *policy", + "unsigned long *nmask", + "unsigned long maxnode", + "unsigned long addr", + "unsigned long flags", + "", + ], + [ + "mq_open", + "const char *name", + "int oflag", + "umode_t mode", + "struct mq_attr *attr", + "", + "", + ], + ["mq_unlink", "const char *name", "", "", "", "", ""], + [ + "mq_timedsend", + "mqd_t mqdes", + "const char *msg_ptr", + "size_t msg_len", + "unsigned int msg_prio", + "const struct __kernel_timespec *abs_timeout", + "", + ], + [ + "mq_timedreceive", + "mqd_t mqdes", + "char *msg_ptr", + "size_t msg_len", + "unsigned int *msg_prio", + "const struct __kernel_timespec *abs_timeout", + "", + ], + [ + "mq_notify", + "mqd_t mqdes", + "const struct sigevent *notification", + "", + "", + "", + "", + ], + [ + "mq_getsetattr", + "mqd_t mqdes", + "const struct mq_attr *mqstat", + "struct mq_attr *omqstat", + "", + "", + "", + ], + [ + "kexec_load", + "unsigned long entry", + "unsigned long nr_segments", + "struct kexec_segment *segments", + "unsigned long flags", + "", + "", + ], + [ + "waitid", + "int which", + "pid_t pid", + "struct siginfo *infop", + "int options", + "struct rusage *ru", + "", + ], + [ + "add_key", + "const char *_type", + "const char *_description", + "const void *_payload", + "size_t plen", + "key_serial_t destringid", + "", + ], + [ + "request_key", + "const char *_type", + "const char *_description", + "const char *_callout_info", + "key_serial_t destringid", + "", + "", + ], + [ + "keyctl", + "int cmd", + "unsigned long arg2", + "unsigned long arg3", + "unsigned long arg4", + "unsigned long arg5", + "", + ], + [ + "ioprio_set", + "int which", + "int who", + "int ioprio", + "", + "", + "", + ], + ["ioprio_get", "int which", "int who", "", "", "", ""], + ["inotify_init", "", "", "", "", "", ""], + [ + "inotify_add_watch", + "int fd", + "const char *path", + "u32 mask", + "", + "", + "", + ], + ["inotify_rm_watch", "int fd", "__s32 wd", "", "", "", ""], + [ + "migrate_pages", + "pid_t pid", + "unsigned long maxnode", + "const unsigned long *from", + "const unsigned long *to", + "", + "", + ], + [ + "openat", + "int dfd", + "const char *filename", + "int flags", + "umode_t mode", + "", + "", + ], + [ + "mkdirat", + "int dfd", + "const char * pathname", + "umode_t mode", + "", + "", + "", + ], + [ + "mknodat", + "int dfd", + "const char * filename", + "umode_t mode", + "unsigned dev", + "", + "", + ], + [ + "fchownat", + "int dfd", + "const char *filename", + "uid_t user", + "gid_t group", + "int flag", + "", + ], + [ + "futimesat", + "int dfd", + "const char *filename", + "struct timeval *utimes", + "", + "", + "", + ], + [ + "newfstatat", + "int dfd", + "const char *filename", + "struct stat *statbuf", + "int flag", + "", + "", + ], + [ + "unlinkat", + "int dfd", + "const char * pathname", + "int flag", + "", + "", + "", + ], + [ + "renameat", + "int olddfd", + "const char * oldname", + "int newdfd", + "const char * newname", + "", + "", + ], + [ + "linkat", + "int olddfd", + "const char *oldname", + "int newdfd", + "const char *newname", + "int flags", + "", + ], + [ + "symlinkat", + "const char * oldname", + "int newdfd", + "const char * newname", + "", + "", + "", + ], + [ + "readlinkat", + "int dfd", + "const char *path", + "char *buf", + "int bufsiz", + "", + "", + ], + [ + "fchmodat", + "int dfd", + "const char * filename", + "umode_t mode", + "", + "", + "", + ], + [ + "faccessat", + "int dfd", + "const char *filename", + "int mode", + "", + "", + "", + ], + [ + "pselect6", + "int", + "fd_set *", + "fd_set *", + "fd_set *", + "struct __kernel_timespec *", + "void *", + ], + [ + "ppoll", + "struct pollfd *", + "unsigned int", + "struct __kernel_timespec *", + "const sigset_t *", + "size_t", + "", + ], + ["unshare", "unsigned long unshare_flags", "", "", "", "", ""], + [ + "set_robust_list", + "struct robust_list_head *head", + "size_t len", + "", + "", + "", + "", + ], + [ + "get_robust_list", + "int pid", + "struct robust_list_head * *head_ptr", + "size_t *len_ptr", + "", + "", + "", + ], + [ + "splice", + "int fd_in", + "loff_t *off_in", + "int fd_out", + "loff_t *off_out", + "size_t len", + "unsigned int flags", + ], + [ + "tee", + "int fdin", + "int fdout", + "size_t len", + "unsigned int flags", + "", + "", + ], + [ + "sync_file_range", + "int fd", + "loff_t offset", + "loff_t nbytes", + "unsigned int flags", + "", + "", + ], + [ + "vmsplice", + "int fd", + "const struct iovec *iov", + "unsigned long nr_segs", + "unsigned int flags", + "", + "", + ], + [ + "move_pages", + "pid_t pid", + "unsigned long nr_pages", + "const void * *pages", + "const int *nodes", + "int *status", + "int flags", + ], + [ + "utimensat", + "int dfd", + "const char *filename", + "struct __kernel_timespec *utimes", + "int flags", + "", + "", + ], + [ + "epoll_pwait", + "int epfd", + "struct epoll_event *events", + "int maxevents", + "int timeout", + "const sigset_t *sigmask", + "size_t sigsetsize", + ], + [ + "signalfd", + "int ufd", + "sigset_t *user_mask", + "size_t sizemask", + "", + "", + "", + ], + ["timerfd_create", "int clockid", "int flags", "", "", "", ""], + ["eventfd", "unsigned int count", "", "", "", "", ""], + [ + "fallocate", + "int fd", + "int mode", + "loff_t offset", + "loff_t len", + "", + "", + ], + [ + "timerfd_settime", + "int ufd", + "int flags", + "const struct __kernel_itimerspec *utmr", + "struct __kernel_itimerspec *otmr", + "", + "", + ], + [ + "timerfd_gettime", + "int ufd", + "struct __kernel_itimerspec *otmr", + "", + "", + "", + "", + ], + [ + "accept4", + "int", + "struct sockaddr *", + "int *", + "int", + "", + "", + ], + [ + "signalfd4", + "int ufd", + "sigset_t *user_mask", + "size_t sizemask", + "int flags", + "", + "", + ], + [ + "eventfd2", + "unsigned int count", + "int flags", + "", + "", + "", + "", + ], + ["epoll_create1", "int flags", "", "", "", "", ""], + [ + "dup3", + "unsigned int oldfd", + "unsigned int newfd", + "int flags", + "", + "", + "", + ], + ["pipe2", "int *fildes", "int flags", "", "", "", ""], + ["inotify_init1", "int flags", "", "", "", "", ""], + [ + "preadv", + "unsigned long fd", + "const struct iovec *vec", + "unsigned long vlen", + "unsigned long pos_l", + "unsigned long pos_h", + "", + ], + [ + "pwritev", + "unsigned long fd", + "const struct iovec *vec", + "unsigned long vlen", + "unsigned long pos_l", + "unsigned long pos_h", + "", + ], + [ + "rt_tgsigqueueinfo", + "pid_t tgid", + "pid_t pid", + "int sig", + "siginfo_t *uinfo", + "", + "", + ], + [ + "perf_event_open", + "struct perf_event_attr *attr_uptr", + "pid_t pid", + "int cpu", + "int group_fd", + "unsigned long flags", + "", + ], + [ + "recvmmsg", + "int fd", + "struct mmsghdr *msg", + "unsigned int vlen", + "unsigned flags", + "struct __kernel_timespec *timeout", + "", + ], + [ + "fanotify_init", + "unsigned int flags", + "unsigned int event_f_flags", + "", + "", + "", + "", + ], + [ + "fanotify_mark", + "int fanotify_fd", + "unsigned int flags", + "u64 mask", + "int fd", + "const char *pathname", + "", + ], + [ + "prlimit64", + "pid_t pid", + "unsigned int resource", + "const struct rlimit64 *new_rlim", + "struct rlimit64 *old_rlim", + "", + "", + ], + [ + "name_to_handle_at", + "int dfd", + "const char *name", + "struct file_handle *handle", + "int *mnt_id", + "int flag", + "", + ], + [ + "open_by_handle_at", + "int mountdirfd", + "struct file_handle *handle", + "int flags", + "", + "", + "", + ], + [ + "clock_adjtime", + "clockid_t which_clock", + "struct __kernel_timex *tx", + "", + "", + "", + "", + ], + ["syncfs", "int fd", "", "", "", "", ""], + [ + "sendmmsg", + "int fd", + "struct mmsghdr *msg", + "unsigned int vlen", + "unsigned flags", + "", + "", + ], + ["setns", "int fd", "int nstype", "", "", "", ""], + [ + "getcpu", + "unsigned *cpu", + "unsigned *node", + "struct getcpu_cache *cache", + "", + "", + "", + ], + [ + "process_vm_readv", + "pid_t pid", + "const struct iovec *lvec", + "unsigned long liovcnt", + "const struct iovec *rvec", + "unsigned long riovcnt", + "unsigned long flags", + ], + [ + "process_vm_writev", + "pid_t pid", + "const struct iovec *lvec", + "unsigned long liovcnt", + "const struct iovec *rvec", + "unsigned long riovcnt", + "unsigned long flags", + ], + [ + "kcmp", + "pid_t pid1", + "pid_t pid2", + "int type", + "unsigned long idx1", + "unsigned long idx2", + "", + ], + [ + "finit_module", + "int fd", + "const char *uargs", + "int flags", + "", + "", + "", + ], + [ + "sched_setattr", + "pid_t pid", + "struct sched_attr *attr", + "unsigned int flags", + "", + "", + "", + ], + [ + "sched_getattr", + "pid_t pid", + "struct sched_attr *attr", + "unsigned int size", + "unsigned int flags", + "", + "", + ], + [ + "renameat2", + "int olddfd", + "const char *oldname", + "int newdfd", + "const char *newname", + "unsigned int flags", + "", + ], + [ + "seccomp", + "unsigned int op", + "unsigned int flags", + "void *uargs", + "", + "", + "", + ], + [ + "getrandom", + "char *buf", + "size_t count", + "unsigned int flags", + "", + "", + "", + ], + [ + "memfd_create", + "const char *uname_ptr", + "unsigned int flags", + "", + "", + "", + "", + ], + [ + "kexec_file_load", + "int kernel_fd", + "int initrd_fd", + "unsigned long cmdline_len", + "const char *cmdline_ptr", + "unsigned long flags", + "", + ], + [ + "bpf", + "int cmd", + "union bpf_attr *attr", + "unsigned int size", + "", + "", + "", + ], + [ + "execveat", + "int dfd", + "const char *filename", + "const char *const *argv", + "const char *const *envp", + "int flags", + "", + ], + ["userfaultfd", "int flags", "", "", "", "", ""], + ["membarrier", "int cmd", "int flags", "", "", "", ""], + [ + "mlock2", + "unsigned long start", + "size_t len", + "int flags", + "", + "", + "", + ], + [ + "copy_file_range", + "int fd_in", + "loff_t *off_in", + "int fd_out", + "loff_t *off_out", + "size_t len", + "unsigned int flags", + ], + [ + "preadv2", + "unsigned long fd", + "const struct iovec *vec", + "unsigned long vlen", + "unsigned long pos_l", + "unsigned long pos_h", + "rwf_t flags", + ], + [ + "pwritev2", + "unsigned long fd", + "const struct iovec *vec", + "unsigned long vlen", + "unsigned long pos_l", + "unsigned long pos_h", + "rwf_t flags", + ], + [ + "pkey_mprotect", + "unsigned long start", + "size_t len", + "unsigned long prot", + "int pkey", + "", + "", + ], + [ + "pkey_alloc", + "unsigned long flags", + "unsigned long init_val", + "", + "", + "", + "", + ], + ["pkey_free", "int pkey", "", "", "", "", ""], + [ + "statx", + "int dfd", + "const char *path", + "unsigned flags", + "unsigned mask", + "struct statx *buffer", + "", + ], ]; /// Returns the name for a `rax` register pub fn syscall_name(rax: u64) -> &'static str { - TABLE[rax as usize] + if (rax as usize) > SYSCALLS_NRO { + return ""; + } + + TABLE[rax as usize][0] +} + +pub fn rdi(rax: u64) -> &'static str { + if (rax as usize) > SYSCALLS_NRO { + return ""; + } + + TABLE[rax as usize][1] +} + +pub fn rsi(rax: u64) -> &'static str { + if (rax as usize) > SYSCALLS_NRO { + return ""; + } + + TABLE[rax as usize][2] +} + +pub fn rdx(rax: u64) -> &'static str { + if (rax as usize) > SYSCALLS_NRO { + return ""; + } + + TABLE[rax as usize][3] +} + +pub fn r10(rax: u64) -> &'static str { + if (rax as usize) > SYSCALLS_NRO { + return ""; + } + + TABLE[rax as usize][4] +} + +pub fn r8(rax: u64) -> &'static str { + if (rax as usize) > SYSCALLS_NRO { + return ""; + } + + TABLE[rax as usize][5] +} + +pub fn r9(rax: u64) -> &'static str { + if (rax as usize) > SYSCALLS_NRO { + return ""; + } + + TABLE[rax as usize][6] } diff --git a/src/registers.rs b/src/registers.rs index 27ca8ea..c42bb12 100644 --- a/src/registers.rs +++ b/src/registers.rs @@ -3,11 +3,11 @@ use nix::libc::user_regs_struct; use owo_colors::OwoColorize; use ratatui::{ prelude::{Line, Span, Style}, - style::Modifier, + style::{Color, Modifier}, }; #[cfg(all(target_arch = "x86_64", target_os = "linux"))] -use crate::arch::linux::x86_64::syscall_name; +use crate::arch::linux::x86_64::*; #[cfg(not(all(target_arch = "x86_64", target_os = "linux")))] use crate::arch::syscall_name; @@ -19,6 +19,9 @@ pub struct RegistersData { rdi: u64, rsi: u64, rdx: u64, + r10: u64, + r8: u64, + r9: u64, rax: u64, } @@ -31,6 +34,9 @@ impl RegistersData { rdi: registers.rdi, rsi: registers.rsi, rdx: registers.rdx, + r10: registers.r10, + r8: registers.r8, + r9: registers.r9, rax: registers.rax, } } @@ -47,29 +53,84 @@ impl RegistersData { /// Returns a good string which shows the output for a line pub fn output(&self) -> String { - format!( - "[{}]: {}({:x}, {:x}, {:x}, ...) = {:x}", - self.date(), - self.name().bold(), - self.rdi, - self.rsi, - self.rdx, - self.rax - ) + let mut output = format!("[{}]: ", self.date()); + + if self.name().len() > 0 { + output.push_str(&format!("{}(", self.name().bold())); + } else { + output.push_str(&format!("{}(", self.orig_rax.yellow().bold())); + } + + let mut has_param = false; + + let params = [ + (self.rdi, rdi(self.orig_rax)), + (self.rsi, rsi(self.orig_rax)), + (self.rdx, rdx(self.orig_rax)), + (self.r10, r10(self.orig_rax)), + (self.r8, r8(self.orig_rax)), + (self.r9, r9(self.orig_rax)), + ]; + + for param in params { + if param.1.len() != 0 { + let output_param = param.1.to_owned() + ":"; + output.push_str(&format!("{} {}, ", output_param.blue(), param.0)); + has_param = true; + } + } + + if has_param { + output.remove(output.len() - 1); + output.remove(output.len() - 1); + } + + output.push_str(&format!(") = 0x{:x}", self.rax)[..]); + output } /// Returns a good line for TUI pub fn output_ui(&self) -> Line { - Line::from(vec![ - Span::raw(format!("[{}]: ", self.date())), - Span::styled( - format!("{}", self.name()), + let mut spans: Vec<Span> = vec![]; + spans.push(Span::raw(format!("[{}]: ", self.date()))); + if self.name().len() > 0 { + spans.push(Span::styled( + format!("{}(", self.name()), Style::default().add_modifier(Modifier::BOLD), - ), - Span::raw(format!( - "({:x}, {:x}, {:x}, ...) = {:x}", - self.rdi, self.rsi, self.rdx, self.rax - )), - ]) + )); + } else { + spans.push(Span::styled( + format!("{}(", self.orig_rax), + Style::default() + .fg(Color::Yellow) + .add_modifier(Modifier::BOLD), + )); + } + + let params = [ + (self.rdi, rdi(self.orig_rax)), + (self.rsi, rsi(self.orig_rax)), + (self.rdx, rdx(self.orig_rax)), + (self.r10, r10(self.orig_rax)), + (self.r8, r8(self.orig_rax)), + (self.r9, r9(self.orig_rax)), + ]; + + for param in params { + if param.1.len() != 0 { + let output_param = param.1.to_owned() + ":"; + spans.push(Span::styled( + format!("{} ", output_param), + Style::default().fg(Color::Blue), + )); + spans.push(Span::styled(format!("{}, ", param.0), Style::default())); + } + } + + spans.push(Span::styled( + format!(") = 0x{:x}", self.rax), + Style::default(), + )); + Line::from(spans) } } |