I am trying to do some very basic stuff using ptrace but I am a getting a really odd behavior.
unsigned long start=strtoul(start_text,NULL,16);
long start_data;
if ((start_data = ptrace(PTRACE_PEEKTEXT,child_pid,(void*)start,NULL))<0){
free_memory(vars,registers,size);
exit(1);
}
start_text
is a string to a valid place in another program, the value of start
is correct, the value of child_pid
is also correct.
For some reason, for some values of start
the call works properly, but for some it fails.
I tried to understand what causes this so I wrote this:
ptrace(PTRACE_PEEKTEXT,child_pid,(void*)start,NULL);
printf("%d",errno);
but errno
is 0 every time.
Can anyone please explain what causes the problem?