mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] ~getName now return undecorated name
git-svn-id: https://pykd.svn.codeplex.com/svn@79579 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
bd94e142d1
commit
eef5cf7596
@ -40,10 +40,54 @@ DiaRegToRegRelativeI386::DiaRegToRegRelativeI386()
|
|||||||
|
|
||||||
const std::string DiaException::descPrefix("pyDia: ");
|
const std::string DiaException::descPrefix("pyDia: ");
|
||||||
|
|
||||||
std::string DiaException::makeFullDesc(const std::string &desc, HRESULT hres)
|
std::string DiaException::makeFullDesc(const std::string &desc, HRESULT hres, IDiaSymbol *symbol /*= NULL*/)
|
||||||
{
|
{
|
||||||
std::stringstream sstream;
|
std::stringstream sstream;
|
||||||
sstream << descPrefix << desc << " failed" << std::endl;
|
sstream << descPrefix << desc << " failed" << std::endl;
|
||||||
|
if (symbol)
|
||||||
|
{
|
||||||
|
BSTR bstrName = NULL;
|
||||||
|
HRESULT locRes = symbol->get_undecoratedName(&bstrName);
|
||||||
|
if (S_OK == locRes && bstrName)
|
||||||
|
{
|
||||||
|
autoBstr freeBstr(bstrName);
|
||||||
|
sstream << "Symbol name: \"" << autoBstr::asStr(bstrName) << "\"";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
locRes = symbol->get_name(&bstrName);
|
||||||
|
if (S_OK == locRes && bstrName)
|
||||||
|
{
|
||||||
|
autoBstr freeBstr(bstrName);
|
||||||
|
sstream << "Symbol name: " << autoBstr::asStr(bstrName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sstream << "Symbol: ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DWORD dwValue;
|
||||||
|
locRes = symbol->get_relativeVirtualAddress(&dwValue);
|
||||||
|
if (S_OK == locRes)
|
||||||
|
{
|
||||||
|
sstream << ", RVA= 0x" << std::hex << dwValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
locRes = symbol->get_symTag(&dwValue);
|
||||||
|
if (S_OK == locRes)
|
||||||
|
{
|
||||||
|
sstream << ", tag= " << std::dec << dwValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
locRes = symbol->get_locationType(&dwValue);
|
||||||
|
if (S_OK == locRes)
|
||||||
|
{
|
||||||
|
sstream << ", location: " << std::dec << dwValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
sstream << std::endl;
|
||||||
|
}
|
||||||
sstream << "Return value is 0x" << std::hex << hres;
|
sstream << "Return value is 0x" << std::hex << hres;
|
||||||
|
|
||||||
PCHAR errMessage = NULL;
|
PCHAR errMessage = NULL;
|
||||||
@ -392,32 +436,11 @@ static const boost::regex stdcallMatch("^_(\\w+)@.+$");
|
|||||||
|
|
||||||
std::string DiaSymbol::getName()
|
std::string DiaSymbol::getName()
|
||||||
{
|
{
|
||||||
autoBstr retValue( callSymbol(get_name) );
|
BSTR bstrName = NULL;
|
||||||
|
HRESULT hres = m_symbol->get_undecoratedName(&bstrName);
|
||||||
boost::cmatch matchResult;
|
if (S_OK != hres)
|
||||||
|
bstrName = callSymbol(get_name);
|
||||||
std::string retStr = retValue.asStr();
|
autoBstr retValue( bstrName );
|
||||||
|
|
||||||
if ( boost::regex_match( retStr.c_str(), matchResult, stdcallMatch ) )
|
|
||||||
{
|
|
||||||
retStr= std::string( matchResult[1].first, matchResult[1].second );
|
|
||||||
}
|
|
||||||
else if (IMAGE_FILE_MACHINE_I386 == m_machineType)
|
|
||||||
{
|
|
||||||
DWORD symTag;
|
|
||||||
HRESULT hres = m_symbol->get_symTag(&symTag);
|
|
||||||
if (S_OK == hres && SymTagPublicSymbol == symTag)
|
|
||||||
retStr.erase( retStr.begin() );
|
|
||||||
}
|
|
||||||
|
|
||||||
return retStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
std::string DiaSymbol::getUndecoratedName()
|
|
||||||
{
|
|
||||||
autoBstr retValue( callSymbol(get_undecoratedName) );
|
|
||||||
return retValue.asStr();
|
return retValue.asStr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +25,8 @@ typedef std::map<ULONG, ULONG> DiaRegToRegRelativeBase;
|
|||||||
|
|
||||||
class DiaException : public SymbolException {
|
class DiaException : public SymbolException {
|
||||||
public:
|
public:
|
||||||
DiaException(const std::string &desc, HRESULT hres)
|
DiaException(const std::string &desc, HRESULT hres, IDiaSymbol *symbol = NULL)
|
||||||
: SymbolException( makeFullDesc(desc, hres) )
|
: SymbolException( makeFullDesc(desc, hres, symbol) )
|
||||||
, m_hres(hres)
|
, m_hres(hres)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -44,7 +44,7 @@ private:
|
|||||||
|
|
||||||
static const std::string descPrefix;
|
static const std::string descPrefix;
|
||||||
|
|
||||||
static std::string makeFullDesc(const std::string &desc, HRESULT hres);
|
static std::string makeFullDesc(const std::string &desc, HRESULT hres, IDiaSymbol *symbol = NULL);
|
||||||
|
|
||||||
HRESULT m_hres;
|
HRESULT m_hres;
|
||||||
};
|
};
|
||||||
@ -71,8 +71,6 @@ public:
|
|||||||
|
|
||||||
std::string getName();
|
std::string getName();
|
||||||
|
|
||||||
std::string getUndecoratedName();
|
|
||||||
|
|
||||||
SymbolPtr getType();
|
SymbolPtr getType();
|
||||||
|
|
||||||
SymbolPtr getIndexType();
|
SymbolPtr getIndexType();
|
||||||
@ -208,7 +206,7 @@ protected:
|
|||||||
TRet retValue;
|
TRet retValue;
|
||||||
HRESULT hres = (m_symbol->*method)(&retValue);
|
HRESULT hres = (m_symbol->*method)(&retValue);
|
||||||
if (S_OK != hres)
|
if (S_OK != hres)
|
||||||
throw DiaException(std::string("Call IDiaSymbol::") + methodName, hres);
|
throw DiaException(std::string("Call IDiaSymbol::") + methodName, hres, m_symbol);
|
||||||
|
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,6 @@ public:
|
|||||||
virtual ULONG getSymTag() = 0;
|
virtual ULONG getSymTag() = 0;
|
||||||
virtual SymbolPtr getType() = 0;
|
virtual SymbolPtr getType() = 0;
|
||||||
virtual ULONG getUdtKind() = 0;
|
virtual ULONG getUdtKind() = 0;
|
||||||
virtual std::string getUndecoratedName() = 0;
|
|
||||||
virtual ULONGLONG getVa() = 0;
|
virtual ULONGLONG getVa() = 0;
|
||||||
virtual void getValue( BaseTypeVariant &vtValue) = 0;
|
virtual void getValue( BaseTypeVariant &vtValue) = 0;
|
||||||
virtual ULONG getVirtualBaseDispIndex() = 0;
|
virtual ULONG getVirtualBaseDispIndex() = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user