views:

307

answers:

1

I'd like to create a breakpoint such that it will create another one-time breakpoint that will 'dd' a certain memory address when that memory is written to.

So when the breakpoint is hit, I'd like to run a command like:

  ba w4 @ESP+4 /1 ''dd [memory address of this breakpoint]''

Since this breakpoint is being created by another breakpoint (and could potentially be called several times), I can't specify the breakpoint number. Otherwise I could use a pseudo register like '$bp3' to get the memory address of breakpoint #3

Would anyone have any thoughts on how to create a breakpoint command that can 'dd' the memory address of the breakpoint?

Thank you!

A: 

you can elaborate to make use of other general purpose pseudo-registers: t0..t19

bp your-address "r$t1=your-other-address; ba w4 @$t1 /1 \"dd @$t1;gc\""
If the 'your-address' breakpoint is hit twice (before the 'your-other-address' is hit), would this change the value of $t1 and cause both of the one-time breakpoints to dd @$t1 on the same address?Thank you!!!
IFacer
In that case, keep the breakpoints to minimum. Knowing you have one on 'your-address', it can also reset all other bps. Use something like 'bc1-10' in its condition (provided the 'your-address' is on bp0!) to get rid of the last 10 breakpoints that did not yet get hit.
Alternatively, you can set $t1 to 0 (to make sure ;o) and reset it to 0 in the single-shot bp. Then simply test for 0 (or for other value) and only create a new single-shot bp if a certain condition (like it being 0) is met.