HRESULT STDMETHODCALLTYPE CorProfiler::Initialize()

in ProfilingAPI/ELTProfiler/CorProfiler.cpp [94:119]


HRESULT STDMETHODCALLTYPE CorProfiler::Initialize(IUnknown *pICorProfilerInfoUnk)
{
    HRESULT queryInterfaceResult = pICorProfilerInfoUnk->QueryInterface(__uuidof(ICorProfilerInfo8), reinterpret_cast<void **>(&this->corProfilerInfo));

    if (FAILED(queryInterfaceResult))
    {
        return E_FAIL;
    }

    DWORD eventMask = COR_PRF_MONITOR_ENTERLEAVE | COR_PRF_ENABLE_FUNCTION_ARGS | COR_PRF_ENABLE_FUNCTION_RETVAL | COR_PRF_ENABLE_FRAME_INFO;

    auto hr = this->corProfilerInfo->SetEventMask(eventMask);
    if (hr != S_OK)
    {
        printf("ERROR: Profiler SetEventMask failed (HRESULT: %d)", hr);
    }

    hr = this->corProfilerInfo->SetEnterLeaveFunctionHooks3WithInfo(EnterNaked, LeaveNaked, TailcallNaked);

    if (hr != S_OK)
    {
        printf("ERROR: Profiler SetEnterLeaveFunctionHooks3WithInfo failed (HRESULT: %d)", hr);
    }

    return S_OK;
}