[0.3.x] added : typedVar.getLocation method ( Return location of the varibale )

git-svn-id: https://pykd.svn.codeplex.com/svn@90929 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\ussrhero_cp 2016-02-22 20:17:56 +00:00 committed by Mikhail I. Izmestev
parent 7497fed621
commit 84bf4b8bfd
4 changed files with 53 additions and 23 deletions

View File

@ -2,7 +2,7 @@
#define PYKD_VERSION_MAJOR 0 #define PYKD_VERSION_MAJOR 0
#define PYKD_VERSION_MINOR 3 #define PYKD_VERSION_MINOR 3
#define PYKD_VERSION_SUBVERSION 0 #define PYKD_VERSION_SUBVERSION 0
#define PYKD_VERSION_BUILDNO 37 #define PYKD_VERSION_BUILDNO 38
#define __VER_STR2__(x) #x #define __VER_STR2__(x) #x
#define __VER_STR1__(x) __VER_STR2__(x) #define __VER_STR1__(x) __VER_STR2__(x)

View File

@ -781,6 +781,8 @@ BOOST_PYTHON_MODULE( pykd )
.def("__init__", python::make_constructor(pykd::getTypedVarByName) ) .def("__init__", python::make_constructor(pykd::getTypedVarByName) )
.def("__init__", python::make_constructor(pykd::getTypedVarByTypeName) ) .def("__init__", python::make_constructor(pykd::getTypedVarByTypeName) )
.def("__init__", python::make_constructor(pykd::getTypedVarByTypeInfo) ) .def("__init__", python::make_constructor(pykd::getTypedVarByTypeInfo) )
.def("getLocation", TypedVarAdapter::getLocation,
"Return location of the varibale")
.def("getAddress", TypedVarAdapter::getAddress, .def("getAddress", TypedVarAdapter::getAddress,
"Return virtual address" ) "Return virtual address" )
.def("getDebugStart", TypedVarAdapter::getDebugStart, .def("getDebugStart", TypedVarAdapter::getDebugStart,
@ -1054,6 +1056,11 @@ BOOST_PYTHON_MODULE( pykd )
.value("AMD64", kdlib::CPU_AMD64 ) .value("AMD64", kdlib::CPU_AMD64 )
; ;
python::enum_<kdlib::VarStorage>("Location", "Location of a varibale")
.value("Reg", kdlib::RegisterVar)
.value("Memory", kdlib::MemoryVar)
;
python::enum_<kdlib::MemoryProtect>("memoryProtect", "Memory protection attribiuties") python::enum_<kdlib::MemoryProtect>("memoryProtect", "Memory protection attribiuties")
.value("PageNoAccess", kdlib::PageNoAccess) .value("PageNoAccess", kdlib::PageNoAccess)
.value("PageReadOnly", kdlib::PageReadOnly) .value("PageReadOnly", kdlib::PageReadOnly)

View File

@ -50,6 +50,26 @@ inline kdlib::TypedVarPtr containingRecordByType( kdlib::MEMOFFSET_64 offset, kd
struct TypedVarAdapter { struct TypedVarAdapter {
static python::tuple getLocation(kdlib::TypedVar& typedVar)
{
kdlib::VarStorage storage;
std::wstring regName;
kdlib::MEMOFFSET_64 memOffset;
{
AutoRestorePyState pystate;
storage = typedVar.getStorage();
if (storage == kdlib::RegisterVar)
regName = typedVar.getRegisterName();
else
memOffset = typedVar.getAddress();
}
if (storage == kdlib::RegisterVar)
return python::make_tuple(storage, regName);
return python::make_tuple(storage, memOffset);
}
static kdlib::MEMOFFSET_64 getAddress( kdlib::TypedVar& typedVar ) static kdlib::MEMOFFSET_64 getAddress( kdlib::TypedVar& typedVar )
{ {
AutoRestorePyState pystate; AutoRestorePyState pystate;

View File

@ -1,4 +1,4 @@
# #
# #
# #
@ -344,3 +344,6 @@ class TypedVarTest( unittest.TestCase ):
int, int,
pykd.typedVar(pykd.baseTypes.UInt4B, 0xFFFFFFFFFFFFFFFF)) pykd.typedVar(pykd.baseTypes.UInt4B, 0xFFFFFFFFFFFFFFFF))
def testLocation(self):
tv = target.module.typedVar( "structTest", target.module.g_structTest )
self.assertEqual( ( pykd.Location.Memory, tv.getAddress()), tv.getLocation() )