private CorDebug.CorValue Dereference(CorDebug.CorValue value) { while (true) { CorDebug.CorReferenceValue rv = value.CastToReferenceValue(); if (rv == null) break; // not a reference if (rv.IsNull) return null; // reference to null CorDebug.CorValue newValue = rv.Dereference(); if (newValue == null) break; // couldn't dereference the reference (eg. void*) value = newValue; } return value; }
private string MakePtrString(CorDebug.CorValue value) { var sb = new StringBuilder(); while (true) { CorDebug.CorReferenceValue rv = value.CastToReferenceValue(); if (rv == null) break; // not a reference if (sb.Length > 0) { sb.Append("->"); } sb.Append("0x" + rv.Value.ToString("X", CultureInfo.CurrentUICulture)); CorDebug.CorValue newValue = null; try { newValue = rv.Dereference(); } catch (COMException ce) { if (ce.ErrorCode != (int) CorDebug.HResult.CORDBG_E_BAD_REFERENCE_VALUE) { throw; // some other error } } if (newValue == null) break; // couldn't dereference the reference (eg. void* or invalid ref) value = newValue; } return sb.ToString(); }