From 8e0ecc173321ccf68c7524e20b8fa76bedfdcab3 Mon Sep 17 00:00:00 2001 From: "SND\\EreTIk_cp" Date: Thu, 17 Mar 2011 09:04:28 +0000 Subject: [PATCH] [+] added debug events defs [~] addr64 conversion for module randge and get tread/process context git-svn-id: https://pykd.svn.codeplex.com/svn@62774 9b283d60-5439-405e-af05-b73fd8c4d996 --- pykd/dbgext.cpp | 15 ++++++++++++++ pykd/dbgmodule.cpp | 6 +++--- pykd/dbgmodule.h | 2 +- pykd/dbgprocess.cpp | 50 +++++++++++++++++++++++---------------------- 4 files changed, 45 insertions(+), 28 deletions(-) diff --git a/pykd/dbgext.cpp b/pykd/dbgext.cpp index 5b49059..231de2f 100644 --- a/pykd/dbgext.cpp +++ b/pykd/dbgext.cpp @@ -246,6 +246,21 @@ BOOST_PYTHON_MODULE( pykd ) // exception flags _DEF_PY_CONST(EXCEPTION_NONCONTINUABLE); + // debug events + _DEF_PY_CONST(DEBUG_EVENT_BREAKPOINT); + _DEF_PY_CONST(DEBUG_EVENT_EXCEPTION); + _DEF_PY_CONST(DEBUG_EVENT_CREATE_THREAD); + _DEF_PY_CONST(DEBUG_EVENT_EXIT_THREAD); + _DEF_PY_CONST(DEBUG_EVENT_CREATE_PROCESS); + _DEF_PY_CONST(DEBUG_EVENT_EXIT_PROCESS); + _DEF_PY_CONST(DEBUG_EVENT_LOAD_MODULE); + _DEF_PY_CONST(DEBUG_EVENT_UNLOAD_MODULE); + _DEF_PY_CONST(DEBUG_EVENT_SYSTEM_ERROR); + _DEF_PY_CONST(DEBUG_EVENT_SESSION_STATUS); + _DEF_PY_CONST(DEBUG_EVENT_CHANGE_DEBUGGEE_STATE); + _DEF_PY_CONST(DEBUG_EVENT_CHANGE_ENGINE_STATE); + _DEF_PY_CONST(DEBUG_EVENT_CHANGE_SYMBOL_STATE); + } #undef _DEF_PY_CONST diff --git a/pykd/dbgmodule.cpp b/pykd/dbgmodule.cpp index e5f4546..e724fc5 100644 --- a/pykd/dbgmodule.cpp +++ b/pykd/dbgmodule.cpp @@ -108,8 +108,8 @@ findModule( ULONG64 addr ) dbgModuleClass::dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ) : m_name( name ), - m_base( base ), - m_end( base + size ) + m_base( addr64(base) ), + m_end( addr64(base) + size ) { reloadSymbols(); @@ -130,7 +130,7 @@ dbgModuleClass::dbgModuleClass( const std::string &name, ULONG64 base, ULONG siz sizeof( nameBuf ), NULL, &offset ); - + if ( FAILED( hres ) ) break; diff --git a/pykd/dbgmodule.h b/pykd/dbgmodule.h index 3eb0d82..a3c8b7d 100644 --- a/pykd/dbgmodule.h +++ b/pykd/dbgmodule.h @@ -65,7 +65,7 @@ public: {} dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ); - + ULONG64 getBegin() const { return m_base; diff --git a/pykd/dbgprocess.cpp b/pykd/dbgprocess.cpp index 6f0ba5c..ae32182 100644 --- a/pykd/dbgprocess.cpp +++ b/pykd/dbgprocess.cpp @@ -72,25 +72,26 @@ setImplicitThread( HRESULT hres; try { - + + newThreadAddr = addr64(newThreadAddr); hres = dbgExt->system2->SetImplicitThreadDataOffset( newThreadAddr ); if ( FAILED( hres ) ) throw DbgException( "IDebugSystemObjects2::SetImplicitThreadDataOffset failed" ); - - return true; - + + return true; + } - catch( std::exception &e ) - { - dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() ); - } - catch(...) - { - dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" ); - } - - return false; -} + catch( std::exception &e ) + { + dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() ); + } + catch(...) + { + dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" ); + } + + return false; +} ///////////////////////////////////////////////////////////////////////////////// @@ -292,22 +293,23 @@ VOID setCurrentProcess( ULONG64 processAddr ) { - HRESULT hres; + HRESULT hres; try { + processAddr = addr64(processAddr); hres = dbgExt->system2->SetImplicitProcessDataOffset( processAddr ); if ( FAILED( hres ) ) throw DbgException( "IDebugSystemObjects2::SetImplicitProcessDataOffset failed" ); } - catch( std::exception &e ) - { - dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() ); - } - catch(...) - { - dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" ); - } + catch( std::exception &e ) + { + dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() ); + } + catch(...) + { + dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" ); + } } /////////////////////////////////////////////////////////////////////////////////