mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:47:36 +00:00
Kernel+LibC: Fix ptrace for 64-bit
This makes the types used in the PT_PEEK and PT_POKE actions suitable for 64-bit platforms as well.
This commit is contained in:
parent
8292061f53
commit
38ddf301f6
6 changed files with 26 additions and 26 deletions
|
@ -10,18 +10,18 @@
|
|||
|
||||
extern "C" {
|
||||
|
||||
int ptrace(int request, pid_t tid, void* addr, int data)
|
||||
long ptrace(int request, pid_t tid, void* addr, void* data)
|
||||
{
|
||||
// PT_PEEK needs special handling since the syscall wrapper
|
||||
// returns the peeked value as an int, which can be negative because of the cast.
|
||||
// When using PT_PEEK, the user can check if an error occurred
|
||||
// by looking at errno rather than the return value.
|
||||
|
||||
u32 out_data;
|
||||
FlatPtr out_data;
|
||||
Syscall::SC_ptrace_peek_params peek_params;
|
||||
auto is_peek_type = request == PT_PEEK || request == PT_PEEKDEBUG;
|
||||
if (is_peek_type) {
|
||||
peek_params.address = reinterpret_cast<u32*>(addr);
|
||||
peek_params.address = reinterpret_cast<FlatPtr*>(addr);
|
||||
peek_params.out_data = &out_data;
|
||||
addr = &peek_params;
|
||||
}
|
||||
|
@ -29,10 +29,10 @@ int ptrace(int request, pid_t tid, void* addr, int data)
|
|||
Syscall::SC_ptrace_params params {
|
||||
request,
|
||||
tid,
|
||||
reinterpret_cast<u8*>(addr),
|
||||
data
|
||||
addr,
|
||||
(FlatPtr)data
|
||||
};
|
||||
int rc = syscall(SC_ptrace, ¶ms);
|
||||
long rc = syscall(SC_ptrace, ¶ms);
|
||||
|
||||
if (is_peek_type) {
|
||||
if (rc < 0) {
|
||||
|
@ -40,7 +40,7 @@ int ptrace(int request, pid_t tid, void* addr, int data)
|
|||
return -1;
|
||||
}
|
||||
errno = 0;
|
||||
return static_cast<int>(out_data);
|
||||
return static_cast<long>(out_data);
|
||||
}
|
||||
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
|
|
|
@ -13,6 +13,6 @@ __BEGIN_DECLS
|
|||
// FIXME: PID/TID ISSUE
|
||||
// Affects the entirety of LibDebug and Userland/strace.cpp.
|
||||
// See also Kernel/Ptrace.cpp
|
||||
int ptrace(int request, pid_t tid, void* addr, int data);
|
||||
long ptrace(int request, pid_t tid, void* addr, void* data);
|
||||
|
||||
__END_DECLS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue