如何使用GDB修改存储器的内容? [英] How to modify memory contents using GDB?
本文介绍了如何使用GDB修改存储器的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道,我们可以使用多种命令来访问和读取记忆:例如,打印,P,X ...
I know that we can use several commands to access and read memory: for example, print, p, x...
但我怎么可以改变内存中的内容在任何特定的位置(在调试中GDB)?
But how can I change the contents of memory at any specific location (while debugging in GDB)?
推荐答案
最简单的就是设置一个程序变量(见的 GDB:分配):
The easiest is setting a program variable (see GDB: assignment):
(gdb) l
6 {
7 int i;
8 struct file *f, *ftmp;
9
(gdb) set variable i = 10
(gdb) p i
$1 = 10
然后,你可以仅仅通过地址更新任意(写的)位置:
Then you can just update arbitrary (writable) location by address:
(gdb) set {int}0x83040 = 4
还有更多。阅读手动。
这篇关于如何使用GDB修改存储器的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文