views:

192

answers:

4

Hello everyone,

I want to set a break point and wants it to be triggered when a piece memory (begin address and length are known) are changed. I am working on Windows Server 2003 x64 platform. Either solution in Windbg or solution in Visual Studio are fine. My purpose is to monitor when the memory content is change.

thanks in advance, George

+4  A: 

Try setting a data breakpoint.

In Visual Studio:

  • Go to Debug >> New Breakpoint >> New Data Breakpoint
  • Enter the address you want to watch (or an expression that evaluates to an address; such as &foo)
  • Enter the number of bytes to watch at that address
  • Click OK, run your program in the debugger, and wait!
Neil Williams
+1  A: 

Not sure about VS, but with windbg you can use the following command

ba w size address

Replace size with the length of the memory and address with the start address of the memory.

JaredPar
+1  A: 

You can set a data breakpoint but you'll need to know the address of the memory location you're interesting in before you can set such a breakpoint. Typically, I either set a breakpoint at the beginning of my program or have the debugger suspend on attach so I can find the memory address of the variable I want to monitor, then set the data breakpoint.

Zach
+2  A: 

This can be done in GDB also. In GDB, this is a watch on a specific address (I've had success setting watches on the address of C++ object members in this way).

dicroce
@dicroce, GDB does not work on Windows Server 2003?
George2
It does if you use Cygwin ;-)
Mawg