system call tracing using ptrace

前端 未结 1 1588
没有蜡笔的小新
没有蜡笔的小新 2020-12-22 01:57

I wrote a program to list all the system calls executed by a command (say /bin/ls). Now what I am trying to do is find all the system call arguments, environment variables,

相关标签:
1条回答
  • 2020-12-22 02:05

    (Revised form of comments above (so you can accept it)):

    Detailed syscall parameters can be looked up in Linux kernel header syscalls.h. In above case, as sys_access (#33 on x86) has only two parameters:

    • first is the pointer to filename, so your file name was stored at address 0x4c4d8e
    • Second parameter is file mode (see mode flag defines)
    • as there is no third parameter to this syscall, edx is not relevant and contains some undefined value

    Return value of this syscall is -2 (ENOENT, defined in errno-base.h), which signifies error (no such file or directory).

    Also note (see Basile's comment above) that you are duplicating the functionality of strace utility.

    0 讨论(0)
提交回复
热议问题