mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.3.x] updated : targetProcess and targetThread classes
git-svn-id: https://pykd.svn.codeplex.com/svn@89661 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
26484b85a0
commit
ebdd06f6bd
@ -507,21 +507,27 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
"Return a current process" ).staticmethod("getCurrent")
|
"Return a current process" ).staticmethod("getCurrent")
|
||||||
.def("getProcess", TargetProcessAdapter::getProcess,
|
.def("getProcess", TargetProcessAdapter::getProcess,
|
||||||
"Return process by index").staticmethod("getProcess")
|
"Return process by index").staticmethod("getProcess")
|
||||||
.def("systemID", TargetProcessAdapter::getSystemId,
|
.add_property("systemID", TargetProcessAdapter::getSystemId,
|
||||||
"Retrun system process ID ( PID )" )
|
"Retrun system process ID ( PID )" )
|
||||||
.def("peb", TargetProcessAdapter::getPebOffset,
|
.add_property("peb", TargetProcessAdapter::getPebOffset,
|
||||||
"Return PEB address" )
|
"Return PEB address" )
|
||||||
|
.add_property("exeName", TargetProcessAdapter::getExeName,
|
||||||
|
"Return the process executbakle file name")
|
||||||
.def("getNumberThreads", TargetProcessAdapter::getNumberThreads,
|
.def("getNumberThreads", TargetProcessAdapter::getNumberThreads,
|
||||||
"Return number of threads for this process" )
|
"Return number of threads for this process" )
|
||||||
.def("thread", TargetProcessAdapter::getThreadByIndex,
|
.def("thread", TargetProcessAdapter::getThreadByIndex,
|
||||||
"Return thread by its index" )
|
"Return thread by its index" )
|
||||||
|
.def("currentThread", TargetProcessAdapter::getCurrentThread,
|
||||||
|
"Return current thread" )
|
||||||
;
|
;
|
||||||
|
|
||||||
python::class_<kdlib::TargetThread, kdlib::TargetThreadPtr, boost::noncopyable>("targetThread", "Class representing process in the target system", python::no_init )
|
python::class_<kdlib::TargetThread, kdlib::TargetThreadPtr, boost::noncopyable>("targetThread", "Class representing process in the target system", python::no_init )
|
||||||
.def("systemID", TargetThreadAdapter::getSystemId,
|
.add_property("systemID", TargetThreadAdapter::getSystemId,
|
||||||
"Retrun system thread ID ( TID )" )
|
"Retrun system thread ID ( TID )" )
|
||||||
.def("teb", TargetThreadAdapter::getTebOffset,
|
.add_property("teb", TargetThreadAdapter::getTebOffset,
|
||||||
"Return TEB address" )
|
"Return TEB address" )
|
||||||
|
.def("setCurrent", TargetThreadAdapter::setCurrent,
|
||||||
|
"Set this thread current")
|
||||||
;
|
;
|
||||||
|
|
||||||
python::class_<kdlib::Module, kdlib::ModulePtr, python::bases<kdlib::NumBehavior>, boost::noncopyable>("module", "Class representing executable module", python::no_init )
|
python::class_<kdlib::Module, kdlib::ModulePtr, python::bases<kdlib::NumBehavior>, boost::noncopyable>("module", "Class representing executable module", python::no_init )
|
||||||
|
@ -38,6 +38,12 @@ struct TargetProcessAdapter {
|
|||||||
return process.getPebOffset();
|
return process.getPebOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::wstring getExeName(kdlib::TargetProcess& process)
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return process.getExecutableName();
|
||||||
|
}
|
||||||
|
|
||||||
static unsigned long getNumberThreads(kdlib::TargetProcess& process )
|
static unsigned long getNumberThreads(kdlib::TargetProcess& process )
|
||||||
{
|
{
|
||||||
AutoRestorePyState pystate;
|
AutoRestorePyState pystate;
|
||||||
@ -49,6 +55,12 @@ struct TargetProcessAdapter {
|
|||||||
AutoRestorePyState pystate;
|
AutoRestorePyState pystate;
|
||||||
return process.getThreadByIndex(index);
|
return process.getThreadByIndex(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static kdlib::TargetThreadPtr getCurrentThread(kdlib::TargetProcess& process)
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return process.getCurrentThread();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -65,6 +77,12 @@ struct TargetThreadAdapter {
|
|||||||
AutoRestorePyState pystate;
|
AutoRestorePyState pystate;
|
||||||
return thread.getTebOffset();
|
return thread.getTebOffset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setCurrent(kdlib::TargetThread& thread)
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return thread.setCurrent();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // pykd namespace
|
} // pykd namespace
|
||||||
|
@ -15,8 +15,8 @@ class ProcessTest(unittest.TestCase):
|
|||||||
|
|
||||||
def testGetCurrentProcess(self):
|
def testGetCurrentProcess(self):
|
||||||
proc = pykd.targetProcess.getCurrent()
|
proc = pykd.targetProcess.getCurrent()
|
||||||
self.assertNotEqual(0, proc.systemID() )
|
self.assertNotEqual(0, proc.systemID )
|
||||||
self.assertNotEqual(0, proc.peb() )
|
self.assertNotEqual(0, proc.peb )
|
||||||
|
|
||||||
def testEnumThreads(self):
|
def testEnumThreads(self):
|
||||||
proc = pykd.targetProcess.getCurrent()
|
proc = pykd.targetProcess.getCurrent()
|
||||||
@ -24,15 +24,24 @@ class ProcessTest(unittest.TestCase):
|
|||||||
self.assertLess(0, threadNumber)
|
self.assertLess(0, threadNumber)
|
||||||
for i in xrange(threadNumber):
|
for i in xrange(threadNumber):
|
||||||
thread = proc.thread(i)
|
thread = proc.thread(i)
|
||||||
self.assertNotEqual(0, thread.systemID() )
|
self.assertNotEqual(0, thread.systemID )
|
||||||
self.assertNotEqual(0, thread.teb() )
|
self.assertNotEqual(0, thread.teb )
|
||||||
|
|
||||||
def testEnumProcesses(self):
|
def testEnumProcesses(self):
|
||||||
processNumber = pykd.targetProcess.getNumber()
|
processNumber = pykd.targetProcess.getNumber()
|
||||||
for i in xrange(processNumber):
|
for i in xrange(processNumber):
|
||||||
proc = pykd.targetProcess.getProcess(i)
|
proc = pykd.targetProcess.getProcess(i)
|
||||||
self.assertNotEqual(0, proc.systemID() )
|
self.assertNotEqual(0, proc.systemID)
|
||||||
self.assertNotEqual(0, proc.peb() )
|
self.assertNotEqual(0, proc.peb)
|
||||||
|
|
||||||
|
def testSetCurrentThread(self):
|
||||||
|
proc = pykd.targetProcess.getCurrent()
|
||||||
|
threadNumber = proc.getNumberThreads()
|
||||||
|
self.assertLess(0, threadNumber)
|
||||||
|
for i in xrange(threadNumber):
|
||||||
|
thread = proc.thread(i)
|
||||||
|
thread.setCurrent()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user