1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 19:17:44 +00:00

LibCore: Implement new ptrace_peekbuf wrapper for PT_PEEKBUF syscall

This commit is contained in:
Ben Wiederhake 2021-11-25 23:04:52 +01:00 committed by Andreas Kling
parent 0f8483f09c
commit 70e96fb917
3 changed files with 26 additions and 0 deletions

View file

@ -12,6 +12,7 @@
#include <stdarg.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/ptrace.h>
#include <sys/socket.h>
#include <termios.h>
#include <unistd.h>
@ -67,6 +68,21 @@ ErrorOr<int> recvfd(int sockfd, int options)
return Error::from_syscall("recvfd"sv, -errno);
return fd;
}
ErrorOr<void> ptrace_peekbuf(pid_t tid, void const* tracee_addr, Bytes destination_buf)
{
Syscall::SC_ptrace_buf_params buf_params {
{ destination_buf.data(), destination_buf.size() }
};
Syscall::SC_ptrace_params params {
PT_PEEKBUF,
tid,
const_cast<void*>(tracee_addr),
(FlatPtr)&buf_params,
};
int rc = syscall(SC_ptrace, &params);
HANDLE_SYSCALL_RETURN_VALUE("ptrace_peekbuf", rc, {});
}
#endif
ErrorOr<void> sigaction(int signal, struct sigaction const* action, struct sigaction* old_action)