mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.2.x] began work at the new version
git-svn-id: https://pykd.svn.codeplex.com/svn@78304 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
487b4a8f6d
commit
73478dc355
21
pykd/dbgengine.h
Normal file
21
pykd/dbgengine.h
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
// manage debug target
|
||||||
|
ULONG startProcess( const std::wstring &processName );
|
||||||
|
void detachProcess( ULONG processId = -1);
|
||||||
|
void terminateProcess( ULONG processId = -1);
|
||||||
|
|
||||||
|
void debugGo();
|
||||||
|
|
||||||
|
//manage debug module
|
||||||
|
ULONG64 findModuleBase( const std::string &moduleName );
|
||||||
|
ULONG64 findModuleBase( ULONG64 offset );
|
||||||
|
std::string getModuleName( ULONG64 baseOffset );
|
||||||
|
|
||||||
|
//manage access to target memory
|
||||||
|
ULONG64 addr64( ULONG64 offset );
|
||||||
|
|
||||||
|
};
|
||||||
|
|
449
pykd/dbgext.cpp
449
pykd/dbgext.cpp
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <boost/tokenizer.hpp>
|
//#include <boost/tokenizer.hpp>
|
||||||
|
//
|
||||||
|
//#include "windbg.h"
|
||||||
|
//#include "dbgclient.h"
|
||||||
|
//#include "dbgpath.h"
|
||||||
|
|
||||||
#include "windbg.h"
|
//using namespace pykd;
|
||||||
#include "dbgclient.h"
|
|
||||||
#include "dbgpath.h"
|
|
||||||
|
|
||||||
using namespace pykd;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -32,46 +32,6 @@ BOOL WINAPI DllMain(
|
|||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
extern "C" void initpykd();
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
WindbgGlobalSession::WindbgGlobalSession() {
|
|
||||||
|
|
||||||
PyImport_AppendInittab("pykd", initpykd );
|
|
||||||
|
|
||||||
PyEval_InitThreads();
|
|
||||||
|
|
||||||
Py_Initialize();
|
|
||||||
|
|
||||||
main = boost::python::import("__main__");
|
|
||||||
|
|
||||||
python::object main_namespace = main.attr("__dict__");
|
|
||||||
|
|
||||||
// äåëàåì àíàëîã from pykd import *
|
|
||||||
python::object pykd = boost::python::import( "pykd" );
|
|
||||||
|
|
||||||
python::dict pykd_namespace( pykd.attr("__dict__") );
|
|
||||||
|
|
||||||
python::list iterkeys( pykd_namespace.iterkeys() );
|
|
||||||
|
|
||||||
for (int i = 0; i < boost::python::len(iterkeys); i++)
|
|
||||||
{
|
|
||||||
std::string key = boost::python::extract<std::string>(iterkeys[i]);
|
|
||||||
|
|
||||||
main_namespace[ key ] = pykd_namespace[ key ];
|
|
||||||
}
|
|
||||||
|
|
||||||
pyState = PyEval_SaveThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
volatile LONG WindbgGlobalSession::sessionCount = 0;
|
|
||||||
|
|
||||||
WindbgGlobalSession *WindbgGlobalSession::windbgGlobalSession = NULL;
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
HRESULT
|
HRESULT
|
||||||
CALLBACK
|
CALLBACK
|
||||||
DebugExtensionInitialize(
|
DebugExtensionInitialize(
|
||||||
@ -81,7 +41,7 @@ DebugExtensionInitialize(
|
|||||||
*Version = DEBUG_EXTENSION_VERSION( 1, 0 );
|
*Version = DEBUG_EXTENSION_VERSION( 1, 0 );
|
||||||
*Flags = 0;
|
*Flags = 0;
|
||||||
|
|
||||||
WindbgGlobalSession::StartWindbgSession();
|
// WindbgGlobalSession::StartWindbgSession();
|
||||||
|
|
||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
@ -92,7 +52,7 @@ VOID
|
|||||||
CALLBACK
|
CALLBACK
|
||||||
DebugExtensionUninitialize()
|
DebugExtensionUninitialize()
|
||||||
{
|
{
|
||||||
WindbgGlobalSession::StopWindbgSession();
|
// WindbgGlobalSession::StopWindbgSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -101,113 +61,7 @@ HRESULT
|
|||||||
CALLBACK
|
CALLBACK
|
||||||
py( PDEBUG_CLIENT4 client, PCSTR args )
|
py( PDEBUG_CLIENT4 client, PCSTR args )
|
||||||
{
|
{
|
||||||
DebugClientPtr dbgClient = DebugClient::createDbgClient( client );
|
return S_OK;
|
||||||
DebugClientPtr oldClient = DebugClient::setDbgClientCurrent( dbgClient );
|
|
||||||
|
|
||||||
WindbgGlobalSession::RestorePyState();
|
|
||||||
|
|
||||||
PyThreadState *globalInterpreter = PyThreadState_Swap( NULL );
|
|
||||||
PyThreadState *localInterpreter = Py_NewInterpreter();
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
// ïîëó÷àåì äîñòïó ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
|
||||||
python::object main = python::import("__main__");
|
|
||||||
|
|
||||||
python::object global(main.attr("__dict__"));
|
|
||||||
|
|
||||||
// íàñòðàèâàåì ââîä/âûâîä ( ÷òîáû â ñêðèïòå ìîæíî áûëî ïèñàòü print )
|
|
||||||
|
|
||||||
python::object sys = python::import("sys");
|
|
||||||
|
|
||||||
sys.attr("stdout") = python::object( dbgClient->dout() );
|
|
||||||
sys.attr("stderr") = python::object( dbgClient->dout() );
|
|
||||||
sys.attr("stdin") = python::object( dbgClient->din() );
|
|
||||||
|
|
||||||
// èìïîðòèðóåì ìîäóëü îáðàáîòêè èñêëþ÷åíèé ( íóæåí äëÿ âûâîäà traceback à )
|
|
||||||
python::object tracebackModule = python::import("traceback");
|
|
||||||
|
|
||||||
// ðàçáîð ïàðàìåòðîâ
|
|
||||||
typedef boost::escaped_list_separator<char> char_separator_t;
|
|
||||||
typedef boost::tokenizer< char_separator_t > char_tokenizer_t;
|
|
||||||
|
|
||||||
std::string argsStr( args );
|
|
||||||
|
|
||||||
char_tokenizer_t token( argsStr , char_separator_t( "", " \t", "\"" ) );
|
|
||||||
std::vector<std::string> argsList;
|
|
||||||
|
|
||||||
for ( char_tokenizer_t::iterator it = token.begin(); it != token.end(); ++it )
|
|
||||||
{
|
|
||||||
if ( *it != "" )
|
|
||||||
argsList.push_back( *it );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( argsList.size() == 0 )
|
|
||||||
return S_OK;
|
|
||||||
|
|
||||||
char **pythonArgs = new char* [ argsList.size() ];
|
|
||||||
|
|
||||||
for ( size_t i = 0; i < argsList.size(); ++i )
|
|
||||||
pythonArgs[i] = const_cast<char*>( argsList[i].c_str() );
|
|
||||||
|
|
||||||
PySys_SetArgv( (int)argsList.size(), pythonArgs );
|
|
||||||
|
|
||||||
delete[] pythonArgs;
|
|
||||||
|
|
||||||
// íàéòè ïóòü ê ôàéëó
|
|
||||||
std::string fullScriptName;
|
|
||||||
DbgPythonPath dbgPythonPath;
|
|
||||||
|
|
||||||
if ( !dbgPythonPath.getFullFileName( argsList[0], fullScriptName ) )
|
|
||||||
{
|
|
||||||
dbgClient->eprintln( L"script file not found" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
try {
|
|
||||||
|
|
||||||
python::object result;
|
|
||||||
|
|
||||||
result = python::exec_file( fullScriptName.c_str(), global, global );
|
|
||||||
}
|
|
||||||
catch( boost::python::error_already_set const & )
|
|
||||||
{
|
|
||||||
// îøèáêà â ñêðèïòå
|
|
||||||
PyObject *errtype = NULL, *errvalue = NULL, *traceback = NULL;
|
|
||||||
|
|
||||||
PyErr_Fetch( &errtype, &errvalue, &traceback );
|
|
||||||
|
|
||||||
PyErr_NormalizeException( &errtype, &errvalue, &traceback );
|
|
||||||
|
|
||||||
std::wstringstream sstr;
|
|
||||||
|
|
||||||
python::object lst =
|
|
||||||
python::object( tracebackModule.attr("format_exception" ) )(
|
|
||||||
python::handle<>( errtype ),
|
|
||||||
python::handle<>( python::allow_null( errvalue ) ),
|
|
||||||
python::handle<>( python::allow_null( traceback ) ) );
|
|
||||||
|
|
||||||
sstr << std::endl << std::endl;
|
|
||||||
|
|
||||||
for ( long i = 0; i < python::len(lst); ++i )
|
|
||||||
sstr << std::wstring( python::extract<std::wstring>(lst[i]) ) << std::endl;
|
|
||||||
|
|
||||||
dbgClient->eprintln( sstr.str() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
dbgClient->eprintln( L"unexpected error" );
|
|
||||||
}
|
|
||||||
|
|
||||||
Py_EndInterpreter( localInterpreter );
|
|
||||||
PyThreadState_Swap( globalInterpreter );
|
|
||||||
|
|
||||||
WindbgGlobalSession::SavePyState();
|
|
||||||
|
|
||||||
DebugClient::setDbgClientCurrent( oldClient );
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -216,49 +70,248 @@ HRESULT
|
|||||||
CALLBACK
|
CALLBACK
|
||||||
pycmd( PDEBUG_CLIENT4 client, PCSTR args )
|
pycmd( PDEBUG_CLIENT4 client, PCSTR args )
|
||||||
{
|
{
|
||||||
if ( g_dbgClient->client() != client )
|
return S_OK;
|
||||||
{
|
|
||||||
DebugClientPtr dbgClient = DebugClient::createDbgClient( client );
|
|
||||||
DebugClient::setDbgClientCurrent( dbgClient );
|
|
||||||
}
|
|
||||||
|
|
||||||
WindbgGlobalSession::RestorePyState();
|
|
||||||
|
|
||||||
ULONG mask = 0;
|
|
||||||
client->GetOutputMask( &mask );
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
// ïåðåíàïðàâëåíèå ñòàíäàðòíûõ ïîòîêîâ ÂÂ
|
|
||||||
python::object sys = python::import("sys");
|
|
||||||
|
|
||||||
sys.attr("stdout") = python::object( DbgOut( client ) );
|
|
||||||
sys.attr("stderr") = python::object( DbgOut( client ) );
|
|
||||||
sys.attr("stdin") = python::object( DbgIn( client ) );
|
|
||||||
|
|
||||||
client->SetOutputMask( DEBUG_OUTPUT_NORMAL );
|
|
||||||
|
|
||||||
PyRun_String(
|
|
||||||
"__import__('code').InteractiveConsole(__import__('__main__').__dict__).interact()",
|
|
||||||
Py_file_input,
|
|
||||||
WindbgGlobalSession::global().ptr(),
|
|
||||||
WindbgGlobalSession::global().ptr()
|
|
||||||
);
|
|
||||||
|
|
||||||
// âûõîä èç èíòåðïðåòàòîðà ïðîèñõîäèò ÷åðåç èñêëþ÷åíèå raise SystemExit(code)
|
|
||||||
// êîòîðîå ïîòîì ìîæåò ïîìåøàòü èñïîëíåíèþ callback îâ
|
|
||||||
PyErr_Clear();
|
|
||||||
}
|
|
||||||
catch(...)
|
|
||||||
{
|
|
||||||
//dbgClient->eprintln( L"unexpected error" );
|
|
||||||
}
|
|
||||||
|
|
||||||
client->SetOutputMask( mask );
|
|
||||||
|
|
||||||
WindbgGlobalSession::SavePyState();
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//extern "C" void initpykd();
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//WindbgGlobalSession::WindbgGlobalSession() {
|
||||||
|
//
|
||||||
|
// PyImport_AppendInittab("pykd", initpykd );
|
||||||
|
//
|
||||||
|
// PyEval_InitThreads();
|
||||||
|
//
|
||||||
|
// Py_Initialize();
|
||||||
|
//
|
||||||
|
// main = boost::python::import("__main__");
|
||||||
|
//
|
||||||
|
// python::object main_namespace = main.attr("__dict__");
|
||||||
|
//
|
||||||
|
// // äåëàåì àíàëîã from pykd import *
|
||||||
|
// python::object pykd = boost::python::import( "pykd" );
|
||||||
|
//
|
||||||
|
// python::dict pykd_namespace( pykd.attr("__dict__") );
|
||||||
|
//
|
||||||
|
// python::list iterkeys( pykd_namespace.iterkeys() );
|
||||||
|
//
|
||||||
|
// for (int i = 0; i < boost::python::len(iterkeys); i++)
|
||||||
|
// {
|
||||||
|
// std::string key = boost::python::extract<std::string>(iterkeys[i]);
|
||||||
|
//
|
||||||
|
// main_namespace[ key ] = pykd_namespace[ key ];
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// pyState = PyEval_SaveThread();
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//volatile LONG WindbgGlobalSession::sessionCount = 0;
|
||||||
|
//
|
||||||
|
//WindbgGlobalSession *WindbgGlobalSession::windbgGlobalSession = NULL;
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//HRESULT
|
||||||
|
//CALLBACK
|
||||||
|
//DebugExtensionInitialize(
|
||||||
|
// OUT PULONG Version,
|
||||||
|
// OUT PULONG Flags )
|
||||||
|
//{
|
||||||
|
// *Version = DEBUG_EXTENSION_VERSION( 1, 0 );
|
||||||
|
// *Flags = 0;
|
||||||
|
//
|
||||||
|
// WindbgGlobalSession::StartWindbgSession();
|
||||||
|
//
|
||||||
|
// return S_OK;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//VOID
|
||||||
|
//CALLBACK
|
||||||
|
//DebugExtensionUninitialize()
|
||||||
|
//{
|
||||||
|
// WindbgGlobalSession::StopWindbgSession();
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//HRESULT
|
||||||
|
//CALLBACK
|
||||||
|
//py( PDEBUG_CLIENT4 client, PCSTR args )
|
||||||
|
//{
|
||||||
|
// DebugClientPtr dbgClient = DebugClient::createDbgClient( client );
|
||||||
|
// DebugClientPtr oldClient = DebugClient::setDbgClientCurrent( dbgClient );
|
||||||
|
//
|
||||||
|
// WindbgGlobalSession::RestorePyState();
|
||||||
|
//
|
||||||
|
// PyThreadState *globalInterpreter = PyThreadState_Swap( NULL );
|
||||||
|
// PyThreadState *localInterpreter = Py_NewInterpreter();
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// // ïîëó÷àåì äîñòïó ê ãëîáàëüíîìó ìàïó ( íóæåí äëÿ âûçîâà exec_file )
|
||||||
|
// python::object main = python::import("__main__");
|
||||||
|
//
|
||||||
|
// python::object global(main.attr("__dict__"));
|
||||||
|
//
|
||||||
|
// // íàñòðàèâàåì ââîä/âûâîä ( ÷òîáû â ñêðèïòå ìîæíî áûëî ïèñàòü print )
|
||||||
|
//
|
||||||
|
// python::object sys = python::import("sys");
|
||||||
|
//
|
||||||
|
// sys.attr("stdout") = python::object( dbgClient->dout() );
|
||||||
|
// sys.attr("stderr") = python::object( dbgClient->dout() );
|
||||||
|
// sys.attr("stdin") = python::object( dbgClient->din() );
|
||||||
|
//
|
||||||
|
// // èìïîðòèðóåì ìîäóëü îáðàáîòêè èñêëþ÷åíèé ( íóæåí äëÿ âûâîäà traceback à )
|
||||||
|
// python::object tracebackModule = python::import("traceback");
|
||||||
|
//
|
||||||
|
// // ðàçáîð ïàðàìåòðîâ
|
||||||
|
// typedef boost::escaped_list_separator<char> char_separator_t;
|
||||||
|
// typedef boost::tokenizer< char_separator_t > char_tokenizer_t;
|
||||||
|
//
|
||||||
|
// std::string argsStr( args );
|
||||||
|
//
|
||||||
|
// char_tokenizer_t token( argsStr , char_separator_t( "", " \t", "\"" ) );
|
||||||
|
// std::vector<std::string> argsList;
|
||||||
|
//
|
||||||
|
// for ( char_tokenizer_t::iterator it = token.begin(); it != token.end(); ++it )
|
||||||
|
// {
|
||||||
|
// if ( *it != "" )
|
||||||
|
// argsList.push_back( *it );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if ( argsList.size() == 0 )
|
||||||
|
// return S_OK;
|
||||||
|
//
|
||||||
|
// char **pythonArgs = new char* [ argsList.size() ];
|
||||||
|
//
|
||||||
|
// for ( size_t i = 0; i < argsList.size(); ++i )
|
||||||
|
// pythonArgs[i] = const_cast<char*>( argsList[i].c_str() );
|
||||||
|
//
|
||||||
|
// PySys_SetArgv( (int)argsList.size(), pythonArgs );
|
||||||
|
//
|
||||||
|
// delete[] pythonArgs;
|
||||||
|
//
|
||||||
|
// // íàéòè ïóòü ê ôàéëó
|
||||||
|
// std::string fullScriptName;
|
||||||
|
// DbgPythonPath dbgPythonPath;
|
||||||
|
//
|
||||||
|
// if ( !dbgPythonPath.getFullFileName( argsList[0], fullScriptName ) )
|
||||||
|
// {
|
||||||
|
// dbgClient->eprintln( L"script file not found" );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// python::object result;
|
||||||
|
//
|
||||||
|
// result = python::exec_file( fullScriptName.c_str(), global, global );
|
||||||
|
// }
|
||||||
|
// catch( boost::python::error_already_set const & )
|
||||||
|
// {
|
||||||
|
// // îøèáêà â ñêðèïòå
|
||||||
|
// PyObject *errtype = NULL, *errvalue = NULL, *traceback = NULL;
|
||||||
|
//
|
||||||
|
// PyErr_Fetch( &errtype, &errvalue, &traceback );
|
||||||
|
//
|
||||||
|
// PyErr_NormalizeException( &errtype, &errvalue, &traceback );
|
||||||
|
//
|
||||||
|
// std::wstringstream sstr;
|
||||||
|
//
|
||||||
|
// python::object lst =
|
||||||
|
// python::object( tracebackModule.attr("format_exception" ) )(
|
||||||
|
// python::handle<>( errtype ),
|
||||||
|
// python::handle<>( python::allow_null( errvalue ) ),
|
||||||
|
// python::handle<>( python::allow_null( traceback ) ) );
|
||||||
|
//
|
||||||
|
// sstr << std::endl << std::endl;
|
||||||
|
//
|
||||||
|
// for ( long i = 0; i < python::len(lst); ++i )
|
||||||
|
// sstr << std::wstring( python::extract<std::wstring>(lst[i]) ) << std::endl;
|
||||||
|
//
|
||||||
|
// dbgClient->eprintln( sstr.str() );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// catch(...)
|
||||||
|
// {
|
||||||
|
// dbgClient->eprintln( L"unexpected error" );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Py_EndInterpreter( localInterpreter );
|
||||||
|
// PyThreadState_Swap( globalInterpreter );
|
||||||
|
//
|
||||||
|
// WindbgGlobalSession::SavePyState();
|
||||||
|
//
|
||||||
|
// DebugClient::setDbgClientCurrent( oldClient );
|
||||||
|
//
|
||||||
|
// return S_OK;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//HRESULT
|
||||||
|
//CALLBACK
|
||||||
|
//pycmd( PDEBUG_CLIENT4 client, PCSTR args )
|
||||||
|
//{
|
||||||
|
// if ( g_dbgClient->client() != client )
|
||||||
|
// {
|
||||||
|
// DebugClientPtr dbgClient = DebugClient::createDbgClient( client );
|
||||||
|
// DebugClient::setDbgClientCurrent( dbgClient );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// WindbgGlobalSession::RestorePyState();
|
||||||
|
//
|
||||||
|
// ULONG mask = 0;
|
||||||
|
// client->GetOutputMask( &mask );
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// // ïåðåíàïðàâëåíèå ñòàíäàðòíûõ ïîòîêîâ ÂÂ
|
||||||
|
// python::object sys = python::import("sys");
|
||||||
|
//
|
||||||
|
// sys.attr("stdout") = python::object( DbgOut( client ) );
|
||||||
|
// sys.attr("stderr") = python::object( DbgOut( client ) );
|
||||||
|
// sys.attr("stdin") = python::object( DbgIn( client ) );
|
||||||
|
//
|
||||||
|
// client->SetOutputMask( DEBUG_OUTPUT_NORMAL );
|
||||||
|
//
|
||||||
|
// PyRun_String(
|
||||||
|
// "__import__('code').InteractiveConsole(__import__('__main__').__dict__).interact()",
|
||||||
|
// Py_file_input,
|
||||||
|
// WindbgGlobalSession::global().ptr(),
|
||||||
|
// WindbgGlobalSession::global().ptr()
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// // âûõîä èç èíòåðïðåòàòîðà ïðîèñõîäèò ÷åðåç èñêëþ÷åíèå raise SystemExit(code)
|
||||||
|
// // êîòîðîå ïîòîì ìîæåò ïîìåøàòü èñïîëíåíèþ callback îâ
|
||||||
|
// PyErr_Clear();
|
||||||
|
// }
|
||||||
|
// catch(...)
|
||||||
|
// {
|
||||||
|
// //dbgClient->eprintln( L"unexpected error" );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// client->SetOutputMask( mask );
|
||||||
|
//
|
||||||
|
// WindbgGlobalSession::SavePyState();
|
||||||
|
//
|
||||||
|
// return S_OK;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////
|
||||||
|
835
pykd/module.cpp
835
pykd/module.cpp
@ -1,423 +1,462 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "dbgengine.h"
|
||||||
#include "module.h"
|
#include "module.h"
|
||||||
#include "dbgclient.h"
|
|
||||||
#include "dbgmem.h"
|
|
||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
ModulePtr Module::loadModuleByName( const std::string &moduleName ) {
|
ModulePtr Module::loadModuleByName( const std::string &moduleName ) {
|
||||||
return g_dbgClient->loadModuleByName( moduleName );
|
return ModulePtr( new Module( moduleName ) );
|
||||||
};
|
};
|
||||||
|
|
||||||
ModulePtr Module::loadModuleByOffset( ULONG64 offset ) {
|
ModulePtr Module::loadModuleByOffset( ULONG64 offset ) {
|
||||||
return g_dbgClient->loadModuleByOffset( offset );
|
return ModulePtr( new Module( offset ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Module::Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, const std::string& moduleName )
|
Module::Module(const std::string &moduleName )
|
||||||
: DbgObject( client )
|
|
||||||
, m_synSymbols(synSymbols)
|
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
m_base = findModuleBase( moduleName );
|
||||||
|
|
||||||
m_name = moduleName;
|
m_name = moduleName;
|
||||||
|
|
||||||
hres = m_symbols->GetModuleByModuleName( moduleName.c_str(), 0, NULL, &m_base );
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugSymbol::GetModuleByModuleName failed" );
|
|
||||||
|
|
||||||
DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
|
||||||
hres = m_symbols->GetModuleParameters( 1, &m_base, 0, &moduleParam );
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugSymbol::GetModuleParameters failed" );
|
|
||||||
|
|
||||||
m_size = moduleParam.Size;
|
|
||||||
m_timeDataStamp = moduleParam.TimeDateStamp;
|
|
||||||
m_checkSum = moduleParam.Checksum;
|
|
||||||
|
|
||||||
char imageName[0x100];
|
|
||||||
|
|
||||||
hres = m_symbols->GetModuleNameString(
|
|
||||||
DEBUG_MODNAME_IMAGE,
|
|
||||||
DEBUG_ANY_ID,
|
|
||||||
m_base,
|
|
||||||
imageName,
|
|
||||||
sizeof( imageName ),
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugSymbol::GetModuleNameString failed" );
|
|
||||||
|
|
||||||
m_imageName = std::string( imageName );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
Module::Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, ULONG64 offset )
|
Module::Module(ULONG64 offset )
|
||||||
: DbgObject( client )
|
|
||||||
, m_synSymbols(synSymbols)
|
|
||||||
{
|
{
|
||||||
HRESULT hres;
|
m_base = findModuleBase( addr64(offset) );
|
||||||
|
m_name = getModuleName( m_base );
|
||||||
offset = addr64( offset );
|
|
||||||
|
|
||||||
ULONG moduleIndex;
|
|
||||||
hres = m_symbols->GetModuleByOffset( offset, 0, &moduleIndex, &m_base );
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugSymbol::GetModuleByOffset failed" );
|
|
||||||
|
|
||||||
char moduleName[0x100];
|
|
||||||
|
|
||||||
hres = m_symbols->GetModuleNameString(
|
|
||||||
DEBUG_MODNAME_MODULE,
|
|
||||||
moduleIndex,
|
|
||||||
0,
|
|
||||||
moduleName,
|
|
||||||
sizeof( moduleName ),
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugSymbol::GetModuleNameString failed" );
|
|
||||||
|
|
||||||
m_name = std::string( moduleName );
|
|
||||||
|
|
||||||
char imageName[0x100];
|
|
||||||
|
|
||||||
hres = m_symbols->GetModuleNameString(
|
|
||||||
DEBUG_MODNAME_IMAGE,
|
|
||||||
DEBUG_ANY_ID,
|
|
||||||
m_base,
|
|
||||||
imageName,
|
|
||||||
sizeof( imageName ),
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugSymbol::GetModuleNameString failed" );
|
|
||||||
|
|
||||||
m_imageName = std::string( imageName );
|
|
||||||
|
|
||||||
DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
|
||||||
hres = m_symbols->GetModuleParameters( 1, &m_base, 0, &moduleParam );
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugSymbol::GetModuleParameters failed" );
|
|
||||||
|
|
||||||
m_size = moduleParam.Size;
|
|
||||||
m_timeDataStamp = moduleParam.TimeDateStamp;
|
|
||||||
m_checkSum = moduleParam.Checksum;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
std::string
|
|
||||||
Module::getPdbName()
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
IMAGEHLP_MODULEW64 moduleInfo = {};
|
|
||||||
|
|
||||||
hres = m_advanced->GetSymbolInformation(
|
|
||||||
DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
|
|
||||||
m_base,
|
|
||||||
0,
|
|
||||||
&moduleInfo,
|
|
||||||
sizeof(moduleInfo),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugAdvanced2::GetSymbolInformation failed" );
|
|
||||||
|
|
||||||
if (!*moduleInfo.LoadedPdbName)
|
|
||||||
{
|
|
||||||
reloadSymbolsImpl();
|
|
||||||
|
|
||||||
hres = m_advanced->GetSymbolInformation(
|
|
||||||
DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
|
|
||||||
m_base,
|
|
||||||
0,
|
|
||||||
&moduleInfo,
|
|
||||||
sizeof(moduleInfo),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugAdvanced2::GetSymbolInformation failed" );
|
|
||||||
}
|
|
||||||
|
|
||||||
char pdbName[ 256 ];
|
|
||||||
WideCharToMultiByte( CP_ACP, 0, moduleInfo.LoadedPdbName, 256, pdbName, 256, NULL, NULL );
|
|
||||||
|
|
||||||
return std::string( pdbName );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void
|
|
||||||
Module::reloadSymbolsImpl()
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
std::string param = "/f ";
|
|
||||||
param += m_imageName;
|
|
||||||
|
|
||||||
hres = m_symbols->Reload( param.c_str() );
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException("IDebugSymbols::Reload failed" );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void
|
|
||||||
Module::reloadSymbols()
|
|
||||||
{
|
|
||||||
reloadSymbolsImpl();
|
|
||||||
|
|
||||||
m_dia.reset();
|
|
||||||
m_dia = pyDia::GlobalScope::loadPdb( getPdbName() );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
TypedVarPtr
|
|
||||||
Module::getTypedVarByTypeName( const std::string &typeName, ULONG64 addr )
|
|
||||||
{
|
|
||||||
return TypedVar::getTypedVar( m_client, getTypeByName(typeName), VarDataMemory::factory(m_dataSpaces, addr) );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
TypedVarPtr
|
|
||||||
Module::getTypedVarByType( const TypeInfoPtr &typeInfo, ULONG64 addr )
|
|
||||||
{
|
|
||||||
return TypedVar::getTypedVar( m_client, typeInfo, VarDataMemory::factory(m_dataSpaces, addr) );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
ULONG64
|
|
||||||
Module::getSymbolSize( const std::string &symName )
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
|
|
||||||
pyDia::SymbolPtr symVar = getDia()->getChildByName( symName );
|
|
||||||
|
|
||||||
if ( symVar->getSymTag() == SymTagData )
|
|
||||||
return symVar->getSize();
|
|
||||||
|
|
||||||
} catch( const SymbolException& )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
return getTypeByName(symName)->getSize();
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
TypedVarPtr
|
|
||||||
Module::getTypedVarByName( const std::string &symName )
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
pyDia::SymbolPtr symVar = getDia()->getChildByName( symName );
|
|
||||||
|
|
||||||
std::string fullName = m_name;
|
|
||||||
fullName += '!';
|
|
||||||
fullName += symName;
|
|
||||||
|
|
||||||
ULONG64 offset;
|
|
||||||
|
|
||||||
hres = m_symbols->GetOffsetByName( fullName.c_str(), &offset );
|
|
||||||
|
|
||||||
TypeInfoPtr typeInfo = TypeInfo::getTypeInfo( symVar->getType() );
|
|
||||||
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
{
|
|
||||||
if ( LocIsConstant == symVar->getLocType() )
|
|
||||||
return TypedVar::getTypedVar( m_client, typeInfo, VarDataConst::factory(m_control, symVar) );
|
|
||||||
throw DbgException("IDebugSymbols::GetOffsetByName failed" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return TypedVar::getTypedVar( m_client, typeInfo, VarDataMemory::factory(m_dataSpaces, offset) );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
TypedVarPtr
|
|
||||||
Module::getTypedVarByAddr( ULONG64 addr )
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
addr = addr64(addr);
|
|
||||||
|
|
||||||
if ( addr < m_base || addr > getEnd() )
|
|
||||||
throw DbgException( "address is out of the module space" );
|
|
||||||
|
|
||||||
char nameBuf[0x100];
|
|
||||||
|
|
||||||
hres =
|
|
||||||
m_symbols->GetNameByOffset(
|
|
||||||
addr,
|
|
||||||
nameBuf,
|
|
||||||
sizeof(nameBuf),
|
|
||||||
NULL,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
std::string fullName( nameBuf );
|
|
||||||
|
|
||||||
size_t symPos = fullName.find ( '!' ) + 1;
|
|
||||||
|
|
||||||
std::string symbolName;
|
|
||||||
symbolName.assign( fullName, symPos, fullName.length() - symPos );
|
|
||||||
|
|
||||||
if ( FAILED(hres) )
|
|
||||||
throw DbgException( "failed IDebugSymbols::GetNameByOffset" );
|
|
||||||
|
|
||||||
return getTypedVarByName( symbolName );
|
|
||||||
|
|
||||||
//LONG displacement;
|
|
||||||
//pyDia::SymbolPtr diaSym =
|
|
||||||
// getDia()->findByRvaImpl((ULONG)(addr - m_base), SymTagData, displacement);
|
|
||||||
//if (displacement)
|
|
||||||
// throw DbgException( "not exactly match by RVA" );
|
|
||||||
|
|
||||||
//return TypedVar::getTypedVar( m_client, TypeInfo::getTypeInfo( diaSym->getType() ), addr );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
ULONG Module::getRvaByName(const std::string &symName)
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
ULONG64 offset;
|
|
||||||
|
|
||||||
hres = m_symbols->GetOffsetByName( symName.c_str(), &offset );
|
|
||||||
if ( SUCCEEDED(hres) )
|
|
||||||
return (ULONG)(offset - m_base);
|
|
||||||
|
|
||||||
return (ULONG)m_synSymbols->getRvaByName(m_timeDataStamp, m_checkSum, symName);
|
|
||||||
|
|
||||||
//try {
|
|
||||||
// pyDia::SymbolPtr sym = getDia()->getChildByName( symName );
|
|
||||||
// return sym->getRva();
|
|
||||||
//}
|
|
||||||
//catch (const pyDia::Exception &) {
|
|
||||||
//}
|
|
||||||
//return (ULONG)m_synSymbols->getRvaByName(m_timeDataStamp, m_checkSumm, symName);
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
TypedVarPtr Module::containingRecordByName( ULONG64 address, const std::string &typeName, const std::string &fieldName )
|
|
||||||
{
|
|
||||||
address = addr64(address);
|
|
||||||
|
|
||||||
TypeInfoPtr typeInfo = getTypeByName( typeName );
|
|
||||||
|
|
||||||
VarDataPtr varData =
|
|
||||||
VarDataMemory::factory(
|
|
||||||
m_dataSpaces,
|
|
||||||
address - typeInfo->getFieldOffsetByNameRecirsive( fieldName )
|
|
||||||
);
|
|
||||||
|
|
||||||
return TypedVar::getTypedVar( m_client, typeInfo, varData );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
TypedVarPtr Module::containingRecordByType( ULONG64 address, const TypeInfoPtr &typeInfo, const std::string &fieldName )
|
|
||||||
{
|
|
||||||
address = addr64(address);
|
|
||||||
|
|
||||||
VarDataPtr varData =
|
|
||||||
VarDataMemory::factory(
|
|
||||||
m_dataSpaces,
|
|
||||||
address - typeInfo->getFieldOffsetByNameRecirsive( fieldName )
|
|
||||||
);
|
|
||||||
|
|
||||||
return TypedVar::getTypedVar( m_client, typeInfo, varData );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
python::list Module::getTypedVarListByTypeName( ULONG64 listHeadAddress, const std::string &typeName, const std::string &listEntryName )
|
|
||||||
{
|
|
||||||
return getTypedVarListByType( listHeadAddress, getTypeByName( typeName ), listEntryName );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
python::list Module::getTypedVarListByType( ULONG64 listHeadAddress, const TypeInfoPtr &typeInfo, const std::string &listEntryName )
|
|
||||||
{
|
|
||||||
python::list lst;
|
|
||||||
|
|
||||||
listHeadAddress = addr64( listHeadAddress );
|
|
||||||
|
|
||||||
ULONG64 entryAddress = 0;
|
|
||||||
|
|
||||||
TypeInfoPtr fieldTypeInfo = typeInfo->getField( listEntryName );
|
|
||||||
|
|
||||||
if ( fieldTypeInfo->getName() == ( typeInfo->getName() + "*" ) )
|
|
||||||
{
|
|
||||||
for( entryAddress = ptrPtr( listHeadAddress, m_dataSpaces ); addr64(entryAddress) != listHeadAddress && entryAddress != NULL; entryAddress = ptrPtr( entryAddress + typeInfo->getFieldOffsetByNameRecirsive(listEntryName) ) )
|
|
||||||
lst.append( getTypedVarByType( typeInfo, entryAddress ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for( entryAddress = ptrPtr( listHeadAddress, m_dataSpaces ); addr64(entryAddress) != listHeadAddress && entryAddress != NULL; entryAddress = ptrPtr( entryAddress ) )
|
|
||||||
lst.append( containingRecordByType( entryAddress, typeInfo, listEntryName ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
return lst;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
python::list Module::getTypedVarArrayByTypeName( ULONG64 addr, const std::string &typeName, ULONG number )
|
|
||||||
{
|
|
||||||
return getTypedVarArrayByType( addr, getTypeByName( typeName ), number );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
python::list Module::getTypedVarArrayByType( ULONG64 address, const TypeInfoPtr &typeInfo, ULONG number )
|
|
||||||
{
|
|
||||||
address = addr64(address);
|
|
||||||
|
|
||||||
python::list lst;
|
|
||||||
|
|
||||||
for( ULONG i = 0; i < number; ++i )
|
|
||||||
lst.append( getTypedVarByType( typeInfo, address + i * typeInfo->getSize() ) );
|
|
||||||
|
|
||||||
return lst;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
std::string Module::print()
|
|
||||||
{
|
|
||||||
std::stringstream sstr;
|
|
||||||
|
|
||||||
sstr << "Module: " << m_name << std::endl;
|
|
||||||
sstr << "Start: " << std::hex << m_base << " End: " << getEnd() << " Size: " << m_size << std::endl;
|
|
||||||
sstr << "Image: " << m_imageName << std::endl;
|
|
||||||
sstr << "Pdb: " << getPdbName() << std::endl;
|
|
||||||
sstr << "Timestamp: " << m_timeDataStamp << std::endl;
|
|
||||||
sstr << "Check Sum: " << m_checkSum << std::endl;
|
|
||||||
|
|
||||||
return sstr.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
}; // end of namespace pykd
|
}; // end of namespace pykd
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#include "module.h"
|
||||||
|
//#include "dbgclient.h"
|
||||||
|
//#include "dbgmem.h"
|
||||||
|
//
|
||||||
|
//namespace pykd {
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//ModulePtr Module::loadModuleByName( const std::string &moduleName ) {
|
||||||
|
// return g_dbgClient->loadModuleByName( moduleName );
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
//ModulePtr Module::loadModuleByOffset( ULONG64 offset ) {
|
||||||
|
// return g_dbgClient->loadModuleByOffset( offset );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//Module::Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, const std::string& moduleName )
|
||||||
|
// : DbgObject( client )
|
||||||
|
// , m_synSymbols(synSymbols)
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
//
|
||||||
|
// m_name = moduleName;
|
||||||
|
//
|
||||||
|
// hres = m_symbols->GetModuleByModuleName( moduleName.c_str(), 0, NULL, &m_base );
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugSymbol::GetModuleByModuleName failed" );
|
||||||
|
//
|
||||||
|
// DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
||||||
|
// hres = m_symbols->GetModuleParameters( 1, &m_base, 0, &moduleParam );
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugSymbol::GetModuleParameters failed" );
|
||||||
|
//
|
||||||
|
// m_size = moduleParam.Size;
|
||||||
|
// m_timeDataStamp = moduleParam.TimeDateStamp;
|
||||||
|
// m_checkSum = moduleParam.Checksum;
|
||||||
|
//
|
||||||
|
// char imageName[0x100];
|
||||||
|
//
|
||||||
|
// hres = m_symbols->GetModuleNameString(
|
||||||
|
// DEBUG_MODNAME_IMAGE,
|
||||||
|
// DEBUG_ANY_ID,
|
||||||
|
// m_base,
|
||||||
|
// imageName,
|
||||||
|
// sizeof( imageName ),
|
||||||
|
// NULL );
|
||||||
|
//
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugSymbol::GetModuleNameString failed" );
|
||||||
|
//
|
||||||
|
// m_imageName = std::string( imageName );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//Module::Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, ULONG64 offset )
|
||||||
|
// : DbgObject( client )
|
||||||
|
// , m_synSymbols(synSymbols)
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
//
|
||||||
|
// offset = addr64( offset );
|
||||||
|
//
|
||||||
|
// ULONG moduleIndex;
|
||||||
|
// hres = m_symbols->GetModuleByOffset( offset, 0, &moduleIndex, &m_base );
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugSymbol::GetModuleByOffset failed" );
|
||||||
|
//
|
||||||
|
// char moduleName[0x100];
|
||||||
|
//
|
||||||
|
// hres = m_symbols->GetModuleNameString(
|
||||||
|
// DEBUG_MODNAME_MODULE,
|
||||||
|
// moduleIndex,
|
||||||
|
// 0,
|
||||||
|
// moduleName,
|
||||||
|
// sizeof( moduleName ),
|
||||||
|
// NULL );
|
||||||
|
//
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugSymbol::GetModuleNameString failed" );
|
||||||
|
//
|
||||||
|
// m_name = std::string( moduleName );
|
||||||
|
//
|
||||||
|
// char imageName[0x100];
|
||||||
|
//
|
||||||
|
// hres = m_symbols->GetModuleNameString(
|
||||||
|
// DEBUG_MODNAME_IMAGE,
|
||||||
|
// DEBUG_ANY_ID,
|
||||||
|
// m_base,
|
||||||
|
// imageName,
|
||||||
|
// sizeof( imageName ),
|
||||||
|
// NULL );
|
||||||
|
//
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugSymbol::GetModuleNameString failed" );
|
||||||
|
//
|
||||||
|
// m_imageName = std::string( imageName );
|
||||||
|
//
|
||||||
|
// DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
||||||
|
// hres = m_symbols->GetModuleParameters( 1, &m_base, 0, &moduleParam );
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugSymbol::GetModuleParameters failed" );
|
||||||
|
//
|
||||||
|
// m_size = moduleParam.Size;
|
||||||
|
// m_timeDataStamp = moduleParam.TimeDateStamp;
|
||||||
|
// m_checkSum = moduleParam.Checksum;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//std::string
|
||||||
|
//Module::getPdbName()
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
//
|
||||||
|
// IMAGEHLP_MODULEW64 moduleInfo = {};
|
||||||
|
//
|
||||||
|
// hres = m_advanced->GetSymbolInformation(
|
||||||
|
// DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
|
||||||
|
// m_base,
|
||||||
|
// 0,
|
||||||
|
// &moduleInfo,
|
||||||
|
// sizeof(moduleInfo),
|
||||||
|
// NULL,
|
||||||
|
// NULL,
|
||||||
|
// 0,
|
||||||
|
// NULL );
|
||||||
|
//
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugAdvanced2::GetSymbolInformation failed" );
|
||||||
|
//
|
||||||
|
// if (!*moduleInfo.LoadedPdbName)
|
||||||
|
// {
|
||||||
|
// reloadSymbolsImpl();
|
||||||
|
//
|
||||||
|
// hres = m_advanced->GetSymbolInformation(
|
||||||
|
// DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
|
||||||
|
// m_base,
|
||||||
|
// 0,
|
||||||
|
// &moduleInfo,
|
||||||
|
// sizeof(moduleInfo),
|
||||||
|
// NULL,
|
||||||
|
// NULL,
|
||||||
|
// 0,
|
||||||
|
// NULL );
|
||||||
|
//
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugAdvanced2::GetSymbolInformation failed" );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// char pdbName[ 256 ];
|
||||||
|
// WideCharToMultiByte( CP_ACP, 0, moduleInfo.LoadedPdbName, 256, pdbName, 256, NULL, NULL );
|
||||||
|
//
|
||||||
|
// return std::string( pdbName );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//void
|
||||||
|
//Module::reloadSymbolsImpl()
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
//
|
||||||
|
// std::string param = "/f ";
|
||||||
|
// param += m_imageName;
|
||||||
|
//
|
||||||
|
// hres = m_symbols->Reload( param.c_str() );
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException("IDebugSymbols::Reload failed" );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//void
|
||||||
|
//Module::reloadSymbols()
|
||||||
|
//{
|
||||||
|
// reloadSymbolsImpl();
|
||||||
|
//
|
||||||
|
// m_dia.reset();
|
||||||
|
// m_dia = pyDia::GlobalScope::loadPdb( getPdbName() );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//TypedVarPtr
|
||||||
|
//Module::getTypedVarByTypeName( const std::string &typeName, ULONG64 addr )
|
||||||
|
//{
|
||||||
|
// return TypedVar::getTypedVar( m_client, getTypeByName(typeName), VarDataMemory::factory(m_dataSpaces, addr) );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//TypedVarPtr
|
||||||
|
//Module::getTypedVarByType( const TypeInfoPtr &typeInfo, ULONG64 addr )
|
||||||
|
//{
|
||||||
|
// return TypedVar::getTypedVar( m_client, typeInfo, VarDataMemory::factory(m_dataSpaces, addr) );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//ULONG64
|
||||||
|
//Module::getSymbolSize( const std::string &symName )
|
||||||
|
//{
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// pyDia::SymbolPtr symVar = getDia()->getChildByName( symName );
|
||||||
|
//
|
||||||
|
// if ( symVar->getSymTag() == SymTagData )
|
||||||
|
// return symVar->getSize();
|
||||||
|
//
|
||||||
|
// } catch( const SymbolException& )
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return getTypeByName(symName)->getSize();
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//TypedVarPtr
|
||||||
|
//Module::getTypedVarByName( const std::string &symName )
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
//
|
||||||
|
// pyDia::SymbolPtr symVar = getDia()->getChildByName( symName );
|
||||||
|
//
|
||||||
|
// std::string fullName = m_name;
|
||||||
|
// fullName += '!';
|
||||||
|
// fullName += symName;
|
||||||
|
//
|
||||||
|
// ULONG64 offset;
|
||||||
|
//
|
||||||
|
// hres = m_symbols->GetOffsetByName( fullName.c_str(), &offset );
|
||||||
|
//
|
||||||
|
// TypeInfoPtr typeInfo = TypeInfo::getTypeInfo( symVar->getType() );
|
||||||
|
//
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// {
|
||||||
|
// if ( LocIsConstant == symVar->getLocType() )
|
||||||
|
// return TypedVar::getTypedVar( m_client, typeInfo, VarDataConst::factory(m_control, symVar) );
|
||||||
|
// throw DbgException("IDebugSymbols::GetOffsetByName failed" );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return TypedVar::getTypedVar( m_client, typeInfo, VarDataMemory::factory(m_dataSpaces, offset) );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//TypedVarPtr
|
||||||
|
//Module::getTypedVarByAddr( ULONG64 addr )
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
//
|
||||||
|
// addr = addr64(addr);
|
||||||
|
//
|
||||||
|
// if ( addr < m_base || addr > getEnd() )
|
||||||
|
// throw DbgException( "address is out of the module space" );
|
||||||
|
//
|
||||||
|
// char nameBuf[0x100];
|
||||||
|
//
|
||||||
|
// hres =
|
||||||
|
// m_symbols->GetNameByOffset(
|
||||||
|
// addr,
|
||||||
|
// nameBuf,
|
||||||
|
// sizeof(nameBuf),
|
||||||
|
// NULL,
|
||||||
|
// NULL );
|
||||||
|
//
|
||||||
|
// std::string fullName( nameBuf );
|
||||||
|
//
|
||||||
|
// size_t symPos = fullName.find ( '!' ) + 1;
|
||||||
|
//
|
||||||
|
// std::string symbolName;
|
||||||
|
// symbolName.assign( fullName, symPos, fullName.length() - symPos );
|
||||||
|
//
|
||||||
|
// if ( FAILED(hres) )
|
||||||
|
// throw DbgException( "failed IDebugSymbols::GetNameByOffset" );
|
||||||
|
//
|
||||||
|
// return getTypedVarByName( symbolName );
|
||||||
|
//
|
||||||
|
// //LONG displacement;
|
||||||
|
// //pyDia::SymbolPtr diaSym =
|
||||||
|
// // getDia()->findByRvaImpl((ULONG)(addr - m_base), SymTagData, displacement);
|
||||||
|
// //if (displacement)
|
||||||
|
// // throw DbgException( "not exactly match by RVA" );
|
||||||
|
//
|
||||||
|
// //return TypedVar::getTypedVar( m_client, TypeInfo::getTypeInfo( diaSym->getType() ), addr );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//ULONG Module::getRvaByName(const std::string &symName)
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
// ULONG64 offset;
|
||||||
|
//
|
||||||
|
// hres = m_symbols->GetOffsetByName( symName.c_str(), &offset );
|
||||||
|
// if ( SUCCEEDED(hres) )
|
||||||
|
// return (ULONG)(offset - m_base);
|
||||||
|
//
|
||||||
|
// return (ULONG)m_synSymbols->getRvaByName(m_timeDataStamp, m_checkSum, symName);
|
||||||
|
//
|
||||||
|
// //try {
|
||||||
|
// // pyDia::SymbolPtr sym = getDia()->getChildByName( symName );
|
||||||
|
// // return sym->getRva();
|
||||||
|
// //}
|
||||||
|
// //catch (const pyDia::Exception &) {
|
||||||
|
// //}
|
||||||
|
// //return (ULONG)m_synSymbols->getRvaByName(m_timeDataStamp, m_checkSumm, symName);
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//TypedVarPtr Module::containingRecordByName( ULONG64 address, const std::string &typeName, const std::string &fieldName )
|
||||||
|
//{
|
||||||
|
// address = addr64(address);
|
||||||
|
//
|
||||||
|
// TypeInfoPtr typeInfo = getTypeByName( typeName );
|
||||||
|
//
|
||||||
|
// VarDataPtr varData =
|
||||||
|
// VarDataMemory::factory(
|
||||||
|
// m_dataSpaces,
|
||||||
|
// address - typeInfo->getFieldOffsetByNameRecirsive( fieldName )
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// return TypedVar::getTypedVar( m_client, typeInfo, varData );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//TypedVarPtr Module::containingRecordByType( ULONG64 address, const TypeInfoPtr &typeInfo, const std::string &fieldName )
|
||||||
|
//{
|
||||||
|
// address = addr64(address);
|
||||||
|
//
|
||||||
|
// VarDataPtr varData =
|
||||||
|
// VarDataMemory::factory(
|
||||||
|
// m_dataSpaces,
|
||||||
|
// address - typeInfo->getFieldOffsetByNameRecirsive( fieldName )
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// return TypedVar::getTypedVar( m_client, typeInfo, varData );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//python::list Module::getTypedVarListByTypeName( ULONG64 listHeadAddress, const std::string &typeName, const std::string &listEntryName )
|
||||||
|
//{
|
||||||
|
// return getTypedVarListByType( listHeadAddress, getTypeByName( typeName ), listEntryName );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//python::list Module::getTypedVarListByType( ULONG64 listHeadAddress, const TypeInfoPtr &typeInfo, const std::string &listEntryName )
|
||||||
|
//{
|
||||||
|
// python::list lst;
|
||||||
|
//
|
||||||
|
// listHeadAddress = addr64( listHeadAddress );
|
||||||
|
//
|
||||||
|
// ULONG64 entryAddress = 0;
|
||||||
|
//
|
||||||
|
// TypeInfoPtr fieldTypeInfo = typeInfo->getField( listEntryName );
|
||||||
|
//
|
||||||
|
// if ( fieldTypeInfo->getName() == ( typeInfo->getName() + "*" ) )
|
||||||
|
// {
|
||||||
|
// for( entryAddress = ptrPtr( listHeadAddress, m_dataSpaces ); addr64(entryAddress) != listHeadAddress && entryAddress != NULL; entryAddress = ptrPtr( entryAddress + typeInfo->getFieldOffsetByNameRecirsive(listEntryName) ) )
|
||||||
|
// lst.append( getTypedVarByType( typeInfo, entryAddress ) );
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// for( entryAddress = ptrPtr( listHeadAddress, m_dataSpaces ); addr64(entryAddress) != listHeadAddress && entryAddress != NULL; entryAddress = ptrPtr( entryAddress ) )
|
||||||
|
// lst.append( containingRecordByType( entryAddress, typeInfo, listEntryName ) );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return lst;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//python::list Module::getTypedVarArrayByTypeName( ULONG64 addr, const std::string &typeName, ULONG number )
|
||||||
|
//{
|
||||||
|
// return getTypedVarArrayByType( addr, getTypeByName( typeName ), number );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//python::list Module::getTypedVarArrayByType( ULONG64 address, const TypeInfoPtr &typeInfo, ULONG number )
|
||||||
|
//{
|
||||||
|
// address = addr64(address);
|
||||||
|
//
|
||||||
|
// python::list lst;
|
||||||
|
//
|
||||||
|
// for( ULONG i = 0; i < number; ++i )
|
||||||
|
// lst.append( getTypedVarByType( typeInfo, address + i * typeInfo->getSize() ) );
|
||||||
|
//
|
||||||
|
// return lst;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//std::string Module::print()
|
||||||
|
//{
|
||||||
|
// std::stringstream sstr;
|
||||||
|
//
|
||||||
|
// sstr << "Module: " << m_name << std::endl;
|
||||||
|
// sstr << "Start: " << std::hex << m_base << " End: " << getEnd() << " Size: " << m_size << std::endl;
|
||||||
|
// sstr << "Image: " << m_imageName << std::endl;
|
||||||
|
// sstr << "Pdb: " << getPdbName() << std::endl;
|
||||||
|
// sstr << "Timestamp: " << m_timeDataStamp << std::endl;
|
||||||
|
// sstr << "Check Sum: " << m_checkSum << std::endl;
|
||||||
|
//
|
||||||
|
// return sstr.str();
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//}; // end of namespace pykd
|
||||||
|
//
|
||||||
|
250
pykd/module.h
250
pykd/module.h
@ -1,12 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include "intbase.h"
|
||||||
|
|
||||||
#include "dbgobj.h"
|
|
||||||
#include "diawrapper.h"
|
|
||||||
#include "typeinfo.h"
|
|
||||||
#include "typedvar.h"
|
|
||||||
#include "synsymbol.h"
|
|
||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
@ -17,7 +11,7 @@ typedef boost::shared_ptr<Module> ModulePtr;
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
class Module : public intBase, private DbgObject {
|
class Module : public intBase {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -28,19 +22,15 @@ public:
|
|||||||
ModulePtr loadModuleByOffset( ULONG64 offset );
|
ModulePtr loadModuleByOffset( ULONG64 offset );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, const std::string& moduleName );
|
|
||||||
|
|
||||||
Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, ULONG64 offset );
|
Module(const std::string &name );
|
||||||
|
|
||||||
|
Module(ULONG64 offset );
|
||||||
|
|
||||||
std::string getName() {
|
std::string getName() {
|
||||||
return m_name;
|
return m_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getImageName() {
|
|
||||||
return m_imageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG64 getBase() const {
|
ULONG64 getBase() const {
|
||||||
return m_base;
|
return m_base;
|
||||||
}
|
}
|
||||||
@ -53,94 +43,20 @@ public:
|
|||||||
return m_size;
|
return m_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string
|
|
||||||
getPdbName();
|
|
||||||
|
|
||||||
void
|
void
|
||||||
reloadSymbols();
|
reloadSymbols()
|
||||||
|
{
|
||||||
ULONG64
|
|
||||||
getSymbol( const std::string &symbolname ) {
|
|
||||||
return m_base + getRvaByName(symbolname);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ULONG
|
|
||||||
getSymbolRva( const std::string &symbolname ) {
|
|
||||||
return getRvaByName(symbolname);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypeInfoPtr getTypeByName( const std::string &typeName ) {
|
|
||||||
return TypeInfo::getTypeInfo( boost::static_pointer_cast<pyDia::Symbol>( getDia() ), typeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
TypedVarPtr getTypedVarByTypeName( const std::string &typeName, ULONG64 addr );
|
|
||||||
|
|
||||||
TypedVarPtr getTypedVarByType( const TypeInfoPtr &typeInfo, ULONG64 addr );
|
|
||||||
|
|
||||||
TypedVarPtr getTypedVarByAddr( ULONG64 addr );
|
|
||||||
|
|
||||||
TypedVarPtr getTypedVarByName( const std::string &symName );
|
|
||||||
|
|
||||||
TypedVarPtr containingRecordByName( ULONG64 addr, const std::string &typeName, const std::string &fieldName );
|
|
||||||
|
|
||||||
TypedVarPtr containingRecordByType( ULONG64 addr, const TypeInfoPtr &typeInfo, const std::string &fieldName );
|
|
||||||
|
|
||||||
python::list getTypedVarListByTypeName( ULONG64 listHeadAddres, const std::string &typeName, const std::string &listEntryName );
|
|
||||||
|
|
||||||
python::list getTypedVarListByType( ULONG64 listHeadAddres, const TypeInfoPtr &typeInfo, const std::string &listEntryName );
|
|
||||||
|
|
||||||
python::list getTypedVarArrayByTypeName( ULONG64 addr, const std::string &typeName, ULONG number );
|
|
||||||
|
|
||||||
python::list getTypedVarArrayByType( ULONG64 addr, const TypeInfoPtr &typeInfo, ULONG number );
|
|
||||||
|
|
||||||
ULONG64 getSymbolSize( const std::string &symName );
|
|
||||||
|
|
||||||
pyDia::GlobalScopePtr& getDia() {
|
|
||||||
if (!m_dia)
|
|
||||||
{
|
|
||||||
m_dia = pyDia::GlobalScope::loadPdb( getPdbName() );
|
|
||||||
if ( m_dia )
|
|
||||||
{
|
|
||||||
m_dia->setLoadAddress( m_base );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m_dia;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG getCheckSum() const {
|
|
||||||
return m_checkSum;
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG getTimeDataStamp() const {
|
|
||||||
return m_timeDataStamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string print();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void
|
|
||||||
reloadSymbolsImpl();
|
|
||||||
|
|
||||||
|
|
||||||
ULONG getRvaByName(const std::string &symName);
|
|
||||||
|
|
||||||
BaseTypeVariant getValue() {
|
BaseTypeVariant getValue() {
|
||||||
return BaseTypeVariant(m_base);
|
return BaseTypeVariant(m_base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
std::string m_imageName;
|
|
||||||
ULONG64 m_base;
|
ULONG64 m_base;
|
||||||
ULONG m_size;
|
ULONG m_size;
|
||||||
|
|
||||||
pyDia::GlobalScopePtr m_dia;
|
|
||||||
|
|
||||||
ULONG m_timeDataStamp;
|
|
||||||
ULONG m_checkSum;
|
|
||||||
SynSymbolsPtr m_synSymbols;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -148,3 +64,155 @@ private:
|
|||||||
}; // end pykd namespace
|
}; // end pykd namespace
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//#include <string>
|
||||||
|
//
|
||||||
|
//#include "dbgobj.h"
|
||||||
|
//#include "diawrapper.h"
|
||||||
|
//#include "typeinfo.h"
|
||||||
|
//#include "typedvar.h"
|
||||||
|
//#include "synsymbol.h"
|
||||||
|
//
|
||||||
|
//namespace pykd {
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//class Module;
|
||||||
|
//typedef boost::shared_ptr<Module> ModulePtr;
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//class Module : public intBase, private DbgObject {
|
||||||
|
//
|
||||||
|
//public:
|
||||||
|
//
|
||||||
|
// static
|
||||||
|
// ModulePtr loadModuleByName( const std::string &name );
|
||||||
|
//
|
||||||
|
// static
|
||||||
|
// ModulePtr loadModuleByOffset( ULONG64 offset );
|
||||||
|
//
|
||||||
|
//public:
|
||||||
|
//
|
||||||
|
// Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, const std::string& moduleName );
|
||||||
|
//
|
||||||
|
// Module( IDebugClient4 *client, SynSymbolsPtr synSymbols, ULONG64 offset );
|
||||||
|
//
|
||||||
|
// std::string getName() {
|
||||||
|
// return m_name;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// std::string getImageName() {
|
||||||
|
// return m_imageName;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ULONG64 getBase() const {
|
||||||
|
// return m_base;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ULONG64 getEnd() const {
|
||||||
|
// return m_base + m_size;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ULONG getSize() const {
|
||||||
|
// return m_size;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// std::string
|
||||||
|
// getPdbName();
|
||||||
|
//
|
||||||
|
// void
|
||||||
|
// reloadSymbols();
|
||||||
|
//
|
||||||
|
// ULONG64
|
||||||
|
// getSymbol( const std::string &symbolname ) {
|
||||||
|
// return m_base + getRvaByName(symbolname);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ULONG
|
||||||
|
// getSymbolRva( const std::string &symbolname ) {
|
||||||
|
// return getRvaByName(symbolname);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TypeInfoPtr getTypeByName( const std::string &typeName ) {
|
||||||
|
// return TypeInfo::getTypeInfo( boost::static_pointer_cast<pyDia::Symbol>( getDia() ), typeName);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// TypedVarPtr getTypedVarByTypeName( const std::string &typeName, ULONG64 addr );
|
||||||
|
//
|
||||||
|
// TypedVarPtr getTypedVarByType( const TypeInfoPtr &typeInfo, ULONG64 addr );
|
||||||
|
//
|
||||||
|
// TypedVarPtr getTypedVarByAddr( ULONG64 addr );
|
||||||
|
//
|
||||||
|
// TypedVarPtr getTypedVarByName( const std::string &symName );
|
||||||
|
//
|
||||||
|
// TypedVarPtr containingRecordByName( ULONG64 addr, const std::string &typeName, const std::string &fieldName );
|
||||||
|
//
|
||||||
|
// TypedVarPtr containingRecordByType( ULONG64 addr, const TypeInfoPtr &typeInfo, const std::string &fieldName );
|
||||||
|
//
|
||||||
|
// python::list getTypedVarListByTypeName( ULONG64 listHeadAddres, const std::string &typeName, const std::string &listEntryName );
|
||||||
|
//
|
||||||
|
// python::list getTypedVarListByType( ULONG64 listHeadAddres, const TypeInfoPtr &typeInfo, const std::string &listEntryName );
|
||||||
|
//
|
||||||
|
// python::list getTypedVarArrayByTypeName( ULONG64 addr, const std::string &typeName, ULONG number );
|
||||||
|
//
|
||||||
|
// python::list getTypedVarArrayByType( ULONG64 addr, const TypeInfoPtr &typeInfo, ULONG number );
|
||||||
|
//
|
||||||
|
// ULONG64 getSymbolSize( const std::string &symName );
|
||||||
|
//
|
||||||
|
// pyDia::GlobalScopePtr& getDia() {
|
||||||
|
// if (!m_dia)
|
||||||
|
// {
|
||||||
|
// m_dia = pyDia::GlobalScope::loadPdb( getPdbName() );
|
||||||
|
// if ( m_dia )
|
||||||
|
// {
|
||||||
|
// m_dia->setLoadAddress( m_base );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return m_dia;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ULONG getCheckSum() const {
|
||||||
|
// return m_checkSum;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ULONG getTimeDataStamp() const {
|
||||||
|
// return m_timeDataStamp;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// std::string print();
|
||||||
|
//
|
||||||
|
//private:
|
||||||
|
//
|
||||||
|
// void
|
||||||
|
// reloadSymbolsImpl();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// ULONG getRvaByName(const std::string &symName);
|
||||||
|
//
|
||||||
|
// BaseTypeVariant getValue() {
|
||||||
|
// return BaseTypeVariant(m_base);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// std::string m_name;
|
||||||
|
// std::string m_imageName;
|
||||||
|
// ULONG64 m_base;
|
||||||
|
// ULONG m_size;
|
||||||
|
//
|
||||||
|
// pyDia::GlobalScopePtr m_dia;
|
||||||
|
//
|
||||||
|
// ULONG m_timeDataStamp;
|
||||||
|
// ULONG m_checkSum;
|
||||||
|
// SynSymbolsPtr m_synSymbols;
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//}; // end pykd namespace
|
||||||
|
|
||||||
|
|
||||||
|
22
pykd/pyaux.h
22
pykd/pyaux.h
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#include "windbg.h"
|
//#include "windbg.h"
|
||||||
|
|
||||||
namespace pykd {
|
namespace pykd {
|
||||||
|
|
||||||
@ -21,23 +21,23 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void saveState() {
|
void saveState() {
|
||||||
if ( !WindbgGlobalSession::isInit() )
|
//if ( !WindbgGlobalSession::isInit() )
|
||||||
TlsSetValue( m_index, PyEval_SaveThread() );
|
TlsSetValue( m_index, PyEval_SaveThread() );
|
||||||
else
|
//else
|
||||||
WindbgGlobalSession::SavePyState();
|
// WindbgGlobalSession::SavePyState();
|
||||||
}
|
}
|
||||||
|
|
||||||
void restoreState() {
|
void restoreState() {
|
||||||
if ( !WindbgGlobalSession::isInit() )
|
//if ( !WindbgGlobalSession::isInit() )
|
||||||
{
|
//{
|
||||||
PyThreadState* state = (PyThreadState*)TlsGetValue( m_index );
|
PyThreadState* state = (PyThreadState*)TlsGetValue( m_index );
|
||||||
if ( state )
|
if ( state )
|
||||||
PyEval_RestoreThread( state );
|
PyEval_RestoreThread( state );
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
WindbgGlobalSession::RestorePyState();
|
// WindbgGlobalSession::RestorePyState();
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -349,30 +349,6 @@
|
|||||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\bpoint.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\context.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\cpureg.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgclient.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgcmd.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgevent.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dbgexcept.cpp"
|
RelativePath=".\dbgexcept.cpp"
|
||||||
>
|
>
|
||||||
@ -381,50 +357,10 @@
|
|||||||
RelativePath=".\dbgext.cpp"
|
RelativePath=".\dbgext.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\dbgio.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgmem.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgpath.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\diadata.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\diaprint.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\diawrapper.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\disasm.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\inteventhandler.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\livevar.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\module.cpp"
|
RelativePath=".\module.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\process.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\pykd.def"
|
RelativePath=".\pykd.def"
|
||||||
>
|
>
|
||||||
@ -470,31 +406,7 @@
|
|||||||
</FileConfiguration>
|
</FileConfiguration>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\stkframe.cpp"
|
RelativePath=".\windbgeng.cpp"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\synsymbol.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\synsymhelpers.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\typedvar.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\typeinfo.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\udtutils.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\vardata.cpp"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
@ -504,81 +416,21 @@
|
|||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
>
|
>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\bpoint.h"
|
RelativePath=".\dbgengine.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\context.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\cpureg.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgclient.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgcmd.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgevent.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dbgexcept.h"
|
RelativePath=".\dbgexcept.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\dbgio.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgmem.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgobj.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgpath.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\diacallback.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\diaregs.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\diawrapper.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\disasm.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\intbase.h"
|
RelativePath=".\intbase.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\inteventhandler.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\module.h"
|
RelativePath=".\module.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\process.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\pyaux.h"
|
RelativePath=".\pyaux.h"
|
||||||
>
|
>
|
||||||
@ -587,48 +439,12 @@
|
|||||||
RelativePath=".\pykdver.h"
|
RelativePath=".\pykdver.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\resource.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\stdafx.h"
|
RelativePath=".\stdafx.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath=".\stkframe.h"
|
RelativePath=".\windbgeng.h"
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\synsymbol.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\synsymhelpers.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\typedvar.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\typeinfo.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\udtutils.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\utils.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\vardata.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\windbg.h"
|
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
#define PYKD_VERSION_MAJOR 0
|
#define PYKD_VERSION_MAJOR 0
|
||||||
#define PYKD_VERSION_MINOR 1
|
#define PYKD_VERSION_MINOR 2
|
||||||
#define PYKD_VERSION_SUBVERSION 0
|
#define PYKD_VERSION_SUBVERSION 0
|
||||||
#define PYKD_VERSION_BUILDNO 16
|
#define PYKD_VERSION_BUILDNO 0
|
||||||
|
|
||||||
|
|
||||||
#define __VER_STR2__(x) #x
|
#define __VER_STR2__(x) #x
|
||||||
|
2001
pykd/pymod.cpp
2001
pykd/pymod.cpp
File diff suppressed because it is too large
Load Diff
@ -54,5 +54,3 @@ namespace python = boost::python;
|
|||||||
|
|
||||||
#include <boost/regex.hpp>
|
#include <boost/regex.hpp>
|
||||||
#include <boost/variant.hpp>
|
#include <boost/variant.hpp>
|
||||||
#include <boost\thread\win32\recursive_mutex.hpp>
|
|
||||||
|
|
||||||
|
209
pykd/windbgeng.cpp
Normal file
209
pykd/windbgeng.cpp
Normal file
@ -0,0 +1,209 @@
|
|||||||
|
#include "stdafx.h"
|
||||||
|
|
||||||
|
#include "windbgeng.h"
|
||||||
|
#include "dbgexcept.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
DebugEngine g_dbgEng;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG startProcess( const std::wstring &processName )
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
ULONG opt;
|
||||||
|
hres = g_dbgEng->control->GetEngineOptions( &opt );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::GetEngineOptions failed" );
|
||||||
|
|
||||||
|
opt |= DEBUG_ENGOPT_INITIAL_BREAK;
|
||||||
|
hres = g_dbgEng->control->SetEngineOptions( opt );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::SetEngineOptions failed" );
|
||||||
|
|
||||||
|
std::vector< std::wstring::value_type > cmdLine( processName.size() + 1 );
|
||||||
|
wcscpy_s( &cmdLine[0], cmdLine.size(), processName.c_str() );
|
||||||
|
|
||||||
|
hres = g_dbgEng->client->CreateProcessWide( 0, &cmdLine[0], DEBUG_PROCESS | DETACHED_PROCESS );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugClient4::CreateProcessWide failed" );
|
||||||
|
|
||||||
|
hres = g_dbgEng->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
|
|
||||||
|
ULONG processId = -1;
|
||||||
|
hres = g_dbgEng->system->GetCurrentProcessId( &processId );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugSystemObjects::GetCurrentProcessId failed" );
|
||||||
|
|
||||||
|
return processId;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void detachProcess( ULONG processId )
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
if ( processId != -1 )
|
||||||
|
{
|
||||||
|
hres = g_dbgEng->system->SetCurrentProcessId(processId);
|
||||||
|
if ( FAILED(hres) )
|
||||||
|
throw DbgException( "IDebugSystemObjects::SetCurrentProcessId failed" );
|
||||||
|
}
|
||||||
|
|
||||||
|
hres = g_dbgEng->client->DetachCurrentProcess();
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugClient::DetachCurrentProcess failed" );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void terminateProcess( ULONG processId )
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
if ( processId != -1 )
|
||||||
|
{
|
||||||
|
hres = g_dbgEng->system->SetCurrentProcessId(processId);
|
||||||
|
if ( FAILED(hres) )
|
||||||
|
throw DbgException( "IDebugSystemObjects::SetCurrentProcessId failed" );
|
||||||
|
}
|
||||||
|
|
||||||
|
hres = g_dbgEng->client->TerminateCurrentProcess();
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugClient::TerminateCurrentProcess", hres );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
void debugGo()
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
hres = g_dbgEng->control->SetExecutionStatus( DEBUG_STATUS_GO );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::SetExecutionStatus failed" );
|
||||||
|
|
||||||
|
ULONG currentStatus;
|
||||||
|
|
||||||
|
do {
|
||||||
|
hres = g_dbgEng->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
|
|
||||||
|
hres = g_dbgEng->control->GetExecutionStatus( ¤tStatus );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::GetExecutionStatus failed" );
|
||||||
|
|
||||||
|
} while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG64 findModuleBase( const std::string &moduleName )
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG64 base;
|
||||||
|
|
||||||
|
hres = g_dbgEng->symbols->GetModuleByModuleName( moduleName.c_str(), 0, NULL, &base );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugSymbol::GetModuleByModuleName failed" );
|
||||||
|
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG64 findModuleBase( ULONG64 offset )
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
ULONG64 base;
|
||||||
|
ULONG moduleIndex;
|
||||||
|
|
||||||
|
hres = g_dbgEng->symbols->GetModuleByOffset( offset, 0, &moduleIndex, &base );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugSymbol::GetModuleByOffset failed" );
|
||||||
|
|
||||||
|
return base;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
std::string getModuleName( ULONG64 baseOffset )
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
char moduleName[0x100];
|
||||||
|
|
||||||
|
hres = g_dbgEng->symbols->GetModuleNameString(
|
||||||
|
DEBUG_MODNAME_MODULE,
|
||||||
|
DEBUG_ANY_ID,
|
||||||
|
baseOffset,
|
||||||
|
moduleName,
|
||||||
|
sizeof( moduleName ),
|
||||||
|
NULL );
|
||||||
|
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugSymbol::GetModuleNameString failed" );
|
||||||
|
|
||||||
|
return std::string( moduleName );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
ULONG64 addr64( ULONG64 addr )
|
||||||
|
{
|
||||||
|
PyThread_StateRestore pyThreadRestore( g_dbgEng->pystate );
|
||||||
|
|
||||||
|
HRESULT hres;
|
||||||
|
|
||||||
|
ULONG processorMode;
|
||||||
|
hres = g_dbgEng->control->GetActualProcessorType( &processorMode );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" );
|
||||||
|
|
||||||
|
switch( processorMode )
|
||||||
|
{
|
||||||
|
case IMAGE_FILE_MACHINE_I386:
|
||||||
|
if ( *( (ULONG*)&addr + 1 ) == 0 )
|
||||||
|
return (ULONG64)(LONG)addr;
|
||||||
|
|
||||||
|
case IMAGE_FILE_MACHINE_AMD64:
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw DbgException( "Unknown processor type" );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
62
pykd/windbgeng.h
Normal file
62
pykd/windbgeng.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dbgengine.h"
|
||||||
|
#include "dbgexcept.h"
|
||||||
|
#include "pyaux.h"
|
||||||
|
|
||||||
|
namespace pykd {
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
class DebugEngine {
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
struct DbgEngBind {
|
||||||
|
|
||||||
|
CComQIPtr<IDebugClient4> client;
|
||||||
|
CComQIPtr<IDebugControl4> control;
|
||||||
|
CComQIPtr<IDebugSystemObjects2> system;
|
||||||
|
CComQIPtr<IDebugSymbols3> symbols;
|
||||||
|
|
||||||
|
DbgEngBind( PDEBUG_CLIENT4 c )
|
||||||
|
{
|
||||||
|
client = c;
|
||||||
|
control = c;
|
||||||
|
system = c;
|
||||||
|
symbols = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
PyThreadStateSaver pystate;
|
||||||
|
};
|
||||||
|
|
||||||
|
DbgEngBind*
|
||||||
|
operator->()
|
||||||
|
{
|
||||||
|
if ( m_bind.get() != NULL )
|
||||||
|
return m_bind.get();
|
||||||
|
|
||||||
|
CComPtr<IDebugClient4> client = NULL;
|
||||||
|
|
||||||
|
HRESULT hres = DebugCreate( __uuidof(IDebugClient4), (void **)&client );
|
||||||
|
if ( FAILED( hres ) )
|
||||||
|
throw DbgException("DebugCreate failed");
|
||||||
|
|
||||||
|
m_bind.reset(new DbgEngBind(client) );
|
||||||
|
|
||||||
|
return m_bind.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
std::auto_ptr<DbgEngBind> m_bind;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
extern DebugEngine g_dbgEng;
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
};
|
@ -7,14 +7,14 @@ import target
|
|||||||
import pykd
|
import pykd
|
||||||
|
|
||||||
class ModuleTest( unittest.TestCase ):
|
class ModuleTest( unittest.TestCase ):
|
||||||
|
|
||||||
def testCtor( self ):
|
def testCtor( self ):
|
||||||
self.assertEqual( target.module.name(), pykd.module(target.module.begin() ).name() )
|
self.assertEqual( target.module.name(), pykd.module(target.module.begin() ).name() )
|
||||||
self.assertEqual( target.module.name(), pykd.module(target.module.name() ).name() )
|
self.assertEqual( target.module.name(), pykd.module(target.module.name() ).name() )
|
||||||
|
|
||||||
def testName( self ):
|
def testName( self ):
|
||||||
self.assertEqual( target.moduleName, target.module.name() )
|
self.assertEqual( target.moduleName, target.module.name() )
|
||||||
|
|
||||||
def testSize( self ):
|
def testSize( self ):
|
||||||
self.assertNotEqual( 0, target.module.size() )
|
self.assertNotEqual( 0, target.module.size() )
|
||||||
|
|
||||||
@ -26,40 +26,40 @@ class ModuleTest( unittest.TestCase ):
|
|||||||
def testEnd( self ):
|
def testEnd( self ):
|
||||||
self.assertEqual( target.module.size(), target.module.end() - target.module.begin() )
|
self.assertEqual( target.module.size(), target.module.end() - target.module.begin() )
|
||||||
|
|
||||||
def testPdb( self ):
|
# def testPdb( self ):
|
||||||
self.assertNotEqual( "", target.module.pdb() )
|
# self.assertNotEqual( "", target.module.pdb() )
|
||||||
|
|
||||||
def testImage( self ):
|
# def testImage( self ):
|
||||||
self.assertEqual( target.module.name() + ".exe", target.module.image() )
|
# self.assertEqual( target.module.name() + ".exe", target.module.image() )
|
||||||
|
|
||||||
def testFindModule( self ):
|
# def testFindModule( self ):
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
pykd.loadModule( target.module.begin() - 0x10 )
|
# pykd.loadModule( target.module.begin() - 0x10 )
|
||||||
self.assertTrue( False )
|
# self.assertTrue( False )
|
||||||
except pykd.BaseException:
|
# except pykd.BaseException:
|
||||||
self.assertTrue( True )
|
# self.assertTrue( True )
|
||||||
|
|
||||||
self.assertNotEqual( None, pykd.loadModule( target.module.begin() ) )
|
# self.assertNotEqual( None, pykd.loadModule( target.module.begin() ) )
|
||||||
self.assertNotEqual( None, pykd.loadModule( target.module.begin() + 0x10) )
|
# self.assertNotEqual( None, pykd.loadModule( target.module.begin() + 0x10) )
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
pykd.loadModule( target.module.end() )
|
# pykd.loadModule( target.module.end() )
|
||||||
self.assertTrue( False )
|
# self.assertTrue( False )
|
||||||
except pykd.BaseException:
|
# except pykd.BaseException:
|
||||||
self.assertTrue( True )
|
# self.assertTrue( True )
|
||||||
|
|
||||||
try:
|
# try:
|
||||||
pykd.loadModule( target.module.end() + 0x10 )
|
# pykd.loadModule( target.module.end() + 0x10 )
|
||||||
self.assertTrue( False )
|
# self.assertTrue( False )
|
||||||
except pykd.BaseException:
|
# except pykd.BaseException:
|
||||||
self.assertTrue( True )
|
# self.assertTrue( True )
|
||||||
|
|
||||||
def testSymbol( self ):
|
# def testSymbol( self ):
|
||||||
self.assertEqual( target.module.rva("FuncWithName0"), target.module.offset("FuncWithName0") - target.module.begin() )
|
# self.assertEqual( target.module.rva("FuncWithName0"), target.module.offset("FuncWithName0") - target.module.begin() )
|
||||||
self.assertEqual( target.module.rva("FuncWithName0"), target.module.FuncWithName0 - target.module.begin() )
|
# self.assertEqual( target.module.rva("FuncWithName0"), target.module.FuncWithName0 - target.module.begin() )
|
||||||
|
|
||||||
def testType( self ):
|
# def testType( self ):
|
||||||
self.assertEqual( "structTest", target.module.type("structTest").name() );
|
# self.assertEqual( "structTest", target.module.type("structTest").name() );
|
||||||
self.assertEqual( "structTest", target.module.type("g_structTest").name() );
|
# self.assertEqual( "structTest", target.module.type("g_structTest").name() );
|
||||||
|
|
||||||
|
@ -8,83 +8,143 @@ import unittest
|
|||||||
|
|
||||||
# Dynamically append current pykd.pyd path to PYTHONPATH
|
# Dynamically append current pykd.pyd path to PYTHONPATH
|
||||||
sys.path.insert(0, os.path.dirname(sys.argv[1]))
|
sys.path.insert(0, os.path.dirname(sys.argv[1]))
|
||||||
|
|
||||||
import pykd
|
import pykd
|
||||||
|
|
||||||
import target
|
import target
|
||||||
import basetest
|
|
||||||
import typeinfo
|
|
||||||
import regtest
|
|
||||||
import moduletest
|
import moduletest
|
||||||
import diatest
|
|
||||||
import dbgcmd
|
|
||||||
import clienttest
|
|
||||||
import eventtest
|
|
||||||
import typedvar
|
|
||||||
import memtest
|
|
||||||
import intbase
|
import intbase
|
||||||
import synsymtest
|
|
||||||
import ehloadtest
|
|
||||||
import thrdctxtest
|
|
||||||
import localstest
|
|
||||||
import ehexcepttest
|
|
||||||
|
|
||||||
def getTestSuite( singleName = "" ):
|
def getTestSuite( singleName = "" ):
|
||||||
if singleName == "":
|
if singleName == "":
|
||||||
return unittest.TestSuite(
|
return unittest.TestSuite(
|
||||||
[ unittest.TestLoader().loadTestsFromTestCase( basetest.BaseTest ),
|
[
|
||||||
unittest.TestLoader().loadTestsFromTestCase( moduletest.ModuleTest ),
|
unittest.TestLoader().loadTestsFromTestCase( target.TargetTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( diatest.DiaTest ),
|
unittest.TestLoader().loadTestsFromTestCase( moduletest.ModuleTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( typeinfo.TypeInfoTest ),
|
unittest.TestLoader().loadTestsFromTestCase( intbase.IntBaseTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( typedvar.TypedVarTest ),
|
] )
|
||||||
unittest.TestLoader().loadTestsFromTestCase( dbgcmd.DbgcmdTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( clienttest.DbgClientTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( eventtest.EventTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( memtest.MemoryTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( intbase.IntBaseTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( synsymtest.SynSymTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( thrdctxtest.ThreadContextTest ),
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( regtest.CpuRegTest ),
|
|
||||||
] )
|
|
||||||
else:
|
else:
|
||||||
return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
||||||
|
|
||||||
def getNewProcessTestSuite():
|
|
||||||
return unittest.TestSuite(
|
|
||||||
[
|
|
||||||
unittest.TestLoader().loadTestsFromTestCase( ehloadtest.EhLoadTest ),
|
|
||||||
# unittest.TestLoader().loadTestsFromTestCase( localstest.LocalVarsTest ),
|
|
||||||
# unittest.TestLoader().loadTestsFromTestCase( ehexcepttest.EhExceptionBreakpointTest ),
|
|
||||||
] )
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
||||||
print "\nTesting PyKd ver. " + pykd.version
|
print "\nTesting PyKd ver. " + pykd.version
|
||||||
|
|
||||||
target.appPath = sys.argv[1]
|
target.appPath = sys.argv[1]
|
||||||
|
|
||||||
target.moduleName = os.path.splitext(os.path.basename(target.appPath))[0]
|
target.moduleName = os.path.splitext(os.path.basename(target.appPath))[0]
|
||||||
print "Test module: %s" % target.appPath
|
#print "Test module: %s" % target.appPath
|
||||||
|
|
||||||
pykd.startProcess( target.appPath )
|
processId = pykd.startProcess( target.appPath )
|
||||||
|
target.module = pykd.module( target.moduleName )
|
||||||
target.module = pykd.loadModule( target.moduleName )
|
|
||||||
target.module.reload();
|
target.module.reload();
|
||||||
|
|
||||||
pykd.go()
|
pykd.go()
|
||||||
|
|
||||||
|
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getTestSuite() )
|
||||||
|
|
||||||
print ""
|
pykd.killProcess( processId )
|
||||||
|
|
||||||
oneProcessTests = getTestSuite()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#import target
|
||||||
|
#import moduletest
|
||||||
|
|
||||||
|
#import basetest
|
||||||
|
#import typeinfo
|
||||||
|
#import regtest
|
||||||
|
#import moduletest
|
||||||
|
#import diatest
|
||||||
|
#import dbgcmd
|
||||||
|
#import clienttest
|
||||||
|
#import eventtest
|
||||||
|
#import typedvar
|
||||||
|
#import memtest
|
||||||
|
#import intbase
|
||||||
|
#import synsymtest
|
||||||
|
#import ehloadtest
|
||||||
|
#import thrdctxtest
|
||||||
|
#import localstest
|
||||||
|
#import ehexcepttest
|
||||||
|
|
||||||
|
#def getTestSuite( singleName = "" ):
|
||||||
|
# if singleName == "":
|
||||||
|
# return unittest.TestSuite(
|
||||||
|
# [
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( target.TargetTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( moduletest.ModuleTest ),
|
||||||
|
|
||||||
|
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( basetest.BaseTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( moduletest.ModuleTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( diatest.DiaTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( typeinfo.TypeInfoTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( typedvar.TypedVarTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( dbgcmd.DbgcmdTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( clienttest.DbgClientTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( eventtest.EventTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( memtest.MemoryTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( intbase.IntBaseTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( synsymtest.SynSymTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( thrdctxtest.ThreadContextTest ),
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( regtest.CpuRegTest ),
|
||||||
|
# ] )
|
||||||
|
# else:
|
||||||
|
# return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
||||||
|
|
||||||
|
#def getNewProcessTestSuite():
|
||||||
|
# return unittest.TestSuite(
|
||||||
|
# [
|
||||||
|
# unittest.TestLoader().loadTestsFromTestCase( ehloadtest.EhLoadTest ),
|
||||||
|
# # unittest.TestLoader().loadTestsFromTestCase( localstest.LocalVarsTest ),
|
||||||
|
# # unittest.TestLoader().loadTestsFromTestCase( ehexcepttest.EhExceptionBreakpointTest ),
|
||||||
|
# ] )
|
||||||
|
|
||||||
|
|
||||||
|
#if __name__ == "__main__":
|
||||||
|
|
||||||
|
# print "\nTesting PyKd ver. " + pykd.version
|
||||||
|
|
||||||
|
# target.appPath = sys.argv[1]
|
||||||
|
|
||||||
|
# unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getTestSuite() )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#target.appPath = sys.argv[1]
|
||||||
|
|
||||||
|
#target.moduleName = os.path.splitext(os.path.basename(target.appPath))[0]
|
||||||
|
#print "Test module: %s" % target.appPath
|
||||||
|
|
||||||
|
#pykd.startProcess( target.appPath )
|
||||||
|
|
||||||
|
#target.module = pykd.loadModule( target.moduleName )
|
||||||
|
#target.module.reload();
|
||||||
|
|
||||||
|
#pykd.go()
|
||||||
|
|
||||||
|
#print ""
|
||||||
|
|
||||||
|
#oneProcessTests = getTestSuite()
|
||||||
|
|
||||||
#oneProcessTests = getTestSuite( "diatest.DiaTest.testFind" )
|
#oneProcessTests = getTestSuite( "diatest.DiaTest.testFind" )
|
||||||
#oneProcessTests = getTestSuite( "typedvar.TypedVarTest.testTypeVarArg" )
|
#oneProcessTests = getTestSuite( "typedvar.TypedVarTest.testTypeVarArg" )
|
||||||
#oneProcessTests = getTestSuite( "typeinfo.TypeInfoTest.testCreateByName" )
|
#oneProcessTests = getTestSuite( "typeinfo.TypeInfoTest.testCreateByName" )
|
||||||
#oneProcessTests = getTestSuite( "typedvar.TypedVarTest.testBitField" )
|
#oneProcessTests = getTestSuite( "typedvar.TypedVarTest.testBitField" )
|
||||||
|
|
||||||
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( oneProcessTests )
|
#unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( oneProcessTests )
|
||||||
|
|
||||||
pykd.killProcess()
|
#pykd.killProcess()
|
||||||
|
|
||||||
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getNewProcessTestSuite() )
|
#unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( getNewProcessTestSuite() )
|
||||||
|
|
||||||
raw_input("\npress return\n")
|
#raw_input("\npress return\n")
|
||||||
|
@ -2,7 +2,22 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
import pykd
|
||||||
|
|
||||||
|
appPath = None
|
||||||
module = None
|
module = None
|
||||||
moduleName = None
|
moduleName = None
|
||||||
dbgext = None
|
|
||||||
appPath = None
|
class TargetTest( unittest.TestCase ):
|
||||||
|
|
||||||
|
def testStartStop(self):
|
||||||
|
processId = pykd.startProcess( appPath )
|
||||||
|
pykd.killProcess( processId )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#module = None
|
||||||
|
#moduleName = None
|
||||||
|
#dbgext = None
|
||||||
|
#appPath = None
|
||||||
|
Loading…
Reference in New Issue
Block a user