I have been using this tutorial to try to set up a debugger in C. I have set up a test program, which looks like this:
#include<stdio.h>
int main()
{
printf("BEFORE");
printf("AFTER");
}
and the dissasembly for the main function looks like this:
but if i try to use the code below to print data at 0x64a, i get the output ffffffffffffffff
long address = 0x64a;
long data = ptrace(PTRACE_PEEKTEXT, status, (void *) address, NULL);
printf("%lx", data);
Also, this is the code where i attach the test program:
char* args[] = {"test", NULL};
if(pid == 0)
{
ptrace(PTRACE_TRACEME, 0, NULL, NULL);
execve("./test", args, NULL);
//execl("./test", "test", NULL);
}