How does strace read the file name of system call sys_open?
我正在编写一个使用Ptrace并执行以下操作的程序:
- 它读取当前的eax并检查系统调用是否为sys_open。
-
如果是,那么我需要知道传递的参数是什么。
int sys_open(const char * filename, const int mode, const int mask)
所以eax = 5表示这是一个开放系统调用
我从这个问题中知道ebx具有文件位置的地址
但是,我如何知道文件名的长度,以便可以读取该位置的内容?
我遇到了以下相同的问题
问题1
问题2(这仅是我的!)
但是我仍然没有解决我的问题的方法。 :(因为两个答案都不清楚。
当我尝试Question-1中的方法时,我仍然遇到细分错误
你可以在这里查看我的代码
所以现在我真的很想知道strace如何如此精美地提取这些值:(
如您所知,
这是标准过程,这是
C示例:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | #include <stdio.h> int main() { const char* filename ="/etc/somefile"; int fname_length = 0; for (int i = 0; filename[i] != '\\0'; i++) { fname_length++; } printf("Found %d chars in: %s\ ", fname_length, filename); return 0; } |
返回手头的任务,您必须访问