2015-01-20 16:45:25 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <kdlib/process.h>
|
|
|
|
|
|
|
|
#include "pythreadstate.h"
|
2015-01-23 04:10:08 +08:00
|
|
|
#include "pyeventhandler.h"
|
2015-01-20 16:45:25 +08:00
|
|
|
|
|
|
|
namespace pykd {
|
|
|
|
|
|
|
|
struct TargetProcessAdapter {
|
|
|
|
|
|
|
|
static kdlib::TargetProcessPtr getCurrent()
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetProcess::getCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::TargetProcessPtr getProcess(unsigned long index)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetProcess::getByIndex(index);
|
|
|
|
}
|
|
|
|
|
2015-01-21 05:14:17 +08:00
|
|
|
static unsigned long getNumberProcesses()
|
2015-01-20 16:45:25 +08:00
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetProcess::getNumber();
|
|
|
|
}
|
|
|
|
|
2015-01-21 05:14:17 +08:00
|
|
|
static kdlib::PROCESS_ID getSystemId(kdlib::TargetProcess& process)
|
2015-01-20 16:45:25 +08:00
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getSystemId();
|
|
|
|
}
|
|
|
|
|
2015-01-21 05:14:17 +08:00
|
|
|
static kdlib::MEMOFFSET_64 getPebOffset(kdlib::TargetProcess& process)
|
2015-01-20 16:45:25 +08:00
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getPebOffset();
|
|
|
|
}
|
|
|
|
|
2015-01-21 05:14:17 +08:00
|
|
|
static std::wstring getExeName(kdlib::TargetProcess& process)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getExecutableName();
|
|
|
|
}
|
|
|
|
|
2015-01-20 16:45:25 +08:00
|
|
|
static unsigned long getNumberThreads(kdlib::TargetProcess& process )
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getNumberThreads();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::TargetThreadPtr getThreadByIndex(kdlib::TargetProcess& process, unsigned long index)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getThreadByIndex(index);
|
|
|
|
}
|
2015-01-21 05:14:17 +08:00
|
|
|
|
|
|
|
static kdlib::TargetThreadPtr getCurrentThread(kdlib::TargetProcess& process)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getCurrentThread();
|
|
|
|
}
|
2015-01-22 04:48:46 +08:00
|
|
|
|
|
|
|
static unsigned long getNumberBreakpoints(kdlib::TargetProcess& process)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getNumberBreakpoints();
|
|
|
|
}
|
|
|
|
|
2015-01-23 04:10:08 +08:00
|
|
|
static Breakpoint* getBreakpointByIndex(kdlib::TargetProcess& process, unsigned long index)
|
2015-01-22 04:48:46 +08:00
|
|
|
{
|
2015-01-23 04:10:08 +08:00
|
|
|
kdlib::BreakpointPtr bp;
|
|
|
|
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
bp = process.getBreakpoint(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new Breakpoint(bp);
|
2015-01-22 04:48:46 +08:00
|
|
|
}
|
2015-01-20 16:45:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct TargetThreadAdapter {
|
|
|
|
|
|
|
|
static kdlib::THREAD_ID getSystemId(kdlib::TargetThread& thread )
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return thread.getSystemId();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::MEMOFFSET_64 getTebOffset(kdlib::TargetThread& thread )
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return thread.getTebOffset();
|
|
|
|
}
|
2015-01-21 05:14:17 +08:00
|
|
|
|
|
|
|
static void setCurrent(kdlib::TargetThread& thread)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return thread.setCurrent();
|
|
|
|
}
|
2015-01-22 04:48:46 +08:00
|
|
|
|
|
|
|
static bool isCurrent(kdlib::TargetThread& thread)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return thread.isCurrent();
|
|
|
|
}
|
2015-01-20 16:45:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // pykd namespace
|
|
|
|
|