mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-05-01 21:53:23 +08:00

[0.3.x] added : targetProcess.setCurrent method ( set the process as a current ) [0.3.x] added : targetProcess.getModuleByOffset ( return a module object by it's offset ) [0.3.x] added : targetProcess.getModuleByName ( return a module object by it's name ) git-svn-id: https://pykd.svn.codeplex.com/svn@91021 9b283d60-5439-405e-af05-b73fd8c4d996
144 lines
4.0 KiB
C++
144 lines
4.0 KiB
C++
#include "stdafx.h"
|
|
|
|
#include "pyprocess.h"
|
|
#include "stladaptor.h"
|
|
|
|
namespace pykd {
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
python::list TargetSystemAdapter::getProcessesList(kdlib::TargetSystem& system)
|
|
{
|
|
std::vector<kdlib::TargetProcessPtr> processLst;
|
|
|
|
do {
|
|
AutoRestorePyState pystate;
|
|
for ( unsigned long i = 0; i < system.getNumberProcesses(); ++i)
|
|
processLst.push_back(system.getProcessByIndex(i));
|
|
} while(false);
|
|
|
|
return vectorToList(processLst);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
std::wstring TargetSystemAdapter::print(kdlib::TargetSystem& system)
|
|
{
|
|
std::wstringstream sstr;
|
|
|
|
sstr << "Target System:" << std::endl;
|
|
sstr << system.getDescription() << std::endl;
|
|
|
|
return sstr.str();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
python::list TargetProcessAdapter::getThreadList(kdlib::TargetProcess& process)
|
|
{
|
|
std::vector<kdlib::TargetThreadPtr> threadLst;
|
|
|
|
do {
|
|
AutoRestorePyState pystate;
|
|
for ( unsigned long i = 0; i < process.getNumberThreads(); ++i)
|
|
threadLst.push_back(process.getThreadByIndex(i));
|
|
} while(false);
|
|
|
|
return vectorToList(threadLst);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
python::list TargetProcessAdapter::getBreakpointsList(kdlib::TargetProcess& process)
|
|
{
|
|
std::vector<pykd::Breakpoint*> bpLst;
|
|
|
|
do {
|
|
AutoRestorePyState pystate;
|
|
for ( unsigned long i = 0; i < process.getNumberBreakpoints(); ++i)
|
|
bpLst.push_back(new Breakpoint(process.getBreakpoint(i)));
|
|
} while(false);
|
|
|
|
return vectorToList(bpLst);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
python::list TargetProcessAdapter::getModulesList(kdlib::TargetProcess& process)
|
|
{
|
|
std::vector<kdlib::ModulePtr > moduleLst;
|
|
|
|
do {
|
|
AutoRestorePyState pystate;
|
|
for ( unsigned long i = 0; i < process.getNumberModules(); ++i)
|
|
moduleLst.push_back(process.getModuleByIndex(i));
|
|
} while(false);
|
|
|
|
return vectorToList(moduleLst);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
std::wstring TargetProcessAdapter::print(kdlib::TargetProcess& process)
|
|
{
|
|
std::wstringstream sstr;
|
|
|
|
|
|
if ( !process.isKernelDebugging() )
|
|
{
|
|
sstr << "Target Process:" << std::endl;
|
|
sstr << "PID: " << std::hex << process.getSystemId() << std::endl;
|
|
sstr << "Name: " << process.getExecutableName() << std::endl;
|
|
}
|
|
else
|
|
{
|
|
sstr << "Kernel virtual process:" << std::endl;
|
|
sstr << "Name: " << process.getExecutableName() << std::endl;
|
|
}
|
|
|
|
return sstr.str();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
python::list TargetThreadAdapter::getStack(kdlib::TargetThread& thread)
|
|
{
|
|
|
|
std::vector<kdlib::StackFramePtr > frameLst;
|
|
|
|
do {
|
|
AutoRestorePyState pystate;
|
|
kdlib::StackPtr stack = thread.getStack();
|
|
|
|
for (unsigned long i = 0; i < stack->getFrameCount(); ++i)
|
|
frameLst.push_back(stack->getFrame(i));
|
|
} while(false);
|
|
|
|
return vectorToList(frameLst);
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
std::wstring TargetThreadAdapter::print(kdlib::TargetThread& thread)
|
|
{
|
|
std::wstringstream sstr;
|
|
|
|
if ( !thread.isKernelDebugging() )
|
|
{
|
|
sstr << "Target Thread:" << std::endl;
|
|
sstr << "PID: " << std::hex << thread.getProcess()->getSystemId() << std::endl;
|
|
sstr << "TID: " << std::hex << thread.getSystemId() << std::endl;
|
|
}
|
|
else
|
|
{
|
|
sstr << "Kernel virtual thread" << std::endl;
|
|
}
|
|
|
|
return sstr.str();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
}
|
|
|