From 5f996dd66155ba44a21c636c41901e2dfd8f2517 Mon Sep 17 00:00:00 2001 From: thrieg Date: Fri, 12 Dec 2025 00:17:37 +0100 Subject: [PATCH] removed 32 bits register names that didn't exist, instead use corresponding 64 bits register and mask the last 32 bits --- srcs/utils.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/srcs/utils.c b/srcs/utils.c index aae4032..9076810 100644 --- a/srcs/utils.c +++ b/srcs/utils.c @@ -6,7 +6,7 @@ /* By: thrieg +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/12/11 04:31:15 by thrieg #+# #+# */ -/* Updated: 2025/12/11 23:27:01 by thrieg ### ########.fr */ +/* Updated: 2025/12/12 00:17:04 by thrieg ### ########.fr */ /* */ /* ************************************************************************** */ @@ -73,12 +73,12 @@ static void fill_args(long long args[6], struct user_regs_struct *regs, size_t b } else if (binary_type == 32) { - args[0] = (long long)(long)regs->ebx; - args[1] = (long long)(long)regs->ecx; - args[2] = (long long)(long)regs->edx; - args[3] = (long long)(long)regs->esi; - args[4] = (long long)(long)regs->edi; - args[5] = (long long)(long)regs->ebp; + args[0] = (long long)(regs->rbx & 0xFFFFFFFF); + args[1] = (long long)(regs->rcx & 0xFFFFFFFF); + args[2] = (long long)(regs->rdx & 0xFFFFFFFF); + args[3] = (long long)(regs->rsi & 0xFFFFFFFF); + args[4] = (long long)(regs->rdi & 0xFFFFFFFF); + args[5] = (long long)(regs->rbp & 0xFFFFFFFF); } } @@ -92,8 +92,8 @@ static const char *get_syscall_name(size_t binary_type, struct user_regs_struct } else if (binary_type == 32 && regs->orig_eax < g_syscalls_32_len) { - *argc = g_syscalls_32[regs->orig_eax].argc; - return (g_syscalls_32[regs->orig_eax].name); + *argc = g_syscalls_32[regs->orig_rax & 0xFFFFFFFF].argc; + return (g_syscalls_32[regs->orig_rax & 0xFFFFFFFF].name); } *argc = 6; return (NULL); @@ -200,7 +200,7 @@ void read_regs_and_print_exit(pid_t pid, size_t binary_type) if (binary_type == 64) ret = (long)regs.rax; else - ret = (long)regs.eax; + ret = (long)regs.rax & 0xFFFFFFFF; printf(" = %ld\n", ret); fflush(stdout); }