removed 32 bits register names that didn't exist, instead use corresponding 64 bits register and mask the last 32 bits

This commit is contained in:
thrieg 2025-12-12 00:17:37 +01:00
parent 6414474ce0
commit 5f996dd661

View file

@ -6,7 +6,7 @@
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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);
}