是否可以在 Linux 中反汇编运行进程? [英] Is it possible to dissembler running process in Linux?
问题描述
要反汇编我使用的程序 objdump -d
工具.是否有可能获得与 objdump
相同的输出,以便在没有 exe
文件的情况下运行进程?我怎样才能用 C
语言从其他程序中做到这一点?我知道存在像 GDB
这样的调试器,但我需要在 C
中使用该功能.由于我的程序,我想获得带有反汇编功能的输出文件以运行进程.我有一个进程的PID.我正在使用 Ubuntu.
To disassemble the program I am using objdump -d
tool. Is it possible to get the same output as with objdump
for running process without condition to have exe
file? How can i do it in C
language from other program? I know that exists debuggers like GDB
, but I need to use that functionality in C
. As result of my program I want to get output file with disassemble functions for running process. I have an PID of process. I am working with Ubuntu.
推荐答案
是否有可能获得与 objdump 相同的输出来运行进程而无需拥有 exe 文件?
Is it possible to get the same output as with objdump for running process without condition to have exe file?
是的,因为我有 PID 并且我需要的文件位于 /proc/
Yes it is, because i have PID and the file i need is located /proc/<PID>/exe
要在 C 中调用它,我将尝试类似的方法:
To call that in C i will try something like that:
char *comp = "objdump -d /proc/1234/exe";
fflush(NULL); // always useful before system(3)
int nok = system(comp);
if (nok) {
fprintf(stderr, "compilation %s failed with %d\n", comp, nok);
exit(EXIT_FAILURE);
}
感谢@dratenik!
这篇关于是否可以在 Linux 中反汇编运行进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!