- Code: Select all
#include <iostream>
#include <sys/ptrace.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <string.h>
#include <sys/wait.h>
int main(int argc, char **argv)
{
int status;
ptrace(PTRACE_ATTACH, 2785);
waitpid(-1, &status, 0);
long word = ptrace(PTRACE_PEEKTEXT, 2785, 0x3ABFC8);
if(word == -1) {
if (errno) {
std::cout << strerror(errno);
}
}
waitpid(-1, &status, 0);
ptrace(PTRACE_DETACH, 2785);
return 0;
}
It always returns "No such process", tried with waitpid and sleep(2) to no avail.
(the process exists and the process is Linux, and I tried error check with ptrace attach as well, no errors).

