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 {
|
|
|
|
|
2015-03-30 15:37:57 +08:00
|
|
|
struct TargetSystemAdapter {
|
|
|
|
|
|
|
|
static unsigned long getNumberSystems()
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetSystem::getNumber();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::TargetSystemPtr getCurrent()
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetSystem::getCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::TargetSystemPtr getSystem(unsigned long index)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetSystem::getByIndex(index);
|
|
|
|
}
|
|
|
|
|
2015-04-06 06:17:31 +08:00
|
|
|
static kdlib::TargetSystemPtr getSystemById(kdlib::SYSTEM_DEBUG_ID id)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetSystem::getById(id);
|
|
|
|
}
|
|
|
|
|
2015-03-30 15:37:57 +08:00
|
|
|
static std::wstring getDescription(kdlib::TargetSystem& system)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.getDescription();
|
|
|
|
}
|
|
|
|
|
2015-04-06 06:17:31 +08:00
|
|
|
static kdlib::SYSTEM_DEBUG_ID getId(kdlib::TargetSystem& system)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.getId();
|
|
|
|
}
|
|
|
|
|
2015-03-31 00:42:00 +08:00
|
|
|
static bool isDumpAnalyzing(kdlib::TargetSystem& system)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.isDumpAnalyzing();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool isKernelDebugging(kdlib::TargetSystem& system)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.isKernelDebugging();
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool is64bitSystem(kdlib::TargetSystem& system)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.is64bitSystem();
|
|
|
|
}
|
|
|
|
|
2015-03-30 15:37:57 +08:00
|
|
|
static unsigned long getNumberProcesses(kdlib::TargetSystem& system)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.getNumberProcesses();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::TargetProcessPtr getProcessByIndex(kdlib::TargetSystem& system, unsigned long index)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.getProcessByIndex(index);
|
|
|
|
}
|
|
|
|
|
2015-04-15 04:46:17 +08:00
|
|
|
static kdlib::TargetProcessPtr getProcessById(kdlib::TargetSystem& system, kdlib::PROCESS_DEBUG_ID id)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.getProcessById(id);
|
|
|
|
}
|
|
|
|
|
2015-03-30 15:37:57 +08:00
|
|
|
static kdlib::TargetProcessPtr getCurrentProcess(kdlib::TargetSystem& system)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.getCurrentProcess();
|
|
|
|
}
|
2015-03-31 05:23:11 +08:00
|
|
|
|
|
|
|
static bool isCurrent(kdlib::TargetSystem& system)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return system.isCurrent();
|
|
|
|
}
|
2015-12-16 05:19:54 +08:00
|
|
|
|
|
|
|
static python::list getProcessesList(kdlib::TargetSystem& system);
|
2015-03-30 15:37:57 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-01-20 16:45:25 +08:00
|
|
|
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-04-06 06:17:31 +08:00
|
|
|
static kdlib::TargetProcessPtr getProcessById(kdlib::PROCESS_DEBUG_ID id)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetProcess::getById(id);
|
|
|
|
}
|
|
|
|
|
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-04-06 06:17:31 +08:00
|
|
|
static kdlib::PROCESS_DEBUG_ID getId(kdlib::TargetProcess& process)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getId();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2015-04-15 04:46:17 +08:00
|
|
|
static kdlib::TargetThreadPtr getThreadById(kdlib::TargetProcess& process, kdlib::THREAD_DEBUG_ID id)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getThreadById(id);
|
|
|
|
}
|
|
|
|
|
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-03-31 05:23:11 +08:00
|
|
|
|
|
|
|
static bool isCurrent(kdlib::TargetProcess& process)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.isCurrent();
|
|
|
|
}
|
2015-05-19 05:51:52 +08:00
|
|
|
|
|
|
|
static unsigned long getNumberModules(kdlib::TargetProcess& process)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getNumberModules();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::ModulePtr getModuleByIndex(kdlib::TargetProcess& process, unsigned long index)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return process.getModuleByIndex(index);
|
|
|
|
}
|
2015-12-16 05:19:54 +08:00
|
|
|
|
|
|
|
static python::list getThreadList(kdlib::TargetProcess& process);
|
|
|
|
|
|
|
|
static python::list getBreakpointsList(kdlib::TargetProcess& process);
|
|
|
|
|
|
|
|
static python::list getModulesList(kdlib::TargetProcess& process);
|
2015-01-20 16:45:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct TargetThreadAdapter {
|
|
|
|
|
2015-04-06 06:17:31 +08:00
|
|
|
static unsigned long getNumberThreads()
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetThread::getNumber();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::TargetThreadPtr getCurrent()
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetThread::getCurrent();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::TargetThreadPtr getThread(unsigned long index)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetThread::getByIndex(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::TargetThreadPtr getThreadById(kdlib::THREAD_DEBUG_ID id)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return kdlib::TargetThread::getById(id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::THREAD_DEBUG_ID getId(kdlib::TargetThread& thread)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return thread.getId();
|
|
|
|
}
|
|
|
|
|
2015-01-20 16:45:25 +08:00
|
|
|
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-12-16 05:19:54 +08:00
|
|
|
|
|
|
|
static python::list getStack(kdlib::TargetThread& thread);
|
2015-12-25 06:00:09 +08:00
|
|
|
|
|
|
|
static kdlib::MEMOFFSET_64 getIP(kdlib::TargetThread& thread)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return thread.getInstructionOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::MEMOFFSET_64 getSP(kdlib::TargetThread& thread)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return thread.getStackOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
static kdlib::MEMOFFSET_64 getFP(kdlib::TargetThread& thread)
|
|
|
|
{
|
|
|
|
AutoRestorePyState pystate;
|
|
|
|
return thread.getFrameOffset();
|
|
|
|
}
|
|
|
|
|
2015-01-20 16:45:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // pykd namespace
|
|
|
|
|