diff --git a/pykd/customtypes.cpp b/pykd/customtypes.cpp index 0b1020a..86ebd3a 100644 --- a/pykd/customtypes.cpp +++ b/pykd/customtypes.cpp @@ -133,6 +133,13 @@ TypeInfoPtr PtrToVoid() //////////////////////////////////////////////////////////////////////////////// +TypeInfoPtr PtrTo(TypeInfoPtr type) +{ + return TypeInfoPtr( new PointerTypeInfo(type, ptrSize()) ); +} + +//////////////////////////////////////////////////////////////////////////////// + } // namespace pykd //////////////////////////////////////////////////////////////////////////////// diff --git a/pykd/customtypes.h b/pykd/customtypes.h index 32c0747..b217e9e 100644 --- a/pykd/customtypes.h +++ b/pykd/customtypes.h @@ -85,6 +85,10 @@ TypeInfoPtr PtrToVoid(); //////////////////////////////////////////////////////////////////////////////// +TypeInfoPtr PtrTo(TypeInfoPtr type); + +//////////////////////////////////////////////////////////////////////////////// + } // namespace pykd //////////////////////////////////////////////////////////////////////////////// diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index bc14370..678cc8f 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -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", python::no_init ) .def( python::init() ) diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index 94a5c47..47feaa9 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -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" ) ) diff --git a/test/targetapp/targetapp.cpp b/test/targetapp/targetapp.cpp index 00b0f0d..9af0bcc 100644 --- a/test/targetapp/targetapp.cpp +++ b/test/targetapp/targetapp.cpp @@ -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;