From 594ebc15a147999bb227c4221f3e7d0c104f72a1 Mon Sep 17 00:00:00 2001 From: "SND\\kernelnet_cp" Date: Thu, 5 Sep 2013 07:04:59 +0000 Subject: [PATCH] [0.2.x] fixed : issue #12145 ( getOffset failes with SymbolException ) git-svn-id: https://pykd.svn.codeplex.com/svn@85081 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/win/dbgmod.cpp | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/pykd/win/dbgmod.cpp b/pykd/win/dbgmod.cpp index 1a3c898..0a32414 100644 --- a/pykd/win/dbgmod.cpp +++ b/pykd/win/dbgmod.cpp @@ -55,15 +55,38 @@ ULONG64 findModuleBySymbol( const std::string &symbolName ) HRESULT hres; ULONG64 base; - hres = g_dbgEng->symbols->GetSymbolModule( ( std::string("!") + symbolName ).c_str(), &base ); - if ( FAILED( hres ) ) + std::string str = "!"; + str += symbolName; + + hres = g_dbgEng->symbols->GetSymbolModule( str.c_str(), &base ); + if ( SUCCEEDED( hres ) ) + return base; + + DEBUG_VALUE debugValue = {}; + ULONG remainderIndex = 0; + + hres = + g_dbgEng->control->Evaluate( + symbolName.c_str(), + DEBUG_VALUE_INT64, + &debugValue, + &remainderIndex ); + + if ( SUCCEEDED( hres ) ) { - std::stringstream sstr; - sstr << "failed to find module for symbol: " << symbolName; - throw SymbolException( sstr.str() ); + ULONG64 base; + ULONG moduleIndex; + + hres = g_dbgEng->symbols->GetModuleByOffset( debugValue.I64, 0, &moduleIndex, &base ); + if ( FAILED( hres ) ) + throw DbgException( "IDebugSymbol::GetModuleByOffset", hres ); + + return base; } - return base; + std::stringstream sstr; + sstr << "failed to find module for symbol: " << symbolName; + throw SymbolException( sstr.str() ); } ///////////////////////////////////////////////////////////////////////////////////