mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 19:13:22 +08:00
[0.2.x] + ptrTo()
git-svn-id: https://pykd.svn.codeplex.com/svn@81363 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
bc1f4ce464
commit
570fe0ead4
@ -133,6 +133,13 @@ TypeInfoPtr PtrToVoid()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TypeInfoPtr PtrTo(TypeInfoPtr type)
|
||||
{
|
||||
return TypeInfoPtr( new PointerTypeInfo(type, ptrSize()) );
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace pykd
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -85,6 +85,10 @@ TypeInfoPtr PtrToVoid();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TypeInfoPtr PtrTo(TypeInfoPtr type);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namespace pykd
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -280,6 +280,8 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
"Create empty union. Use append() method for building" );
|
||||
python::def( "pVoid", &PtrToVoid,
|
||||
"Create \"Void *\" type" );
|
||||
python::def( "ptrTo", &PtrTo,
|
||||
"Create pointer to target type" );
|
||||
|
||||
python::class_<intBase>( "intBase", "intBase", python::no_init )
|
||||
.def( python::init<python::object&>() )
|
||||
|
@ -31,6 +31,16 @@ class TypedVarTest( unittest.TestCase ):
|
||||
self.assertEqual( -4, target.module.typedVar( "g_longValue" ) )
|
||||
self.assertEqual( -8, target.module.typedVar( "g_longlongValue" ) )
|
||||
|
||||
def testPtrTo(self):
|
||||
tv1 = target.module.typedVar( "g_ulonglongValue" )
|
||||
tv2 = pykd.typedVar( pykd.ptrTo(tv1.type()),
|
||||
target.module.offset("g_pUlonglongValue") )
|
||||
self.assertEqual( tv1, tv2.deref() )
|
||||
|
||||
tv3 = pykd.typedVar( pykd.ptrTo( target.module.type("structTest") ).deref(),
|
||||
target.module.offset("g_structTest") )
|
||||
self.assertEqual( 500, tv3.m_field1 )
|
||||
|
||||
def testConst(self):
|
||||
self.assertEqual( True, target.module.typedVar( "g_constBoolValue" ) )
|
||||
self.assertEqual( 0x5555, target.module.typedVar( "g_constNumValue" ) )
|
||||
|
@ -29,6 +29,7 @@ UCHAR g_ucharValue = 1;
|
||||
USHORT g_ushortValue = 2;
|
||||
ULONG g_ulongValue = 4;
|
||||
ULONGLONG g_ulonglongValue = 8;
|
||||
ULONGLONG *g_pUlonglongValue = &g_ulonglongValue;
|
||||
|
||||
CHAR g_charValue = -1;
|
||||
SHORT g_shortValue = -2;
|
||||
@ -391,6 +392,7 @@ void FuncWithName0()
|
||||
std::cout << g_ushortValue;
|
||||
std::cout << g_ulongValue;
|
||||
std::cout << g_ulonglongValue;
|
||||
std::cout << *g_pUlonglongValue;
|
||||
std::cout << g_charValue;
|
||||
std::cout << g_shortValue;
|
||||
std::cout << g_longValue;
|
||||
|
Loading…
Reference in New Issue
Block a user