为什么我需要以 root 身份运行(而不是 r00t_)?
// main()
scan.scanProcessOffset(10838, 0x7f8c14000000); // proper pid and offset
void MemoryMapper::scanProcessOffset(unsigned int procId, unsigned long long offset)
{
long attach = ptrace(PTRACE_ATTACH, procId, NULL, NULL);
cout << attach << endl << errno << endl;
long memory = ptrace(PTRACE_PEEKDATA, procId, offset);
if (memory == -1 && errno == 3)
{
cout << errno << endl;
errno = 0;
}
cout << memory;
}
正如您所看到的,我正在连接的进程归 r00t_ 所有
r00t_@:/proc/10838$ ls -l
lrwxrwxrwx 1 r00t r00t_ 0 2012-04-15 08:21 exe -> /usr/bin/gedit
-rw------- 1 r00t r00t_ 0 2012-04-15 09:04 mem
输出未以 root 身份运行:
r00t_@:~/memedit$ ./a.out
-1
1
3
-1
作为根输出:
r00t_@:~/memedit$ sudo ./a.out
0
0
140239607693344
当我是我试图附加到的进程的所有者时,为什么我不能附加?