0

I am new here this is my first post

I know how to set a register in gdb but I want to set a register (or the address pointed by this register minus 0xC... the instruction where I see this is:

cmpl $0xcc07c9,-0xc(%ebp)

so, is %ebp the address pointed by ebp?

but

set $(%ebp-0xc) =... does not works

How can I do it?

Thank you in advance!

and yes, new here posting but not reading/consulting you

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
cavielles
  • 1
  • 1
  • Could be `set *(int*)($ebg-0xc) = 42`. – j6t Nov 25 '22 at 16:08
  • No, AT&T syntax prefixes every register name with `%`, to distinguish them from a symbol of the same name. `-0xc(%ebp)` is the same addressing mode as Intel `[ebp - 0xc]`, as various Q&As about AT&T syntax point out. https://stackoverflow.com/tags/att/info. If you prefer Intel syntax, `set disassembly-flavor intel`. – Peter Cordes Nov 25 '22 at 16:23
  • Related: [How to print register values in GDB?](https://stackoverflow.com/a/31340294) has an answer that shows how to set register values via the `$ebp` GDB variable that's tied to the CPU register value in the process being debugged. – Peter Cordes Nov 25 '22 at 16:24
  • Do you actually want to set *memory* pointed to by a register? Your question title asked how to set a register. – Peter Cordes Nov 25 '22 at 16:26
  • I tried what j6t said but doesn't works... finally I print the address pointed by the register, minus 0xc and later set this address normally. But I can't do it directly even consulting your related questios @PeterCordes maybe I am a bit noob with gbd i only dissasembly in early 2000 with "w32program dissasembler" so imagine... I need time to catch up! Thank you both! – cavielles Nov 25 '22 at 18:05
  • @j6t's comment has a typo in the register name. It should work with `set *(int*)($ebp-0xc) = 42` while you're stopped at this instruction so EBP has the right value. – Peter Cordes Nov 25 '22 at 22:17

0 Answers0