diff --git a/pykd/pykdver.h b/pykd/pykdver.h index 4ceaba0..456d770 100644 --- a/pykd/pykdver.h +++ b/pykd/pykdver.h @@ -2,7 +2,7 @@ #define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MINOR 3 #define PYKD_VERSION_SUBVERSION 1 -#define PYKD_VERSION_BUILDNO 6 +#define PYKD_VERSION_BUILDNO 7 #define __VER_STR2__(x) #x #define __VER_STR1__(x) __VER_STR2__(x) diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index d2c16aa..f6a442e 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -89,6 +89,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS( getThreadIdBySystemId_, pykd::getThreadIdBySyst BOOST_PYTHON_FUNCTION_OVERLOADS( createStruct_, pykd::defineStruct, 1, 2 ); BOOST_PYTHON_FUNCTION_OVERLOADS( createUnion_, pykd::defineUnion, 1, 2 ); +BOOST_PYTHON_FUNCTION_OVERLOADS( defineFunction_, pykd::defineFunction, 1, 2 ); BOOST_PYTHON_FUNCTION_OVERLOADS( setSoftwareBreakpoint_, Breakpoint::setSoftwareBreakpoint, 1, 2 ); BOOST_PYTHON_FUNCTION_OVERLOADS( setHardwareBreakpoint_, Breakpoint::setHardwareBreakpoint, 3, 4 ); @@ -405,6 +406,8 @@ BOOST_PYTHON_MODULE( pykd ) "Create custom struct" ) ); python::def( "createUnion", &pykd::defineUnion, createUnion_( python::args( "name", "align" ), "Create custom union" ) ); + python::def( "defineFunction", &pykd::defineFunction, defineFunction_( python::args("returnType", "callconv"), + "Define custom function prototype" ) ); // CPU registers python::def( "reg", pykd::getRegisterByName, diff --git a/pykd/pytypeinfo.h b/pykd/pytypeinfo.h index 1bf8de6..c388399 100644 --- a/pykd/pytypeinfo.h +++ b/pykd/pytypeinfo.h @@ -38,6 +38,12 @@ inline kdlib::TypeInfoPtr defineUnion( const std::wstring& unionName, size_t ali } +inline kdlib::TypeInfoPtr defineFunction( const kdlib::TypeInfoPtr& returnType, kdlib::CallingConventionType callconv = kdlib::CallConv_NearC) +{ + AutoRestorePyState pystate; + return kdlib::defineFunction(returnType, callconv); +} + inline kdlib::TypeInfoPtr getTypeInfoByName( const std::wstring &name ) { AutoRestorePyState pystate; diff --git a/test/scripts/customtypestest.py b/test/scripts/customtypestest.py index 99b1b4f..f9b1302 100644 --- a/test/scripts/customtypestest.py +++ b/test/scripts/customtypestest.py @@ -1,4 +1,4 @@ -"""Custom types tests""" +"""Custom types tests""" import unittest import target @@ -137,3 +137,9 @@ class CustomTypesTest(unittest.TestCase): struct.append( "field2", baseTypes.UInt1B ) self.assertEqual( struct.size(), 8 ) self.assertEqual( struct.fieldOffset("field2"), 4 ) + + def testCustomFunction(self): + functype = pykd.defineFunction( baseTypes.UInt4B ) + functype.append( "var1", baseTypes.WChar) + functype.append( "var2", baseTypes.UInt4B.ptrTo() ) + self.assertEqual( "UInt4B(__cdecl)(WChar, UInt4B*)", functype.name() )