mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 19:13:22 +08:00
83 lines
2.4 KiB
C++
83 lines
2.4 KiB
C++
#include "stdafx.h"
|
|
#include "pysupport.h"
|
|
|
|
#include "dbgengine.h"
|
|
#include "typeinfo.h"
|
|
#include <vector>
|
|
#include <variant.h>
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
namespace pykd {
|
|
namespace pysupport {
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
python::list getProcessThreads()
|
|
{
|
|
std::vector<ULONG64> threads;
|
|
getAllProcessThreads( threads );
|
|
|
|
python::list threadsLst;
|
|
|
|
std::vector<ULONG64>::iterator it;
|
|
for ( it = threads.begin(); it != threads.end(); ++it )
|
|
threadsLst.append( *it );
|
|
|
|
return threadsLst;
|
|
}
|
|
|
|
python::tuple getBugCheckData()
|
|
{
|
|
BUG_CHECK_DATA bugCheckData;
|
|
readBugCheckData(bugCheckData);
|
|
return python::make_tuple(bugCheckData.code, bugCheckData.arg1, bugCheckData.arg2, bugCheckData.arg3, bugCheckData.arg4);
|
|
}
|
|
|
|
python::tuple findSymbolAndDisp( ULONG64 offset )
|
|
{
|
|
std::string symbolName;
|
|
LONG displacement;
|
|
|
|
pykd::TypeInfo::findSymbolAndDisp( offset, symbolName, displacement );
|
|
|
|
return python::make_tuple(symbolName,displacement);
|
|
}
|
|
|
|
python::tuple moduleFindSymbolAndDisp( pykd::Module &module, ULONG64 offset )
|
|
{
|
|
std::string symbolName;
|
|
LONG displacement;
|
|
|
|
module.getSymbolAndDispByVa( offset, symbolName, displacement );
|
|
|
|
return python::make_tuple(symbolName,displacement);
|
|
}
|
|
|
|
std::string printSystemVersion(SystemVersionPtr sysVer)
|
|
{
|
|
std::stringstream sstream;
|
|
if (VER_PLATFORM_WIN32_NT == sysVer->platformId)
|
|
sstream << "WIN32_NT";
|
|
else
|
|
sstream << "Platform ID: " << std::dec << sysVer->platformId;
|
|
sstream << " " << std::dec << sysVer->win32Major << "." << sysVer->win32Minor;
|
|
sstream << ", " << (sysVer->isCheckedBuild ? "checked" : "free") << " build: ";
|
|
sstream << std::dec << sysVer->buildNumber << ", " << sysVer->buildString;
|
|
if (!sysVer->servicePackString.empty())
|
|
sstream << " (" << sysVer->servicePackString << ")";
|
|
|
|
return sstream.str();
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
python::object evaluate( const std::wstring &expression, bool cplusplus )
|
|
{
|
|
BaseTypeVariant var = pykd::evaluate( expression, cplusplus );
|
|
|
|
return boost::apply_visitor( pykd::VariantToPyobj(), var );
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
} } //pykd::support namespace end
|