diff --git a/pykd/dbgmodule.cpp b/pykd/dbgmodule.cpp index 0764417..fc89f73 100644 --- a/pykd/dbgmodule.cpp +++ b/pykd/dbgmodule.cpp @@ -101,6 +101,47 @@ findModule( ULONG64 addr ) ///////////////////////////////////////////////////////////////////////////////// +dbgModuleClass::dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ) : + m_name( name ), + m_base( base ), + m_end( base + size ) +{ + reloadSymbols(); + + std::string pattern = name + "!*"; + ULONG64 enumHandle = 0; + + HRESULT hres = dbgExt->symbols->StartSymbolMatch( pattern.c_str(), &enumHandle ); + + while( SUCCEEDED( hres ) ) + { + char nameBuf[0x100]; + ULONG64 offset = 0; + + hres = + dbgExt->symbols->GetNextSymbolMatch( + enumHandle, + nameBuf, + sizeof( nameBuf ), + NULL, + &offset ); + + if ( FAILED( hres ) ) + break; + + std::string symbolName( nameBuf ); + + symbolName.erase( 0, name.size() + 1 ); + + m_offsets.insert( std::make_pair( symbolName, offset ) ); + } + + if ( enumHandle ) + dbgExt->symbols->EndSymbolMatch( enumHandle ); +} + +///////////////////////////////////////////////////////////////////////////////// + void dbgModuleClass::reloadSymbols() { @@ -136,14 +177,8 @@ dbgModuleClass::getOffset( const std::string &symName ) { return offset->second; } - - ULONG64 offsetVal = findAddressForSymbol( m_name, symName ); - if ( (ULONG64)~0 == offsetVal ) - return offsetVal; - - m_offsets.insert( std::make_pair( symName, offsetVal ) ); - - return offsetVal; + + return 0; } ///////////////////////////////////////////////////////////////////////////////// diff --git a/pykd/dbgmodule.h b/pykd/dbgmodule.h index 4d159fa..47e0f4f 100644 --- a/pykd/dbgmodule.h +++ b/pykd/dbgmodule.h @@ -17,11 +17,7 @@ public: m_end( 0 ) {} - dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ) : - m_name( name ), - m_base( base ), - m_end( base + size ) - {} + dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ); ULONG64 getBegin() const { diff --git a/pykd/dbgsym.cpp b/pykd/dbgsym.cpp index 181d925..7a26680 100644 --- a/pykd/dbgsym.cpp +++ b/pykd/dbgsym.cpp @@ -72,10 +72,8 @@ findAddressForSymbol( const std::string &moduleName, const std::string &symbol ULONG64 offset = 0ULL; hres = dbgExt->symbols->GetOffsetByName( ModuleSymName.c_str(), &offset ); - if ( FAILED( hres ) ) - throw DbgException( "IDebugSymbol::GetOffsetByName failed" ); - - return offset; + if ( SUCCEEDED( hres ) ) + return offset; } catch( std::exception &e ) { @@ -86,7 +84,7 @@ findAddressForSymbol( const std::string &moduleName, const std::string &symbol dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" ); } - return (ULONG64)~0; + return 0; } ///////////////////////////////////////////////////////////////////////////////// \ No newline at end of file