mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-19 19:13:22 +08:00
[0.2.x] added : module obejcts cache
git-svn-id: https://pykd.svn.codeplex.com/svn@81471 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
b7a7f97ea4
commit
00faeae705
@ -1,6 +1,7 @@
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "eventhandler.h"
|
||||
#include "module.h"
|
||||
|
||||
namespace pykd {
|
||||
|
||||
@ -56,6 +57,15 @@ DEBUG_CALLBACK_RESULT EventHandlerImpl::OnBreakpoint( ULONG bpId )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEBUG_CALLBACK_RESULT EventHandlerImpl::OnModuleUnload( ULONG64 offset, const std::string &name )
|
||||
{
|
||||
Module::onUnloadModule( offset );
|
||||
|
||||
return DebugCallbackNoChange;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}; // namespace pykd
|
||||
|
||||
|
||||
|
@ -132,6 +132,8 @@ private:
|
||||
|
||||
virtual DEBUG_CALLBACK_RESULT OnBreakpoint( ULONG bpId );
|
||||
|
||||
virtual DEBUG_CALLBACK_RESULT OnModuleUnload( ULONG64 offset, const std::string &name );
|
||||
|
||||
private:
|
||||
|
||||
typedef std::map<ULONG, python::object> BpMap;
|
||||
|
@ -8,12 +8,58 @@ namespace pykd {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ModulePtr Module::loadModuleByName( const std::string &moduleName ) {
|
||||
return ModulePtr( new Module( moduleName ) );
|
||||
Module::ModuleList Module::m_moduleList;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ModulePtr Module::loadModuleByName( const std::string &moduleName )
|
||||
{
|
||||
|
||||
ModuleList::iterator it;
|
||||
for ( it = m_moduleList.begin(); it != m_moduleList.end(); ++it )
|
||||
{
|
||||
if ( (*it)->m_name == moduleName )
|
||||
return *it;
|
||||
}
|
||||
|
||||
ModulePtr modPtr = ModulePtr( new Module( moduleName ) );
|
||||
|
||||
m_moduleList.push_back( modPtr );
|
||||
|
||||
return modPtr;
|
||||
};
|
||||
|
||||
ModulePtr Module::loadModuleByOffset( ULONG64 offset ) {
|
||||
return ModulePtr( new Module( offset ) );
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ModulePtr Module::loadModuleByOffset( ULONG64 offset )
|
||||
{
|
||||
ModuleList::iterator it;
|
||||
for ( it = m_moduleList.begin(); it != m_moduleList.end(); ++it )
|
||||
{
|
||||
if ( (*it)->m_base <= offset && offset < (*it)->m_base + (*it)->m_size )
|
||||
return *it;
|
||||
}
|
||||
|
||||
ModulePtr modPtr = ModulePtr( new Module( offset ) );
|
||||
|
||||
m_moduleList.push_back( modPtr );
|
||||
|
||||
return modPtr;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Module::onUnloadModule( ULONG64 offset )
|
||||
{
|
||||
ModuleList::iterator it;
|
||||
for ( it = m_moduleList.begin(); it != m_moduleList.end(); ++it )
|
||||
{
|
||||
if ( (*it)->m_base == offset )
|
||||
{
|
||||
m_moduleList.erase( it );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -24,6 +24,14 @@ public:
|
||||
static
|
||||
ModulePtr loadModuleByOffset( ULONG64 offset );
|
||||
|
||||
static
|
||||
void onUnloadModule( ULONG64 offset );
|
||||
|
||||
private:
|
||||
|
||||
typedef std::list<ModulePtr> ModuleList;
|
||||
static ModuleList m_moduleList;
|
||||
|
||||
public:
|
||||
|
||||
Module(const std::string &name );
|
||||
|
Loading…
Reference in New Issue
Block a user