Why does IDiaEnumSymbolsByAddr::Next crash?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 10:08:26

问题


I wanted to enumerate symbols by address but it seems IDiaEnumSymbolsByAddr::Next crash when I call it.

The documentation doesn't say anything extra about it. Minimal code to reproduce:

int main()
{
    IDiaDataSource *ds;
    IDiaSession *session;
    IDiaEnumSymbolsByAddr *symbolEnum;
    IDiaSymbol *symbol;
    HRESULT hr;
    ULONG fetched;

    CoInitialize(NULL);

    hr = makeDiaDataSource(&ds);
    assert(SUCCEEDED(hr));

    hr = ds->loadDataForExe(L"readpdb.exe", NULL, NULL);
    assert(SUCCEEDED(hr));

    hr = ds->openSession(&session);
    assert(SUCCEEDED(hr));

    hr = session->getSymbolsByAddr(&symbolEnum);
    assert(SUCCEEDED(hr));

    hr = symbolEnum->Next(1, &symbol, &fetched); // crash at this line.
    assert(SUCCEEDED(hr));

    printf("All is OK.\n");

    return 0;
}

Is this a bug in the DIA DSK? Or maybe I'm not supposed to use the interface this way?

来源:https://stackoverflow.com/questions/28745962/why-does-idiaenumsymbolsbyaddrnext-crash

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!