[0.3.x] added : defineFunction ( "Define custom function prototype" )

git-svn-id: https://pykd.svn.codeplex.com/svn@91037 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\ussrhero_cp 2016-09-13 10:49:39 +00:00 committed by Mikhail I. Izmestev
parent 06239a502a
commit 669df8e55b
4 changed files with 17 additions and 2 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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;

View File

@ -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() )