In gdb, how can I write a string to memory?

前端 未结 2 1867
借酒劲吻你
借酒劲吻你 2020-12-30 08:24

It is quite straightforward to write ints or hexadecimals to a memory address with gdb:

(gdb) set {int}0x08040000 = 42
(gdb) set {int}0x08040000 = 0xffffffff         


        
2条回答
  •  爱一瞬间的悲伤
    2020-12-30 09:09

    Use strcpy()

    (gdb) p malloc(20)
    $3 = (void *) 0x6ce81808
    (gdb) p strcpy($3, "my string")
    $4 = 1827149832
    (gdb) x/s $3
    0x6ce81808: "my string"
    

提交回复
热议问题