在 gdb 中我可以使用call
运行函数,但是如果我想运行一些额外的程序集怎么办?
Prior to GCC 5 (1), I don't know of a way to run arbitrary machine code unless you actually enter the machine code into memory and then run it.
如果你想运行代码already在内存中,您可以将指令指针设置为开始,在结束处设置断点,然后继续。然后,在断点之后,将指令指针更改回其原始值。
但我实际上看不到这个的用例。这并不意味着那里isn't第一,任何你能通过运行代码做的事情,你也可以通过直接修改寄存器、标志、内存等来实现。
例如,命令:
info registers
将转储寄存器的当前值,同时:
set $eax = 42
将改变eax
注册到42
.
您还可以通过以下方式更改内存:
set *((char*)0xb7ffeca0) = 4
这会将单个字节写入内存位置0xb7ffeca0
您还可以使用相同的方法来存储更广泛的数据类型。
(1) GCC 5 allows you to compile and execute arbitrary code with the compile code
command, as documented here https://sourceware.org/gdb/onlinedocs/gdb/Compiling-and-Injecting-Code.html.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)