in natvis/object_visualizer.cpp [98:171]
static HRESULT EvaluatePropertyExpression(
_In_ PropertyData const& prop,
_In_ DkmVisualizedExpression* pExpression,
_In_ DkmPointerValueHome* pObject,
bool isAbiObject,
_Out_ com_ptr<DkmEvaluationResult>& pEvaluationResult
)
{
wchar_t abiAddress[40];
auto process = pExpression->RuntimeInstance()->Process();
bool is64Bit = ((process->SystemInformation()->Flags() & DefaultPort::DkmSystemInformationFlags::Is64Bit) != 0);
swprintf_s(abiAddress, is64Bit ? L"%s0x%I64x" : L"%s0x%08x", isAbiObject ? L"(::IUnknown*)" : L"*(::IUnknown**)", pObject->Address());
wchar_t wszEvalText[500];
std::wstring propCast;
PCWSTR propField;
if (prop.category < PropertyCategory::Value)
{
propField = g_categoryData[(int)prop.category].propField;
}
else
{
propField = L"v";
propCast = L"*(" + prop.abiType + L"*)";
}
swprintf_s(wszEvalText, L"%sWINRT_abi_val(%s, L\"{%s}\", %i).%s", propCast.c_str(), abiAddress, prop.iid.c_str(), prop.index, propField);
com_ptr<DkmString> pEvalText;
IF_FAIL_RET(DkmString::Create(DkmSourceString(wszEvalText), pEvalText.put()));
NatvisDiagnostic(process, wszEvalText, NatvisDiagnosticLevel::Verbose);
auto evalFlags = DkmEvaluationFlags::TreatAsExpression | DkmEvaluationFlags::ForceEvaluationNow | DkmEvaluationFlags::ForceRealFuncEval;
auto inspectionContext = pExpression->InspectionContext();
com_ptr<DkmLanguageExpression> pLanguageExpression;
IF_FAIL_RET(DkmLanguageExpression::Create(
inspectionContext->Language(),
evalFlags,
pEvalText.get(),
DkmDataItem::Null(),
pLanguageExpression.put()
));
com_ptr<DkmInspectionContext> pInspectionContext;
if ( (pExpression->InspectionContext()->EvaluationFlags() & evalFlags) != evalFlags)
{
DkmInspectionContext::Create(
inspectionContext->InspectionSession(),
inspectionContext->RuntimeInstance(),
inspectionContext->Thread(),
inspectionContext->Timeout(),
evalFlags,
inspectionContext->FuncEvalFlags(),
inspectionContext->Radix(),
inspectionContext->Language(),
inspectionContext->ReturnValue(),
pInspectionContext.put()
);
}
else
{
pInspectionContext.copy_from(inspectionContext);
}
auto hr = pExpression->EvaluateExpressionCallback(
pInspectionContext.get(),
pLanguageExpression.get(),
pExpression->StackFrame(),
pEvaluationResult.put()
);
if (hr != S_OK)
{
NatvisDiagnostic(process, L"EvaluateExpressionCallback failed", NatvisDiagnosticLevel::Warning, hr);
}
return hr;
}