mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] ~fix: size of basic type ptr
git-svn-id: https://pykd.svn.codeplex.com/svn@82228 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
30837343b3
commit
310d1e9c7d
@ -21,19 +21,19 @@ public:
|
|||||||
m_ptrSize = pointerSize ? pointerSize : ptrSize();
|
m_ptrSize = pointerSize ? pointerSize : ptrSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
TypeInfoPtr getUInt1B() { return TypeInfo::getBaseTypeInfo( "UInt1B" ); }
|
TypeInfoPtr getUInt1B() { return TypeInfo::getBaseTypeInfo( "UInt1B", m_ptrSize ); }
|
||||||
TypeInfoPtr getUInt2B() { return TypeInfo::getBaseTypeInfo( "UInt2B" ); }
|
TypeInfoPtr getUInt2B() { return TypeInfo::getBaseTypeInfo( "UInt2B", m_ptrSize ); }
|
||||||
TypeInfoPtr getUInt4B() { return TypeInfo::getBaseTypeInfo( "UInt4B" ); }
|
TypeInfoPtr getUInt4B() { return TypeInfo::getBaseTypeInfo( "UInt4B", m_ptrSize ); }
|
||||||
TypeInfoPtr getUInt8B() { return TypeInfo::getBaseTypeInfo( "UInt8B" ); }
|
TypeInfoPtr getUInt8B() { return TypeInfo::getBaseTypeInfo( "UInt8B", m_ptrSize ); }
|
||||||
TypeInfoPtr getInt1B() { return TypeInfo::getBaseTypeInfo( "Int1B" ); }
|
TypeInfoPtr getInt1B() { return TypeInfo::getBaseTypeInfo( "Int1B", m_ptrSize ); }
|
||||||
TypeInfoPtr getInt2B() { return TypeInfo::getBaseTypeInfo( "Int2B" ); }
|
TypeInfoPtr getInt2B() { return TypeInfo::getBaseTypeInfo( "Int2B", m_ptrSize ); }
|
||||||
TypeInfoPtr getInt4B() { return TypeInfo::getBaseTypeInfo( "Int4B" ); }
|
TypeInfoPtr getInt4B() { return TypeInfo::getBaseTypeInfo( "Int4B", m_ptrSize ); }
|
||||||
TypeInfoPtr getInt8B() { return TypeInfo::getBaseTypeInfo( "Int8B" ); }
|
TypeInfoPtr getInt8B() { return TypeInfo::getBaseTypeInfo( "Int8B", m_ptrSize ); }
|
||||||
TypeInfoPtr getLong() { return TypeInfo::getBaseTypeInfo( "Long" ); }
|
TypeInfoPtr getLong() { return TypeInfo::getBaseTypeInfo( "Long", m_ptrSize ); }
|
||||||
TypeInfoPtr getULong() { return TypeInfo::getBaseTypeInfo( "ULong" ); }
|
TypeInfoPtr getULong() { return TypeInfo::getBaseTypeInfo( "ULong", m_ptrSize ); }
|
||||||
TypeInfoPtr getBool() { return TypeInfo::getBaseTypeInfo( "Bool" ); }
|
TypeInfoPtr getBool() { return TypeInfo::getBaseTypeInfo( "Bool", m_ptrSize ); }
|
||||||
TypeInfoPtr getChar() { return TypeInfo::getBaseTypeInfo( "Char" ); }
|
TypeInfoPtr getChar() { return TypeInfo::getBaseTypeInfo( "Char", m_ptrSize ); }
|
||||||
TypeInfoPtr getWChar() { return TypeInfo::getBaseTypeInfo( "WChar" ); }
|
TypeInfoPtr getWChar() { return TypeInfo::getBaseTypeInfo( "WChar", m_ptrSize ); }
|
||||||
|
|
||||||
TypeInfoPtr getVoidPtr() {
|
TypeInfoPtr getVoidPtr() {
|
||||||
return TypeInfoPtr( new PointerTypeInfo(m_ptrSize) );
|
return TypeInfoPtr( new PointerTypeInfo(m_ptrSize) );
|
||||||
|
@ -46,7 +46,7 @@ TypeInfoPtr TypeInfo::getTypeInfoByName( const std::string &typeName )
|
|||||||
std::string symName;
|
std::string symName;
|
||||||
|
|
||||||
if ( TypeInfo::isBaseType( typeName ) )
|
if ( TypeInfo::isBaseType( typeName ) )
|
||||||
return TypeInfo::getBaseTypeInfo( typeName );
|
return TypeInfo::getBaseTypeInfo( typeName, pykd::ptrSize() );
|
||||||
|
|
||||||
splitSymName( typeName, moduleName, symName );
|
splitSymName( typeName, moduleName, symName );
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ ULONG64 TypeInfo::getSymbolSize( const std::string &fullName )
|
|||||||
std::string symName;
|
std::string symName;
|
||||||
|
|
||||||
if ( TypeInfo::isBaseType( fullName ) )
|
if ( TypeInfo::isBaseType( fullName ) )
|
||||||
return TypeInfo::getBaseTypeInfo( fullName )->getSize();
|
return TypeInfo::getBaseTypeInfo( fullName, pykd::ptrSize() )->getSize();
|
||||||
|
|
||||||
splitSymName( fullName, moduleName, symName );
|
splitSymName( fullName, moduleName, symName );
|
||||||
|
|
||||||
@ -124,6 +124,13 @@ ULONG64 TypeInfo::getOffset( const std::string &fullName )
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
inline ULONG getTypePointerSize( SymbolPtr &typeSym )
|
||||||
|
{
|
||||||
|
return (typeSym->getMachineType() == IMAGE_FILE_MACHINE_AMD64) ? 8 : 4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &typeSym )
|
TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &typeSym )
|
||||||
{
|
{
|
||||||
ULONG symTag = typeSym->getSymTag();
|
ULONG symTag = typeSym->getSymTag();
|
||||||
@ -185,7 +192,7 @@ TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &typeSym )
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( ptr )
|
if ( ptr )
|
||||||
ptr->m_ptrSize = (typeSym->getMachineType() == IMAGE_FILE_MACHINE_AMD64) ? 8 : 4;
|
ptr->m_ptrSize = getTypePointerSize(typeSym);
|
||||||
|
|
||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
@ -208,7 +215,7 @@ TypeInfoPtr TypeInfo::getTypeInfo( SymbolPtr &symScope, const std::string &symN
|
|||||||
|
|
||||||
if ( pos == std::string::npos )
|
if ( pos == std::string::npos )
|
||||||
{
|
{
|
||||||
TypeInfoPtr basePtr = getBaseTypeInfo( symName );
|
TypeInfoPtr basePtr = getBaseTypeInfo( symName, getTypePointerSize(symScope) );
|
||||||
if ( basePtr != 0 )
|
if ( basePtr != 0 )
|
||||||
return basePtr;
|
return basePtr;
|
||||||
|
|
||||||
@ -252,56 +259,56 @@ TypeInfo::isBaseType( const std::string &symName )
|
|||||||
}
|
}
|
||||||
|
|
||||||
TypeInfoPtr
|
TypeInfoPtr
|
||||||
TypeInfo::getBaseTypeInfo( const std::string &symName )
|
TypeInfo::getBaseTypeInfo( const std::string &symName, ULONG pointerSize )
|
||||||
{
|
{
|
||||||
boost::cmatch baseMatchResult;
|
boost::cmatch baseMatchResult;
|
||||||
|
|
||||||
if ( boost::regex_match( symName.c_str(), baseMatchResult, baseMatch ) )
|
if ( boost::regex_match( symName.c_str(), baseMatchResult, baseMatch ) )
|
||||||
{
|
{
|
||||||
if ( baseMatchResult[1].matched )
|
if ( baseMatchResult[1].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<char>("Char") );
|
return TypeInfoPtr( new TypeInfoWrapper<char>("Char", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[2].matched )
|
if ( baseMatchResult[2].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<wchar_t>("WChar") );
|
return TypeInfoPtr( new TypeInfoWrapper<wchar_t>("WChar", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[3].matched )
|
if ( baseMatchResult[3].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<char>("Int1B") );
|
return TypeInfoPtr( new TypeInfoWrapper<char>("Int1B", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[4].matched )
|
if ( baseMatchResult[4].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<unsigned char>("UInt1B") );
|
return TypeInfoPtr( new TypeInfoWrapper<unsigned char>("UInt1B", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[5].matched )
|
if ( baseMatchResult[5].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<short>("Int2B") );
|
return TypeInfoPtr( new TypeInfoWrapper<short>("Int2B", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[6].matched )
|
if ( baseMatchResult[6].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<unsigned short>("UInt2B") );
|
return TypeInfoPtr( new TypeInfoWrapper<unsigned short>("UInt2B", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[7].matched )
|
if ( baseMatchResult[7].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<long>("Int4B") );
|
return TypeInfoPtr( new TypeInfoWrapper<long>("Int4B", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[8].matched )
|
if ( baseMatchResult[8].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("UInt4B") );
|
return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("UInt4B", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[9].matched )
|
if ( baseMatchResult[9].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<__int64>("Int8B") );
|
return TypeInfoPtr( new TypeInfoWrapper<__int64>("Int8B", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[10].matched )
|
if ( baseMatchResult[10].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<unsigned __int64>("UInt8B") );
|
return TypeInfoPtr( new TypeInfoWrapper<unsigned __int64>("UInt8B", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[11].matched )
|
if ( baseMatchResult[11].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<long>("Long") );
|
return TypeInfoPtr( new TypeInfoWrapper<long>("Long", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[12].matched )
|
if ( baseMatchResult[12].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("ULong") );
|
return TypeInfoPtr( new TypeInfoWrapper<unsigned long>("ULong", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[13].matched )
|
if ( baseMatchResult[13].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<float>("Float") );
|
return TypeInfoPtr( new TypeInfoWrapper<float>("Float", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[14].matched )
|
if ( baseMatchResult[14].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<bool>("Bool") );
|
return TypeInfoPtr( new TypeInfoWrapper<bool>("Bool", pointerSize) );
|
||||||
|
|
||||||
if ( baseMatchResult[15].matched )
|
if ( baseMatchResult[15].matched )
|
||||||
return TypeInfoPtr( new TypeInfoWrapper<double>("Double") );
|
return TypeInfoPtr( new TypeInfoWrapper<double>("Double", pointerSize) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return TypeInfoPtr();
|
return TypeInfoPtr();
|
||||||
@ -319,7 +326,7 @@ TypeInfo::getBaseTypeInfo( SymbolPtr &symbol )
|
|||||||
std::stringstream sstr;
|
std::stringstream sstr;
|
||||||
sstr << symName << symbol->getSize() << "B";
|
sstr << symName << symbol->getSize() << "B";
|
||||||
|
|
||||||
return getBaseTypeInfo( sstr.str() );
|
return getBaseTypeInfo( sstr.str(), getTypePointerSize(symbol) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( symName == "Float" && symbol->getSize() == 8 )
|
if ( symName == "Float" && symbol->getSize() == 8 )
|
||||||
@ -327,7 +334,7 @@ TypeInfo::getBaseTypeInfo( SymbolPtr &symbol )
|
|||||||
symName = "Double";
|
symName = "Double";
|
||||||
}
|
}
|
||||||
|
|
||||||
return getBaseTypeInfo( symName );
|
return getBaseTypeInfo( symName, getTypePointerSize(symbol) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -401,7 +408,7 @@ PointerTypeInfo::PointerTypeInfo( SymbolPtr &symScope, const std::string &symNam
|
|||||||
{
|
{
|
||||||
m_derefType.swap( TypeInfoPtr() );
|
m_derefType.swap( TypeInfoPtr() );
|
||||||
}
|
}
|
||||||
m_size = (symScope->getMachineType() == IMAGE_FILE_MACHINE_AMD64) ? 8 : 4;
|
m_size = getTypePointerSize(symScope);
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -531,7 +538,7 @@ static const boost::regex symbolMatch("^([\\*]*)([^\\(\\)\\*\\[\\]]*)([\\(\\)\\*
|
|||||||
|
|
||||||
TypeInfoPtr TypeInfo::getComplexType( SymbolPtr &symScope, const std::string &symName )
|
TypeInfoPtr TypeInfo::getComplexType( SymbolPtr &symScope, const std::string &symName )
|
||||||
{
|
{
|
||||||
ULONG ptrSize = (symScope->getMachineType() == IMAGE_FILE_MACHINE_AMD64) ? 8 : 4;
|
ULONG ptrSize = getTypePointerSize(symScope);
|
||||||
|
|
||||||
boost::cmatch matchResult;
|
boost::cmatch matchResult;
|
||||||
|
|
||||||
@ -540,7 +547,7 @@ TypeInfoPtr TypeInfo::getComplexType( SymbolPtr &symScope, const std::string &sy
|
|||||||
|
|
||||||
std::string innerSymName = std::string( matchResult[2].first, matchResult[2].second );
|
std::string innerSymName = std::string( matchResult[2].first, matchResult[2].second );
|
||||||
|
|
||||||
TypeInfoPtr basePtr = getBaseTypeInfo( innerSymName );
|
TypeInfoPtr basePtr = getBaseTypeInfo( innerSymName, getTypePointerSize(symScope) );
|
||||||
if ( basePtr != 0 )
|
if ( basePtr != 0 )
|
||||||
{
|
{
|
||||||
return getRecurciveComplexType( basePtr, std::string( matchResult[3].first, matchResult[3].second ), ptrSize );
|
return getRecurciveComplexType( basePtr, std::string( matchResult[3].first, matchResult[3].second ), ptrSize );
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
TypeInfoPtr getTypeInfo( SymbolPtr &symbol );
|
TypeInfoPtr getTypeInfo( SymbolPtr &symbol );
|
||||||
|
|
||||||
static
|
static
|
||||||
TypeInfoPtr getBaseTypeInfo( const std::string &name );
|
TypeInfoPtr getBaseTypeInfo( const std::string &name, ULONG pointerSize );
|
||||||
|
|
||||||
static
|
static
|
||||||
TypeInfoPtr getBaseTypeInfo( SymbolPtr &symbol );
|
TypeInfoPtr getBaseTypeInfo( SymbolPtr &symbol );
|
||||||
@ -248,9 +248,11 @@ template<typename T>
|
|||||||
class TypeInfoWrapper : public TypeInfo
|
class TypeInfoWrapper : public TypeInfo
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TypeInfoWrapper( const std::string &name ) :
|
TypeInfoWrapper( const std::string &name, ULONG pointerSize )
|
||||||
m_name(name)
|
: m_name(name)
|
||||||
{}
|
{
|
||||||
|
m_ptrSize = pointerSize;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user