如何使用 GDB 修改内存内容? [英] How to modify memory contents using GDB?
本文介绍了如何使用 GDB 修改内存内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道我们可以使用几个命令来访问和读取内存:例如,print、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
或者您可以通过地址更新任意(可写)位置:
Or you can just update arbitrary (writable) location by address:
(gdb) set {int}0x83040 = 4
还有更多.阅读手册.
这篇关于如何使用 GDB 修改内存内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文