[pykd] added: cpuReg class based on intBase

[pykd] updated: debugEvent class

git-svn-id: https://pykd.svn.codeplex.com/svn@68108 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-07-22 06:55:01 +00:00
parent 2bc8e5760f
commit 679b315aac
9 changed files with 649 additions and 481 deletions

View File

@ -1,112 +1,265 @@
/////////////////////////////////////////////////////////////////////////////////
// Load/Unload module events
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//// Load/Unload module events
///////////////////////////////////////////////////////////////////////////////////
//
#include "stdafx.h"
#include <memory>
#include <dbgeng.h>
#include "dbgmodule.h"
#include "dbgio.h"
#include "dbgevent.h"
#include "dbgio.h"
#include "dbgexcept.h"
/////////////////////////////////////////////////////////////////////////////////
debugEvent::modCallbacksColl debugEvent::modCallbacks;
debugEvent::modCallbacksLock debugEvent::modCallbacksMtx;
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
debugEvent::debugEvent()
{
modCallbacksScopedLock lock(modCallbacksMtx);
modCallbacks.insert(this);
HRESULT hres;
hres = dbgExt->client->CreateClient( &m_debugClient );
if ( FAILED( hres ) )
throw DbgException( "IDebugClient::CreateClient" );
hres = m_debugClient->SetEventCallbacks(this);
if (FAILED(hres))
throw DbgException( "IDebugClient::SetEventCallbacks" );
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
debugEvent::~debugEvent()
{
modCallbacksScopedLock lock(modCallbacksMtx);
modCallbacks.erase(this);
m_debugClient->SetEventCallbacks( NULL );
m_debugClient->Release();
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
ULONG debugEvent::moduleLoaded(__in ULONG64 addr)
HRESULT debugEvent::GetInterestMask(
__out PULONG Mask
)
{
modCallbacksScopedLock lock(modCallbacksMtx);
if (modCallbacks.empty())
return DEBUG_STATUS_NO_CHANGE;
*Mask = 0;
ULONG64 moduleBase;
ULONG moduleSize;
std::string moduleName;
*Mask |= DEBUG_EVENT_LOAD_MODULE;
*Mask |= DEBUG_EVENT_UNLOAD_MODULE;
*Mask |= DEBUG_EVENT_SESSION_STATUS;
return S_OK;
}
///////////////////////////////////////////////////////////////////////////////////
HRESULT debugEvent::LoadModule(
__in ULONG64 ImageFileHandle,
__in ULONG64 BaseOffset,
__in ULONG ModuleSize,
__in PCSTR ModuleName,
__in PCSTR ImageName,
__in ULONG CheckSum,
__in ULONG TimeDateStamp
)
{
std::auto_ptr<OutputReader> silentMode( new OutputReader(dbgExt->client) );
queryModuleParams(addr, moduleName, moduleBase, moduleSize);
ULONG64 moduleBase;
ULONG moduleSize;
std::string moduleName;
queryModuleParams(BaseOffset, moduleName, moduleBase, moduleSize);
dbgModuleClass module(moduleName, moduleBase, moduleSize);
silentMode.reset();
modCallbacksColl::iterator itCallback = modCallbacks.begin();
while (itCallback != modCallbacks.end())
{
const ULONG retValue = (*itCallback)->onLoadModule(module);
if (DEBUG_STATUS_NO_CHANGE != retValue)
return retValue;
++itCallback;
}
return DEBUG_STATUS_NO_CHANGE;
return onLoadModule( module );
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
ULONG debugEvent::moduleUnloaded(__in ULONG64 addr)
HRESULT debugEvent::UnloadModule(
__in PCSTR ImageBaseName,
__in ULONG64 BaseOffset
)
{
modCallbacksScopedLock lock(modCallbacksMtx);
if (modCallbacks.empty())
return DEBUG_STATUS_NO_CHANGE;
ULONG64 moduleBase;
ULONG moduleSize;
std::string moduleName;
std::auto_ptr<OutputReader> silentMode( new OutputReader(dbgExt->client) );
queryModuleParams(addr, moduleName, moduleBase, moduleSize);
ULONG64 moduleBase;
ULONG moduleSize;
std::string moduleName;
queryModuleParams(BaseOffset, moduleName, moduleBase, moduleSize);
dbgModuleClass module(moduleName, moduleBase, moduleSize);
silentMode.reset();
modCallbacksColl::iterator itCallback = modCallbacks.begin();
while (itCallback != modCallbacks.end())
{
const ULONG retValue = (*itCallback)->onUnloadModule(module);
if (DEBUG_STATUS_NO_CHANGE != retValue)
return retValue;
++itCallback;
}
return DEBUG_STATUS_NO_CHANGE;
return onUnloadModule( module );
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
ULONG debugEventWrap::onLoadModule(const dbgModuleClass &module)
HRESULT debugEvent::SessionStatus(
__in ULONG Status
)
{
if (boost::python::override override = get_override("onLoadModule"))
return override(module);
return debugEvent::onLoadModule(module);
return onChangeSessionStatus( Status );
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
ULONG debugEventWrap::onUnloadModule(const dbgModuleClass &module)
HRESULT debugEvent::ChangeDebuggeeState(
__in ULONG Flags,
__in ULONG64 Argument
)
{
if (boost::python::override override = get_override("onUnloadModule"))
return override(module);
return debugEvent::onUnloadModule(module);
return onChangeDebugeeState();
}
/////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////
//
// STDMETHOD(GetInterestMask)(
// __out PULONG Mask
// );
//
// STDMETHOD(LoadModule)(
// __in ULONG64 ImageFileHandle,
// __in ULONG64 BaseOffset,
// __in ULONG ModuleSize,
// __in PCSTR ModuleName,
// __in PCSTR ImageName,
// __in ULONG CheckSum,
// __in ULONG TimeDateStamp
// );
//
// STDMETHOD(UnloadModule)(
// __in PCSTR ImageBaseName,
// __in ULONG64 BaseOffset
// );
//
//public:
//
// ULONG onLoadModule(const dbgModuleClass &module);
//
// ULONG onUnloadModule(const dbgModuleClass &module);
//
//#include <memory>
//#include <dbgeng.h>
//
//#include "dbgmodule.h"
//#include "dbgio.h"
//#include "dbgevent.h"
//
///////////////////////////////////////////////////////////////////////////////////
//
//debugEvent::modCallbacksColl debugEvent::modCallbacks;
//debugEvent::modCallbacksLock debugEvent::modCallbacksMtx;
//
///////////////////////////////////////////////////////////////////////////////////
//
//debugEvent::debugEvent()
//{
// modCallbacksScopedLock lock(modCallbacksMtx);
// modCallbacks.insert(this);
//}
//
///////////////////////////////////////////////////////////////////////////////////
//
//debugEvent::~debugEvent()
//{
// modCallbacksScopedLock lock(modCallbacksMtx);
// modCallbacks.erase(this);
//}
//
///////////////////////////////////////////////////////////////////////////////////
//
//ULONG debugEvent::moduleLoaded(__in ULONG64 addr)
//{
// modCallbacksScopedLock lock(modCallbacksMtx);
// if (modCallbacks.empty())
// return DEBUG_STATUS_NO_CHANGE;
//
// ULONG64 moduleBase;
// ULONG moduleSize;
// std::string moduleName;
//
// std::auto_ptr<OutputReader> silentMode( new OutputReader(dbgExt->client) );
// queryModuleParams(addr, moduleName, moduleBase, moduleSize);
// dbgModuleClass module(moduleName, moduleBase, moduleSize);
// silentMode.reset();
//
// modCallbacksColl::iterator itCallback = modCallbacks.begin();
// while (itCallback != modCallbacks.end())
// {
// const ULONG retValue = (*itCallback)->onLoadModule(module);
// if (DEBUG_STATUS_NO_CHANGE != retValue)
// return retValue;
//
// ++itCallback;
// }
// return DEBUG_STATUS_NO_CHANGE;
//}
//
///////////////////////////////////////////////////////////////////////////////////
//
//ULONG debugEvent::moduleUnloaded(__in ULONG64 addr)
//{
// modCallbacksScopedLock lock(modCallbacksMtx);
// if (modCallbacks.empty())
// return DEBUG_STATUS_NO_CHANGE;
//
// ULONG64 moduleBase;
// ULONG moduleSize;
// std::string moduleName;
//
// std::auto_ptr<OutputReader> silentMode( new OutputReader(dbgExt->client) );
// queryModuleParams(addr, moduleName, moduleBase, moduleSize);
// dbgModuleClass module(moduleName, moduleBase, moduleSize);
// silentMode.reset();
//
// modCallbacksColl::iterator itCallback = modCallbacks.begin();
// while (itCallback != modCallbacks.end())
// {
// const ULONG retValue = (*itCallback)->onUnloadModule(module);
// if (DEBUG_STATUS_NO_CHANGE != retValue)
// return retValue;
//
// ++itCallback;
// }
// return DEBUG_STATUS_NO_CHANGE;
//}
//
///////////////////////////////////////////////////////////////////////////////////
//
//ULONG debugEvent::sessionStatus(__in ULONG status )
//{
//
//}
//
///////////////////////////////////////////////////////////////////////////////////
//
//ULONG debugEventWrap::onLoadModule(const dbgModuleClass &module)
//{
// if (boost::python::override override = get_override("onLoadModule"))
// return override(module);
//
// return debugEvent::onLoadModule(module);
//}
//
///////////////////////////////////////////////////////////////////////////////////
//
//ULONG debugEventWrap::onUnloadModule(const dbgModuleClass &module)
//{
// if (boost::python::override override = get_override("onUnloadModule"))
// return override(module);
//
// return debugEvent::onUnloadModule(module);
//}
//
///////////////////////////////////////////////////////////////////////////////////

View File

@ -1,54 +1,169 @@
/////////////////////////////////////////////////////////////////////////////////
// Load/Unload module events
// user-customizing debug event handler
/////////////////////////////////////////////////////////////////////////////////
#include <set>
#include "dbgeventcb.h"
#include "dbgmodule.h"
#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
#include <boost/interprocess/sync/scoped_lock.hpp>
/////////////////////////////////////////////////////////////////////////////////
interface debugEvent
class debugEvent : public DebugBaseEventCallbacks
{
public:
debugEvent();
virtual ~debugEvent();
virtual ULONG onLoadModule(const dbgModuleClass &/* module */)
{
return DEBUG_STATUS_NO_CHANGE;
}
virtual ULONG onUnloadModule(const dbgModuleClass &/* module */)
{
return DEBUG_STATUS_NO_CHANGE;
}
virtual ULONG onLoadModule(const dbgModuleClass &/* module */) = 0;
// call from debug engine
static ULONG moduleLoaded(__in ULONG64 addr);
static ULONG moduleUnloaded(__in ULONG64 addr);
virtual ULONG onUnloadModule(const dbgModuleClass &/* module */) = 0;
virtual ULONG onChangeSessionStatus( ULONG status ) = 0;
virtual ULONG onChangeDebugeeState() = 0;
private:
typedef std::set<debugEvent *> modCallbacksColl;
static modCallbacksColl modCallbacks;
STDMETHOD_(ULONG, AddRef)() { return 1; }
STDMETHOD_(ULONG, Release)() { return 1; }
typedef boost::interprocess::interprocess_recursive_mutex modCallbacksLock;
static modCallbacksLock modCallbacksMtx;
typedef boost::interprocess::scoped_lock<modCallbacksLock> modCallbacksScopedLock;
STDMETHOD(GetInterestMask)(
__out PULONG Mask
);
STDMETHOD(LoadModule)(
__in ULONG64 ImageFileHandle,
__in ULONG64 BaseOffset,
__in ULONG ModuleSize,
__in PCSTR ModuleName,
__in PCSTR ImageName,
__in ULONG CheckSum,
__in ULONG TimeDateStamp
);
STDMETHOD(UnloadModule)(
__in PCSTR ImageBaseName,
__in ULONG64 BaseOffset
);
STDMETHOD(SessionStatus)(
__in ULONG Status
);
STDMETHOD(ChangeDebuggeeState)(
__in ULONG Flags,
__in ULONG64 Argument );
private:
IDebugClient *m_debugClient;
};
// python wrapper for debugEvent
struct debugEventWrap : debugEvent, boost::python::wrapper<debugEvent>
/////////////////////////////////////////////////////////////////////////////////
class debugEventWrap : public boost::python::wrapper<debugEvent>, public debugEvent
{
ULONG onLoadModule(const dbgModuleClass &module);
ULONG onLoadModuleDef(const dbgModuleClass &module)
{
return debugEvent::onLoadModule(module);
public:
ULONG onLoadModule(const dbgModuleClass &module) {
return handler<const dbgModuleClass &>("onLoadModule", module );
}
ULONG onUnloadModule(const dbgModuleClass &module);
ULONG onUnloadModuleDef(const dbgModuleClass &module)
ULONG onUnloadModule(const dbgModuleClass &module) {
return handler<const dbgModuleClass &>("onUnloadModule", module );
}
ULONG onChangeSessionStatus( ULONG status ) {
return handler( "onChangeSessionStatus", status );
}
ULONG onChangeDebugeeState() {
return handler( "onChangeDebugeeState" );
}
private:
template<typename Arg1Type>
ULONG handler( const char* handlerName, Arg1Type arg1 )
{
return debugEvent::onUnloadModule(module);
if (boost::python::override pythonHandler = get_override( handlerName ))
return pythonHandler(arg1);
return DEBUG_STATUS_NO_CHANGE;
}
ULONG handler( const char* handlerName )
{
if (boost::python::override pythonHandler = get_override( handlerName ))
return pythonHandler();
return DEBUG_STATUS_NO_CHANGE;
}
};
/////////////////////////////////////////////////////////////////////////////////
//
//#include <set>
//
//#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
//#include <boost/interprocess/sync/scoped_lock.hpp>
//
//class debugEvent
//{
// debugEvent();
// virtual ~debugEvent();
//
// virtual ULONG onLoadModule(const dbgModuleClass &/* module */)
// {
// return DEBUG_STATUS_NO_CHANGE;
// }
//
// virtual ULONG onUnloadModule(const dbgModuleClass &/* module */)
// {
// return DEBUG_STATUS_NO_CHANGE;
// }
//
// virtual ULONG onChangeSessionState( ULONG state )
// {
// return DEBUG_STATUS_NO_CHANGE;
// }
//
//
// // call from debug engine
// static ULONG moduleLoaded(__in ULONG64 addr);
// static ULONG moduleUnloaded(__in ULONG64 addr);
// static ULONG sessionStatus(__in ULONG status );
//
//private:
//
// typedef std::set<debugEvent *> modCallbacksColl;
// static modCallbacksColl modCallbacks;
//
//
// //typedef boost::interprocess::interprocess_recursive_mutex modCallbacksLock;
// //static modCallbacksLock modCallbacksMtx;
// //typedef boost::interprocess::scoped_lock<modCallbacksLock> modCallbacksScopedLock;
//};
//
//// python wrapper for debugEvent
//struct debugEventWrap : debugEvent, boost::python::wrapper<debugEvent>
//{
// ULONG onLoadModule(const dbgModuleClass &module);
// ULONG onLoadModuleDef(const dbgModuleClass &module)
// {
// return debugEvent::onLoadModule(module);
// }
//
// ULONG onUnloadModule(const dbgModuleClass &module);
// ULONG onUnloadModuleDef(const dbgModuleClass &module)
// {
// return debugEvent::onUnloadModule(module);
// }
//};
//
///////////////////////////////////////////////////////////////////////////////////

View File

@ -13,26 +13,14 @@
DbgEventCallbacksManager::DbgEventCallbacksManager( IDebugClient *client )
{
m_debugClient = client;
m_debugClient->AddRef();
HRESULT hres;
try {
m_debugClient = client;
m_debugClient->AddRef();
hres = m_debugClient->SetEventCallbacks(this);
if (FAILED(hres))
throw DbgException( "IDebugClient::SetEventCallbacks" );
}
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" );
}
hres = m_debugClient->SetEventCallbacks(this);
if (FAILED(hres))
throw DbgException( "IDebugClient::SetEventCallbacks" );
}
///////////////////////////////////////////////////////////////////////////////////
@ -46,6 +34,7 @@ DbgEventCallbacksManager::~DbgEventCallbacksManager()
}
}
///////////////////////////////////////////////////////////////////////////////////
HRESULT DbgEventCallbacksManager::GetInterestMask(
@ -54,9 +43,9 @@ HRESULT DbgEventCallbacksManager::GetInterestMask(
{
*Mask =
DEBUG_EVENT_CHANGE_SYMBOL_STATE |
DEBUG_EVENT_BREAKPOINT |
DEBUG_EVENT_LOAD_MODULE |
DEBUG_EVENT_UNLOAD_MODULE;
DEBUG_EVENT_BREAKPOINT;
// DEBUG_EVENT_LOAD_MODULE |
// DEBUG_EVENT_UNLOAD_MODULE
return S_OK;
}
@ -93,7 +82,7 @@ HRESULT DbgEventCallbacksManager::ChangeSymbolState(
return S_OK;
}
return S_OK;
return DEBUG_STATUS_NO_CHANGE;
}
///////////////////////////////////////////////////////////////////////////////////
@ -106,42 +95,59 @@ HRESULT DbgEventCallbacksManager::Breakpoint(
}
///////////////////////////////////////////////////////////////////////////////////
HRESULT DbgEventCallbacksManager::LoadModule(
__in ULONG64 ImageFileHandle,
__in ULONG64 BaseOffset,
__in ULONG ModuleSize,
__in PCSTR ModuleName,
__in PCSTR ImageName,
__in ULONG CheckSum,
__in ULONG TimeDateStamp
)
{
try
{
return debugEvent::moduleLoaded(BaseOffset);
}
catch (std::exception &)
{
}
return DEBUG_STATUS_NO_CHANGE;
}
///////////////////////////////////////////////////////////////////////////////////
HRESULT DbgEventCallbacksManager::UnloadModule(
__in PCSTR ImageBaseName,
__in ULONG64 BaseOffset
)
{
try
{
return debugEvent::moduleUnloaded(BaseOffset);
}
catch (std::exception &)
{
}
return DEBUG_STATUS_NO_CHANGE;
}
///////////////////////////////////////////////////////////////////////////////////
//
//HRESULT DbgEventCallbacksManager::LoadModule(
// __in ULONG64 ImageFileHandle,
// __in ULONG64 BaseOffset,
// __in ULONG ModuleSize,
// __in PCSTR ModuleName,
// __in PCSTR ImageName,
// __in ULONG CheckSum,
// __in ULONG TimeDateStamp
//)
//{
// try
// {
// return debugEvent::moduleLoaded(BaseOffset);
// }
// catch (std::exception &)
// {
// }
// return DEBUG_STATUS_NO_CHANGE;
//}
//
/////////////////////////////////////////////////////////////////////////////////////
//
//HRESULT DbgEventCallbacksManager::UnloadModule(
// __in PCSTR ImageBaseName,
// __in ULONG64 BaseOffset
//)
//{
// try
// {
// return debugEvent::moduleUnloaded(BaseOffset);
// }
// catch (std::exception &)
// {
// }
// return DEBUG_STATUS_NO_CHANGE;
//}
//
/////////////////////////////////////////////////////////////////////////////////////
//
//HRESULT DbgEventCallbacksManager::SessionStatus(
// __in ULONG status
//)
//{
// try
// {
// return debugEvent::sessionStatus( status );
// }
// catch( std::exception& )
// {
// }
//
// return DEBUG_STATUS_NO_CHANGE;
//}
//
/////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,6 +1,8 @@
#pragma once
#include <dbgeng.h>
//////////////////////////////////////////////////////////////////////////////
// monitoring and processing debug events
@ -36,7 +38,7 @@ private:
__in PDEBUG_BREAKPOINT Bp
);
STDMETHOD(LoadModule)(
/* STDMETHOD(LoadModule)(
__in ULONG64 ImageFileHandle,
__in ULONG64 BaseOffset,
__in ULONG ModuleSize,
@ -51,6 +53,10 @@ private:
__in ULONG64 BaseOffset
);
STDMETHOD(SessionStatus)(
__in ULONG status
); */
private:
IDebugClient *m_debugClient;
};

View File

@ -27,6 +27,7 @@
#include "dbgevent.h"
#include "dbgbreak.h"
#include "dbgio.h"
#include "intbase.h"
//////////////////////////////////////////////////////////////////////////////
@ -211,6 +212,7 @@ BOOST_PYTHON_MODULE( pykd )
boost::python::def( "delSynSymbolsMask", &delSyntheticSymbolsMask,
"Delete synthetic symbols by mask of module and symbol name");
boost::python::class_<TypeInfo>( "typeInfo",
"Class representing non-primitive type info: structure, union, etc. attributes is a fields of non-primitive type" )
.def(boost::python::init<std::string,std::string>( boost::python::args("module", "type"), "constructor" ) )
@ -258,7 +260,7 @@ BOOST_PYTHON_MODULE( pykd )
.def("data", &TypedVar::data,
"Return raw string object with data stream" )
.def("__getattr__", &TypedVar::getFieldWrap,
"Return field of structure as a object attribute" )
"Return field of structure as an object attribute" )
.def("__str__", &TypedVar::print,
"Return a nice string represention: print names and offsets of fields" );
@ -337,10 +339,10 @@ BOOST_PYTHON_MODULE( pykd )
boost::python::class_<debugEventWrap, boost::noncopyable>( "debugEvent",
"Base class for debug events handlers" )
.def( "onLoadModule", &debugEvent::onLoadModule, &debugEventWrap::onLoadModuleDef,
.def( "onLoadModule", &debugEventWrap::onLoadModule,
"Load module event. Parameter is instance of dbgModuleClass. "
"For ignore event method must return DEBUG_STATUS_NO_CHANGE value" )
.def( "onUnloadModule", &debugEvent::onUnloadModule, &debugEventWrap::onUnloadModuleDef,
.def( "onUnloadModule", &debugEventWrap::onUnloadModule,
"Unload module event. Parameter is instance of dbgModuleClass. "
"For ignore event method must return DEBUG_STATUS_NO_CHANGE value" );
@ -377,6 +379,102 @@ BOOST_PYTHON_MODULE( pykd )
boost::python::register_exception_translator<IndexException>( &IndexException::translate);
boost::python::register_exception_translator<MemoryException>( &MemoryException::translate );
boost::python::class_<intBase>(
"intBase",
"intBase")
.def( boost::python::init<>() )
.def( boost::python::init<ULONG64>( boost::python::args("value"), "constructor" ) )
.def( "value", &intBase::value )
.def( int_( boost::python::self ) )
//.def( boost::python::self = long() )
.def( boost::python::self + long() )
.def( long() + boost::python::self )
.def( boost::python::self += long() )
.def( boost::python::self + boost::python::self )
.def( boost::python::self += boost::python::self )
.def( boost::python::self - long() )
.def( long() - boost::python::self )
.def( boost::python::self -= long() )
.def( boost::python::self - boost::python::self )
.def( boost::python::self -= boost::python::self )
.def( boost::python::self * long() )
.def( long() * boost::python::self )
.def( boost::python::self *= long() )
.def( boost::python::self * boost::python::self )
.def( boost::python::self *= boost::python::self )
.def( boost::python::self / long() )
.def( long() / boost::python::self )
.def( boost::python::self /= long() )
.def( boost::python::self / boost::python::self )
.def( boost::python::self /= boost::python::self )
.def( boost::python::self % long() )
.def( long() % boost::python::self )
.def( boost::python::self %= long() )
.def( boost::python::self % boost::python::self )
.def( boost::python::self %= boost::python::self )
.def( boost::python::self & long() )
.def( long() & boost::python::self )
.def( boost::python::self &= long() )
.def( boost::python::self & boost::python::self )
.def( boost::python::self &= boost::python::self )
.def( boost::python::self | long() )
.def( long() | boost::python::self )
.def( boost::python::self |= long() )
.def( boost::python::self | boost::python::self )
.def( boost::python::self |= boost::python::self )
.def( boost::python::self ^ long() )
.def( long() ^ boost::python::self )
.def( boost::python::self ^= long() )
.def( boost::python::self ^ boost::python::self )
.def( boost::python::self ^= boost::python::self )
.def( boost::python::self << long() )
.def( boost::python::self <<= long() )
.def( boost::python::self >> long() )
.def( boost::python::self >>= long() )
.def( boost::python::self < long() )
.def( boost::python::self < boost::python::self )
.def( boost::python::self <= long() )
.def( boost::python::self <= boost::python::self )
.def( boost::python::self == long() )
.def( boost::python::self == boost::python::self )
.def( boost::python::self >= long() )
.def( boost::python::self >= boost::python::self )
.def( boost::python::self > long() )
.def( boost::python::self > boost::python::self )
.def( boost::python::self != long() )
.def( boost::python::self != boost::python::self )
.def( ~boost::python::self )
.def( !boost::python::self )
.def( "__str__", &intBase::str )
.def( "__hex__", &intBase::hex );
boost::python::class_<cpuReg, boost::python::bases<intBase> >(
"cpuReg",
"CPU regsiter class",
boost::python::no_init )
.def( boost::python::init<std::string>(boost::python::args("name"), "constructor" ) )
.def( "name", &cpuReg::name, "The name of the regsiter" )
.def( "beLive", &cpuReg::beLive, "Turn the object to live: its value will be following thr target register value" );
// debug status
DEF_PY_CONST(DEBUG_STATUS_NO_CHANGE);
@ -636,6 +734,9 @@ DbgExt::~DbgExt()
if ( client4 )
client4->Release();
if ( client5 )
client5->Release();
if ( control )
control->Release();

View File

@ -8,6 +8,52 @@ using namespace std;
///////////////////////////////////////////////////////////////////////////////////
cpuReg::cpuReg( std::string regName )
{
m_name = regName;
m_lived = false;
reloadValue();
}
///////////////////////////////////////////////////////////////////////////////////
void cpuReg::reloadValue() const
{
HRESULT hres;
ULONG registerIndex = 0;
hres = dbgExt->registers->GetIndexByName( m_name.c_str(), &registerIndex );
if ( FAILED( hres ) )
throw DbgException( "IDebugRegister::GetIndexByName failed" );
DEBUG_VALUE debugValue;
hres = dbgExt->registers->GetValue( registerIndex, &debugValue );
if ( FAILED( hres ) )
throw DbgException( "IDebugRegister::GetValue failed" );
switch( debugValue.Type )
{
case DEBUG_VALUE_INT8:
m_value = debugValue.I8;
break;
case DEBUG_VALUE_INT16:
m_value = debugValue.I16;
break;
case DEBUG_VALUE_INT32:
m_value = debugValue.I32;
break;
case DEBUG_VALUE_INT64:
m_value = debugValue.I64;
break;
}
}
///////////////////////////////////////////////////////////////////////////////////
boost::python::object
loadRegister( const std::string &registerName )
{

View File

@ -1,6 +1,43 @@
#pragma once
#include <string>
#include <list>
#include "intbase.h"
/////////////////////////////////////////////////////////////////////////////////
class cpuReg : public intBase {
public :
cpuReg( std::string regName );
std::string
name() const {
return m_name;
}
void beLive() {
m_lived = true;
}
ULONG64 value() const
{
if ( m_lived )
reloadValue();
return intBase::value();
}
private:
void reloadValue() const;
std::string m_name;
bool m_lived;
};
/////////////////////////////////////////////////////////////////////////////////

View File

@ -267,303 +267,3 @@ sizeofType( const std::string &moduleName, const std::string &typeName );
///////////////////////////////////////////////////////////////////////////////////
//public:
//
// typedVarClass() : m_addr(0)
// {}
//
// typedVarClass( const TypeInfo &typeInfo, ULONG64 addr) :
// m_typeInfo( typeInfo ),
// m_addr( addr )
// {}
//
// ULONG64
// getAddress() const {
// return m_addr;
// }
//
// //virtual void
// //printField( const TypeInfo::TypeField &field, std::stringstream &sstr ) const override;
//
// //virtual void
// //printSelf( std::stringstream &sstr ) const override
// //{
// // sstr << std::hex << "0x" << getAddress() << std::dec << " ";
// //}
//
//private:
//
// TypeInfo m_typeInfo;
//
// ULONG64 m_addr;
//};
///////////////////////////////////////////////////////////////////////////////////
//
//boost::python::object
//loadTypedVar( const std::string &moduleName, const std::string &typeName, ULONG64 address );
//
//boost::python::object
//loadTypedVarList( ULONG64 address, const std::string &moduleName, const std::string &typeName, const std::string &listEntryName );
//
//boost::python::object
//loadTypedVarArray( ULONG64 address, const std::string &moduleName, const std::string &typeName, long number );
//
//boost::python::object
//containingRecord( ULONG64 address, const std::string &moduleName, const std::string &typeName, const std::string &fieldName );
//
//boost::python::object
//getTypeClass( const std::string &moduleName, const std::string &typeName );
//
//ULONG
//sizeofType( const std::string &moduleName, const std::string &typeName );
//
//
///////////////////////////////////////////////////////////////////////////////////
//
//class TypeInfo {
//
//public:
//
// template< typename TTypeInfo>
// struct TypeFieldT {
// ULONG size;
// ULONG offset;
// TTypeInfo type;
// std::string name;
//
// TypeFieldT( const std::string &name_, const TTypeInfo &type_, ULONG size_, ULONG offset_ ) :
// name( name_ ),
// size( size_ ),
// offset( offset_ ),
// type( type_ )
// {}
// };
//
// struct TypeName {
// std::string module;
// std::string symbol;
//
// TypeName( const std::string &module_, const std::string &symbol_ ) :
// module( module_ ),
// symbol( symbol_ )
// {}
//
// bool
// operator < ( const TypeName &typeName ) const {
//
// if ( typeName.module < module )
// return true;
//
// if ( typeName.module > module )
// return false;
//
// return typeName.symbol < symbol;
// }
//
// };
//
// typedef TypeFieldT<TypeInfo> TypeField;
//
// typedef std::map<TypeName, TypeInfo> TypeInfoMap;
//
// typedef std::list<TypeField> TypeFieldList;
//
//public:
//
// TypeInfo() :
// m_size( 0 ),
// m_baseType( false ),
// m_pointer( false )
// {}
//
// TypeInfo( const std::string &typeName ) :
// m_size( 0 ),
// m_baseType( false ),
// m_pointer( false ),
// m_typeName( typeName )
// {}
//
// boost::python::object
// load( ULONG64 targetAddr, PVOID cacheBuffer = NULL, ULONG offset = 0 ) const;
//
// boost::python::object
// build( ULONG offset = 0 ) const;
//
// ULONG64
// size() const
// {
// return m_size;
// }
//
// const std::string&
// name() const
// {
// return m_typeName;
// }
//
// const TypeFieldList&
// getFields() const {
// return m_fields;
// }
//
// bool
// isComplex() const {
// return !m_baseType;
// }
//
// bool
// isPtr() const {
// return m_pointer;
// }
//
// static const TypeInfo*
// get( const std::string &moduleName, const std::string &typeName );
//
//private:
//
// static TypeInfoMap g_typeInfoCache;
//
// boost::python::object
// loadBaseType( PVOID addr ) const;
//
// boost::python::object
// ptrLoader( PVOID addr ) const {
// if ( is64bitSystem() )
// return boost::python::object( *(PULONG64)addr );
// else
// return boost::python::object( addr64( *(PULONG)addr ) );
// }
//
// void
// setupBaseType();
//
// static bool
// getById( const std::string &moduleName, ULONG typeId, TypeInfo& typeInfo );
//
//private:
//
// bool m_baseType;
// bool m_pointer;
// TypeFieldList m_fields;
// std::string m_typeName;
// ULONG m_size;
//};
//
///////////////////////////////////////////////////////////////////////////////////
//
//class typeClass
//{
//public:
//
// typeClass()
// : m_offset(0)
// {
// }
//
// typeClass(
// const TypeInfo &typeInfo,
// ULONG offset
// ) : m_typeInfo(typeInfo)
// , m_offset(offset)
// {
// }
//
// // sizeof(TYPE)
// ULONG size() const
// {
// return (ULONG)m_typeInfo.size();
// }
//
// void setPyObj( const boost::python::object &obj )
// {
// m_pyobj = obj;
// }
//
// // TypeInfo getter
// TypeInfo &getTypeInfo()
// {
// return m_typeInfo;
// }
// const TypeInfo &getTypeInfo() const
// {
// return m_typeInfo;
// }
//
// // boost::python::object getter
// boost::python::object &getPyObj()
// {
// return m_pyobj;
// }
// const boost::python::object &getPyObj() const
// {
// return m_pyobj;
// }
//
// std::string print() const;
//
// virtual void printField(
// const TypeInfo::TypeField &field,
// std::stringstream &sstr
// ) const
// {
// // no data - nothing print
// }
// virtual void printSelf(
// std::stringstream &sstr
// ) const
// {
// // no data - nothing print
// }
//
// // field offset getter/setter
// ULONG getOffset() const { return m_offset; }
//
//private:
// TypeInfo m_typeInfo;
// ULONG m_offset;
// boost::python::object m_pyobj;
//};
//
///////////////////////////////////////////////////////////////////////////////////
//
//class typedVarClass : public typeClass {
//
//public:
//
// typedVarClass() : m_addr(0)
// {}
//
// typedVarClass( const TypeInfo &typeInfo, ULONG offset, ULONG64 addr) :
// typeClass( typeInfo, offset ),
// m_addr( addr )
// {}
//
// ULONG64
// getAddress() const {
// return m_addr;
// }
//
// virtual void
// printField( const TypeInfo::TypeField &field, std::stringstream &sstr ) const override;
//
// virtual void
// printSelf( std::stringstream &sstr ) const override
// {
// sstr << std::hex << "0x" << getAddress() << std::dec << " ";
// }
//
//private:
//
// ULONG64 m_addr;
//};
//
///////////////////////////////////////////////////////////////////////////////////

View File

@ -151,7 +151,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dbgeng.lib"
AdditionalDependencies="dbgeng.lib dbghelp.lib"
OutputFile="$(OutDir)\$(ProjectName).pyd"
LinkIncremental="2"
AdditionalLibraryDirectories="&quot;$(DBG_SDK_ROOT)\lib\amd64&quot;;&quot;$(PYTHON_ROOT)\x64\libs&quot;;&quot;$(BOOST_ROOT)\stage64\lib&quot;"
@ -311,7 +311,7 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="dbgeng.lib"
AdditionalDependencies="dbgeng.lib dbghelp.lib"
OutputFile="$(OutDir)\$(ProjectName).pyd"
LinkIncremental="1"
AdditionalLibraryDirectories="&quot;$(DBG_SDK_ROOT)\lib\amd64&quot;;&quot;$(PYTHON_ROOT)\x64\libs&quot;;&quot;$(BOOST_ROOT)\stage64\lib&quot;"
@ -550,6 +550,10 @@
RelativePath=".\dbgtype.h"
>
</File>
<File
RelativePath=".\intbase.h"
>
</File>
<File
RelativePath=".\resource.h"
>