From c4a08ee6b0be2980c13d8da584590b5de23ec858 Mon Sep 17 00:00:00 2001 From: "SND\\ussrhero_cp" Date: Tue, 13 Sep 2016 19:22:07 +0000 Subject: [PATCH] [0.3.x] added : typedVar.__call__ method ( run function in the target process ) git-svn-id: https://pykd.svn.codeplex.com/svn@91042 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/pymod.cpp | 2 ++ test/scripts/typedvar.py | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 2ee7b85..463786d 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -919,12 +919,14 @@ BOOST_PYTHON_MODULE( pykd ) "Cast variable to the type and return new typedVar instance") .def("castTo", TypedVarAdapter::castByTypeInfo, "Cast variable to the type and return new typedVar instance") + .def("call", python::raw_function(pykd::callFunctionByVar, 0) ) .def("__getattr__", TypedVarAdapter::getFieldAttr, "Return field of structure as an object attribute" ) .def( "__str__", TypedVarAdapter::print ) .def("__len__", TypedVarAdapter::getElementCount ) .def("__getitem__", TypedVarAdapter::getElementByIndex ) .def("__dir__", TypedVarAdapter::getElementsDir) + .def("__call__", python::raw_function(pykd::callFunctionByVar, 0) ) //.def("__getitem__", &kdlib::TypedVar::getElementByIndexPtr ) #if PY_VERSION_HEX >= 0x03000000 .def("__bool__", TypedVarAdapter::isNotZero) diff --git a/test/scripts/typedvar.py b/test/scripts/typedvar.py index 0406454..e0ccc8d 100644 --- a/test/scripts/typedvar.py +++ b/test/scripts/typedvar.py @@ -380,8 +380,12 @@ class TypedVarTest( unittest.TestCase ): funcptr = target.module.typedVar("CdeclFuncLong"); self.assertEqual( 0xffffff000000 + 5, pykd.callFunctionByPtr( funcptr, target.module.typedVar("ulonglongConst") ) ) + self.assertEqual( 0x7777 + 5, funcptr.call(0x7777) ) + self.assertEqual( 0x11223344556677 + 5, funcptr(0x11223344556677) ); functype = pykd.defineFunction( pykd.baseTypes.Int4B, pykd.callingConvention.NearStd) functype.append("arg1", pykd.baseTypes.Int1B) functype.append("arg2", pykd.baseTypes.Long) self.assertEqual( 500 / 25, pykd.callFunctionByAddr(functype, target.module.offset("StdcallFuncRet"), 25, 500 ) ) + +