diff --git a/symbol_enum.cpp b/symbol_enum.cpp index 7f19234..7e83df1 100644 --- a/symbol_enum.cpp +++ b/symbol_enum.cpp @@ -371,11 +371,10 @@ SymbolEnum::SymbolEnum(PCWSTR modulePath, wil::com_ptr diaSession; THROW_IF_FAILED(diaSource->openSession(&diaSession)); - wil::com_ptr diaGlobal; - THROW_IF_FAILED(diaSession->get_globalScope(&diaGlobal)); + THROW_IF_FAILED(diaSession->get_globalScope(&m_diaGlobal)); THROW_IF_FAILED( - diaGlobal->findChildren(SymTagNull, nullptr, nsNone, &m_diaSymbols)); + m_diaGlobal->findChildren(kSymTags[0], nullptr, nsNone, &m_diaSymbols)); } std::optional SymbolEnum::GetNextSymbol() { @@ -386,6 +385,13 @@ std::optional SymbolEnum::GetNextSymbol() { THROW_IF_FAILED(hr); if (hr == S_FALSE || count == 0) { + m_symTagIndex++; + if (m_symTagIndex < ARRAYSIZE(kSymTags)) { + THROW_IF_FAILED(m_diaGlobal->findChildren( + kSymTags[m_symTagIndex], nullptr, nsNone, &m_diaSymbols)); + continue; + } + return std::nullopt; } diff --git a/symbol_enum.h b/symbol_enum.h index 4bb7564..a8c54eb 100644 --- a/symbol_enum.h +++ b/symbol_enum.h @@ -39,10 +39,18 @@ class SymbolEnum { private: wil::com_ptr LoadMsdia(); + static constexpr enum SymTagEnum kSymTags[] = { + SymTagPublicSymbol, + SymTagFunction, + SymTagData, + }; + HMODULE m_moduleBase; UndecorateMode m_undecorateMode; wil::unique_hmodule m_msdiaModule; + wil::com_ptr m_diaGlobal; wil::com_ptr m_diaSymbols; + size_t m_symTagIndex = 0; wil::unique_bstr m_currentSymbolName; wil::unique_bstr m_currentDecoratedSymbolName; };