Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
void *entrypoint; /*virtual address of process*/ fscanf(debuggedfile, "%p", &entrypoint);
其中 debuggedfile 是指向 int 入口点所在偏移量的 elf 文件的流。当我使用 ptrace(PTRACE_PEEKTEXT, 0, entrypoint, 0) 它返回 -1
ELF 是一种二进制文件格式。fscanf用于从文本文件中读取。试试fread吧。
fscanf
fread
如果您正在编写解析 ELF 文件的代码,我建议您使用像libelf这样的标准库,而不是手动编写您自己的 ELF 解析器。
这样,您就可以让 libelf 处理偶尔出现的极端情况,例如使用扩展节编号的 ELF 对象。
有一些活跃的开源项目正在开发BSD 许可 和GPL的 libelf 实现——任你选择。