04-09-2010
3,
0
Join Date: Apr 2010
Last Activity: 12 April 2010, 5:47 PM EDT
Posts: 3
Thanks Given: 0
Thanked 0 Times in 0 Posts
ptrace-get register values
Hi,All,
I use ptrace to capture the OPEN syscall, and find problems on getting filename as its argument. Basically, what ebx returns is a pointer to the filename of file to open. My code is as follows, and the program keep throwing segment fault. Besides, even if I can get filePath[0], how can I know the length of the string(or the char*), so I can get all related chars? Thanks in advance for any ideas.
Richard
//after capturing OPEN syscall
long ebx = ptrace(PTRACE_PEEKUSER, traced_process, 4 * EBX, NULL);
char * filePath = (char *) ebx;
//this line throws segment fault
cout << " filename to open is " << filePath[0];
...