如何使用LLDB修改内存内容?

8

在LLDB中,如何等价于下面GDB中的命令?

(gdb) set {char}0x02ae4=0x12

这里提供的值是任意的示例。在使用GDB时,我可以轻松地编辑给定十六进制地址处的字节码,同时查看终端中的转储。自从我升级到Mavericks后,我一直试图更多地摆弄lldb,但在某些领域我遇到了很大的困难。也许它现在甚至还没有这种功能。

2个回答

17
根据 lldb-basics guide,LLDB 的替代方法是 memory write
同时,(lldb) help memory write 定义了这样一种输入格式:
memory write -i <filename> [-s <byte-size>] [-o <offset>] <address> <value> [<value> [...]]

   -f <format> ( --format <format> )
        Specify a format to be used for display.

   -i <filename> ( --infile <filename> )
        Write memory using the contents of a file.

   -o <offset> ( --offset <offset> )
        Start writng bytes from an offset within the input file.

   -s <byte-size> ( --size <byte-size> )
        The size in bytes to use when displaying with the selected format.

因此,在您的情况下,类似于(lldb) memory write 0x02ae4 0x12这样的内容应该可以直接使用。

1
如果您需要写入多个字节,请使用 -s 选项:(lldb) memory write 0x02ae4 -s 2 0xFFFF - Picard

4

内存写入 是有效的,但你也可以使用表达式引擎和 C 表达式。

p *(char*)0x2ae4 = 0x12

1
我认为这个例子应该使用0x12来等同于问题的例子。 - ecm

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接