ptrace never working

Contribute code & patches
Forum rules
No support questions here please

ptrace never working

Postby xleniz on Tue Feb 21, 2012 8:51 am

Dont know if this is right place to post, but I have a beginner problem with ptrace.

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).
xleniz
Level 1
Level 1
 
Posts: 26
Joined: Fri Feb 17, 2012 8:32 am

Linux Mint is funded by ads and donations.
 

Return to Code & Patches

Who is online

Users browsing this forum: No registered users and 1 guest