Setting a data breakpoint in Visual Studio 2005 at the address of a dereferenced pointer

I wonder if there is a way to do the following: I have a structure that contains an element that is a pointer to a block of memory allocated by the kernel when I pass the structure to the API function (WAVEHDR structure, member is a reserved field.)

I can set the data breakpoint to the value of the reserved element - this in itself is not very useful. What I would like to do when a breakpoint is hit is to dereference the pointer stored in the reserved state and set a new data breakpoint in the memory pointed to by this pointer. I would like VisualStudio to interrupt when this memory is set to a known value.

I know how to set a breakpoint from a macro and how to get Visual Studio to call this macro from a breakpoint when it is hit, but I don’t know if I can pass the pointer value to the macro so that it can set a breakpoint to the right address. The user interface does not provide a way to do this.

Is there a way for a macro to access information about a running program and do something like evaluating global variables or other expressions? I could do what I am trying to do if I had such programmatic access to the executable code (during the breakpoint) from the macro.

+4
source share
2 answers

A macro can evaluate everything you can in the viewport:

Dim e As EnvDTE.Expression e = DTE.Debugger.GetExpression("<my expression>", True) If e.IsValidValue Then ... use e.Value to do something End If 

The value you return in e.Value is exactly the line you see in the viewport, so you may need to split it. There are many other properties on an Expression object that you can use. See the MSDN documentation .

+2
source

I am not sure if this is possible. I know that there are conditional breakpoints, but this will require knowing the memory address ahead of time ...

Something along the lines * p == 0xADDRESS in the conditional break dialog box.

0
source

Source: https://habr.com/ru/post/1277572/


All Articles