0

How to get the address of the object in a Microsoft.VisualStudio.Debugger.IDebugProperty2? Prepending & (&expression) isn't solution because I'll lose children of a property, but it is what I want.

I'm getting property2 via IDebugExpression2::EvaluateSync with variable name as an expression.

Wootiae
  • 728
  • 1
  • 7
  • 17

1 Answers1

0

If a variable inside is a pointer (variable for reference type) it returns address.

if (property2.GetMemoryContext(out var memoryContext2) != (int) HResults.S_OK || memoryContext2 == null)
  return 0;

var info = new CONTEXT_INFO[1];
memoryContext2.GetInfo(enum_CONTEXT_INFO_FIELDS.CIF_ADDRESS, info);

return long.Parse(info[0].bstrAddress.Substring(2), System.Globalization.NumberStyles.HexNumber);
Wootiae
  • 728
  • 1
  • 7
  • 17