mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-29 20:03:33 +08:00
[0.1.x] cleaned project
git-svn-id: https://pykd.svn.codeplex.com/svn@69712 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
1eea32e3cf
commit
7329a9f7bc
@ -1,162 +1,162 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
//#include <boost/format.hpp>
|
||||||
|
//
|
||||||
#include "dbgbreak.h"
|
//#include "dbgbreak.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "pyaux.h"
|
//#include "pyaux.h"
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
dbgBreakpointClass::breakpointMap dbgBreakpointClass::m_breakMap;
|
//dbgBreakpointClass::breakpointMap dbgBreakpointClass::m_breakMap;
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
HRESULT dbgBreakpointClass::onBreakpointEvnet( IDebugBreakpoint* bp )
|
//HRESULT dbgBreakpointClass::onBreakpointEvnet( IDebugBreakpoint* bp )
|
||||||
{
|
//{
|
||||||
PyThread_StateSave pyThreadSave;
|
// PyThread_StateSave pyThreadSave;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
breakpointMap::iterator it = m_breakMap.find( bp );
|
// breakpointMap::iterator it = m_breakMap.find( bp );
|
||||||
if ( it != m_breakMap.end() )
|
// if ( it != m_breakMap.end() )
|
||||||
{
|
// {
|
||||||
boost::python::object &callback = it->second->m_callback;
|
// boost::python::object &callback = it->second->m_callback;
|
||||||
if (!callback.is_none())
|
// if (!callback.is_none())
|
||||||
return boost::python::extract<HRESULT>( callback() );
|
// return boost::python::extract<HRESULT>( callback() );
|
||||||
|
//
|
||||||
return DEBUG_STATUS_BREAK;
|
// return DEBUG_STATUS_BREAK;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
catch(...)
|
// catch(...)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return DEBUG_STATUS_NO_CHANGE;
|
// return DEBUG_STATUS_NO_CHANGE;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
dbgBreakpointClass::dbgBreakpointClass( ULONG64 offset, boost::python::object &callback )
|
//dbgBreakpointClass::dbgBreakpointClass( ULONG64 offset, boost::python::object &callback )
|
||||||
: m_offset(offset)
|
// : m_offset(offset)
|
||||||
, m_callback(callback)
|
// , m_callback(callback)
|
||||||
, m_breakpoint(NULL)
|
// , m_breakpoint(NULL)
|
||||||
{
|
//{
|
||||||
set();
|
// set();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
dbgBreakpointClass::dbgBreakpointClass( ULONG64 offset)
|
//dbgBreakpointClass::dbgBreakpointClass( ULONG64 offset)
|
||||||
: m_offset(offset)
|
// : m_offset(offset)
|
||||||
, m_breakpoint(NULL)
|
// , m_breakpoint(NULL)
|
||||||
{
|
//{
|
||||||
// m_callback is None, see dbgBreakpointClass::onBreakpointEvnet
|
// // m_callback is None, see dbgBreakpointClass::onBreakpointEvnet
|
||||||
set();
|
// set();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
dbgBreakpointClass::~dbgBreakpointClass()
|
//dbgBreakpointClass::~dbgBreakpointClass()
|
||||||
{
|
//{
|
||||||
remove();
|
// remove();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
bool
|
//bool
|
||||||
dbgBreakpointClass::set()
|
//dbgBreakpointClass::set()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
if ( m_breakpoint )
|
// if ( m_breakpoint )
|
||||||
return true;
|
// return true;
|
||||||
|
//
|
||||||
hres = dbgExt->control->AddBreakpoint( DEBUG_BREAKPOINT_CODE, DEBUG_ANY_ID, &m_breakpoint );
|
// hres = dbgExt->control->AddBreakpoint( DEBUG_BREAKPOINT_CODE, DEBUG_ANY_ID, &m_breakpoint );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::AddBreakpoint failed" );
|
// throw DbgException( "IDebugControl::AddBreakpoint failed" );
|
||||||
|
//
|
||||||
hres = m_breakpoint->SetOffset( m_offset );
|
// hres = m_breakpoint->SetOffset( m_offset );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugBreakpoint::SetOffset failed" );
|
// throw DbgException( "IDebugBreakpoint::SetOffset failed" );
|
||||||
|
//
|
||||||
hres = m_breakpoint->SetFlags( DEBUG_BREAKPOINT_ENABLED );
|
// hres = m_breakpoint->SetFlags( DEBUG_BREAKPOINT_ENABLED );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugBreakpoint::SetFlags failed" );
|
// throw DbgException( "IDebugBreakpoint::SetFlags failed" );
|
||||||
|
//
|
||||||
m_breakMap.insert( std::make_pair( m_breakpoint, this ) );
|
// m_breakMap.insert( std::make_pair( m_breakpoint, this ) );
|
||||||
|
//
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
catch( std::exception &e )
|
// catch( std::exception &e )
|
||||||
{
|
// {
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
}
|
// }
|
||||||
catch(...)
|
// catch(...)
|
||||||
{
|
// {
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
remove();
|
// remove();
|
||||||
|
//
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
dbgBreakpointClass::remove()
|
//dbgBreakpointClass::remove()
|
||||||
{
|
//{
|
||||||
if ( m_breakpoint )
|
// if ( m_breakpoint )
|
||||||
{
|
// {
|
||||||
dbgExt->control->RemoveBreakpoint( m_breakpoint );
|
// dbgExt->control->RemoveBreakpoint( m_breakpoint );
|
||||||
|
//
|
||||||
breakpointMap::iterator bp = m_breakMap.find( m_breakpoint );
|
// breakpointMap::iterator bp = m_breakMap.find( m_breakpoint );
|
||||||
if ( bp != m_breakMap.end() )
|
// if ( bp != m_breakMap.end() )
|
||||||
m_breakMap.erase( bp );
|
// m_breakMap.erase( bp );
|
||||||
|
//
|
||||||
m_breakpoint = NULL;
|
// m_breakpoint = NULL;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgBreakpointClass::print() const
|
//dbgBreakpointClass::print() const
|
||||||
{
|
//{
|
||||||
HRESULT status = S_OK;
|
// HRESULT status = S_OK;
|
||||||
|
//
|
||||||
try
|
// try
|
||||||
{
|
// {
|
||||||
if (!m_breakpoint)
|
// if (!m_breakpoint)
|
||||||
return "not set";
|
// return "not set";
|
||||||
|
//
|
||||||
DEBUG_BREAKPOINT_PARAMETERS params;
|
// DEBUG_BREAKPOINT_PARAMETERS params;
|
||||||
status = m_breakpoint->GetParameters(¶ms);
|
// status = m_breakpoint->GetParameters(¶ms);
|
||||||
if (FAILED(status))
|
// if (FAILED(status))
|
||||||
throw DbgException("IDebugBreakpoint::GetParameters failed");
|
// throw DbgException("IDebugBreakpoint::GetParameters failed");
|
||||||
|
//
|
||||||
boost::format fmt("%1$2d %2%%3% %4%:*** ");
|
// boost::format fmt("%1$2d %2%%3% %4%:*** ");
|
||||||
fmt % params.Id
|
// fmt % params.Id
|
||||||
% (params.Flags & DEBUG_BREAKPOINT_ENABLED ? 'e' : 'd')
|
// % (params.Flags & DEBUG_BREAKPOINT_ENABLED ? 'e' : 'd')
|
||||||
% 'u'
|
// % 'u'
|
||||||
% params.CurrentPassCount;
|
// % params.CurrentPassCount;
|
||||||
|
//
|
||||||
return fmt.str();
|
// return fmt.str();
|
||||||
}
|
// }
|
||||||
catch (std::exception & e)
|
// catch (std::exception & e)
|
||||||
{
|
// {
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
}
|
// }
|
||||||
catch (...)
|
// catch (...)
|
||||||
{
|
// {
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return "";
|
// return "";
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
@ -1,46 +1,46 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <map>
|
//#include <map>
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class dbgBreakpointClass {
|
//class dbgBreakpointClass {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
dbgBreakpointClass( ULONG64 offset, boost::python::object &callback );
|
// dbgBreakpointClass( ULONG64 offset, boost::python::object &callback );
|
||||||
dbgBreakpointClass( ULONG64 offset );
|
// dbgBreakpointClass( ULONG64 offset );
|
||||||
|
//
|
||||||
~dbgBreakpointClass();
|
// ~dbgBreakpointClass();
|
||||||
|
//
|
||||||
bool
|
// bool
|
||||||
set();
|
// set();
|
||||||
|
//
|
||||||
void
|
// void
|
||||||
remove();
|
// remove();
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
print() const;
|
// print() const;
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
ULONG64 m_offset;
|
// ULONG64 m_offset;
|
||||||
|
//
|
||||||
IDebugBreakpoint *m_breakpoint;
|
// IDebugBreakpoint *m_breakpoint;
|
||||||
|
//
|
||||||
boost::python::object m_callback;
|
// boost::python::object m_callback;
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
typedef std::map<IDebugBreakpoint*, dbgBreakpointClass*> breakpointMap;
|
// typedef std::map<IDebugBreakpoint*, dbgBreakpointClass*> breakpointMap;
|
||||||
static breakpointMap m_breakMap;
|
// static breakpointMap m_breakMap;
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
static HRESULT onBreakpointEvnet( IDebugBreakpoint* bp );
|
// static HRESULT onBreakpointEvnet( IDebugBreakpoint* bp );
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
102
pykd/dbgclient.h
102
pykd/dbgclient.h
@ -1,53 +1,53 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgeventcb.h"
|
//#include "dbgeventcb.h"
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class dbgClient {
|
//class dbgClient {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
dbgClient()
|
// dbgClient()
|
||||||
{
|
// {
|
||||||
m_callbacks = NULL;
|
// m_callbacks = NULL;
|
||||||
|
//
|
||||||
IDebugClient4 *client = NULL;
|
// IDebugClient4 *client = NULL;
|
||||||
DebugCreate( __uuidof(IDebugClient4), (void **)&client );
|
// DebugCreate( __uuidof(IDebugClient4), (void **)&client );
|
||||||
|
//
|
||||||
m_ext = new DbgExt( client );
|
// m_ext = new DbgExt( client );
|
||||||
|
//
|
||||||
client->Release();
|
// client->Release();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
~dbgClient()
|
// ~dbgClient()
|
||||||
{
|
// {
|
||||||
removeEventsMgr();
|
// removeEventsMgr();
|
||||||
|
//
|
||||||
delete m_ext;
|
// delete m_ext;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void startEventsMgr() {
|
// void startEventsMgr() {
|
||||||
|
//
|
||||||
m_callbacks = new DbgEventCallbacksManager( m_ext->client );
|
// m_callbacks = new DbgEventCallbacksManager( m_ext->client );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void removeEventsMgr() {
|
// void removeEventsMgr() {
|
||||||
|
//
|
||||||
if ( m_callbacks )
|
// if ( m_callbacks )
|
||||||
{
|
// {
|
||||||
delete m_callbacks;
|
// delete m_callbacks;
|
||||||
m_callbacks = NULL;
|
// m_callbacks = NULL;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
DbgExt *m_ext;
|
// DbgExt *m_ext;
|
||||||
DbgEventCallbacksManager *m_callbacks;
|
// DbgEventCallbacksManager *m_callbacks;
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
extern dbgClient g_dbgClient;
|
//extern dbgClient g_dbgClient;
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
262
pykd/dbgcmd.cpp
262
pykd/dbgcmd.cpp
@ -1,132 +1,132 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
//
|
||||||
#include <boost/format.hpp>
|
//#include <boost/format.hpp>
|
||||||
|
//
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgcmd.h"
|
//#include "dbgcmd.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "dbgio.h"
|
//#include "dbgio.h"
|
||||||
#include "dbgsystem.h"
|
//#include "dbgsystem.h"
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgCommand( const std::string &command )
|
//dbgCommand( const std::string &command )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
OutputReader outReader( dbgExt->client );
|
// OutputReader outReader( dbgExt->client );
|
||||||
{
|
// {
|
||||||
PyThread_StateRestore pyThreadRestore;
|
// PyThread_StateRestore pyThreadRestore;
|
||||||
|
//
|
||||||
hres = dbgExt->control->Execute( DEBUG_OUTCTL_THIS_CLIENT, command.c_str(), 0 );
|
// hres = dbgExt->control->Execute( DEBUG_OUTCTL_THIS_CLIENT, command.c_str(), 0 );
|
||||||
}
|
// }
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::Execute failed" );
|
// throw DbgException( "IDebugControl::Execute failed" );
|
||||||
|
//
|
||||||
return std::string( outReader.Line() );
|
// return std::string( outReader.Line() );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
dbgExtensionClass::dbgExtensionClass( const char* path ) : m_path(path)
|
//dbgExtensionClass::dbgExtensionClass( const char* path ) : m_path(path)
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
hres = dbgExt->control->AddExtension( path, 0, &m_handle );
|
// hres = dbgExt->control->AddExtension( path, 0, &m_handle );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::AddExtension failed" );
|
// throw DbgException( "IDebugControl::AddExtension failed" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
dbgExtensionClass::~dbgExtensionClass()
|
//dbgExtensionClass::~dbgExtensionClass()
|
||||||
{
|
//{
|
||||||
if ( m_handle )
|
// if ( m_handle )
|
||||||
dbgExt->control->RemoveExtension( m_handle );
|
// dbgExt->control->RemoveExtension( m_handle );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgExtensionClass::call( const std::string &command, const std::string params )
|
//dbgExtensionClass::call( const std::string &command, const std::string params )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
OutputReader outReader( dbgExt->client );
|
// OutputReader outReader( dbgExt->client );
|
||||||
|
//
|
||||||
hres = dbgExt->control->CallExtension( m_handle, command.c_str(), params.c_str() );
|
// hres = dbgExt->control->CallExtension( m_handle, command.c_str(), params.c_str() );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::CallExtension failed" );
|
// throw DbgException( "IDebugControl::CallExtension failed" );
|
||||||
|
//
|
||||||
return std::string( outReader.Line() );
|
// return std::string( outReader.Line() );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgExtensionClass::print() const
|
//dbgExtensionClass::print() const
|
||||||
{
|
//{
|
||||||
return m_handle ? m_path : "";
|
// return m_handle ? m_path : "";
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
evaluate( const std::string &expression )
|
//evaluate( const std::string &expression )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
ULONG64 value = 0;
|
// ULONG64 value = 0;
|
||||||
|
//
|
||||||
DEBUG_VALUE debugValue = {};
|
// DEBUG_VALUE debugValue = {};
|
||||||
ULONG remainderIndex = 0;
|
// ULONG remainderIndex = 0;
|
||||||
|
//
|
||||||
if ( is64bitSystem() )
|
// if ( is64bitSystem() )
|
||||||
{
|
// {
|
||||||
hres = dbgExt->control->Evaluate(
|
// hres = dbgExt->control->Evaluate(
|
||||||
expression.c_str(),
|
// expression.c_str(),
|
||||||
DEBUG_VALUE_INT64,
|
// DEBUG_VALUE_INT64,
|
||||||
&debugValue,
|
// &debugValue,
|
||||||
&remainderIndex );
|
// &remainderIndex );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::Evaluate failed" );
|
// throw DbgException( "IDebugControl::Evaluate failed" );
|
||||||
|
//
|
||||||
if ( remainderIndex == expression.length() )
|
// if ( remainderIndex == expression.length() )
|
||||||
value = debugValue.I64;
|
// value = debugValue.I64;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
hres = dbgExt->control->Evaluate(
|
// hres = dbgExt->control->Evaluate(
|
||||||
expression.c_str(),
|
// expression.c_str(),
|
||||||
DEBUG_VALUE_INT32,
|
// DEBUG_VALUE_INT32,
|
||||||
&debugValue,
|
// &debugValue,
|
||||||
&remainderIndex );
|
// &remainderIndex );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::Evaluate failed" );
|
// throw DbgException( "IDebugControl::Evaluate failed" );
|
||||||
|
//
|
||||||
if ( remainderIndex == expression.length() )
|
// if ( remainderIndex == expression.length() )
|
||||||
value = debugValue.I32;
|
// value = debugValue.I32;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return value;
|
// return value;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
breakin()
|
//breakin()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
{
|
// {
|
||||||
PyThread_StateRestore pyThreadRestore;
|
// PyThread_StateRestore pyThreadRestore;
|
||||||
hres = dbgExt->control->SetInterrupt( DEBUG_INTERRUPT_ACTIVE );
|
// hres = dbgExt->control->SetInterrupt( DEBUG_INTERRUPT_ACTIVE );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::SetInterrupt" );
|
// throw DbgException( "IDebugControl::SetInterrupt" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
168
pykd/dbgcmd.h
168
pykd/dbgcmd.h
@ -1,86 +1,86 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
#include <map>
|
//#include <map>
|
||||||
#include "pyaux.h"
|
//#include "pyaux.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgCommand( const std::string &command );
|
//dbgCommand( const std::string &command );
|
||||||
|
//
|
||||||
template <ULONG status>
|
//template <ULONG status>
|
||||||
void
|
//void
|
||||||
setExecutionStatus()
|
//setExecutionStatus()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
hres = dbgExt->control->SetExecutionStatus( status );
|
// hres = dbgExt->control->SetExecutionStatus( status );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::SetExecutionStatus failed" );
|
// throw DbgException( "IDebugControl::SetExecutionStatus failed" );
|
||||||
|
//
|
||||||
ULONG currentStatus;
|
// ULONG currentStatus;
|
||||||
|
//
|
||||||
do {
|
// do {
|
||||||
|
//
|
||||||
{
|
// {
|
||||||
PyThread_StateRestore pyThreadRestore;
|
// PyThread_StateRestore pyThreadRestore;
|
||||||
hres = dbgExt->control->WaitForEvent( 0, INFINITE );
|
// hres = dbgExt->control->WaitForEvent( 0, INFINITE );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
{
|
// {
|
||||||
if (E_UNEXPECTED == hres)
|
// if (E_UNEXPECTED == hres)
|
||||||
throw WaitEventException();
|
// throw WaitEventException();
|
||||||
|
//
|
||||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
// throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
hres = dbgExt->control->GetExecutionStatus( ¤tStatus );
|
// hres = dbgExt->control->GetExecutionStatus( ¤tStatus );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::GetExecutionStatus failed" );
|
// throw DbgException( "IDebugControl::GetExecutionStatus failed" );
|
||||||
|
//
|
||||||
} while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE );
|
// } while( currentStatus != DEBUG_STATUS_BREAK && currentStatus != DEBUG_STATUS_NO_DEBUGGEE );
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class dbgExtensionClass {
|
//class dbgExtensionClass {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
dbgExtensionClass() :
|
// dbgExtensionClass() :
|
||||||
m_handle( NULL )
|
// m_handle( NULL )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
dbgExtensionClass( const char* path );
|
// dbgExtensionClass( const char* path );
|
||||||
|
//
|
||||||
~dbgExtensionClass();
|
// ~dbgExtensionClass();
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
call( const std::string &command, const std::string param );
|
// call( const std::string &command, const std::string param );
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
print() const;
|
// print() const;
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
ULONG64 m_handle;
|
// ULONG64 m_handle;
|
||||||
std::string m_path;
|
// std::string m_path;
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
evaluate( const std::string &expression );
|
//evaluate( const std::string &expression );
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
breakin();
|
//breakin();
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
198
pykd/dbgdump.cpp
198
pykd/dbgdump.cpp
@ -1,101 +1,101 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgdump.h"
|
//#include "dbgdump.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "dbgeventcb.h"
|
//#include "dbgeventcb.h"
|
||||||
#include "dbgsystem.h"
|
//#include "dbgsystem.h"
|
||||||
#include "dbgcmd.h"
|
//#include "dbgcmd.h"
|
||||||
#include "dbgclient.h"
|
//#include "dbgclient.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
static
|
//static
|
||||||
bool dbgStarted = false;
|
//bool dbgStarted = false;
|
||||||
|
//
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
dbgLoadDump( const std::wstring &fileName )
|
//dbgLoadDump( const std::wstring &fileName )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
if ( dbgStarted || isWindbgExt() )
|
// if ( dbgStarted || isWindbgExt() )
|
||||||
throw DbgException( "debugger is alread attached" );
|
// throw DbgException( "debugger is alread attached" );
|
||||||
|
//
|
||||||
g_dbgClient.startEventsMgr();
|
// g_dbgClient.startEventsMgr();
|
||||||
|
//
|
||||||
hres = dbgExt->client4->OpenDumpFileWide( fileName.c_str(), NULL );
|
// hres = dbgExt->client4->OpenDumpFileWide( fileName.c_str(), NULL );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
// throw DbgException( "IDebugClient4::OpenDumpFileWide failed" );
|
||||||
|
//
|
||||||
hres = dbgExt->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
// hres = dbgExt->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
// throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
|
//
|
||||||
dbgStarted = true;
|
// dbgStarted = true;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
startProcess( const std::wstring &processName )
|
//startProcess( const std::wstring &processName )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
if ( dbgStarted || isWindbgExt() )
|
// if ( dbgStarted || isWindbgExt() )
|
||||||
throw DbgException( "debugger is alread attached" );
|
// throw DbgException( "debugger is alread attached" );
|
||||||
|
//
|
||||||
g_dbgClient.startEventsMgr();
|
// g_dbgClient.startEventsMgr();
|
||||||
|
//
|
||||||
ULONG opt;
|
// ULONG opt;
|
||||||
hres = dbgExt->control->GetEngineOptions( &opt );
|
// hres = dbgExt->control->GetEngineOptions( &opt );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::GetEngineOptions failed" );
|
// throw DbgException( "IDebugControl::GetEngineOptions failed" );
|
||||||
|
//
|
||||||
opt |= DEBUG_ENGOPT_INITIAL_BREAK;
|
// opt |= DEBUG_ENGOPT_INITIAL_BREAK;
|
||||||
hres = dbgExt->control->SetEngineOptions( opt );
|
// hres = dbgExt->control->SetEngineOptions( opt );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::SetEngineOptions failed" );
|
// throw DbgException( "IDebugControl::SetEngineOptions failed" );
|
||||||
|
//
|
||||||
std::vector< std::wstring::value_type> cmdLine( processName.size() + 1 );
|
// std::vector< std::wstring::value_type> cmdLine( processName.size() + 1 );
|
||||||
wcscpy_s( &cmdLine[0], cmdLine.size(), processName.c_str() );
|
// wcscpy_s( &cmdLine[0], cmdLine.size(), processName.c_str() );
|
||||||
|
//
|
||||||
hres = dbgExt->client4->CreateProcessWide( 0, &cmdLine[0], DEBUG_PROCESS | DETACHED_PROCESS );
|
// hres = dbgExt->client4->CreateProcessWide( 0, &cmdLine[0], DEBUG_PROCESS | DETACHED_PROCESS );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient4::CreateProcessWide failed" );
|
// throw DbgException( "IDebugClient4::CreateProcessWide failed" );
|
||||||
|
//
|
||||||
hres = dbgExt->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
// hres = dbgExt->control->WaitForEvent(DEBUG_WAIT_DEFAULT, INFINITE);
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::WaitForEvent failed" );
|
// throw DbgException( "IDebugControl::WaitForEvent failed" );
|
||||||
|
//
|
||||||
dbgStarted = true;
|
// dbgStarted = true;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
attachProcess( ULONG processId )
|
//attachProcess( ULONG processId )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
hres = dbgExt->client->AttachProcess( 0, processId, 0 );
|
// hres = dbgExt->client->AttachProcess( 0, processId, 0 );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient::AttachProcess failed" );
|
// throw DbgException( "IDebugClient::AttachProcess failed" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
attachKernel( const std::wstring param )
|
//attachKernel( const std::wstring param )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
hres = dbgExt->client5->AttachKernelWide( DEBUG_ATTACH_KERNEL_CONNECTION, param.c_str() );
|
// hres = dbgExt->client5->AttachKernelWide( DEBUG_ATTACH_KERNEL_CONNECTION, param.c_str() );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient5::AttachKernelWide failed" );
|
// throw DbgException( "IDebugClient5::AttachKernelWide failed" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
@ -1,19 +1,19 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
dbgLoadDump( const std::wstring &dumpName );
|
//dbgLoadDump( const std::wstring &dumpName );
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
startProcess( const std::wstring &processName );
|
//startProcess( const std::wstring &processName );
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
attachProcess( ULONG processId );
|
//attachProcess( ULONG processId );
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
attachKernel( const std::wstring param );
|
//attachKernel( const std::wstring param );
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -3,215 +3,215 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "dbgevent.h"
|
//#include "dbgevent.h"
|
||||||
#include "dbgio.h"
|
//#include "dbgio.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "pyaux.h"
|
//#include "pyaux.h"
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
debugEvent::debugEvent()
|
//debugEvent::debugEvent()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
hres = dbgExt->client->CreateClient( &m_debugClient );
|
// hres = dbgExt->client->CreateClient( &m_debugClient );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugClient::CreateClient" );
|
// throw DbgException( "IDebugClient::CreateClient" );
|
||||||
|
//
|
||||||
hres = m_debugClient->SetEventCallbacks(this);
|
// hres = m_debugClient->SetEventCallbacks(this);
|
||||||
if (FAILED(hres))
|
// if (FAILED(hres))
|
||||||
throw DbgException( "IDebugClient::SetEventCallbacks" );
|
// throw DbgException( "IDebugClient::SetEventCallbacks" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
debugEvent::~debugEvent()
|
//debugEvent::~debugEvent()
|
||||||
{
|
//{
|
||||||
m_debugClient->SetEventCallbacks( NULL );
|
// m_debugClient->SetEventCallbacks( NULL );
|
||||||
|
//
|
||||||
m_debugClient->Release();
|
// m_debugClient->Release();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
HRESULT debugEvent::GetInterestMask(
|
//HRESULT debugEvent::GetInterestMask(
|
||||||
__out PULONG Mask
|
// __out PULONG Mask
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
*Mask = 0;
|
// *Mask = 0;
|
||||||
|
//
|
||||||
*Mask |= DEBUG_EVENT_LOAD_MODULE;
|
// *Mask |= DEBUG_EVENT_LOAD_MODULE;
|
||||||
*Mask |= DEBUG_EVENT_UNLOAD_MODULE;
|
// *Mask |= DEBUG_EVENT_UNLOAD_MODULE;
|
||||||
*Mask |= DEBUG_EVENT_SESSION_STATUS;
|
// *Mask |= DEBUG_EVENT_SESSION_STATUS;
|
||||||
*Mask |= DEBUG_EVENT_EXCEPTION;
|
// *Mask |= DEBUG_EVENT_EXCEPTION;
|
||||||
*Mask |= DEBUG_EVENT_BREAKPOINT;
|
// *Mask |= DEBUG_EVENT_BREAKPOINT;
|
||||||
|
//
|
||||||
return S_OK;
|
// return S_OK;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
HRESULT debugEvent::Breakpoint(
|
//HRESULT debugEvent::Breakpoint(
|
||||||
__in PDEBUG_BREAKPOINT Bp
|
// __in PDEBUG_BREAKPOINT Bp
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
boost::python::dict bpParameters;
|
// boost::python::dict bpParameters;
|
||||||
|
//
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
ULONG Value = 0;
|
// ULONG Value = 0;
|
||||||
ULONG Value2 = 0;
|
// ULONG Value2 = 0;
|
||||||
ULONG64 Value64 = 0;
|
// ULONG64 Value64 = 0;
|
||||||
std::string str;
|
// std::string str;
|
||||||
|
//
|
||||||
#define _ADD_BP_ULONG(x) \
|
//#define _ADD_BP_ULONG(x) \
|
||||||
hres = Bp->Get##x(&Value); \
|
// hres = Bp->Get##x(&Value); \
|
||||||
BOOST_ASSERT( SUCCEEDED( hres ) || hres == E_NOINTERFACE ); \
|
// BOOST_ASSERT( SUCCEEDED( hres ) || hres == E_NOINTERFACE ); \
|
||||||
if (SUCCEEDED( hres )) \
|
// if (SUCCEEDED( hres )) \
|
||||||
bpParameters[#x] = Value;
|
// bpParameters[#x] = Value;
|
||||||
|
//
|
||||||
#define _ADD_BP_ULONG2(x, n1, n2) \
|
//#define _ADD_BP_ULONG2(x, n1, n2) \
|
||||||
hres = Bp->Get##x(&Value, &Value2); \
|
// hres = Bp->Get##x(&Value, &Value2); \
|
||||||
BOOST_ASSERT( SUCCEEDED( hres ) || hres == E_NOINTERFACE ); \
|
// BOOST_ASSERT( SUCCEEDED( hres ) || hres == E_NOINTERFACE ); \
|
||||||
if (SUCCEEDED( hres )) \
|
// if (SUCCEEDED( hres )) \
|
||||||
{ \
|
// { \
|
||||||
bpParameters[n1] = Value; bpParameters[n2] = Value2; \
|
// bpParameters[n1] = Value; bpParameters[n2] = Value2; \
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
#define _ADD_BP_ULONG64(x) \
|
//#define _ADD_BP_ULONG64(x) \
|
||||||
hres = Bp->Get##x(&Value64); \
|
// hres = Bp->Get##x(&Value64); \
|
||||||
BOOST_ASSERT( SUCCEEDED( hres ) || hres == E_NOINTERFACE ); \
|
// BOOST_ASSERT( SUCCEEDED( hres ) || hres == E_NOINTERFACE ); \
|
||||||
if (SUCCEEDED( hres )) \
|
// if (SUCCEEDED( hres )) \
|
||||||
bpParameters[#x] = Value64;
|
// bpParameters[#x] = Value64;
|
||||||
|
//
|
||||||
#define _ADD_BP_STR(x) \
|
//#define _ADD_BP_STR(x) \
|
||||||
Value = 0; \
|
// Value = 0; \
|
||||||
Bp->Get##x(NULL, 0, &Value); \
|
// Bp->Get##x(NULL, 0, &Value); \
|
||||||
if (Value) \
|
// if (Value) \
|
||||||
{ \
|
// { \
|
||||||
str.resize(Value + 1); \
|
// str.resize(Value + 1); \
|
||||||
BOOST_VERIFY( SUCCEEDED( \
|
// BOOST_VERIFY( SUCCEEDED( \
|
||||||
Bp->Get##x(&str[0], (ULONG)str.size(), NULL) \
|
// Bp->Get##x(&str[0], (ULONG)str.size(), NULL) \
|
||||||
) ); \
|
// ) ); \
|
||||||
if (!str.empty()) bpParameters[#x] = str.c_str(); \
|
// if (!str.empty()) bpParameters[#x] = str.c_str(); \
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
_ADD_BP_ULONG(Id);
|
// _ADD_BP_ULONG(Id);
|
||||||
_ADD_BP_ULONG2(Type, "BreakType", "ProcType");
|
// _ADD_BP_ULONG2(Type, "BreakType", "ProcType");
|
||||||
_ADD_BP_ULONG(Flags);
|
// _ADD_BP_ULONG(Flags);
|
||||||
_ADD_BP_ULONG64(Offset);
|
// _ADD_BP_ULONG64(Offset);
|
||||||
_ADD_BP_ULONG2(DataParameters, "Size", "AccessType");
|
// _ADD_BP_ULONG2(DataParameters, "Size", "AccessType");
|
||||||
_ADD_BP_ULONG(PassCount);
|
// _ADD_BP_ULONG(PassCount);
|
||||||
_ADD_BP_ULONG(CurrentPassCount);
|
// _ADD_BP_ULONG(CurrentPassCount);
|
||||||
_ADD_BP_ULONG(MatchThreadId);
|
// _ADD_BP_ULONG(MatchThreadId);
|
||||||
_ADD_BP_STR(Command);
|
// _ADD_BP_STR(Command);
|
||||||
_ADD_BP_STR(OffsetExpression);
|
// _ADD_BP_STR(OffsetExpression);
|
||||||
|
//
|
||||||
#undef _ADD_BP_ULONG
|
//#undef _ADD_BP_ULONG
|
||||||
#undef _ADD_BP_ULONG2
|
//#undef _ADD_BP_ULONG2
|
||||||
#undef _ADD_BP_ULONG64
|
//#undef _ADD_BP_ULONG64
|
||||||
#undef _ADD_BP_STR
|
//#undef _ADD_BP_STR
|
||||||
|
//
|
||||||
PyThread_StateSave pyThreadSave;
|
// PyThread_StateSave pyThreadSave;
|
||||||
return onException(bpParameters);
|
// return onException(bpParameters);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
HRESULT debugEvent::Exception(
|
//HRESULT debugEvent::Exception(
|
||||||
__in PEXCEPTION_RECORD64 Exception,
|
// __in PEXCEPTION_RECORD64 Exception,
|
||||||
__in ULONG FirstChance
|
// __in ULONG FirstChance
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
boost::python::list exceptParams;
|
// boost::python::list exceptParams;
|
||||||
boost::python::dict exceptData;
|
// boost::python::dict exceptData;
|
||||||
|
//
|
||||||
// build list of parameters
|
// // build list of parameters
|
||||||
for (ULONG i = 0; i < Exception->NumberParameters; ++i)
|
// for (ULONG i = 0; i < Exception->NumberParameters; ++i)
|
||||||
exceptParams.append(Exception->ExceptionInformation[i]);
|
// exceptParams.append(Exception->ExceptionInformation[i]);
|
||||||
|
//
|
||||||
// build dict of exception data
|
// // build dict of exception data
|
||||||
#define _ADD_EXCEPTION_ENTRY(x) exceptData[#x] = Exception->Exception##x
|
//#define _ADD_EXCEPTION_ENTRY(x) exceptData[#x] = Exception->Exception##x
|
||||||
_ADD_EXCEPTION_ENTRY(Code);
|
// _ADD_EXCEPTION_ENTRY(Code);
|
||||||
_ADD_EXCEPTION_ENTRY(Flags);
|
// _ADD_EXCEPTION_ENTRY(Flags);
|
||||||
_ADD_EXCEPTION_ENTRY(Record);
|
// _ADD_EXCEPTION_ENTRY(Record);
|
||||||
_ADD_EXCEPTION_ENTRY(Address);
|
// _ADD_EXCEPTION_ENTRY(Address);
|
||||||
#undef _ADD_EXCEPTION_ENTRY
|
//#undef _ADD_EXCEPTION_ENTRY
|
||||||
|
//
|
||||||
exceptData["Parameters"] = exceptParams;
|
// exceptData["Parameters"] = exceptParams;
|
||||||
|
//
|
||||||
exceptData["FirstChance"] = (0 != FirstChance);
|
// exceptData["FirstChance"] = (0 != FirstChance);
|
||||||
|
//
|
||||||
PyThread_StateSave pyThreadSave;
|
// PyThread_StateSave pyThreadSave;
|
||||||
return onException(exceptData);
|
// return onException(exceptData);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
HRESULT debugEvent::LoadModule(
|
//HRESULT debugEvent::LoadModule(
|
||||||
__in ULONG64 ImageFileHandle,
|
// __in ULONG64 ImageFileHandle,
|
||||||
__in ULONG64 BaseOffset,
|
// __in ULONG64 BaseOffset,
|
||||||
__in ULONG ModuleSize,
|
// __in ULONG ModuleSize,
|
||||||
__in PCSTR ModuleName,
|
// __in PCSTR ModuleName,
|
||||||
__in PCSTR ImageName,
|
// __in PCSTR ImageName,
|
||||||
__in ULONG CheckSum,
|
// __in ULONG CheckSum,
|
||||||
__in ULONG TimeDateStamp
|
// __in ULONG TimeDateStamp
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
std::auto_ptr<OutputReader> silentMode( new OutputReader(dbgExt->client) );
|
// std::auto_ptr<OutputReader> silentMode( new OutputReader(dbgExt->client) );
|
||||||
|
//
|
||||||
ULONG64 moduleBase;
|
// ULONG64 moduleBase;
|
||||||
ULONG moduleSize;
|
// ULONG moduleSize;
|
||||||
std::string moduleName;
|
// std::string moduleName;
|
||||||
|
//
|
||||||
queryModuleParams(BaseOffset, moduleName, moduleBase, moduleSize);
|
// queryModuleParams(BaseOffset, moduleName, moduleBase, moduleSize);
|
||||||
dbgModuleClass module(moduleName, moduleBase, moduleSize);
|
// dbgModuleClass module(moduleName, moduleBase, moduleSize);
|
||||||
silentMode.reset();
|
// silentMode.reset();
|
||||||
|
//
|
||||||
PyThread_StateSave pyThreadSave;
|
// PyThread_StateSave pyThreadSave;
|
||||||
return onLoadModule( module );
|
// return onLoadModule( module );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
HRESULT debugEvent::UnloadModule(
|
//HRESULT debugEvent::UnloadModule(
|
||||||
__in PCSTR ImageBaseName,
|
// __in PCSTR ImageBaseName,
|
||||||
__in ULONG64 BaseOffset
|
// __in ULONG64 BaseOffset
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
std::auto_ptr<OutputReader> silentMode( new OutputReader(dbgExt->client) );
|
// std::auto_ptr<OutputReader> silentMode( new OutputReader(dbgExt->client) );
|
||||||
|
//
|
||||||
ULONG64 moduleBase;
|
// ULONG64 moduleBase;
|
||||||
ULONG moduleSize;
|
// ULONG moduleSize;
|
||||||
std::string moduleName;
|
// std::string moduleName;
|
||||||
|
//
|
||||||
queryModuleParams(BaseOffset, moduleName, moduleBase, moduleSize);
|
// queryModuleParams(BaseOffset, moduleName, moduleBase, moduleSize);
|
||||||
dbgModuleClass module(moduleName, moduleBase, moduleSize);
|
// dbgModuleClass module(moduleName, moduleBase, moduleSize);
|
||||||
silentMode.reset();
|
// silentMode.reset();
|
||||||
|
//
|
||||||
PyThread_StateSave pyThreadSave;
|
// PyThread_StateSave pyThreadSave;
|
||||||
return onUnloadModule( module );
|
// return onUnloadModule( module );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
HRESULT debugEvent::SessionStatus(
|
//HRESULT debugEvent::SessionStatus(
|
||||||
__in ULONG Status
|
// __in ULONG Status
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
PyThread_StateSave pyThreadSave;
|
// PyThread_StateSave pyThreadSave;
|
||||||
return onChangeSessionStatus( Status );
|
// return onChangeSessionStatus( Status );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
HRESULT debugEvent::ChangeDebuggeeState(
|
//HRESULT debugEvent::ChangeDebuggeeState(
|
||||||
__in ULONG Flags,
|
// __in ULONG Flags,
|
||||||
__in ULONG64 Argument
|
// __in ULONG64 Argument
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
PyThread_StateSave pyThreadSave;
|
// PyThread_StateSave pyThreadSave;
|
||||||
return onChangeDebugeeState();
|
// return onChangeDebugeeState();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
269
pykd/dbgevent.h
269
pykd/dbgevent.h
@ -1,191 +1,132 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////////
|
#pragma once
|
||||||
// user-customizing debug event handler
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#include "dbgeventcb.h"
|
|
||||||
#include "dbgmodule.h"
|
|
||||||
#include "pyaux.h"
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class debugEvent : public DebugBaseEventCallbacks
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
debugEvent();
|
|
||||||
|
|
||||||
virtual ~debugEvent();
|
|
||||||
|
|
||||||
virtual ULONG onBreakpoint(boost::python::dict &/*bpParameters*/) = 0;
|
|
||||||
|
|
||||||
virtual ULONG onException(boost::python::dict &/*exceptData*/) = 0;
|
|
||||||
|
|
||||||
virtual ULONG onLoadModule(const dbgModuleClass &/* module */) = 0;
|
|
||||||
|
|
||||||
virtual ULONG onUnloadModule(const dbgModuleClass &/* module */) = 0;
|
|
||||||
|
|
||||||
virtual ULONG onChangeSessionStatus( ULONG status ) = 0;
|
|
||||||
|
|
||||||
virtual ULONG onChangeDebugeeState() = 0;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
STDMETHOD_(ULONG, AddRef)() { return 1; }
|
|
||||||
STDMETHOD_(ULONG, Release)() { return 1; }
|
|
||||||
|
|
||||||
STDMETHOD(GetInterestMask)(
|
|
||||||
__out PULONG Mask
|
|
||||||
);
|
|
||||||
|
|
||||||
STDMETHOD(Breakpoint)(
|
|
||||||
__in PDEBUG_BREAKPOINT Bp
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
STDMETHOD(Exception)(
|
|
||||||
__in PEXCEPTION_RECORD64 Exception,
|
|
||||||
__in ULONG FirstChance
|
|
||||||
);
|
|
||||||
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class debugEventWrap : public boost::python::wrapper<debugEvent>, public debugEvent
|
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ULONG onBreakpoint(boost::python::dict &bpParameters) {
|
|
||||||
return handler<boost::python::dict &>("onBreakpoint", bpParameters);
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG onException(boost::python::dict &exceptData) {
|
|
||||||
return handler<boost::python::dict &>("onException", exceptData);
|
|
||||||
}
|
|
||||||
|
|
||||||
ULONG onLoadModule(const dbgModuleClass &module) {
|
|
||||||
return handler<const dbgModuleClass &>("onLoadModule", 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 )
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//// user-customizing debug event handler
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//#include <set>
|
//#include "dbgeventcb.h"
|
||||||
|
//#include "dbgmodule.h"
|
||||||
|
//#include "pyaux.h"
|
||||||
//
|
//
|
||||||
//#include <boost/interprocess/sync/interprocess_recursive_mutex.hpp>
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
//#include <boost/interprocess/sync/scoped_lock.hpp>
|
|
||||||
//
|
//
|
||||||
//class debugEvent
|
//class debugEvent : public DebugBaseEventCallbacks
|
||||||
//{
|
//{
|
||||||
|
//public:
|
||||||
|
//
|
||||||
// debugEvent();
|
// debugEvent();
|
||||||
|
//
|
||||||
// virtual ~debugEvent();
|
// virtual ~debugEvent();
|
||||||
//
|
//
|
||||||
// virtual ULONG onLoadModule(const dbgModuleClass &/* module */)
|
// virtual ULONG onBreakpoint(boost::python::dict &/*bpParameters*/) = 0;
|
||||||
// {
|
|
||||||
// return DEBUG_STATUS_NO_CHANGE;
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// virtual ULONG onUnloadModule(const dbgModuleClass &/* module */)
|
// virtual ULONG onException(boost::python::dict &/*exceptData*/) = 0;
|
||||||
// {
|
|
||||||
// return DEBUG_STATUS_NO_CHANGE;
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// virtual ULONG onChangeSessionState( ULONG state )
|
// virtual ULONG onLoadModule(const dbgModuleClass &/* module */) = 0;
|
||||||
// {
|
|
||||||
// return DEBUG_STATUS_NO_CHANGE;
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
|
// virtual ULONG onUnloadModule(const dbgModuleClass &/* module */) = 0;
|
||||||
//
|
//
|
||||||
// // call from debug engine
|
// virtual ULONG onChangeSessionStatus( ULONG status ) = 0;
|
||||||
// static ULONG moduleLoaded(__in ULONG64 addr);
|
//
|
||||||
// static ULONG moduleUnloaded(__in ULONG64 addr);
|
// virtual ULONG onChangeDebugeeState() = 0;
|
||||||
// static ULONG sessionStatus(__in ULONG status );
|
|
||||||
//
|
//
|
||||||
//private:
|
//private:
|
||||||
//
|
//
|
||||||
// typedef std::set<debugEvent *> modCallbacksColl;
|
// STDMETHOD_(ULONG, AddRef)() { return 1; }
|
||||||
// static modCallbacksColl modCallbacks;
|
// STDMETHOD_(ULONG, Release)() { return 1; }
|
||||||
|
//
|
||||||
|
// STDMETHOD(GetInterestMask)(
|
||||||
|
// __out PULONG Mask
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// STDMETHOD(Breakpoint)(
|
||||||
|
// __in PDEBUG_BREAKPOINT Bp
|
||||||
|
// );
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
// //typedef boost::interprocess::interprocess_recursive_mutex modCallbacksLock;
|
// STDMETHOD(Exception)(
|
||||||
// //static modCallbacksLock modCallbacksMtx;
|
// __in PEXCEPTION_RECORD64 Exception,
|
||||||
// //typedef boost::interprocess::scoped_lock<modCallbacksLock> modCallbacksScopedLock;
|
// __in ULONG FirstChance
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// 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)
|
//public:
|
||||||
// {
|
//
|
||||||
// return debugEvent::onLoadModule(module);
|
// ULONG onBreakpoint(boost::python::dict &bpParameters) {
|
||||||
|
// return handler<boost::python::dict &>("onBreakpoint", bpParameters);
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// ULONG onUnloadModule(const dbgModuleClass &module);
|
// ULONG onException(boost::python::dict &exceptData) {
|
||||||
// ULONG onUnloadModuleDef(const dbgModuleClass &module)
|
// return handler<boost::python::dict &>("onException", exceptData);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ULONG onLoadModule(const dbgModuleClass &module) {
|
||||||
|
// return handler<const dbgModuleClass &>("onLoadModule", 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;
|
||||||
// }
|
// }
|
||||||
//};
|
//};
|
||||||
//
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
@ -1,153 +1,153 @@
|
|||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "dbgeng.h"
|
//#include "dbgeng.h"
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgeventcb.h"
|
//#include "dbgeventcb.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "dbgmodule.h"
|
//#include "dbgmodule.h"
|
||||||
#include "dbgsynsym.h"
|
//#include "dbgsynsym.h"
|
||||||
#include "dbgbreak.h"
|
//#include "dbgbreak.h"
|
||||||
#include "dbgevent.h"
|
//#include "dbgevent.h"
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
DbgEventCallbacksManager::DbgEventCallbacksManager( IDebugClient *client )
|
|
||||||
{
|
|
||||||
m_debugClient = client;
|
|
||||||
m_debugClient->AddRef();
|
|
||||||
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
hres = m_debugClient->SetEventCallbacks(this);
|
|
||||||
if (FAILED(hres))
|
|
||||||
throw DbgException( "IDebugClient::SetEventCallbacks" );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
DbgEventCallbacksManager::~DbgEventCallbacksManager()
|
|
||||||
{
|
|
||||||
if ( m_debugClient )
|
|
||||||
{
|
|
||||||
m_debugClient->SetEventCallbacks( NULL );
|
|
||||||
m_debugClient->Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
HRESULT DbgEventCallbacksManager::GetInterestMask(
|
|
||||||
__out PULONG Mask
|
|
||||||
)
|
|
||||||
{
|
|
||||||
*Mask =
|
|
||||||
DEBUG_EVENT_CHANGE_SYMBOL_STATE |
|
|
||||||
DEBUG_EVENT_BREAKPOINT;
|
|
||||||
// DEBUG_EVENT_LOAD_MODULE |
|
|
||||||
// DEBUG_EVENT_UNLOAD_MODULE
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
HRESULT DbgEventCallbacksManager::ChangeSymbolState(
|
|
||||||
__in ULONG Flags,
|
|
||||||
__in ULONG64 Argument
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if ((DEBUG_CSS_LOADS & Flags))
|
|
||||||
{
|
|
||||||
if (Argument)
|
|
||||||
{
|
|
||||||
DEBUG_MODULE_PARAMETERS dbgModuleParameters;
|
|
||||||
HRESULT hres = dbgExt->symbols3->GetModuleParameters(
|
|
||||||
1,
|
|
||||||
&Argument,
|
|
||||||
0,
|
|
||||||
&dbgModuleParameters);
|
|
||||||
|
|
||||||
if (SUCCEEDED(hres))
|
|
||||||
{
|
|
||||||
ModuleInfo moduleInfo(dbgModuleParameters);
|
|
||||||
restoreSyntheticSymbolForModule(moduleInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
//// f.e. is case ".reload /f image.exe", if for image.exe no symbols
|
|
||||||
restoreSyntheticSymbolForAllModules();
|
|
||||||
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
return DEBUG_STATUS_NO_CHANGE;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
HRESULT DbgEventCallbacksManager::Breakpoint(
|
|
||||||
__in IDebugBreakpoint * bp
|
|
||||||
)
|
|
||||||
{
|
|
||||||
return dbgBreakpointClass::onBreakpointEvnet( bp );
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
//
|
//
|
||||||
//HRESULT DbgEventCallbacksManager::LoadModule(
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
// __in ULONG64 ImageFileHandle,
|
//
|
||||||
// __in ULONG64 BaseOffset,
|
//DbgEventCallbacksManager::DbgEventCallbacksManager( IDebugClient *client )
|
||||||
// __in ULONG ModuleSize,
|
|
||||||
// __in PCSTR ModuleName,
|
|
||||||
// __in PCSTR ImageName,
|
|
||||||
// __in ULONG CheckSum,
|
|
||||||
// __in ULONG TimeDateStamp
|
|
||||||
//)
|
|
||||||
//{
|
//{
|
||||||
// try
|
// m_debugClient = client;
|
||||||
// {
|
// m_debugClient->AddRef();
|
||||||
// return debugEvent::moduleLoaded(BaseOffset);
|
//
|
||||||
// }
|
// HRESULT hres;
|
||||||
// catch (std::exception &)
|
//
|
||||||
// {
|
// hres = m_debugClient->SetEventCallbacks(this);
|
||||||
// }
|
// if (FAILED(hres))
|
||||||
// return DEBUG_STATUS_NO_CHANGE;
|
// throw DbgException( "IDebugClient::SetEventCallbacks" );
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//HRESULT DbgEventCallbacksManager::UnloadModule(
|
//DbgEventCallbacksManager::~DbgEventCallbacksManager()
|
||||||
// __in PCSTR ImageBaseName,
|
//{
|
||||||
// __in ULONG64 BaseOffset
|
// if ( m_debugClient )
|
||||||
|
// {
|
||||||
|
// m_debugClient->SetEventCallbacks( NULL );
|
||||||
|
// m_debugClient->Release();
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//HRESULT DbgEventCallbacksManager::GetInterestMask(
|
||||||
|
// __out PULONG Mask
|
||||||
//)
|
//)
|
||||||
//{
|
//{
|
||||||
// try
|
// *Mask =
|
||||||
// {
|
// DEBUG_EVENT_CHANGE_SYMBOL_STATE |
|
||||||
// return debugEvent::moduleUnloaded(BaseOffset);
|
// DEBUG_EVENT_BREAKPOINT;
|
||||||
// }
|
//// DEBUG_EVENT_LOAD_MODULE |
|
||||||
// catch (std::exception &)
|
//// DEBUG_EVENT_UNLOAD_MODULE
|
||||||
// {
|
// return S_OK;
|
||||||
// }
|
|
||||||
// return DEBUG_STATUS_NO_CHANGE;
|
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
//HRESULT DbgEventCallbacksManager::SessionStatus(
|
//HRESULT DbgEventCallbacksManager::ChangeSymbolState(
|
||||||
// __in ULONG status
|
// __in ULONG Flags,
|
||||||
|
// __in ULONG64 Argument
|
||||||
//)
|
//)
|
||||||
//{
|
//{
|
||||||
// try
|
// if ((DEBUG_CSS_LOADS & Flags))
|
||||||
// {
|
// {
|
||||||
// return debugEvent::sessionStatus( status );
|
// if (Argument)
|
||||||
|
// {
|
||||||
|
// DEBUG_MODULE_PARAMETERS dbgModuleParameters;
|
||||||
|
// HRESULT hres = dbgExt->symbols3->GetModuleParameters(
|
||||||
|
// 1,
|
||||||
|
// &Argument,
|
||||||
|
// 0,
|
||||||
|
// &dbgModuleParameters);
|
||||||
|
//
|
||||||
|
// if (SUCCEEDED(hres))
|
||||||
|
// {
|
||||||
|
// ModuleInfo moduleInfo(dbgModuleParameters);
|
||||||
|
// restoreSyntheticSymbolForModule(moduleInfo);
|
||||||
// }
|
// }
|
||||||
// catch( std::exception& )
|
//
|
||||||
// {
|
// return S_OK;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //// f.e. is case ".reload /f image.exe", if for image.exe no symbols
|
||||||
|
// restoreSyntheticSymbolForAllModules();
|
||||||
|
//
|
||||||
|
// return S_OK;
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// return DEBUG_STATUS_NO_CHANGE;
|
// return DEBUG_STATUS_NO_CHANGE;
|
||||||
//}
|
//}
|
||||||
//
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//HRESULT DbgEventCallbacksManager::Breakpoint(
|
||||||
|
// __in IDebugBreakpoint * bp
|
||||||
|
//)
|
||||||
|
//{
|
||||||
|
// return dbgBreakpointClass::onBreakpointEvnet( bp );
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
////
|
||||||
|
////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;
|
||||||
|
////}
|
||||||
|
////
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1,64 +1,64 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <dbgeng.h>
|
//#include <dbgeng.h>
|
||||||
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
// monitoring and processing debug events
|
//// monitoring and processing debug events
|
||||||
class DbgEventCallbacksManager : public DebugBaseEventCallbacks
|
//class DbgEventCallbacksManager : public DebugBaseEventCallbacks
|
||||||
{
|
//{
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
DbgEventCallbacksManager( IDebugClient *client = NULL );
|
// DbgEventCallbacksManager( IDebugClient *client = NULL );
|
||||||
|
//
|
||||||
virtual ~DbgEventCallbacksManager();
|
// virtual ~DbgEventCallbacksManager();
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////////////
|
||||||
// IUnknown interface implementation
|
// // IUnknown interface implementation
|
||||||
|
//
|
||||||
STDMETHOD_(ULONG, AddRef)() { return 1; }
|
// STDMETHOD_(ULONG, AddRef)() { return 1; }
|
||||||
STDMETHOD_(ULONG, Release)() { return 1; }
|
// STDMETHOD_(ULONG, Release)() { return 1; }
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////////////
|
||||||
// IDebugEventCallbacks interface implementation
|
// // IDebugEventCallbacks interface implementation
|
||||||
|
//
|
||||||
STDMETHOD(GetInterestMask)(
|
// STDMETHOD(GetInterestMask)(
|
||||||
__out PULONG Mask
|
// __out PULONG Mask
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
STDMETHOD(ChangeSymbolState)(
|
// STDMETHOD(ChangeSymbolState)(
|
||||||
__in ULONG Flags,
|
// __in ULONG Flags,
|
||||||
__in ULONG64 Argument
|
// __in ULONG64 Argument
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
STDMETHOD(Breakpoint)(
|
// STDMETHOD(Breakpoint)(
|
||||||
__in PDEBUG_BREAKPOINT Bp
|
// __in PDEBUG_BREAKPOINT Bp
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
/* STDMETHOD(LoadModule)(
|
///* STDMETHOD(LoadModule)(
|
||||||
__in ULONG64 ImageFileHandle,
|
// __in ULONG64 ImageFileHandle,
|
||||||
__in ULONG64 BaseOffset,
|
// __in ULONG64 BaseOffset,
|
||||||
__in ULONG ModuleSize,
|
// __in ULONG ModuleSize,
|
||||||
__in PCSTR ModuleName,
|
// __in PCSTR ModuleName,
|
||||||
__in PCSTR ImageName,
|
// __in PCSTR ImageName,
|
||||||
__in ULONG CheckSum,
|
// __in ULONG CheckSum,
|
||||||
__in ULONG TimeDateStamp
|
// __in ULONG TimeDateStamp
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
STDMETHOD(UnloadModule)(
|
// STDMETHOD(UnloadModule)(
|
||||||
__in PCSTR ImageBaseName,
|
// __in PCSTR ImageBaseName,
|
||||||
__in ULONG64 BaseOffset
|
// __in ULONG64 BaseOffset
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
STDMETHOD(SessionStatus)(
|
// STDMETHOD(SessionStatus)(
|
||||||
__in ULONG status
|
// __in ULONG status
|
||||||
); */
|
// ); */
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
IDebugClient *m_debugClient;
|
// IDebugClient *m_debugClient;
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
@ -1,51 +1,51 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
// òèïû èñêëþ÷åíèé
|
//// òèïû èñêëþ÷åíèé
|
||||||
|
//
|
||||||
PyObject *baseExceptionType = NULL;
|
//PyObject *baseExceptionType = NULL;
|
||||||
PyObject *eventExceptionType = NULL;
|
//PyObject *eventExceptionType = NULL;
|
||||||
PyObject *typeExceptionType = NULL;
|
//PyObject *typeExceptionType = NULL;
|
||||||
PyObject *memoryExceptionType = NULL;
|
//PyObject *memoryExceptionType = NULL;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void DbgException::exceptionTranslate( const DbgException &e )
|
//void DbgException::exceptionTranslate( const DbgException &e )
|
||||||
{
|
//{
|
||||||
boost::python::object pyExcept(e);
|
// boost::python::object pyExcept(e);
|
||||||
|
//
|
||||||
PyErr_SetObject( baseExceptionType, pyExcept.ptr());
|
// PyErr_SetObject( baseExceptionType, pyExcept.ptr());
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void WaitEventException::exceptionTranslate( const WaitEventException &e )
|
//void WaitEventException::exceptionTranslate( const WaitEventException &e )
|
||||||
{
|
//{
|
||||||
boost::python::object pyExcept(e);
|
// boost::python::object pyExcept(e);
|
||||||
|
//
|
||||||
PyErr_SetObject( eventExceptionType, pyExcept.ptr());
|
// PyErr_SetObject( eventExceptionType, pyExcept.ptr());
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void TypeException::exceptionTranslate( const TypeException &e )
|
//void TypeException::exceptionTranslate( const TypeException &e )
|
||||||
{
|
//{
|
||||||
boost::python::object pyExcept(e);
|
// boost::python::object pyExcept(e);
|
||||||
|
//
|
||||||
PyErr_SetObject( typeExceptionType, pyExcept.ptr());
|
// PyErr_SetObject( typeExceptionType, pyExcept.ptr());
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void MemoryException::translate( const MemoryException &e )
|
//void MemoryException::translate( const MemoryException &e )
|
||||||
{
|
//{
|
||||||
boost::python::object pyExcept(e);
|
// boost::python::object pyExcept(e);
|
||||||
|
//
|
||||||
PyErr_SetObject( memoryExceptionType, pyExcept.ptr());
|
// PyErr_SetObject( memoryExceptionType, pyExcept.ptr());
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
258
pykd/dbgexcept.h
258
pykd/dbgexcept.h
@ -1,131 +1,131 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <exception>
|
//#include <exception>
|
||||||
#include <string>
|
//#include <string>
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class DbgException : public std::exception
|
//class DbgException : public std::exception
|
||||||
{
|
//{
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
DbgException( const std::string &desc ) :
|
// DbgException( const std::string &desc ) :
|
||||||
std::exception( desc.c_str() )
|
// std::exception( desc.c_str() )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
const char* getDesc() const {
|
// const char* getDesc() const {
|
||||||
return what();
|
// return what();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
static
|
// static
|
||||||
void
|
// void
|
||||||
exceptionTranslate(const DbgException &e );
|
// exceptionTranslate(const DbgException &e );
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
class WaitEventException : public DbgException
|
//class WaitEventException : public DbgException
|
||||||
{
|
//{
|
||||||
public:
|
//public:
|
||||||
WaitEventException()
|
// WaitEventException()
|
||||||
: DbgException( "none of the targets could generate events" )
|
// : DbgException( "none of the targets could generate events" )
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
static void exceptionTranslate(const WaitEventException &e);
|
// static void exceptionTranslate(const WaitEventException &e);
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class TypeException : public DbgException
|
//class TypeException : public DbgException
|
||||||
{
|
//{
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
TypeException() :
|
// TypeException() :
|
||||||
DbgException( "type operation invalid" )
|
// DbgException( "type operation invalid" )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
TypeException( const std::string &desc ) :
|
// TypeException( const std::string &desc ) :
|
||||||
DbgException( desc )
|
// DbgException( desc )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
static
|
// static
|
||||||
void
|
// void
|
||||||
exceptionTranslate(const TypeException &e );
|
// exceptionTranslate(const TypeException &e );
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class IndexException : public DbgException
|
//class IndexException : public DbgException
|
||||||
{
|
//{
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
IndexException() :
|
// IndexException() :
|
||||||
DbgException( "Index out of range" )
|
// DbgException( "Index out of range" )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
static
|
// static
|
||||||
void
|
// void
|
||||||
translate(const IndexException &e ) {
|
// translate(const IndexException &e ) {
|
||||||
PyErr_SetString(PyExc_IndexError, "Index out of range");
|
// PyErr_SetString(PyExc_IndexError, "Index out of range");
|
||||||
}
|
// }
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class MemoryException : public DbgException
|
//class MemoryException : public DbgException
|
||||||
{
|
//{
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
MemoryException( ULONG64 targetAddr ) :
|
// MemoryException( ULONG64 targetAddr ) :
|
||||||
m_targetAddress( targetAddr ),
|
// m_targetAddress( targetAddr ),
|
||||||
DbgException( MemoryException::DescMaker( targetAddr, false ).desc() )
|
// DbgException( MemoryException::DescMaker( targetAddr, false ).desc() )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
MemoryException( ULONG64 targetAddr, bool phyAddr ) :
|
// MemoryException( ULONG64 targetAddr, bool phyAddr ) :
|
||||||
m_targetAddress( targetAddr ),
|
// m_targetAddress( targetAddr ),
|
||||||
DbgException( MemoryException::DescMaker( targetAddr, phyAddr ).desc() )
|
// DbgException( MemoryException::DescMaker( targetAddr, phyAddr ).desc() )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
static
|
// static
|
||||||
void
|
// void
|
||||||
translate( const MemoryException &e );
|
// translate( const MemoryException &e );
|
||||||
|
//
|
||||||
ULONG64
|
// ULONG64
|
||||||
getAddress() const {
|
// getAddress() const {
|
||||||
return m_targetAddress;
|
// return m_targetAddress;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
ULONG64 m_targetAddress;
|
// ULONG64 m_targetAddress;
|
||||||
|
//
|
||||||
class DescMaker {
|
// class DescMaker {
|
||||||
public:
|
// public:
|
||||||
DescMaker( ULONG64 addr, bool phyAddr )
|
// DescMaker( ULONG64 addr, bool phyAddr )
|
||||||
{
|
// {
|
||||||
std::stringstream sstr;
|
// std::stringstream sstr;
|
||||||
if ( phyAddr )
|
// if ( phyAddr )
|
||||||
sstr << "Memory exception at 0x" << std::hex << addr << " target physical address";
|
// sstr << "Memory exception at 0x" << std::hex << addr << " target physical address";
|
||||||
else
|
// else
|
||||||
sstr << "Memory exception at 0x" << std::hex << addr << " target virtual address";
|
// sstr << "Memory exception at 0x" << std::hex << addr << " target virtual address";
|
||||||
m_desc = sstr.str();
|
// m_desc = sstr.str();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
const std::string&
|
// const std::string&
|
||||||
desc() const {
|
// desc() const {
|
||||||
return m_desc;
|
// return m_desc;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private:
|
// private:
|
||||||
std::string m_desc;
|
// std::string m_desc;
|
||||||
};
|
// };
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
extern PyObject *baseExceptionType;
|
//extern PyObject *baseExceptionType;
|
||||||
extern PyObject *eventExceptionType;
|
//extern PyObject *eventExceptionType;
|
||||||
extern PyObject *typeExceptionType;
|
//extern PyObject *typeExceptionType;
|
||||||
extern PyObject *memoryExceptionType;
|
//extern PyObject *memoryExceptionType;
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
2197
pykd/dbgext.cpp
2197
pykd/dbgext.cpp
File diff suppressed because it is too large
Load Diff
@ -1,43 +1,43 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <dbgeng.h>
|
//#include <dbgeng.h>
|
||||||
#include <dbghelp.h>
|
//#include <dbghelp.h>
|
||||||
|
//
|
||||||
class DbgExt {
|
//class DbgExt {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
IDebugClient *client;
|
// IDebugClient *client;
|
||||||
IDebugClient4 *client4;
|
// IDebugClient4 *client4;
|
||||||
IDebugClient5 *client5;
|
// IDebugClient5 *client5;
|
||||||
|
//
|
||||||
IDebugControl *control;
|
// IDebugControl *control;
|
||||||
IDebugControl4 *control4;
|
// IDebugControl4 *control4;
|
||||||
|
//
|
||||||
IDebugRegisters *registers;
|
// IDebugRegisters *registers;
|
||||||
|
//
|
||||||
IDebugSymbols *symbols;
|
// IDebugSymbols *symbols;
|
||||||
IDebugSymbols2 *symbols2;
|
// IDebugSymbols2 *symbols2;
|
||||||
IDebugSymbols3 *symbols3;
|
// IDebugSymbols3 *symbols3;
|
||||||
|
//
|
||||||
IDebugDataSpaces *dataSpaces;
|
// IDebugDataSpaces *dataSpaces;
|
||||||
IDebugDataSpaces4 *dataSpaces4;
|
// IDebugDataSpaces4 *dataSpaces4;
|
||||||
|
//
|
||||||
IDebugAdvanced2 *advanced2;
|
// IDebugAdvanced2 *advanced2;
|
||||||
|
//
|
||||||
IDebugSystemObjects *system;
|
// IDebugSystemObjects *system;
|
||||||
IDebugSystemObjects2 *system2;
|
// IDebugSystemObjects2 *system2;
|
||||||
|
//
|
||||||
DbgExt( IDebugClient4 *client );
|
// DbgExt( IDebugClient4 *client );
|
||||||
|
//
|
||||||
~DbgExt();
|
// ~DbgExt();
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
DbgExt *m_previosExt;
|
// DbgExt *m_previosExt;
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
extern DbgExt *dbgExt;
|
//extern DbgExt *dbgExt;
|
||||||
|
//
|
||||||
|
//
|
||||||
bool isWindbgExt();
|
//bool isWindbgExt();
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <iostream>
|
//#include <iostream>
|
||||||
#include <Fcntl.h>
|
//#include <Fcntl.h>
|
||||||
|
//
|
||||||
#include "dbgio.h"
|
//#include "dbgio.h"
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
|
//
|
||||||
using namespace std;
|
//using namespace std;
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void dbgPrint::dprint( const boost::python::object& obj, bool dml )
|
//void dbgPrint::dprint( const boost::python::object& obj, bool dml )
|
||||||
{
|
//{
|
||||||
std::wstring str = boost::python::extract<std::wstring>( obj );
|
// std::wstring str = boost::python::extract<std::wstring>( obj );
|
||||||
|
//
|
||||||
HRESULT hres = dbgExt->control4->ControlledOutputWide( dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL, str.c_str() );
|
// HRESULT hres = dbgExt->control4->ControlledOutputWide( dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL, str.c_str() );
|
||||||
|
//
|
||||||
std::wcout << str;
|
// std::wcout << str;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void dbgPrint::dprintln( const boost::python::object& obj, bool dml )
|
//void dbgPrint::dprintln( const boost::python::object& obj, bool dml )
|
||||||
{
|
//{
|
||||||
std::wstring str = boost::python::extract<std::wstring>( obj );
|
// std::wstring str = boost::python::extract<std::wstring>( obj );
|
||||||
str += L"\r\n";
|
// str += L"\r\n";
|
||||||
|
//
|
||||||
dbgExt->control4->ControlledOutputWide( dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL, str.c_str() );
|
// dbgExt->control4->ControlledOutputWide( dml ? DEBUG_OUTCTL_AMBIENT_DML : DEBUG_OUTCTL_AMBIENT_TEXT, DEBUG_OUTPUT_NORMAL, str.c_str() );
|
||||||
|
//
|
||||||
std::wcout << str;
|
// std::wcout << str;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
440
pykd/dbgio.h
440
pykd/dbgio.h
@ -1,224 +1,224 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
#include <dbgeng.h>
|
//#include <dbgeng.h>
|
||||||
|
//
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//class dbgPrint {
|
||||||
|
//
|
||||||
|
//public:
|
||||||
|
//
|
||||||
|
// static void dprint( const boost::python::object& obj, bool dml = false );
|
||||||
|
//
|
||||||
|
// static void dprintln( const boost::python::object& obj, bool dml = false );
|
||||||
|
//
|
||||||
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class dbgPrint {
|
//// êëàññ äëÿ ïåðåõâàòà âûâîäà â îòëàä÷èê
|
||||||
|
//
|
||||||
public:
|
//class OutputReader : public IDebugOutputCallbacks {
|
||||||
|
//
|
||||||
static void dprint( const boost::python::object& obj, bool dml = false );
|
//public:
|
||||||
|
//
|
||||||
static void dprintln( const boost::python::object& obj, bool dml = false );
|
// OutputReader( IDebugClient *debugClient )
|
||||||
|
// {
|
||||||
};
|
// HRESULT hres;
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
// try {
|
||||||
|
//
|
||||||
// êëàññ äëÿ ïåðåõâàòà âûâîäà â îòëàä÷èê
|
// m_debugClient = debugClient;
|
||||||
|
// m_debugClient->AddRef();
|
||||||
class OutputReader : public IDebugOutputCallbacks {
|
//
|
||||||
|
// hres = m_debugClient->GetOutputCallbacks( &m_previousCallback );
|
||||||
public:
|
// if ( FAILED( hres ) )
|
||||||
|
// {
|
||||||
OutputReader( IDebugClient *debugClient )
|
// throw hres;
|
||||||
{
|
// }
|
||||||
HRESULT hres;
|
//
|
||||||
|
// hres = m_debugClient->SetOutputCallbacks( this );
|
||||||
try {
|
// if ( FAILED( hres ) )
|
||||||
|
// {
|
||||||
m_debugClient = debugClient;
|
// throw hres;
|
||||||
m_debugClient->AddRef();
|
// }
|
||||||
|
//
|
||||||
hres = m_debugClient->GetOutputCallbacks( &m_previousCallback );
|
// } catch( ... )
|
||||||
if ( FAILED( hres ) )
|
// {
|
||||||
{
|
// m_debugClient->Release();
|
||||||
throw hres;
|
// m_debugClient = NULL;
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
hres = m_debugClient->SetOutputCallbacks( this );
|
//
|
||||||
if ( FAILED( hres ) )
|
// ~OutputReader()
|
||||||
{
|
// {
|
||||||
throw hres;
|
// if ( m_debugClient )
|
||||||
}
|
// {
|
||||||
|
// m_debugClient->SetOutputCallbacks( m_previousCallback );
|
||||||
} catch( ... )
|
// m_debugClient->Release();
|
||||||
{
|
// }
|
||||||
m_debugClient->Release();
|
// }
|
||||||
m_debugClient = NULL;
|
//
|
||||||
}
|
// const std::string&
|
||||||
}
|
// Line() const {
|
||||||
|
// return m_readLine;
|
||||||
~OutputReader()
|
// }
|
||||||
{
|
//
|
||||||
if ( m_debugClient )
|
//private:
|
||||||
{
|
//
|
||||||
m_debugClient->SetOutputCallbacks( m_previousCallback );
|
// // IUnknown.
|
||||||
m_debugClient->Release();
|
// STDMETHOD(QueryInterface)(
|
||||||
}
|
// __in REFIID InterfaceId,
|
||||||
}
|
// __out PVOID* Interface ) {
|
||||||
|
// return E_NOINTERFACE;
|
||||||
const std::string&
|
// }
|
||||||
Line() const {
|
//
|
||||||
return m_readLine;
|
// STDMETHOD_(ULONG, AddRef)() {
|
||||||
}
|
// return 1L;
|
||||||
|
// }
|
||||||
private:
|
//
|
||||||
|
//
|
||||||
// IUnknown.
|
// STDMETHOD_(ULONG, Release)() {
|
||||||
STDMETHOD(QueryInterface)(
|
// return 0L;
|
||||||
__in REFIID InterfaceId,
|
// }
|
||||||
__out PVOID* Interface ) {
|
//
|
||||||
return E_NOINTERFACE;
|
// STDMETHOD(Output)(
|
||||||
}
|
// __in ULONG Mask,
|
||||||
|
// __in PCSTR Text )
|
||||||
STDMETHOD_(ULONG, AddRef)() {
|
// {
|
||||||
return 1L;
|
// if ( Mask == DEBUG_OUTPUT_NORMAL )
|
||||||
}
|
// {
|
||||||
|
// m_readLine += std::string( Text );
|
||||||
|
// }
|
||||||
STDMETHOD_(ULONG, Release)() {
|
//
|
||||||
return 0L;
|
// return S_OK;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
STDMETHOD(Output)(
|
//private:
|
||||||
__in ULONG Mask,
|
//
|
||||||
__in PCSTR Text )
|
// std::string m_readLine;
|
||||||
{
|
//
|
||||||
if ( Mask == DEBUG_OUTPUT_NORMAL )
|
// IDebugClient *m_debugClient;
|
||||||
{
|
//
|
||||||
m_readLine += std::string( Text );
|
// IDebugOutputCallbacks *m_previousCallback;
|
||||||
}
|
//};
|
||||||
|
//
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
std::string m_readLine;
|
|
||||||
|
|
||||||
IDebugClient *m_debugClient;
|
|
||||||
|
|
||||||
IDebugOutputCallbacks *m_previousCallback;
|
|
||||||
};
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
class InputReader : public IDebugInputCallbacks {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
InputReader( IDebugClient *debugClient )
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
m_debugClient = debugClient;
|
|
||||||
m_debugClient->AddRef();
|
|
||||||
|
|
||||||
hres = m_debugClient->GetInputCallbacks( &m_previousCallback );
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
{
|
|
||||||
throw hres;
|
|
||||||
}
|
|
||||||
|
|
||||||
hres = m_debugClient->SetInputCallbacks( this );
|
|
||||||
if ( FAILED( hres ) )
|
|
||||||
{
|
|
||||||
throw hres;
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch( ... )
|
|
||||||
{
|
|
||||||
m_debugClient->Release();
|
|
||||||
m_debugClient = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~InputReader()
|
|
||||||
{
|
|
||||||
if ( m_debugClient )
|
|
||||||
{
|
|
||||||
m_debugClient->SetInputCallbacks( m_previousCallback );
|
|
||||||
m_debugClient->Release();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// IUnknown.
|
|
||||||
STDMETHOD(QueryInterface)(
|
|
||||||
__in REFIID InterfaceId,
|
|
||||||
__out PVOID* Interface ) {
|
|
||||||
return E_NOINTERFACE;
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHOD_(ULONG, AddRef)() {
|
|
||||||
return 1L;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
STDMETHOD_(ULONG, Release)() {
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHOD( EndInput )() {
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
STDMETHOD( StartInput )(
|
|
||||||
IN ULONG BufferSize ) {
|
|
||||||
return S_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
IDebugClient *m_debugClient;
|
|
||||||
|
|
||||||
IDebugInputCallbacks *m_previousCallback;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class dbgOut {
|
//class InputReader : public IDebugInputCallbacks {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
void
|
// InputReader( IDebugClient *debugClient )
|
||||||
write( const boost::python::object &str ) {
|
// {
|
||||||
dbgPrint::dprint( str );
|
// HRESULT hres;
|
||||||
}
|
//
|
||||||
|
// try {
|
||||||
};
|
//
|
||||||
|
// m_debugClient = debugClient;
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
// m_debugClient->AddRef();
|
||||||
|
//
|
||||||
class dbgIn {
|
// hres = m_debugClient->GetInputCallbacks( &m_previousCallback );
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
public:
|
// {
|
||||||
|
// throw hres;
|
||||||
std::string
|
// }
|
||||||
readline() {
|
//
|
||||||
|
// hres = m_debugClient->SetInputCallbacks( this );
|
||||||
char str[100];
|
// if ( FAILED( hres ) )
|
||||||
ULONG inputSize;
|
// {
|
||||||
|
// throw hres;
|
||||||
OutputReader outputReader( dbgExt->client );
|
// }
|
||||||
|
//
|
||||||
dbgExt->control->Input( str, sizeof(str), &inputSize );
|
// } catch( ... )
|
||||||
|
// {
|
||||||
return std::string( str );
|
// m_debugClient->Release();
|
||||||
}
|
// m_debugClient = NULL;
|
||||||
|
// }
|
||||||
};
|
// }
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
// ~InputReader()
|
||||||
|
// {
|
||||||
|
// if ( m_debugClient )
|
||||||
|
// {
|
||||||
|
// m_debugClient->SetInputCallbacks( m_previousCallback );
|
||||||
|
// m_debugClient->Release();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//private:
|
||||||
|
//
|
||||||
|
// // IUnknown.
|
||||||
|
// STDMETHOD(QueryInterface)(
|
||||||
|
// __in REFIID InterfaceId,
|
||||||
|
// __out PVOID* Interface ) {
|
||||||
|
// return E_NOINTERFACE;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// STDMETHOD_(ULONG, AddRef)() {
|
||||||
|
// return 1L;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// STDMETHOD_(ULONG, Release)() {
|
||||||
|
// return 0L;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// STDMETHOD( EndInput )() {
|
||||||
|
// return S_OK;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// STDMETHOD( StartInput )(
|
||||||
|
// IN ULONG BufferSize ) {
|
||||||
|
// return S_OK;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//private:
|
||||||
|
//
|
||||||
|
// IDebugClient *m_debugClient;
|
||||||
|
//
|
||||||
|
// IDebugInputCallbacks *m_previousCallback;
|
||||||
|
//
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//class dbgOut {
|
||||||
|
//
|
||||||
|
//public:
|
||||||
|
//
|
||||||
|
// void
|
||||||
|
// write( const boost::python::object &str ) {
|
||||||
|
// dbgPrint::dprint( str );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//class dbgIn {
|
||||||
|
//
|
||||||
|
//public:
|
||||||
|
//
|
||||||
|
// std::string
|
||||||
|
// readline() {
|
||||||
|
//
|
||||||
|
// char str[100];
|
||||||
|
// ULONG inputSize;
|
||||||
|
//
|
||||||
|
// OutputReader outputReader( dbgExt->client );
|
||||||
|
//
|
||||||
|
// dbgExt->control->Input( str, sizeof(str), &inputSize );
|
||||||
|
//
|
||||||
|
// return std::string( str );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
1002
pykd/dbgmem.cpp
1002
pykd/dbgmem.cpp
File diff suppressed because it is too large
Load Diff
176
pykd/dbgmem.h
176
pykd/dbgmem.h
@ -1,90 +1,90 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <boost/scoped_array.hpp>
|
//#include <boost/scoped_array.hpp>
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
loadMemory( ULONG64 address, PVOID dest, ULONG length, BOOLEAN phyAddr = FALSE );
|
//loadMemory( ULONG64 address, PVOID dest, ULONG length, BOOLEAN phyAddr = FALSE );
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
loadPtrByPtr( ULONG64 address );
|
//loadPtrByPtr( ULONG64 address );
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
loadMWord( ULONG64 address );
|
//loadMWord( ULONG64 address );
|
||||||
|
//
|
||||||
LONG64
|
//LONG64
|
||||||
loadSignMWord( ULONG64 address );
|
//loadSignMWord( ULONG64 address );
|
||||||
|
//
|
||||||
|
//
|
||||||
template<typename T>
|
//template<typename T>
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadArray( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE )
|
//loadArray( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE )
|
||||||
{
|
//{
|
||||||
boost::scoped_array<T> buffer(new T[number]);
|
// boost::scoped_array<T> buffer(new T[number]);
|
||||||
|
//
|
||||||
loadMemory( address, buffer.get(), number*sizeof(T), phyAddr );
|
// loadMemory( address, buffer.get(), number*sizeof(T), phyAddr );
|
||||||
|
//
|
||||||
boost::python::list lst;
|
// boost::python::list lst;
|
||||||
|
//
|
||||||
for ( ULONG i = 0; i < number; ++i )
|
// for ( ULONG i = 0; i < number; ++i )
|
||||||
lst.append( buffer[i] );
|
// lst.append( buffer[i] );
|
||||||
|
//
|
||||||
return lst;
|
// return lst;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadChars( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE );
|
//loadChars( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadWChars( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE );
|
//loadWChars( ULONG64 address, ULONG number, BOOLEAN phyAddr = FALSE );
|
||||||
|
//
|
||||||
template<typename T>
|
//template<typename T>
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadByPtr( ULONG64 address )
|
//loadByPtr( ULONG64 address )
|
||||||
{
|
//{
|
||||||
T value;
|
// T value;
|
||||||
|
//
|
||||||
loadMemory( address, &value, sizeof(T) );
|
// loadMemory( address, &value, sizeof(T) );
|
||||||
|
//
|
||||||
return boost::python::object( value );
|
// return boost::python::object( value );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
template<>
|
//template<>
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadByPtr<char>( ULONG64 address );
|
//loadByPtr<char>( ULONG64 address );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadPtrArray( ULONG64 address, ULONG number );
|
//loadPtrArray( ULONG64 address, ULONG number );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadUnicodeStr( ULONG64 address );
|
//loadUnicodeStr( ULONG64 address );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadAnsiStr( ULONG64 address );
|
//loadAnsiStr( ULONG64 address );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadCStr( ULONG64 address );
|
//loadCStr( ULONG64 address );
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
loadCStrToBuffer( ULONG64 address, PCHAR buffer, ULONG bufferLen );
|
//loadCStrToBuffer( ULONG64 address, PCHAR buffer, ULONG bufferLen );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadWStr( ULONG64 address );
|
//loadWStr( ULONG64 address );
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
loadWStrToBuffer( ULONG64 address, PWCHAR buffer, ULONG bufferLen );
|
//loadWStrToBuffer( ULONG64 address, PWCHAR buffer, ULONG bufferLen );
|
||||||
|
//
|
||||||
bool
|
//bool
|
||||||
compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr = FALSE );
|
//compareMemory( ULONG64 addr1, ULONG64 addr2, ULONG length, BOOLEAN phyAddr = FALSE );
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
addr64( ULONG64 addr );
|
//addr64( ULONG64 addr );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadLinkedList( ULONG64 address );
|
//loadLinkedList( ULONG64 address );
|
||||||
|
//
|
||||||
bool
|
//bool
|
||||||
isOffsetValid( ULONG64 addr );
|
//isOffsetValid( ULONG64 addr );
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
@ -1,345 +1,345 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
//#include <boost/format.hpp>
|
||||||
|
//
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgmem.h"
|
//#include "dbgmem.h"
|
||||||
#include "dbgmodule.h"
|
//#include "dbgmodule.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "dbgsym.h"
|
//#include "dbgsym.h"
|
||||||
#include "dbgio.h"
|
//#include "dbgio.h"
|
||||||
#include "dbgsynsym.h"
|
//#include "dbgsynsym.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadModule( const std::string &moduleName )
|
//loadModule( const std::string &moduleName )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
ULONG64 moduleBase;
|
// ULONG64 moduleBase;
|
||||||
hres = dbgExt->symbols->GetModuleByModuleName( moduleName.c_str(), 0, NULL, &moduleBase );
|
// hres = dbgExt->symbols->GetModuleByModuleName( moduleName.c_str(), 0, NULL, &moduleBase );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol::GetModuleByModuleName failed" );
|
// throw DbgException( "IDebugSymbol::GetModuleByModuleName failed" );
|
||||||
|
//
|
||||||
DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
// DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
||||||
hres = dbgExt->symbols->GetModuleParameters( 1, &moduleBase, 0, &moduleParam );
|
// hres = dbgExt->symbols->GetModuleParameters( 1, &moduleBase, 0, &moduleParam );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol::GetModuleParameters failed" );
|
// throw DbgException( "IDebugSymbol::GetModuleParameters failed" );
|
||||||
|
//
|
||||||
|
//
|
||||||
return boost::python::object( dbgModuleClass( moduleName, moduleBase, moduleParam.Size ) );
|
// return boost::python::object( dbgModuleClass( moduleName, moduleBase, moduleParam.Size ) );
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void queryModuleParams(
|
//void queryModuleParams(
|
||||||
__in ULONG64 addr,
|
// __in ULONG64 addr,
|
||||||
__out std::string &name,
|
// __out std::string &name,
|
||||||
__out ULONG64 &base,
|
// __out ULONG64 &base,
|
||||||
__out ULONG &size
|
// __out ULONG &size
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
addr = addr64( addr );
|
// addr = addr64( addr );
|
||||||
|
//
|
||||||
ULONG moduleIndex;
|
// ULONG moduleIndex;
|
||||||
HRESULT hres =
|
// HRESULT hres =
|
||||||
dbgExt->symbols->GetModuleByOffset( addr, 0, &moduleIndex, &base);
|
// dbgExt->symbols->GetModuleByOffset( addr, 0, &moduleIndex, &base);
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol::GetModuleByOffset failed" );
|
// throw DbgException( "IDebugSymbol::GetModuleByOffset failed" );
|
||||||
|
//
|
||||||
DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
// DEBUG_MODULE_PARAMETERS moduleParam = { 0 };
|
||||||
hres = dbgExt->symbols->GetModuleParameters( 1, &base, 0, &moduleParam );
|
// hres = dbgExt->symbols->GetModuleParameters( 1, &base, 0, &moduleParam );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol::GetModuleParameters failed" );
|
// throw DbgException( "IDebugSymbol::GetModuleParameters failed" );
|
||||||
size = moduleParam.Size;
|
// size = moduleParam.Size;
|
||||||
|
//
|
||||||
ULONG moduleNameChars = 0;
|
// ULONG moduleNameChars = 0;
|
||||||
dbgExt->symbols->GetModuleNames(
|
// dbgExt->symbols->GetModuleNames(
|
||||||
moduleIndex,
|
// moduleIndex,
|
||||||
0,
|
// 0,
|
||||||
NULL,
|
// NULL,
|
||||||
0,
|
// 0,
|
||||||
NULL,
|
// NULL,
|
||||||
NULL,
|
// NULL,
|
||||||
0,
|
// 0,
|
||||||
&moduleNameChars,
|
// &moduleNameChars,
|
||||||
NULL,
|
// NULL,
|
||||||
0,
|
// 0,
|
||||||
NULL );
|
// NULL );
|
||||||
name.resize(moduleNameChars + 1);
|
// name.resize(moduleNameChars + 1);
|
||||||
hres = dbgExt->symbols->GetModuleNames(
|
// hres = dbgExt->symbols->GetModuleNames(
|
||||||
moduleIndex,
|
// moduleIndex,
|
||||||
0,
|
// 0,
|
||||||
NULL,
|
// NULL,
|
||||||
0,
|
// 0,
|
||||||
NULL,
|
// NULL,
|
||||||
&name[0],
|
// &name[0],
|
||||||
(ULONG)name.size(),
|
// (ULONG)name.size(),
|
||||||
NULL,
|
// NULL,
|
||||||
NULL,
|
// NULL,
|
||||||
0,
|
// 0,
|
||||||
NULL );
|
// NULL );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol::GetModuleNames failed" );
|
// throw DbgException( "IDebugSymbol::GetModuleNames failed" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
findModule( ULONG64 addr )
|
//findModule( ULONG64 addr )
|
||||||
{
|
//{
|
||||||
ULONG64 moduleBase;
|
// ULONG64 moduleBase;
|
||||||
ULONG moduleSize;
|
// ULONG moduleSize;
|
||||||
std::string moduleName;
|
// std::string moduleName;
|
||||||
|
//
|
||||||
queryModuleParams(addr, moduleName, moduleBase, moduleSize);
|
// queryModuleParams(addr, moduleName, moduleBase, moduleSize);
|
||||||
|
//
|
||||||
return boost::python::object( dbgModuleClass( moduleName, moduleBase, moduleSize ) );
|
// return boost::python::object( dbgModuleClass( moduleName, moduleBase, moduleSize ) );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
dbgModuleClass::dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ) :
|
//dbgModuleClass::dbgModuleClass( const std::string &name, ULONG64 base, ULONG size ) :
|
||||||
m_name( name ),
|
// m_name( name ),
|
||||||
m_base( addr64(base) ),
|
// m_base( addr64(base) ),
|
||||||
m_end( addr64(base) + size )
|
// m_end( addr64(base) + size )
|
||||||
{
|
//{
|
||||||
reloadSymbols();
|
// reloadSymbols();
|
||||||
|
//
|
||||||
std::string pattern = name + "!*";
|
// std::string pattern = name + "!*";
|
||||||
ULONG64 enumHandle = 0;
|
// ULONG64 enumHandle = 0;
|
||||||
|
//
|
||||||
HRESULT hres = dbgExt->symbols->StartSymbolMatch( pattern.c_str(), &enumHandle );
|
// HRESULT hres = dbgExt->symbols->StartSymbolMatch( pattern.c_str(), &enumHandle );
|
||||||
|
//
|
||||||
while( SUCCEEDED( hres ) )
|
// while( SUCCEEDED( hres ) )
|
||||||
{
|
// {
|
||||||
char nameBuf[0x100];
|
// char nameBuf[0x100];
|
||||||
ULONG64 offset = 0;
|
// ULONG64 offset = 0;
|
||||||
|
//
|
||||||
hres =
|
// hres =
|
||||||
dbgExt->symbols->GetNextSymbolMatch(
|
// dbgExt->symbols->GetNextSymbolMatch(
|
||||||
enumHandle,
|
// enumHandle,
|
||||||
nameBuf,
|
// nameBuf,
|
||||||
sizeof( nameBuf ),
|
// sizeof( nameBuf ),
|
||||||
NULL,
|
// NULL,
|
||||||
&offset );
|
// &offset );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
std::string symbolName( nameBuf );
|
// std::string symbolName( nameBuf );
|
||||||
|
//
|
||||||
symbolName.erase( 0, name.size() + 1 );
|
// symbolName.erase( 0, name.size() + 1 );
|
||||||
|
//
|
||||||
m_offsets.insert( std::make_pair( symbolName, offset ) );
|
// m_offsets.insert( std::make_pair( symbolName, offset ) );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if ( enumHandle )
|
// if ( enumHandle )
|
||||||
dbgExt->symbols->EndSymbolMatch( enumHandle );
|
// dbgExt->symbols->EndSymbolMatch( enumHandle );
|
||||||
|
//
|
||||||
memset( &m_debugInfo, 0, sizeof( m_debugInfo ) );
|
// memset( &m_debugInfo, 0, sizeof( m_debugInfo ) );
|
||||||
|
//
|
||||||
hres = dbgExt->advanced2->GetSymbolInformation(
|
// hres = dbgExt->advanced2->GetSymbolInformation(
|
||||||
DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
|
// DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
|
||||||
base,
|
// base,
|
||||||
0,
|
// 0,
|
||||||
&m_debugInfo,
|
// &m_debugInfo,
|
||||||
sizeof( m_debugInfo ),
|
// sizeof( m_debugInfo ),
|
||||||
NULL,
|
// NULL,
|
||||||
NULL,
|
// NULL,
|
||||||
0,
|
// 0,
|
||||||
NULL );
|
// NULL );
|
||||||
|
//
|
||||||
if ( SUCCEEDED( hres ) )
|
// if ( SUCCEEDED( hres ) )
|
||||||
getImagePath();
|
// getImagePath();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
dbgModuleClass::reloadSymbols()
|
//dbgModuleClass::reloadSymbols()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
static const char *szReloadParam = "/f "; //"/f /s ";
|
// static const char *szReloadParam = "/f "; //"/f /s ";
|
||||||
std::string reloadParam = szReloadParam;
|
// std::string reloadParam = szReloadParam;
|
||||||
reloadParam += m_name;
|
// reloadParam += m_name;
|
||||||
|
//
|
||||||
{
|
// {
|
||||||
// try reload module by entered name, "silent mode"
|
// // try reload module by entered name, "silent mode"
|
||||||
OutputReader outputReader( dbgExt->client );
|
// OutputReader outputReader( dbgExt->client );
|
||||||
hres = dbgExt->symbols->Reload( reloadParam.c_str() );
|
// hres = dbgExt->symbols->Reload( reloadParam.c_str() );
|
||||||
}
|
// }
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
{
|
// {
|
||||||
// failed => try reload symbols by image file name
|
// // failed => try reload symbols by image file name
|
||||||
char szImageName[MAX_PATH/2];
|
// char szImageName[MAX_PATH/2];
|
||||||
HRESULT hres2 = dbgExt->symbols2->GetModuleNameString(
|
// HRESULT hres2 = dbgExt->symbols2->GetModuleNameString(
|
||||||
DEBUG_MODNAME_IMAGE,
|
// DEBUG_MODNAME_IMAGE,
|
||||||
DEBUG_ANY_ID,
|
// DEBUG_ANY_ID,
|
||||||
m_base,
|
// m_base,
|
||||||
szImageName,
|
// szImageName,
|
||||||
_countof(szImageName),
|
// _countof(szImageName),
|
||||||
NULL);
|
// NULL);
|
||||||
if (SUCCEEDED(hres2))
|
// if (SUCCEEDED(hres2))
|
||||||
{
|
// {
|
||||||
PCSTR szImageFileName = strrchr(szImageName, '\\');
|
// PCSTR szImageFileName = strrchr(szImageName, '\\');
|
||||||
if (!szImageFileName)
|
// if (!szImageFileName)
|
||||||
szImageFileName = szImageName;
|
// szImageFileName = szImageName;
|
||||||
else
|
// else
|
||||||
++szImageFileName;
|
// ++szImageFileName;
|
||||||
|
//
|
||||||
reloadParam = szReloadParam;
|
// reloadParam = szReloadParam;
|
||||||
reloadParam += szImageFileName;
|
// reloadParam += szImageFileName;
|
||||||
hres = dbgExt->symbols->Reload( reloadParam.c_str() );
|
// hres = dbgExt->symbols->Reload( reloadParam.c_str() );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol::Reload failed" );
|
// throw DbgException( "IDebugSymbol::Reload failed" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
dbgModuleClass::getOffset( const std::string &symName )
|
//dbgModuleClass::getOffset( const std::string &symName )
|
||||||
{
|
//{
|
||||||
OffsetMap::iterator offset = m_offsets.find( symName );
|
// OffsetMap::iterator offset = m_offsets.find( symName );
|
||||||
if ( offset != m_offsets.end() )
|
// if ( offset != m_offsets.end() )
|
||||||
{
|
// {
|
||||||
return offset->second;
|
// return offset->second;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ModuleInfo moduleInfo(m_debugInfo);
|
// ModuleInfo moduleInfo(m_debugInfo);
|
||||||
ULONG64 syntheticOffset = getSyntheticSymbol(moduleInfo, symName);
|
// ULONG64 syntheticOffset = getSyntheticSymbol(moduleInfo, symName);
|
||||||
|
//
|
||||||
if ( syntheticOffset == 0 )
|
// if ( syntheticOffset == 0 )
|
||||||
throw DbgException( "failed to find offset for symbol" );
|
// throw DbgException( "failed to find offset for symbol" );
|
||||||
|
//
|
||||||
return syntheticOffset;
|
// return syntheticOffset;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
bool dbgModuleClass::addSyntheticSymbol(
|
//bool dbgModuleClass::addSyntheticSymbol(
|
||||||
ULONG64 offset,
|
// ULONG64 offset,
|
||||||
ULONG size,
|
// ULONG size,
|
||||||
const std::string &symName
|
// const std::string &symName
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
ModuleInfo moduleInfo(m_debugInfo);
|
// ModuleInfo moduleInfo(m_debugInfo);
|
||||||
return ::addSyntheticSymbolForModule(offset, size, symName, moduleInfo);
|
// return ::addSyntheticSymbolForModule(offset, size, symName, moduleInfo);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void dbgModuleClass::delAllSyntheticSymbols()
|
//void dbgModuleClass::delAllSyntheticSymbols()
|
||||||
{
|
//{
|
||||||
ModuleInfo moduleInfo(m_debugInfo);
|
// ModuleInfo moduleInfo(m_debugInfo);
|
||||||
::delAllSyntheticSymbolsForModule(moduleInfo);
|
// ::delAllSyntheticSymbolsForModule(moduleInfo);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG dbgModuleClass::delSyntheticSymbol(
|
//ULONG dbgModuleClass::delSyntheticSymbol(
|
||||||
ULONG64 offset
|
// ULONG64 offset
|
||||||
)
|
//)
|
||||||
{
|
//{
|
||||||
ModuleInfo moduleInfo(m_debugInfo);
|
// ModuleInfo moduleInfo(m_debugInfo);
|
||||||
return ::delSyntheticSymbolForModule(offset, moduleInfo);
|
// return ::delSyntheticSymbolForModule(offset, moduleInfo);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG dbgModuleClass::delSyntheticSymbolsMask( const std::string &symName )
|
//ULONG dbgModuleClass::delSyntheticSymbolsMask( const std::string &symName )
|
||||||
{
|
//{
|
||||||
return ::delSyntheticSymbolsMask(m_name, symName);
|
// return ::delSyntheticSymbolsMask(m_name, symName);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
dbgModuleClass::getImagePath()
|
//dbgModuleClass::getImagePath()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
ULONG pathSize = 0;
|
// ULONG pathSize = 0;
|
||||||
hres = dbgExt->symbols3->GetSymbolPathWide( NULL, 0, &pathSize );
|
// hres = dbgExt->symbols3->GetSymbolPathWide( NULL, 0, &pathSize );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol3::GetImagePathWide failed" );
|
// throw DbgException( "IDebugSymbol3::GetImagePathWide failed" );
|
||||||
|
//
|
||||||
std::vector<WCHAR> pathBuffer(pathSize);
|
// std::vector<WCHAR> pathBuffer(pathSize);
|
||||||
|
//
|
||||||
hres = dbgExt->symbols3->GetSymbolPathWide( &pathBuffer[0], pathSize, NULL );
|
// hres = dbgExt->symbols3->GetSymbolPathWide( &pathBuffer[0], pathSize, NULL );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol3::GetImagePathWide failed" );
|
// throw DbgException( "IDebugSymbol3::GetImagePathWide failed" );
|
||||||
|
//
|
||||||
std::wstring symPath( &pathBuffer[0], pathSize );
|
// std::wstring symPath( &pathBuffer[0], pathSize );
|
||||||
|
//
|
||||||
std::wstring altName = m_debugInfo.CVData;
|
// std::wstring altName = m_debugInfo.CVData;
|
||||||
altName = altName.substr( 0, altName.find_last_of(L".") );
|
// altName = altName.substr( 0, altName.find_last_of(L".") );
|
||||||
|
//
|
||||||
std::wstring imageName = m_debugInfo.LoadedImageName;
|
// std::wstring imageName = m_debugInfo.LoadedImageName;
|
||||||
altName += imageName.substr( imageName.find_last_of(L".") );
|
// altName += imageName.substr( imageName.find_last_of(L".") );
|
||||||
|
//
|
||||||
for ( size_t offset = 0; offset < symPath.length(); )
|
// for ( size_t offset = 0; offset < symPath.length(); )
|
||||||
{
|
// {
|
||||||
size_t newOffset = symPath.find( L";", offset );
|
// size_t newOffset = symPath.find( L";", offset );
|
||||||
std::wstring subPath = symPath.substr( offset, newOffset - offset );
|
// std::wstring subPath = symPath.substr( offset, newOffset - offset );
|
||||||
|
//
|
||||||
std::wstringstream sstr;
|
// std::wstringstream sstr;
|
||||||
|
//
|
||||||
sstr << subPath << L"\\" << m_debugInfo.LoadedImageName << L"\\" << std::hex <<
|
// sstr << subPath << L"\\" << m_debugInfo.LoadedImageName << L"\\" << std::hex <<
|
||||||
m_debugInfo.TimeDateStamp << m_debugInfo.ImageSize << L"\\" <<
|
// m_debugInfo.TimeDateStamp << m_debugInfo.ImageSize << L"\\" <<
|
||||||
m_debugInfo.LoadedImageName;
|
// m_debugInfo.LoadedImageName;
|
||||||
|
//
|
||||||
if( (_waccess( sstr.str().c_str(), 0 )) != -1 )
|
// if( (_waccess( sstr.str().c_str(), 0 )) != -1 )
|
||||||
{
|
// {
|
||||||
m_imageFullName = sstr.str();
|
// m_imageFullName = sstr.str();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
std::wstringstream altstr;
|
// std::wstringstream altstr;
|
||||||
|
//
|
||||||
altstr << subPath << L"\\" << altName << L"\\" << std::hex <<
|
// altstr << subPath << L"\\" << altName << L"\\" << std::hex <<
|
||||||
m_debugInfo.TimeDateStamp << m_debugInfo.ImageSize << L"\\" <<
|
// m_debugInfo.TimeDateStamp << m_debugInfo.ImageSize << L"\\" <<
|
||||||
altName;
|
// altName;
|
||||||
|
//
|
||||||
if( (_waccess( altstr.str().c_str(), 0 )) != -1 )
|
// if( (_waccess( altstr.str().c_str(), 0 )) != -1 )
|
||||||
{
|
// {
|
||||||
m_imageFullName = altstr.str();
|
// m_imageFullName = altstr.str();
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if ( newOffset == std::wstring::npos )
|
// if ( newOffset == std::wstring::npos )
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
offset = newOffset + 1;
|
// offset = newOffset + 1;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgModuleClass::print() const
|
//dbgModuleClass::print() const
|
||||||
{
|
//{
|
||||||
const char * format_string(dbgExt->control->IsPointer64Bit() == S_OK ?
|
// const char * format_string(dbgExt->control->IsPointer64Bit() == S_OK ?
|
||||||
"%1$016x %2$016x %3$20s %4$20s" : "%1$08x %2$08x %3$20s %4$20s");
|
// "%1$016x %2$016x %3$20s %4$20s" : "%1$08x %2$08x %3$20s %4$20s");
|
||||||
boost::format fmt(format_string);
|
// boost::format fmt(format_string);
|
||||||
std::vector<char> v(MAX_PATH);
|
// std::vector<char> v(MAX_PATH);
|
||||||
::WideCharToMultiByte(
|
// ::WideCharToMultiByte(
|
||||||
CP_ACP,
|
// CP_ACP,
|
||||||
0,
|
// 0,
|
||||||
m_imageFullName.c_str(),
|
// m_imageFullName.c_str(),
|
||||||
-1,
|
// -1,
|
||||||
&v[0],
|
// &v[0],
|
||||||
(ULONG)v.size(),
|
// (ULONG)v.size(),
|
||||||
0,
|
// 0,
|
||||||
0);
|
// 0);
|
||||||
std::string fullname(&v[0]);
|
// std::string fullname(&v[0]);
|
||||||
fmt % m_base % (m_end - m_base) % m_name % fullname;
|
// fmt % m_base % (m_end - m_base) % m_name % fullname;
|
||||||
return fmt.str();
|
// return fmt.str();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
350
pykd/dbgmodule.h
350
pykd/dbgmodule.h
@ -1,177 +1,177 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
#include <map>
|
//#include <map>
|
||||||
|
//
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgmem.h"
|
//#include "dbgmem.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
// global unique module data
|
//// global unique module data
|
||||||
// WARNING: add only numeric field or change operator <
|
//// WARNING: add only numeric field or change operator <
|
||||||
struct ModuleInfo
|
//struct ModuleInfo
|
||||||
{
|
//{
|
||||||
ULONG64 m_base;
|
// ULONG64 m_base;
|
||||||
ULONG m_timeDataStamp;
|
// ULONG m_timeDataStamp;
|
||||||
ULONG m_checkSumm;
|
// ULONG m_checkSumm;
|
||||||
|
//
|
||||||
ModuleInfo()
|
// ModuleInfo()
|
||||||
: m_base(0)
|
// : m_base(0)
|
||||||
, m_timeDataStamp(0)
|
// , m_timeDataStamp(0)
|
||||||
, m_checkSumm(0)
|
// , m_checkSumm(0)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
ModuleInfo(
|
// ModuleInfo(
|
||||||
const ModuleInfo &rhs
|
// const ModuleInfo &rhs
|
||||||
) : m_base(rhs.m_base)
|
// ) : m_base(rhs.m_base)
|
||||||
, m_timeDataStamp(rhs.m_timeDataStamp)
|
// , m_timeDataStamp(rhs.m_timeDataStamp)
|
||||||
, m_checkSumm(rhs.m_checkSumm)
|
// , m_checkSumm(rhs.m_checkSumm)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
ModuleInfo(
|
// ModuleInfo(
|
||||||
const IMAGEHLP_MODULEW64 &dbgImageHelperInfo
|
// const IMAGEHLP_MODULEW64 &dbgImageHelperInfo
|
||||||
) : m_base(addr64(dbgImageHelperInfo.BaseOfImage))
|
// ) : m_base(addr64(dbgImageHelperInfo.BaseOfImage))
|
||||||
, m_timeDataStamp(dbgImageHelperInfo.TimeDateStamp)
|
// , m_timeDataStamp(dbgImageHelperInfo.TimeDateStamp)
|
||||||
, m_checkSumm(dbgImageHelperInfo.CheckSum)
|
// , m_checkSumm(dbgImageHelperInfo.CheckSum)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
ModuleInfo(
|
// ModuleInfo(
|
||||||
const DEBUG_MODULE_PARAMETERS &dbgModuleParameters
|
// const DEBUG_MODULE_PARAMETERS &dbgModuleParameters
|
||||||
) : m_base(addr64(dbgModuleParameters.Base))
|
// ) : m_base(addr64(dbgModuleParameters.Base))
|
||||||
, m_timeDataStamp(dbgModuleParameters.TimeDateStamp)
|
// , m_timeDataStamp(dbgModuleParameters.TimeDateStamp)
|
||||||
, m_checkSumm(dbgModuleParameters.Checksum)
|
// , m_checkSumm(dbgModuleParameters.Checksum)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
bool operator ==(const ModuleInfo &rhs) const
|
// bool operator ==(const ModuleInfo &rhs) const
|
||||||
{
|
// {
|
||||||
return m_base == rhs.m_base
|
// return m_base == rhs.m_base
|
||||||
&& m_timeDataStamp == rhs.m_timeDataStamp
|
// && m_timeDataStamp == rhs.m_timeDataStamp
|
||||||
&& m_checkSumm == rhs.m_checkSumm;
|
// && m_checkSumm == rhs.m_checkSumm;
|
||||||
}
|
// }
|
||||||
bool operator < (const ModuleInfo &rhs) const
|
// bool operator < (const ModuleInfo &rhs) const
|
||||||
{
|
// {
|
||||||
return memcmp(this, &rhs, sizeof(ModuleInfo)) < 0;
|
// return memcmp(this, &rhs, sizeof(ModuleInfo)) < 0;
|
||||||
}
|
// }
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class dbgModuleClass {
|
//class dbgModuleClass {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
dbgModuleClass() :
|
// dbgModuleClass() :
|
||||||
m_base( 0 ),
|
// m_base( 0 ),
|
||||||
m_end( 0 )
|
// m_end( 0 )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
dbgModuleClass( const std::string &name, ULONG64 base, ULONG size );
|
// dbgModuleClass( const std::string &name, ULONG64 base, ULONG size );
|
||||||
|
//
|
||||||
ULONG64
|
// ULONG64
|
||||||
getBegin() const {
|
// getBegin() const {
|
||||||
return m_base;
|
// return m_base;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG64
|
// ULONG64
|
||||||
getEnd() const {
|
// getEnd() const {
|
||||||
return m_end;
|
// return m_end;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
getSize() const {
|
// getSize() const {
|
||||||
return (ULONG)( m_end - m_base );
|
// return (ULONG)( m_end - m_base );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
bool
|
// bool
|
||||||
contain( ULONG64 addr ) const {
|
// contain( ULONG64 addr ) const {
|
||||||
if ( *( (ULONG*)&addr + 1 ) == 0 )
|
// if ( *( (ULONG*)&addr + 1 ) == 0 )
|
||||||
*( (ULONG*)&addr + 1 ) = 0xFFFFFFFF;
|
// *( (ULONG*)&addr + 1 ) = 0xFFFFFFFF;
|
||||||
|
//
|
||||||
return m_base <= addr && addr <= m_end;
|
// return m_base <= addr && addr <= m_end;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
getName() const {
|
// getName() const {
|
||||||
return m_name;
|
// return m_name;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void
|
// void
|
||||||
reloadSymbols();
|
// reloadSymbols();
|
||||||
|
//
|
||||||
ULONG64
|
// ULONG64
|
||||||
getOffset( const std::string &symName );
|
// getOffset( const std::string &symName );
|
||||||
|
//
|
||||||
std::wstring
|
// std::wstring
|
||||||
getImageSymbolName() const {
|
// getImageSymbolName() const {
|
||||||
return m_imageFullName;
|
// return m_imageFullName;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::wstring
|
// std::wstring
|
||||||
getPdbName() const {
|
// getPdbName() const {
|
||||||
return std::wstring( m_debugInfo.LoadedPdbName );
|
// return std::wstring( m_debugInfo.LoadedPdbName );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
getCheckSum() const {
|
// getCheckSum() const {
|
||||||
return m_debugInfo.CheckSum;
|
// return m_debugInfo.CheckSum;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
getTimeStamp() const {
|
// getTimeStamp() const {
|
||||||
return m_debugInfo.TimeDateStamp;
|
// return m_debugInfo.TimeDateStamp;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
bool
|
// bool
|
||||||
addSyntheticSymbol( ULONG64 offset, ULONG size, const std::string &symName );
|
// addSyntheticSymbol( ULONG64 offset, ULONG size, const std::string &symName );
|
||||||
|
//
|
||||||
void
|
// void
|
||||||
delAllSyntheticSymbols();
|
// delAllSyntheticSymbols();
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
delSyntheticSymbol( ULONG64 offset );
|
// delSyntheticSymbol( ULONG64 offset );
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
delSyntheticSymbolsMask( const std::string &symName );
|
// delSyntheticSymbolsMask( const std::string &symName );
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
print() const;
|
// print() const;
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
ULONG64 m_base;
|
// ULONG64 m_base;
|
||||||
|
//
|
||||||
ULONG64 m_end;
|
// ULONG64 m_end;
|
||||||
|
//
|
||||||
std::string m_name;
|
// std::string m_name;
|
||||||
|
//
|
||||||
std::wstring m_imageFullName;
|
// std::wstring m_imageFullName;
|
||||||
|
//
|
||||||
IMAGEHLP_MODULEW64 m_debugInfo;
|
// IMAGEHLP_MODULEW64 m_debugInfo;
|
||||||
|
//
|
||||||
typedef std::map<std::string, ULONG64> OffsetMap;
|
// typedef std::map<std::string, ULONG64> OffsetMap;
|
||||||
OffsetMap m_offsets;
|
// OffsetMap m_offsets;
|
||||||
|
//
|
||||||
void
|
// void
|
||||||
getImagePath();
|
// getImagePath();
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadModule( const std::string &moduleName );
|
//loadModule( const std::string &moduleName );
|
||||||
|
//
|
||||||
// query module parameters (for construct dbgModuleClass) by virtual address
|
//// query module parameters (for construct dbgModuleClass) by virtual address
|
||||||
// error : DbgException exception
|
//// error : DbgException exception
|
||||||
void queryModuleParams(
|
//void queryModuleParams(
|
||||||
__in ULONG64 addr,
|
// __in ULONG64 addr,
|
||||||
__out std::string &name,
|
// __out std::string &name,
|
||||||
__out ULONG64 &base,
|
// __out ULONG64 &base,
|
||||||
__out ULONG &size
|
// __out ULONG &size
|
||||||
);
|
//);
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
findModule( ULONG64 addr );
|
//findModule( ULONG64 addr );
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
292
pykd/dbgpath.cpp
292
pykd/dbgpath.cpp
@ -1,148 +1,148 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "dbgpath.h"
|
//#include "dbgpath.h"
|
||||||
|
//
|
||||||
#include <boost/tokenizer.hpp>
|
//#include <boost/tokenizer.hpp>
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
DbgPythonPath::DbgPythonPath()
|
//DbgPythonPath::DbgPythonPath()
|
||||||
{
|
//{
|
||||||
DWORD enviromentSize = 0;
|
// DWORD enviromentSize = 0;
|
||||||
|
//
|
||||||
enviromentSize = GetEnvironmentVariableA( "PYTHONPATH", NULL, enviromentSize );
|
// enviromentSize = GetEnvironmentVariableA( "PYTHONPATH", NULL, enviromentSize );
|
||||||
|
//
|
||||||
std::vector<char> enviromentBuffer(enviromentSize);
|
// std::vector<char> enviromentBuffer(enviromentSize);
|
||||||
|
//
|
||||||
if (!enviromentBuffer.empty())
|
// if (!enviromentBuffer.empty())
|
||||||
{
|
// {
|
||||||
GetEnvironmentVariableA( "PYTHONPATH", &enviromentBuffer[0], enviromentSize );
|
// GetEnvironmentVariableA( "PYTHONPATH", &enviromentBuffer[0], enviromentSize );
|
||||||
|
//
|
||||||
typedef boost::escaped_list_separator<char> char_separator_t;
|
// typedef boost::escaped_list_separator<char> char_separator_t;
|
||||||
typedef boost::tokenizer< char_separator_t > char_tokenizer_t;
|
// typedef boost::tokenizer< char_separator_t > char_tokenizer_t;
|
||||||
|
//
|
||||||
std::string pytonPath( &enviromentBuffer[0] );
|
// std::string pytonPath( &enviromentBuffer[0] );
|
||||||
|
//
|
||||||
char_tokenizer_t token( pytonPath, char_separator_t( "", "; \t", "\"" ) );
|
// char_tokenizer_t token( pytonPath, char_separator_t( "", "; \t", "\"" ) );
|
||||||
|
//
|
||||||
for ( char_tokenizer_t::iterator it = token.begin(); it != token.end(); ++it )
|
// for ( char_tokenizer_t::iterator it = token.begin(); it != token.end(); ++it )
|
||||||
{
|
// {
|
||||||
if ( *it != "" )
|
// if ( *it != "" )
|
||||||
m_pathList.push_back( *it );
|
// m_pathList.push_back( *it );
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
DbgPythonPath::getStr() const
|
//DbgPythonPath::getStr() const
|
||||||
{
|
//{
|
||||||
std::string str;
|
// std::string str;
|
||||||
std::vector<std::string>::const_iterator it = m_pathList.begin();
|
// std::vector<std::string>::const_iterator it = m_pathList.begin();
|
||||||
|
//
|
||||||
for ( ; it != m_pathList.end(); ++it )
|
// for ( ; it != m_pathList.end(); ++it )
|
||||||
{
|
// {
|
||||||
str += *it;
|
// str += *it;
|
||||||
str += ";";
|
// str += ";";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return str;
|
// return str;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
bool
|
//bool
|
||||||
DbgPythonPath::findPath(
|
//DbgPythonPath::findPath(
|
||||||
const std::string &fileName,
|
// const std::string &fileName,
|
||||||
std::string &fullFileName,
|
// std::string &fullFileName,
|
||||||
std::string &filePath ) const
|
// std::string &filePath ) const
|
||||||
{
|
//{
|
||||||
std::vector< std::string > extPathList;
|
// std::vector< std::string > extPathList;
|
||||||
|
//
|
||||||
boost::python::object sys = boost::python::import( "sys");
|
// boost::python::object sys = boost::python::import( "sys");
|
||||||
|
//
|
||||||
boost::python::list pathList( sys.attr("path") );
|
// boost::python::list pathList( sys.attr("path") );
|
||||||
|
//
|
||||||
boost::python::ssize_t n = boost::python::len(pathList);
|
// boost::python::ssize_t n = boost::python::len(pathList);
|
||||||
for(boost::python::ssize_t i=0;i<n;i++)
|
// for(boost::python::ssize_t i=0;i<n;i++)
|
||||||
extPathList.push_back( boost::python::extract<std::string>( pathList[i] ) );
|
// extPathList.push_back( boost::python::extract<std::string>( pathList[i] ) );
|
||||||
|
//
|
||||||
bool pyExt = fileName.rfind( ".py" ) == fileName.length() - 3;
|
// bool pyExt = fileName.rfind( ".py" ) == fileName.length() - 3;
|
||||||
|
//
|
||||||
// 1. Èùåì â ðàáî÷åé äèðåêòîðèè
|
// // 1. Èùåì â ðàáî÷åé äèðåêòîðèè
|
||||||
DWORD bufSize =
|
// DWORD bufSize =
|
||||||
SearchPathA(
|
// SearchPathA(
|
||||||
NULL,
|
// NULL,
|
||||||
fileName.c_str(),
|
// fileName.c_str(),
|
||||||
pyExt ? NULL : ".py",
|
// pyExt ? NULL : ".py",
|
||||||
0,
|
// 0,
|
||||||
NULL,
|
// NULL,
|
||||||
NULL );
|
// NULL );
|
||||||
|
//
|
||||||
if ( bufSize > 0 )
|
// if ( bufSize > 0 )
|
||||||
{
|
// {
|
||||||
bufSize += 1;
|
// bufSize += 1;
|
||||||
std::vector<char> fullFileNameCStr(bufSize);
|
// std::vector<char> fullFileNameCStr(bufSize);
|
||||||
char *partFileNameCStr = NULL;
|
// char *partFileNameCStr = NULL;
|
||||||
|
//
|
||||||
SearchPathA(
|
// SearchPathA(
|
||||||
NULL,
|
// NULL,
|
||||||
fileName.c_str(),
|
// fileName.c_str(),
|
||||||
pyExt ? NULL : ".py",
|
// pyExt ? NULL : ".py",
|
||||||
bufSize,
|
// bufSize,
|
||||||
&fullFileNameCStr[0],
|
// &fullFileNameCStr[0],
|
||||||
&partFileNameCStr );
|
// &partFileNameCStr );
|
||||||
|
//
|
||||||
fullFileName = std::string( &fullFileNameCStr[0] );
|
// fullFileName = std::string( &fullFileNameCStr[0] );
|
||||||
if ( !fullFileName.empty() )
|
// if ( !fullFileName.empty() )
|
||||||
{
|
// {
|
||||||
filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
// filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 2. Èùåì âî âñåõ äèðåêòîðèÿõ, óêàçàííûõ â m_pathList
|
// // 2. Èùåì âî âñåõ äèðåêòîðèÿõ, óêàçàííûõ â m_pathList
|
||||||
|
//
|
||||||
std::vector<std::string>::const_iterator it = extPathList.begin();
|
// std::vector<std::string>::const_iterator it = extPathList.begin();
|
||||||
|
//
|
||||||
for ( ; it != extPathList.end(); ++it )
|
// for ( ; it != extPathList.end(); ++it )
|
||||||
{
|
// {
|
||||||
DWORD bufSize =
|
// DWORD bufSize =
|
||||||
SearchPathA(
|
// SearchPathA(
|
||||||
(*it).c_str(),
|
// (*it).c_str(),
|
||||||
fileName.c_str(),
|
// fileName.c_str(),
|
||||||
pyExt ? NULL : ".py",
|
// pyExt ? NULL : ".py",
|
||||||
0,
|
// 0,
|
||||||
NULL,
|
// NULL,
|
||||||
NULL );
|
// NULL );
|
||||||
|
//
|
||||||
if ( bufSize > 0 )
|
// if ( bufSize > 0 )
|
||||||
{
|
// {
|
||||||
bufSize += 1;
|
// bufSize += 1;
|
||||||
std::vector<char> fullFileNameCStr(bufSize);
|
// std::vector<char> fullFileNameCStr(bufSize);
|
||||||
char *partFileNameCStr = NULL;
|
// char *partFileNameCStr = NULL;
|
||||||
|
//
|
||||||
bufSize = SearchPathA(
|
// bufSize = SearchPathA(
|
||||||
(*it).c_str(),
|
// (*it).c_str(),
|
||||||
fileName.c_str(),
|
// fileName.c_str(),
|
||||||
pyExt ? NULL : ".py",
|
// pyExt ? NULL : ".py",
|
||||||
bufSize,
|
// bufSize,
|
||||||
&fullFileNameCStr[0],
|
// &fullFileNameCStr[0],
|
||||||
&partFileNameCStr );
|
// &partFileNameCStr );
|
||||||
|
//
|
||||||
fullFileName = std::string( &fullFileNameCStr[0] );
|
// fullFileName = std::string( &fullFileNameCStr[0] );
|
||||||
if ( !fullFileName.empty() )
|
// if ( !fullFileName.empty() )
|
||||||
{
|
// {
|
||||||
filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
// filePath = std::string( &fullFileNameCStr[0], partFileNameCStr );
|
||||||
return true;
|
// return true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1,32 +1,32 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class DbgPythonPath
|
//class DbgPythonPath
|
||||||
{
|
//{
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
DbgPythonPath();
|
// DbgPythonPath();
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
getStr() const;
|
// getStr() const;
|
||||||
|
//
|
||||||
bool
|
// bool
|
||||||
findPath(
|
// findPath(
|
||||||
const std::string &fileName,
|
// const std::string &fileName,
|
||||||
std::string &fullFileName,
|
// std::string &fullFileName,
|
||||||
std::string &filePath ) const;
|
// std::string &filePath ) const;
|
||||||
|
//
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
std::vector< std::string > m_pathList;
|
// std::vector< std::string > m_pathList;
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
//extern DbgPythonPath& dbgPythonPath;
|
////extern DbgPythonPath& dbgPythonPath;
|
||||||
|
//
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
@ -1,289 +1,289 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <boost/format.hpp>
|
//#include <boost/format.hpp>
|
||||||
#include <boost/scoped_array.hpp>
|
//#include <boost/scoped_array.hpp>
|
||||||
|
//
|
||||||
#include "dbgprocess.h"
|
//#include "dbgprocess.h"
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "dbgtype.h"
|
//#include "dbgtype.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
getThreadList()
|
//getThreadList()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
ULONG i;
|
// ULONG i;
|
||||||
ULONG oldThreadId = 0;
|
// ULONG oldThreadId = 0;
|
||||||
|
//
|
||||||
ULONG threadCount;
|
// ULONG threadCount;
|
||||||
hres = dbgExt->system->GetNumberThreads( &threadCount );
|
// hres = dbgExt->system->GetNumberThreads( &threadCount );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSystemObjects::GetNumberThreads failed" );
|
// throw DbgException( "IDebugSystemObjects::GetNumberThreads failed" );
|
||||||
|
//
|
||||||
boost::scoped_array<ULONG> ids(new ULONG[threadCount]);
|
// boost::scoped_array<ULONG> ids(new ULONG[threadCount]);
|
||||||
hres = dbgExt->system->GetThreadIdsByIndex( 0, threadCount, ids.get(), NULL );
|
// hres = dbgExt->system->GetThreadIdsByIndex( 0, threadCount, ids.get(), NULL );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSystemObjects::GetThreadIdsByIndex failed" );
|
// throw DbgException( "IDebugSystemObjects::GetThreadIdsByIndex failed" );
|
||||||
|
//
|
||||||
hres = dbgExt->system->GetCurrentThreadId( &oldThreadId );
|
// hres = dbgExt->system->GetCurrentThreadId( &oldThreadId );
|
||||||
|
//
|
||||||
boost::python::list threadList;
|
// boost::python::list threadList;
|
||||||
|
//
|
||||||
for ( i = 0; i < threadCount; ++i )
|
// for ( i = 0; i < threadCount; ++i )
|
||||||
{
|
// {
|
||||||
dbgExt->system->SetCurrentThreadId( ids[i] );
|
// dbgExt->system->SetCurrentThreadId( ids[i] );
|
||||||
|
//
|
||||||
ULONG64 threadOffset;
|
// ULONG64 threadOffset;
|
||||||
hres = dbgExt->system->GetCurrentThreadDataOffset( &threadOffset );
|
// hres = dbgExt->system->GetCurrentThreadDataOffset( &threadOffset );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
{
|
// {
|
||||||
dbgExt->system->SetCurrentThreadId( oldThreadId );
|
// dbgExt->system->SetCurrentThreadId( oldThreadId );
|
||||||
throw DbgException( "IDebugSystemObjects::GetCurrentThreadDataOffset failed" );
|
// throw DbgException( "IDebugSystemObjects::GetCurrentThreadDataOffset failed" );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
threadList.append( threadOffset );
|
// threadList.append( threadOffset );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return threadList;
|
// return threadList;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
setImplicitThread(
|
//setImplicitThread(
|
||||||
ULONG64 newThreadAddr )
|
// ULONG64 newThreadAddr )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
newThreadAddr = addr64(newThreadAddr);
|
// newThreadAddr = addr64(newThreadAddr);
|
||||||
hres = dbgExt->system2->SetImplicitThreadDataOffset( newThreadAddr );
|
// hres = dbgExt->system2->SetImplicitThreadDataOffset( newThreadAddr );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSystemObjects2::SetImplicitThreadDataOffset failed" );
|
// throw DbgException( "IDebugSystemObjects2::SetImplicitThreadDataOffset failed" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
getImplicitThread()
|
//getImplicitThread()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
ULONG64 threadOffset = -1;
|
// ULONG64 threadOffset = -1;
|
||||||
|
//
|
||||||
hres = dbgExt->system2->GetImplicitThreadDataOffset( &threadOffset );
|
// hres = dbgExt->system2->GetImplicitThreadDataOffset( &threadOffset );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSystemObjects2::GetImplicitThreadDataOffset failed" );
|
// throw DbgException( "IDebugSystemObjects2::GetImplicitThreadDataOffset failed" );
|
||||||
|
//
|
||||||
return threadOffset;
|
// return threadOffset;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
getCurrentStack()
|
//getCurrentStack()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
ULONG currentScope = 0;
|
// ULONG currentScope = 0;
|
||||||
|
//
|
||||||
hres = dbgExt->symbols3->GetCurrentScopeFrameIndex( ¤tScope );
|
// hres = dbgExt->symbols3->GetCurrentScopeFrameIndex( ¤tScope );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol3::GetCurrentScopeFrameIndex failed" );
|
// throw DbgException( "IDebugSymbol3::GetCurrentScopeFrameIndex failed" );
|
||||||
|
//
|
||||||
boost::scoped_array<DEBUG_STACK_FRAME> frames(new DEBUG_STACK_FRAME [ 1000 ]);
|
// boost::scoped_array<DEBUG_STACK_FRAME> frames(new DEBUG_STACK_FRAME [ 1000 ]);
|
||||||
|
//
|
||||||
ULONG filledFrames;
|
// ULONG filledFrames;
|
||||||
hres = dbgExt->control->GetStackTrace( 0, 0, 0, frames.get(), 1000, &filledFrames );
|
// hres = dbgExt->control->GetStackTrace( 0, 0, 0, frames.get(), 1000, &filledFrames );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::GetStackTrace failed" );
|
// throw DbgException( "IDebugControl::GetStackTrace failed" );
|
||||||
|
//
|
||||||
boost::python::list frameList;
|
// boost::python::list frameList;
|
||||||
|
//
|
||||||
for ( ULONG i = 0; i < filledFrames; ++i )
|
// for ( ULONG i = 0; i < filledFrames; ++i )
|
||||||
{
|
// {
|
||||||
dbgStackFrameClass frame( frames[i] );
|
// dbgStackFrameClass frame( frames[i] );
|
||||||
|
//
|
||||||
boost::python::object frameObj( frame );
|
// boost::python::object frameObj( frame );
|
||||||
|
//
|
||||||
hres = dbgExt->symbols->SetScope( NULL, &frames[i], NULL, sizeof(DEBUG_STACK_FRAME) );
|
// hres = dbgExt->symbols->SetScope( NULL, &frames[i], NULL, sizeof(DEBUG_STACK_FRAME) );
|
||||||
if ( SUCCEEDED( hres ) )
|
// if ( SUCCEEDED( hres ) )
|
||||||
frameObj.attr( "locals" ) = getLocals();
|
// frameObj.attr( "locals" ) = getLocals();
|
||||||
|
//
|
||||||
frameList.append( frameObj );
|
// frameList.append( frameObj );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
dbgExt->symbols3->SetScopeFrameByIndex( currentScope );
|
// dbgExt->symbols3->SetScopeFrameByIndex( currentScope );
|
||||||
|
//
|
||||||
return frameList;
|
// return frameList;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
getProcessorMode()
|
//getProcessorMode()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
ULONG processorMode;
|
// ULONG processorMode;
|
||||||
hres = dbgExt->control->GetEffectiveProcessorType( &processorMode );
|
// hres = dbgExt->control->GetEffectiveProcessorType( &processorMode );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" );
|
// throw DbgException( "IDebugControl::GetEffectiveProcessorType failed" );
|
||||||
|
//
|
||||||
switch( processorMode )
|
// switch( processorMode )
|
||||||
{
|
// {
|
||||||
case IMAGE_FILE_MACHINE_I386:
|
// case IMAGE_FILE_MACHINE_I386:
|
||||||
return "X86";
|
// return "X86";
|
||||||
|
//
|
||||||
case IMAGE_FILE_MACHINE_ARM:
|
// case IMAGE_FILE_MACHINE_ARM:
|
||||||
return "ARM";
|
// return "ARM";
|
||||||
|
//
|
||||||
case IMAGE_FILE_MACHINE_IA64:
|
// case IMAGE_FILE_MACHINE_IA64:
|
||||||
return "IA64";
|
// return "IA64";
|
||||||
|
//
|
||||||
case IMAGE_FILE_MACHINE_AMD64:
|
// case IMAGE_FILE_MACHINE_AMD64:
|
||||||
return "X64";
|
// return "X64";
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
throw DbgException( "Unknown CPU type" );
|
// throw DbgException( "Unknown CPU type" );
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
setProcessorMode(
|
//setProcessorMode(
|
||||||
const std::string &mode )
|
// const std::string &mode )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
ULONG processorMode = ~0;
|
// ULONG processorMode = ~0;
|
||||||
|
//
|
||||||
if ( mode == "X86" )
|
// if ( mode == "X86" )
|
||||||
processorMode = IMAGE_FILE_MACHINE_I386;
|
// processorMode = IMAGE_FILE_MACHINE_I386;
|
||||||
else if ( mode == "ARM" )
|
// else if ( mode == "ARM" )
|
||||||
processorMode = IMAGE_FILE_MACHINE_ARM;
|
// processorMode = IMAGE_FILE_MACHINE_ARM;
|
||||||
else if ( mode == "IA64" )
|
// else if ( mode == "IA64" )
|
||||||
processorMode = IMAGE_FILE_MACHINE_IA64;
|
// processorMode = IMAGE_FILE_MACHINE_IA64;
|
||||||
else if ( mode == "X64" )
|
// else if ( mode == "X64" )
|
||||||
processorMode = IMAGE_FILE_MACHINE_AMD64;
|
// processorMode = IMAGE_FILE_MACHINE_AMD64;
|
||||||
else
|
// else
|
||||||
throw DbgException( "Unknown processor type" );
|
// throw DbgException( "Unknown processor type" );
|
||||||
|
//
|
||||||
hres = dbgExt->control->SetEffectiveProcessorType( processorMode );
|
// hres = dbgExt->control->SetEffectiveProcessorType( processorMode );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::SetEffectiveProcessorType failed" );
|
// throw DbgException( "IDebugControl::SetEffectiveProcessorType failed" );
|
||||||
|
//
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
getCurrentProcess()
|
//getCurrentProcess()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
ULONG64 processAddr = 0;
|
// ULONG64 processAddr = 0;
|
||||||
|
//
|
||||||
hres = dbgExt->system2->GetImplicitProcessDataOffset( &processAddr );
|
// hres = dbgExt->system2->GetImplicitProcessDataOffset( &processAddr );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSystemObjects2::GetImplicitProcessDataOffset failed" );
|
// throw DbgException( "IDebugSystemObjects2::GetImplicitProcessDataOffset failed" );
|
||||||
|
//
|
||||||
return processAddr;
|
// return processAddr;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
VOID
|
//VOID
|
||||||
setCurrentProcess(
|
//setCurrentProcess(
|
||||||
ULONG64 processAddr )
|
// ULONG64 processAddr )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
processAddr = addr64(processAddr);
|
// processAddr = addr64(processAddr);
|
||||||
hres = dbgExt->system2->SetImplicitProcessDataOffset( processAddr );
|
// hres = dbgExt->system2->SetImplicitProcessDataOffset( processAddr );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSystemObjects2::SetImplicitProcessDataOffset failed" );
|
// throw DbgException( "IDebugSystemObjects2::SetImplicitProcessDataOffset failed" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
dbgStackFrameClass::dbgStackFrameClass( const DEBUG_STACK_FRAME &stackFrame )
|
//dbgStackFrameClass::dbgStackFrameClass( const DEBUG_STACK_FRAME &stackFrame )
|
||||||
{
|
//{
|
||||||
memcpy( static_cast<DEBUG_STACK_FRAME*>( this ), &stackFrame, sizeof(DEBUG_STACK_FRAME) );
|
// memcpy( static_cast<DEBUG_STACK_FRAME*>( this ), &stackFrame, sizeof(DEBUG_STACK_FRAME) );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgStackFrameClass::print() const
|
//dbgStackFrameClass::print() const
|
||||||
{
|
//{
|
||||||
boost::format fmt(dbgExt->control->IsPointer64Bit() == S_OK ? "%1$4d %2$16x" : "%1$4d %2$08x");
|
// boost::format fmt(dbgExt->control->IsPointer64Bit() == S_OK ? "%1$4d %2$16x" : "%1$4d %2$08x");
|
||||||
fmt % FrameNumber % ReturnOffset;
|
// fmt % FrameNumber % ReturnOffset;
|
||||||
return fmt.str();
|
// return fmt.str();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
getLocals()
|
//getLocals()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
CComPtr<IDebugSymbolGroup> localSymbols;
|
// CComPtr<IDebugSymbolGroup> localSymbols;
|
||||||
CComPtr<IDebugSymbolGroup2> localSymbols2;
|
// CComPtr<IDebugSymbolGroup2> localSymbols2;
|
||||||
|
//
|
||||||
hres = dbgExt->symbols->GetScopeSymbolGroup( DEBUG_SCOPE_GROUP_ARGUMENTS|DEBUG_SCOPE_GROUP_LOCALS, NULL, &localSymbols );
|
// hres = dbgExt->symbols->GetScopeSymbolGroup( DEBUG_SCOPE_GROUP_ARGUMENTS|DEBUG_SCOPE_GROUP_LOCALS, NULL, &localSymbols );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbols::GetScopeSymbolGroup failed" );
|
// throw DbgException( "IDebugSymbols::GetScopeSymbolGroup failed" );
|
||||||
|
//
|
||||||
hres = localSymbols->QueryInterface( __uuidof(IDebugSymbolGroup2), (void**) &localSymbols2 );
|
// hres = localSymbols->QueryInterface( __uuidof(IDebugSymbolGroup2), (void**) &localSymbols2 );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbols::QueryInterface failed to get IDebugSymbolGroup2" );
|
// throw DbgException( "IDebugSymbols::QueryInterface failed to get IDebugSymbolGroup2" );
|
||||||
|
//
|
||||||
ULONG localNumber;
|
// ULONG localNumber;
|
||||||
hres = localSymbols->GetNumberSymbols( &localNumber );
|
// hres = localSymbols->GetNumberSymbols( &localNumber );
|
||||||
|
//
|
||||||
boost::python::dict arr;
|
// boost::python::dict arr;
|
||||||
|
//
|
||||||
for ( ULONG i = 0; i < localNumber; ++i )
|
// for ( ULONG i = 0; i < localNumber; ++i )
|
||||||
{
|
// {
|
||||||
char varName[0x100];
|
// char varName[0x100];
|
||||||
|
//
|
||||||
hres = localSymbols->GetSymbolName( i, varName, sizeof(varName), NULL );
|
// hres = localSymbols->GetSymbolName( i, varName, sizeof(varName), NULL );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbolGroup::GetSymbolName failed" );
|
// throw DbgException( "IDebugSymbolGroup::GetSymbolName failed" );
|
||||||
|
//
|
||||||
DEBUG_SYMBOL_PARAMETERS symbolParam = {};
|
// DEBUG_SYMBOL_PARAMETERS symbolParam = {};
|
||||||
hres = localSymbols->GetSymbolParameters( i, 1, &symbolParam );
|
// hres = localSymbols->GetSymbolParameters( i, 1, &symbolParam );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbolGroup::GetSymbolParameters failed" );
|
// throw DbgException( "IDebugSymbolGroup::GetSymbolParameters failed" );
|
||||||
|
//
|
||||||
char typeName[0x100];
|
// char typeName[0x100];
|
||||||
hres = dbgExt->symbols->GetTypeName( symbolParam.Module, symbolParam.TypeId, typeName, sizeof(typeName), NULL );
|
// hres = dbgExt->symbols->GetTypeName( symbolParam.Module, symbolParam.TypeId, typeName, sizeof(typeName), NULL );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbols::GetTypeName failed" );
|
// throw DbgException( "IDebugSymbols::GetTypeName failed" );
|
||||||
|
//
|
||||||
char moduleName[0x100];
|
// char moduleName[0x100];
|
||||||
hres = dbgExt->symbols2->GetModuleNameString(
|
// hres = dbgExt->symbols2->GetModuleNameString(
|
||||||
DEBUG_MODNAME_MODULE,
|
// DEBUG_MODNAME_MODULE,
|
||||||
DEBUG_ANY_ID,
|
// DEBUG_ANY_ID,
|
||||||
symbolParam.Module,
|
// symbolParam.Module,
|
||||||
moduleName,
|
// moduleName,
|
||||||
sizeof(moduleName),
|
// sizeof(moduleName),
|
||||||
NULL );
|
// NULL );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbols2::GetModuleNameString failed" );
|
// throw DbgException( "IDebugSymbols2::GetModuleNameString failed" );
|
||||||
|
//
|
||||||
|
//
|
||||||
ULONG64 varOffset;
|
// ULONG64 varOffset;
|
||||||
hres = localSymbols2->GetSymbolOffset( i, &varOffset );
|
// hres = localSymbols2->GetSymbolOffset( i, &varOffset );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbolGroup2::GetSymbolOffset failed" );
|
// throw DbgException( "IDebugSymbolGroup2::GetSymbolOffset failed" );
|
||||||
|
//
|
||||||
arr[ varName ] = TypedVar( moduleName, typeName, varOffset );
|
// arr[ varName ] = TypedVar( moduleName, typeName, varOffset );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return arr;
|
// return arr;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,54 +1,54 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <dbgeng.h>
|
//#include <dbgeng.h>
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
|
||||||
getThreadList();
|
|
||||||
|
|
||||||
void
|
|
||||||
setImplicitThread(
|
|
||||||
ULONG64 newThreadAddr );
|
|
||||||
|
|
||||||
ULONG64
|
|
||||||
getImplicitThread();
|
|
||||||
|
|
||||||
boost::python::object
|
|
||||||
getCurrentStack();
|
|
||||||
|
|
||||||
boost::python::object
|
|
||||||
getLocals();
|
|
||||||
|
|
||||||
|
|
||||||
class dbgStackFrameClass : public DEBUG_STACK_FRAME {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
dbgStackFrameClass()
|
|
||||||
{
|
|
||||||
memset( static_cast<DEBUG_STACK_FRAME*>( this ), 0, sizeof(DEBUG_STACK_FRAME) );
|
|
||||||
}
|
|
||||||
|
|
||||||
dbgStackFrameClass( const DEBUG_STACK_FRAME &stackFrame );
|
|
||||||
|
|
||||||
std::string
|
|
||||||
print() const;
|
|
||||||
};
|
|
||||||
|
|
||||||
//boost::python::object
|
//boost::python::object
|
||||||
std::string
|
//getThreadList();
|
||||||
getProcessorMode();
|
//
|
||||||
|
//void
|
||||||
void
|
//setImplicitThread(
|
||||||
setProcessorMode(
|
// ULONG64 newThreadAddr );
|
||||||
const std::string &mode );
|
//
|
||||||
|
//ULONG64
|
||||||
ULONG64
|
//getImplicitThread();
|
||||||
getCurrentProcess();
|
//
|
||||||
|
//boost::python::object
|
||||||
VOID
|
//getCurrentStack();
|
||||||
setCurrentProcess(
|
//
|
||||||
ULONG64 processAddr );
|
//boost::python::object
|
||||||
|
//getLocals();
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
//
|
||||||
|
//
|
||||||
|
//class dbgStackFrameClass : public DEBUG_STACK_FRAME {
|
||||||
|
//
|
||||||
|
//public:
|
||||||
|
//
|
||||||
|
// dbgStackFrameClass()
|
||||||
|
// {
|
||||||
|
// memset( static_cast<DEBUG_STACK_FRAME*>( this ), 0, sizeof(DEBUG_STACK_FRAME) );
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// dbgStackFrameClass( const DEBUG_STACK_FRAME &stackFrame );
|
||||||
|
//
|
||||||
|
// std::string
|
||||||
|
// print() const;
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
////boost::python::object
|
||||||
|
//std::string
|
||||||
|
//getProcessorMode();
|
||||||
|
//
|
||||||
|
//void
|
||||||
|
//setProcessorMode(
|
||||||
|
// const std::string &mode );
|
||||||
|
//
|
||||||
|
//ULONG64
|
||||||
|
//getCurrentProcess();
|
||||||
|
//
|
||||||
|
//VOID
|
||||||
|
//setCurrentProcess(
|
||||||
|
// ULONG64 processAddr );
|
||||||
|
//
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
320
pykd/dbgreg.cpp
320
pykd/dbgreg.cpp
@ -1,162 +1,162 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgreg.h"
|
//#include "dbgreg.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
|
//
|
||||||
using namespace std;
|
//using namespace std;
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
cpuReg::cpuReg( std::string regName )
|
//cpuReg::cpuReg( std::string regName )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
m_name = regName;
|
// m_name = regName;
|
||||||
m_lived = false;
|
// m_lived = false;
|
||||||
|
//
|
||||||
hres = dbgExt->registers->GetIndexByName( m_name.c_str(), &m_index );
|
// hres = dbgExt->registers->GetIndexByName( m_name.c_str(), &m_index );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegister::GetIndexByName failed" );
|
// throw DbgException( "IDebugRegister::GetIndexByName failed" );
|
||||||
|
//
|
||||||
reloadValue();
|
// reloadValue();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
cpuReg::cpuReg( ULONG index )
|
//cpuReg::cpuReg( ULONG index )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
m_index = index;
|
// m_index = index;
|
||||||
m_lived = false;
|
// m_lived = false;
|
||||||
|
//
|
||||||
ULONG nameSize = 0;
|
// ULONG nameSize = 0;
|
||||||
|
//
|
||||||
hres =
|
// hres =
|
||||||
dbgExt->registers->GetDescription(
|
// dbgExt->registers->GetDescription(
|
||||||
m_index,
|
// m_index,
|
||||||
NULL,
|
// NULL,
|
||||||
0,
|
// 0,
|
||||||
&nameSize,
|
// &nameSize,
|
||||||
NULL );
|
// NULL );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegister::GetDescription failed" );
|
// throw DbgException( "IDebugRegister::GetDescription failed" );
|
||||||
|
//
|
||||||
std::vector<char> nameBuffer(nameSize);
|
// std::vector<char> nameBuffer(nameSize);
|
||||||
|
//
|
||||||
hres =
|
// hres =
|
||||||
dbgExt->registers->GetDescription(
|
// dbgExt->registers->GetDescription(
|
||||||
m_index,
|
// m_index,
|
||||||
&nameBuffer[0],
|
// &nameBuffer[0],
|
||||||
nameSize,
|
// nameSize,
|
||||||
NULL,
|
// NULL,
|
||||||
NULL );
|
// NULL );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegister::GetDescription failed" );
|
// throw DbgException( "IDebugRegister::GetDescription failed" );
|
||||||
|
//
|
||||||
m_name = std::string( &nameBuffer[0] );
|
// m_name = std::string( &nameBuffer[0] );
|
||||||
|
//
|
||||||
reloadValue();
|
// reloadValue();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void cpuReg::reloadValue() const
|
//void cpuReg::reloadValue() const
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
DEBUG_VALUE debugValue;
|
// DEBUG_VALUE debugValue;
|
||||||
hres = dbgExt->registers->GetValue( m_index, &debugValue );
|
// hres = dbgExt->registers->GetValue( m_index, &debugValue );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegister::GetValue failed" );
|
// throw DbgException( "IDebugRegister::GetValue failed" );
|
||||||
|
//
|
||||||
switch( debugValue.Type )
|
// switch( debugValue.Type )
|
||||||
{
|
// {
|
||||||
case DEBUG_VALUE_INT8:
|
// case DEBUG_VALUE_INT8:
|
||||||
m_value = debugValue.I8;
|
// m_value = debugValue.I8;
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case DEBUG_VALUE_INT16:
|
// case DEBUG_VALUE_INT16:
|
||||||
m_value = debugValue.I16;
|
// m_value = debugValue.I16;
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case DEBUG_VALUE_INT32:
|
// case DEBUG_VALUE_INT32:
|
||||||
m_value = debugValue.I32;
|
// m_value = debugValue.I32;
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case DEBUG_VALUE_INT64:
|
// case DEBUG_VALUE_INT64:
|
||||||
m_value = debugValue.I64;
|
// m_value = debugValue.I64;
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadRegister( const std::string ®isterName )
|
//loadRegister( const std::string ®isterName )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
ULONG registerIndex = 0;
|
// ULONG registerIndex = 0;
|
||||||
|
//
|
||||||
hres = dbgExt->registers->GetIndexByName( registerName.c_str(), ®isterIndex );
|
// hres = dbgExt->registers->GetIndexByName( registerName.c_str(), ®isterIndex );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegister::GetIndexByName failed" );
|
// throw DbgException( "IDebugRegister::GetIndexByName failed" );
|
||||||
|
//
|
||||||
DEBUG_VALUE debugValue;
|
// DEBUG_VALUE debugValue;
|
||||||
hres = dbgExt->registers->GetValue( registerIndex, &debugValue );
|
// hres = dbgExt->registers->GetValue( registerIndex, &debugValue );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegister::GetValue failed" );
|
// throw DbgException( "IDebugRegister::GetValue failed" );
|
||||||
|
//
|
||||||
switch( debugValue.Type )
|
// switch( debugValue.Type )
|
||||||
{
|
// {
|
||||||
case DEBUG_VALUE_INT8:
|
// case DEBUG_VALUE_INT8:
|
||||||
return boost::python::long_( debugValue.I8 );
|
// return boost::python::long_( debugValue.I8 );
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case DEBUG_VALUE_INT16:
|
// case DEBUG_VALUE_INT16:
|
||||||
return boost::python::long_( debugValue.I16 );
|
// return boost::python::long_( debugValue.I16 );
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case DEBUG_VALUE_INT32:
|
// case DEBUG_VALUE_INT32:
|
||||||
return boost::python::long_( debugValue.I32 );
|
// return boost::python::long_( debugValue.I32 );
|
||||||
break;
|
// break;
|
||||||
|
//
|
||||||
case DEBUG_VALUE_INT64:
|
// case DEBUG_VALUE_INT64:
|
||||||
return boost::python::long_(debugValue.I64 );
|
// return boost::python::long_(debugValue.I64 );
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
throw DbgException( "Invalid register value" );
|
// throw DbgException( "Invalid register value" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
loadMSR( ULONG msr )
|
//loadMSR( ULONG msr )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
ULONG64 value;
|
// ULONG64 value;
|
||||||
|
//
|
||||||
hres = dbgExt->dataSpaces->ReadMsr( msr, &value );
|
// hres = dbgExt->dataSpaces->ReadMsr( msr, &value );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugDataSpaces::ReadMsr failed" );
|
// throw DbgException( "IDebugDataSpaces::ReadMsr failed" );
|
||||||
|
//
|
||||||
return value;
|
// return value;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void setMSR( ULONG msr, ULONG64 value)
|
//void setMSR( ULONG msr, ULONG64 value)
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
hres = dbgExt->dataSpaces->WriteMsr(msr, value);
|
// hres = dbgExt->dataSpaces->WriteMsr(msr, value);
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugDataSpaces::WriteMsr failed" );
|
// throw DbgException( "IDebugDataSpaces::WriteMsr failed" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
118
pykd/dbgreg.h
118
pykd/dbgreg.h
@ -1,61 +1,61 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
#include <list>
|
//#include <list>
|
||||||
|
//
|
||||||
#include "intbase.h"
|
//#include "intbase.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class cpuReg : public intBase {
|
//class cpuReg : public intBase {
|
||||||
|
//
|
||||||
public :
|
//public :
|
||||||
|
//
|
||||||
cpuReg( std::string regName );
|
// cpuReg( std::string regName );
|
||||||
|
//
|
||||||
cpuReg( ULONG index );
|
// cpuReg( ULONG index );
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
name() const {
|
// name() const {
|
||||||
return m_name;
|
// return m_name;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
index() const {
|
// index() const {
|
||||||
return m_index;
|
// return m_index;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void beLive() {
|
// void beLive() {
|
||||||
m_lived = true;
|
// m_lived = true;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG64 value() const
|
// ULONG64 value() const
|
||||||
{
|
// {
|
||||||
if ( m_lived )
|
// if ( m_lived )
|
||||||
reloadValue();
|
// reloadValue();
|
||||||
|
//
|
||||||
return intBase::value();
|
// return intBase::value();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
void reloadValue() const;
|
// void reloadValue() const;
|
||||||
|
//
|
||||||
std::string m_name;
|
// std::string m_name;
|
||||||
|
//
|
||||||
ULONG m_index;
|
// ULONG m_index;
|
||||||
|
//
|
||||||
bool m_lived;
|
// bool m_lived;
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadRegister( const std::string ®isterName );
|
//loadRegister( const std::string ®isterName );
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
loadMSR( ULONG msr );
|
//loadMSR( ULONG msr );
|
||||||
|
//
|
||||||
void setMSR( ULONG msr, ULONG64 val);
|
//void setMSR( ULONG msr, ULONG64 val);
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
152
pykd/dbgsym.cpp
152
pykd/dbgsym.cpp
@ -1,78 +1,78 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgsym.h"
|
//#include "dbgsym.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "dbgmem.h"
|
//#include "dbgmem.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
findSymbolForAddress( ULONG64 addr )
|
//findSymbolForAddress( ULONG64 addr )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
addr = addr64( addr );
|
// addr = addr64( addr );
|
||||||
|
//
|
||||||
ULONG moduleIndex;
|
// ULONG moduleIndex;
|
||||||
ULONG64 moduleBase;
|
// ULONG64 moduleBase;
|
||||||
hres = dbgExt->symbols->GetModuleByOffset( addr, 0, &moduleIndex, &moduleBase );
|
// hres = dbgExt->symbols->GetModuleByOffset( addr, 0, &moduleIndex, &moduleBase );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
{
|
// {
|
||||||
return boost::python::object();
|
// return boost::python::object();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
char moduleName[0x100];
|
// char moduleName[0x100];
|
||||||
hres = dbgExt->symbols2->GetModuleNameString( DEBUG_MODNAME_MODULE, moduleIndex, moduleBase,
|
// hres = dbgExt->symbols2->GetModuleNameString( DEBUG_MODNAME_MODULE, moduleIndex, moduleBase,
|
||||||
moduleName, sizeof( moduleName ), NULL );
|
// moduleName, sizeof( moduleName ), NULL );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol2::GetModuleNameString failed" );
|
// throw DbgException( "IDebugSymbol2::GetModuleNameString failed" );
|
||||||
|
//
|
||||||
char symbolName[0x100];
|
// char symbolName[0x100];
|
||||||
ULONG64 displace = 0;
|
// ULONG64 displace = 0;
|
||||||
hres = dbgExt->symbols->GetNameByOffset( addr, symbolName, sizeof(symbolName), NULL, &displace );
|
// hres = dbgExt->symbols->GetNameByOffset( addr, symbolName, sizeof(symbolName), NULL, &displace );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugSymbol::GetNameByOffset failed" );
|
// throw DbgException( "IDebugSymbol::GetNameByOffset failed" );
|
||||||
|
//
|
||||||
std::stringstream ss;
|
// std::stringstream ss;
|
||||||
displace == 0 ? ss << symbolName : ss << symbolName << '+' << std::hex << displace;
|
// displace == 0 ? ss << symbolName : ss << symbolName << '+' << std::hex << displace;
|
||||||
|
//
|
||||||
return boost::python::object( ss.str() );
|
// return boost::python::object( ss.str() );
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
catch( std::exception &e )
|
// catch( std::exception &e )
|
||||||
{
|
// {
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
}
|
// }
|
||||||
catch(...)
|
// catch(...)
|
||||||
{
|
// {
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return boost::python::object();
|
// return boost::python::object();
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
findAddressForSymbol( const std::string &moduleName, const std::string &symbolName )
|
//findAddressForSymbol( const std::string &moduleName, const std::string &symbolName )
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
std::string ModuleSymName = moduleName;
|
// std::string ModuleSymName = moduleName;
|
||||||
ModuleSymName += "!";
|
// ModuleSymName += "!";
|
||||||
ModuleSymName += symbolName;
|
// ModuleSymName += symbolName;
|
||||||
|
//
|
||||||
ULONG64 offset = 0ULL;
|
// ULONG64 offset = 0ULL;
|
||||||
hres = dbgExt->symbols->GetOffsetByName( ModuleSymName.c_str(), &offset );
|
// hres = dbgExt->symbols->GetOffsetByName( ModuleSymName.c_str(), &offset );
|
||||||
if ( SUCCEEDED( hres ) )
|
// if ( SUCCEEDED( hres ) )
|
||||||
return offset;
|
// return offset;
|
||||||
|
//
|
||||||
throw DbgException( "failed to find offset for symbol" );
|
// throw DbgException( "failed to find offset for symbol" );
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
findSymbolForAddress( ULONG64 addr );
|
//findSymbolForAddress( ULONG64 addr );
|
||||||
|
//
|
||||||
ULONG64
|
//ULONG64
|
||||||
findAddressForSymbol( const std::string &moduleName, const std::string &symbolName );
|
//findAddressForSymbol( const std::string &moduleName, const std::string &symbolName );
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
1298
pykd/dbgsynsym.cpp
1298
pykd/dbgsynsym.cpp
File diff suppressed because it is too large
Load Diff
106
pykd/dbgsynsym.h
106
pykd/dbgsynsym.h
@ -1,56 +1,56 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Global functions
|
//// Global functions
|
||||||
|
//
|
||||||
bool addSyntheticSymbol(
|
//bool addSyntheticSymbol(
|
||||||
ULONG64 addr,
|
// ULONG64 addr,
|
||||||
ULONG size,
|
// ULONG size,
|
||||||
const std::string &symName
|
// const std::string &symName
|
||||||
);
|
//);
|
||||||
|
//
|
||||||
void delAllSyntheticSymbols();
|
//void delAllSyntheticSymbols();
|
||||||
|
//
|
||||||
ULONG delSyntheticSymbol(
|
//ULONG delSyntheticSymbol(
|
||||||
ULONG64 addr
|
// ULONG64 addr
|
||||||
);
|
//);
|
||||||
|
//
|
||||||
ULONG delSyntheticSymbolsMask(
|
//ULONG delSyntheticSymbolsMask(
|
||||||
const std::string &moduleName,
|
// const std::string &moduleName,
|
||||||
const std::string &symName
|
// const std::string &symName
|
||||||
);
|
//);
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Functions for dbgModuleClass
|
//// Functions for dbgModuleClass
|
||||||
|
//
|
||||||
ULONG64 getSyntheticSymbol(
|
//ULONG64 getSyntheticSymbol(
|
||||||
const ModuleInfo &moduleInfo,
|
// const ModuleInfo &moduleInfo,
|
||||||
const std::string &symName
|
// const std::string &symName
|
||||||
);
|
//);
|
||||||
|
//
|
||||||
bool addSyntheticSymbolForModule(
|
//bool addSyntheticSymbolForModule(
|
||||||
ULONG64 offset,
|
// ULONG64 offset,
|
||||||
ULONG size,
|
// ULONG size,
|
||||||
const std::string &symName,
|
// const std::string &symName,
|
||||||
const ModuleInfo &moduleInfo
|
// const ModuleInfo &moduleInfo
|
||||||
);
|
//);
|
||||||
|
//
|
||||||
ULONG delSyntheticSymbolForModule(
|
//ULONG delSyntheticSymbolForModule(
|
||||||
ULONG64 offset,
|
// ULONG64 offset,
|
||||||
const ModuleInfo &moduleInfo
|
// const ModuleInfo &moduleInfo
|
||||||
);
|
//);
|
||||||
|
//
|
||||||
void delAllSyntheticSymbolsForModule(
|
//void delAllSyntheticSymbolsForModule(
|
||||||
const ModuleInfo &moduleInfo
|
// const ModuleInfo &moduleInfo
|
||||||
);
|
//);
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// External callbacks
|
//// External callbacks
|
||||||
|
//
|
||||||
void restoreSyntheticSymbolForModule(
|
//void restoreSyntheticSymbolForModule(
|
||||||
const ModuleInfo &moduleInfo );
|
// const ModuleInfo &moduleInfo );
|
||||||
|
//
|
||||||
void restoreSyntheticSymbolForAllModules();
|
//void restoreSyntheticSymbolForAllModules();
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1,210 +1,210 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <exception>
|
//#include <exception>
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "dbgsystem.h"
|
//#include "dbgsystem.h"
|
||||||
#include "dbgio.h"
|
//#include "dbgio.h"
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
bool
|
//bool
|
||||||
is64bitSystem()
|
//is64bitSystem()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
hres = dbgExt->control->IsPointer64Bit();
|
// hres = dbgExt->control->IsPointer64Bit();
|
||||||
|
//
|
||||||
return hres == S_OK;
|
// return hres == S_OK;
|
||||||
|
//
|
||||||
}
|
// }
|
||||||
catch( std::exception &e )
|
// catch( std::exception &e )
|
||||||
{
|
// {
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
}
|
// }
|
||||||
catch(...)
|
// catch(...)
|
||||||
{
|
// {
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return false;
|
// return false;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
int
|
//int
|
||||||
ptrSize()
|
//ptrSize()
|
||||||
{
|
//{
|
||||||
return is64bitSystem() ? 8 : 4;
|
// return is64bitSystem() ? 8 : 4;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgSymPath()
|
//dbgSymPath()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
std::string pathStr;
|
// std::string pathStr;
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
|
//
|
||||||
ULONG size;
|
// ULONG size;
|
||||||
dbgExt->symbols->GetSymbolPath( NULL, 0, &size );
|
// dbgExt->symbols->GetSymbolPath( NULL, 0, &size );
|
||||||
|
//
|
||||||
std::vector<char> path(size);
|
// std::vector<char> path(size);
|
||||||
hres = dbgExt->symbols->GetSymbolPath( &path[0], size, NULL );
|
// hres = dbgExt->symbols->GetSymbolPath( &path[0], size, NULL );
|
||||||
if ( FAILED( hres ) )
|
|
||||||
throw DbgException( "IDebugSymbols::GetSymbolPath failed" );
|
|
||||||
|
|
||||||
pathStr = &path[0];
|
|
||||||
|
|
||||||
}
|
|
||||||
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 pathStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
std::string
|
|
||||||
getPdbFile( ULONG64 moduleBase )
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
|
|
||||||
IMAGEHLP_MODULEW64 imageHelpInfo = { 0 };
|
|
||||||
|
|
||||||
hres =
|
|
||||||
dbgExt->advanced2->GetSymbolInformation(
|
|
||||||
DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
|
|
||||||
moduleBase,
|
|
||||||
0,
|
|
||||||
&imageHelpInfo,
|
|
||||||
sizeof( imageHelpInfo ),
|
|
||||||
NULL,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
NULL );
|
|
||||||
|
|
||||||
char fileName[ 256 ];
|
|
||||||
WideCharToMultiByte( CP_ACP, 0, imageHelpInfo.LoadedPdbName, 256, fileName, 256, NULL, NULL );
|
|
||||||
|
|
||||||
return std::string( fileName );
|
|
||||||
|
|
||||||
}
|
|
||||||
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 std::string();
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
void
|
|
||||||
reloadModule( const char * moduleName )
|
|
||||||
{
|
|
||||||
HRESULT hres;
|
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
// ïîäàâèòü âûâîä ñîîáùåíèé îá îòñóòñòâèè ñèìâîëîâ
|
|
||||||
OutputReader outputReader( dbgExt->client );
|
|
||||||
|
|
||||||
hres = dbgExt->symbols->Reload( moduleName );
|
|
||||||
|
|
||||||
// if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
// throw DbgException( "IDebugSymbol::Reload failed" );
|
// throw DbgException( "IDebugSymbols::GetSymbolPath failed" );
|
||||||
}
|
//
|
||||||
catch( std::exception &e )
|
// pathStr = &path[0];
|
||||||
{
|
//
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
// }
|
||||||
}
|
// catch( std::exception &e )
|
||||||
catch(...)
|
// {
|
||||||
{
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
// }
|
||||||
}
|
// catch(...)
|
||||||
}
|
// {
|
||||||
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
// }
|
||||||
|
//
|
||||||
bool
|
// return pathStr;
|
||||||
isKernelDebugging()
|
//}
|
||||||
{
|
//
|
||||||
HRESULT hres;
|
//
|
||||||
bool result = false;
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
try {
|
//std::string
|
||||||
|
//getPdbFile( ULONG64 moduleBase )
|
||||||
ULONG debugClass, debugQualifier;
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
|
//
|
||||||
|
// try {
|
||||||
if ( FAILED( hres ) )
|
//
|
||||||
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
|
//
|
||||||
|
// IMAGEHLP_MODULEW64 imageHelpInfo = { 0 };
|
||||||
result = debugClass == DEBUG_CLASS_KERNEL;
|
//
|
||||||
|
// hres =
|
||||||
}
|
// dbgExt->advanced2->GetSymbolInformation(
|
||||||
catch( std::exception &e )
|
// DEBUG_SYMINFO_IMAGEHLP_MODULEW64,
|
||||||
{
|
// moduleBase,
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
// 0,
|
||||||
}
|
// &imageHelpInfo,
|
||||||
catch(...)
|
// sizeof( imageHelpInfo ),
|
||||||
{
|
// NULL,
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
// NULL,
|
||||||
}
|
// 0,
|
||||||
|
// NULL );
|
||||||
return result;
|
//
|
||||||
}
|
// char fileName[ 256 ];
|
||||||
|
// WideCharToMultiByte( CP_ACP, 0, imageHelpInfo.LoadedPdbName, 256, fileName, 256, NULL, NULL );
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
//
|
||||||
|
// return std::string( fileName );
|
||||||
bool
|
//
|
||||||
isDumpAnalyzing()
|
// }
|
||||||
{
|
// catch( std::exception &e )
|
||||||
HRESULT hres;
|
// {
|
||||||
bool result = false;
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
||||||
|
// }
|
||||||
try {
|
// catch(...)
|
||||||
|
// {
|
||||||
ULONG debugClass, debugQualifier;
|
// dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
||||||
|
// }
|
||||||
hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
|
//
|
||||||
|
// return std::string();
|
||||||
if ( FAILED( hres ) )
|
//}
|
||||||
throw DbgException( "IDebugControl::GetDebuggeeType failed" );
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
result = debugQualifier >= DEBUG_DUMP_SMALL;
|
//
|
||||||
|
//void
|
||||||
}
|
//reloadModule( const char * moduleName )
|
||||||
catch( std::exception &e )
|
//{
|
||||||
{
|
// HRESULT hres;
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd error: %s\n", e.what() );
|
//
|
||||||
}
|
// try {
|
||||||
catch(...)
|
//
|
||||||
{
|
// // ïîäàâèòü âûâîä ñîîáùåíèé îá îòñóòñòâèè ñèìâîëîâ
|
||||||
dbgExt->control->Output( DEBUG_OUTPUT_ERROR, "pykd unexpected error\n" );
|
// OutputReader outputReader( dbgExt->client );
|
||||||
}
|
//
|
||||||
|
// hres = dbgExt->symbols->Reload( moduleName );
|
||||||
return result;
|
//
|
||||||
}
|
// //if ( FAILED( hres ) )
|
||||||
|
// // throw DbgException( "IDebugSymbol::Reload 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" );
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//bool
|
||||||
|
//isKernelDebugging()
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
// bool result = false;
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// ULONG debugClass, debugQualifier;
|
||||||
|
//
|
||||||
|
// hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
|
||||||
|
//
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugControl::GetDebuggeeType failed" );
|
||||||
|
//
|
||||||
|
// result = debugClass == DEBUG_CLASS_KERNEL;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// 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 result;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//bool
|
||||||
|
//isDumpAnalyzing()
|
||||||
|
//{
|
||||||
|
// HRESULT hres;
|
||||||
|
// bool result = false;
|
||||||
|
//
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// ULONG debugClass, debugQualifier;
|
||||||
|
//
|
||||||
|
// hres = dbgExt->control->GetDebuggeeType( &debugClass, &debugQualifier );
|
||||||
|
//
|
||||||
|
// if ( FAILED( hres ) )
|
||||||
|
// throw DbgException( "IDebugControl::GetDebuggeeType failed" );
|
||||||
|
//
|
||||||
|
// result = debugQualifier >= DEBUG_DUMP_SMALL;
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
// 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 result;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
bool
|
//bool
|
||||||
is64bitSystem();
|
//is64bitSystem();
|
||||||
|
//
|
||||||
int
|
//int
|
||||||
ptrSize();
|
//ptrSize();
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
dbgSymPath();
|
//dbgSymPath();
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
getPdbFile( ULONG64 moduleBase );
|
//getPdbFile( ULONG64 moduleBase );
|
||||||
|
//
|
||||||
std::string
|
//std::string
|
||||||
getImageFile( ULONG64 moduleBase );
|
//getImageFile( ULONG64 moduleBase );
|
||||||
|
//
|
||||||
void
|
//void
|
||||||
reloadModule( const char * moduleName );
|
//reloadModule( const char * moduleName );
|
||||||
|
//
|
||||||
bool
|
//bool
|
||||||
isKernelDebugging();
|
//isKernelDebugging();
|
||||||
|
//
|
||||||
bool
|
//bool
|
||||||
isDumpAnalyzing();
|
//isDumpAnalyzing();
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
2188
pykd/dbgtype.cpp
2188
pykd/dbgtype.cpp
File diff suppressed because it is too large
Load Diff
586
pykd/dbgtype.h
586
pykd/dbgtype.h
@ -1,295 +1,295 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
#include <map>
|
//#include <map>
|
||||||
|
//
|
||||||
#include "dbgmem.h"
|
//#include "dbgmem.h"
|
||||||
#include "dbgsystem.h"
|
//#include "dbgsystem.h"
|
||||||
|
//
|
||||||
#include <boost/python/slice.hpp>
|
//#include <boost/python/slice.hpp>
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class TypedVar;
|
//class TypedVar;
|
||||||
class TypeInfo;
|
//class TypeInfo;
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class TypeInfo {
|
//class TypeInfo {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
TypeInfo() :
|
// TypeInfo() :
|
||||||
m_size(0),
|
// m_size(0),
|
||||||
m_arraySize( 0 ),
|
// m_arraySize( 0 ),
|
||||||
m_parentOffset( 0 ),
|
// m_parentOffset( 0 ),
|
||||||
m_align( 0 ),
|
// m_align( 0 ),
|
||||||
m_isFreezed( false ),
|
// m_isFreezed( false ),
|
||||||
m_isBaseType( false ),
|
// m_isBaseType( false ),
|
||||||
m_isPointer( false ),
|
// m_isPointer( false ),
|
||||||
m_alignReq(1)
|
// m_alignReq(1)
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
TypeInfo( const std::string customName, ULONG align = 0) :
|
// TypeInfo( const std::string customName, ULONG align = 0) :
|
||||||
m_typeName( customName ),
|
// m_typeName( customName ),
|
||||||
m_size( 0 ),
|
// m_size( 0 ),
|
||||||
m_arraySize( 0 ),
|
// m_arraySize( 0 ),
|
||||||
m_parentOffset( 0 ),
|
// m_parentOffset( 0 ),
|
||||||
m_isFreezed( false ),
|
// m_isFreezed( false ),
|
||||||
m_align( align ),
|
// m_align( align ),
|
||||||
m_isBaseType( false ),
|
// m_isBaseType( false ),
|
||||||
m_isPointer( false ),
|
// m_isPointer( false ),
|
||||||
m_alignReq(1)
|
// m_alignReq(1)
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
TypeInfo( const std::string &moduleName, const std::string &typeName );
|
// TypeInfo( const std::string &moduleName, const std::string &typeName );
|
||||||
|
//
|
||||||
TypeInfo( const std::string &moduleName, ULONG64 moduleBase, ULONG typeId );
|
// TypeInfo( const std::string &moduleName, ULONG64 moduleBase, ULONG typeId );
|
||||||
|
//
|
||||||
static
|
// static
|
||||||
const TypeInfo&
|
// const TypeInfo&
|
||||||
get( const std::string &moduleName, const std::string &typeName );
|
// get( const std::string &moduleName, const std::string &typeName );
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
size() const {
|
// size() const {
|
||||||
return m_size;
|
// return m_size;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
count() const {
|
// count() const {
|
||||||
assert( m_size != 0 && m_arraySize >= m_size );
|
// assert( m_size != 0 && m_arraySize >= m_size );
|
||||||
return m_arraySize / m_size;
|
// return m_arraySize / m_size;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
fullSize() const {
|
// fullSize() const {
|
||||||
return m_arraySize;
|
// return m_arraySize;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
const std::string
|
// const std::string
|
||||||
name() const {
|
// name() const {
|
||||||
return m_typeName;
|
// return m_typeName;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
const std::string
|
// const std::string
|
||||||
moduleName() const {
|
// moduleName() const {
|
||||||
return m_moduleName;
|
// return m_moduleName;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
boost::python::object
|
// boost::python::object
|
||||||
load( void* buffer, size_t bufferLength ) const;
|
// load( void* buffer, size_t bufferLength ) const;
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
printField( size_t index, void* buffer, size_t bufferLength ) const;
|
// printField( size_t index, void* buffer, size_t bufferLength ) const;
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
print() const;
|
// print() const;
|
||||||
|
//
|
||||||
TypeInfo
|
// TypeInfo
|
||||||
getField( const std::string &fieldName ) const;
|
// getField( const std::string &fieldName ) const;
|
||||||
|
//
|
||||||
TypeInfo
|
// TypeInfo
|
||||||
getFieldAt( size_t index ) const;
|
// getFieldAt( size_t index ) const;
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
getFieldOffset() const {
|
// getFieldOffset() const {
|
||||||
return m_parentOffset;
|
// return m_parentOffset;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
boost::python::object
|
// boost::python::object
|
||||||
getFieldByIndex( boost::python::object &index ) const;
|
// getFieldByIndex( boost::python::object &index ) const;
|
||||||
|
//
|
||||||
size_t
|
// size_t
|
||||||
getFieldCount() const {
|
// getFieldCount() const {
|
||||||
return m_fields.size();
|
// return m_fields.size();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
void
|
// void
|
||||||
appendField( const TypeInfo &typeInfo, const std::string &fieldName, ULONG count = 1 );
|
// appendField( const TypeInfo &typeInfo, const std::string &fieldName, ULONG count = 1 );
|
||||||
|
//
|
||||||
bool
|
// bool
|
||||||
isBaseType() const {
|
// isBaseType() const {
|
||||||
return m_isBaseType;
|
// return m_isBaseType;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
bool
|
// bool
|
||||||
isPtr() const {
|
// isPtr() const {
|
||||||
return m_isPointer;
|
// return m_isPointer;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
bool
|
// bool
|
||||||
isEnum() const {
|
// isEnum() const {
|
||||||
return !m_isBaseType && !m_isPointer && m_fields.size() == 0 && m_size == 4;
|
// return !m_isBaseType && !m_isPointer && m_fields.size() == 0 && m_size == 4;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
boost::python::object
|
// boost::python::object
|
||||||
loadVar( ULONG64 targetOffset, ULONG count = 1) const;
|
// loadVar( ULONG64 targetOffset, ULONG count = 1) const;
|
||||||
|
//
|
||||||
void setAlignReq(ULONG alignReq) {
|
// void setAlignReq(ULONG alignReq) {
|
||||||
m_alignReq = alignReq;
|
// m_alignReq = alignReq;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
typedef std::map< std::pair<std::string, std::string>, TypeInfo> TypeInfoMap;
|
// typedef std::map< std::pair<std::string, std::string>, TypeInfo> TypeInfoMap;
|
||||||
|
//
|
||||||
template< typename TTypeInfo>
|
// template< typename TTypeInfo>
|
||||||
struct TypeFieldT {
|
// struct TypeFieldT {
|
||||||
|
//
|
||||||
std::string name;
|
// std::string name;
|
||||||
|
//
|
||||||
ULONG offset;
|
// ULONG offset;
|
||||||
|
//
|
||||||
ULONG size;
|
// ULONG size;
|
||||||
|
//
|
||||||
TTypeInfo type;
|
// TTypeInfo type;
|
||||||
|
//
|
||||||
TypeFieldT( const std::string &name_, const TTypeInfo &type_, ULONG size_, ULONG offset_ ) :
|
// TypeFieldT( const std::string &name_, const TTypeInfo &type_, ULONG size_, ULONG offset_ ) :
|
||||||
name( name_ ),
|
// name( name_ ),
|
||||||
size( size_ ),
|
// size( size_ ),
|
||||||
offset( offset_ ),
|
// offset( offset_ ),
|
||||||
type( type_ )
|
// type( type_ )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
std::string print() const;
|
// std::string print() const;
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
typedef TypeFieldT<TypeInfo> TypeField;
|
// typedef TypeFieldT<TypeInfo> TypeField;
|
||||||
|
//
|
||||||
typedef std::vector<TypeField> TypeFieldList;
|
// typedef std::vector<TypeField> TypeFieldList;
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
ULONG getAlignReq() const;
|
// ULONG getAlignReq() const;
|
||||||
|
//
|
||||||
void addField(
|
// void addField(
|
||||||
const std::string &name_,
|
// const std::string &name_,
|
||||||
const TypeInfo &type_,
|
// const TypeInfo &type_,
|
||||||
ULONG size_,
|
// ULONG size_,
|
||||||
ULONG offset_
|
// ULONG offset_
|
||||||
);
|
// );
|
||||||
|
//
|
||||||
typedef
|
// typedef
|
||||||
boost::python::object
|
// boost::python::object
|
||||||
(*basicTypeLoader)( void* address, size_t size );
|
// (*basicTypeLoader)( void* address, size_t size );
|
||||||
|
//
|
||||||
typedef
|
// typedef
|
||||||
std::string
|
// std::string
|
||||||
(*basicTypePrinter)( void* address, size_t size );
|
// (*basicTypePrinter)( void* address, size_t size );
|
||||||
|
//
|
||||||
static TypeInfoMap g_typeInfoCache;
|
// static TypeInfoMap g_typeInfoCache;
|
||||||
|
//
|
||||||
static const char* basicTypeNames[];
|
// static const char* basicTypeNames[];
|
||||||
|
//
|
||||||
static size_t basicTypeSizes[];
|
// static size_t basicTypeSizes[];
|
||||||
|
//
|
||||||
static basicTypeLoader basicTypeLoaders[];
|
// static basicTypeLoader basicTypeLoaders[];
|
||||||
|
//
|
||||||
static basicTypePrinter basicTypePrinters[];
|
// static basicTypePrinter basicTypePrinters[];
|
||||||
|
//
|
||||||
ULONG m_size;
|
// ULONG m_size;
|
||||||
|
//
|
||||||
ULONG m_arraySize;
|
// ULONG m_arraySize;
|
||||||
|
//
|
||||||
std::string m_typeName;
|
// std::string m_typeName;
|
||||||
|
//
|
||||||
std::string m_moduleName;
|
// std::string m_moduleName;
|
||||||
|
//
|
||||||
TypeFieldList m_fields;
|
// TypeFieldList m_fields;
|
||||||
|
//
|
||||||
bool m_isPointer;
|
// bool m_isPointer;
|
||||||
|
//
|
||||||
bool m_isBaseType;
|
// bool m_isBaseType;
|
||||||
|
//
|
||||||
bool m_isFreezed;
|
// bool m_isFreezed;
|
||||||
|
//
|
||||||
ULONG m_align;
|
// ULONG m_align;
|
||||||
|
//
|
||||||
ULONG m_alignReq;
|
// ULONG m_alignReq;
|
||||||
|
//
|
||||||
ULONG m_parentOffset;
|
// ULONG m_parentOffset;
|
||||||
|
//
|
||||||
static bool checkBaseType( const std::string &typeName );
|
// static bool checkBaseType( const std::string &typeName );
|
||||||
|
//
|
||||||
static ULONG getBaseTypeSize( const std::string &typeName );
|
// static ULONG getBaseTypeSize( const std::string &typeName );
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class TypedVar {
|
//class TypedVar {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
TypedVar() :
|
// TypedVar() :
|
||||||
m_targetOffset ( 0 )
|
// m_targetOffset ( 0 )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
TypedVar( const TypeInfo &typeInfo, ULONG64 targetOffset ) :
|
// TypedVar( const TypeInfo &typeInfo, ULONG64 targetOffset ) :
|
||||||
m_typeInfo( typeInfo ),
|
// m_typeInfo( typeInfo ),
|
||||||
m_targetOffset( addr64(targetOffset) )
|
// m_targetOffset( addr64(targetOffset) )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
TypedVar( const std::string &moduleName, const std::string &typeName, ULONG64 targetOffset ) :
|
// TypedVar( const std::string &moduleName, const std::string &typeName, ULONG64 targetOffset ) :
|
||||||
m_typeInfo( moduleName, typeName ),
|
// m_typeInfo( moduleName, typeName ),
|
||||||
m_targetOffset( addr64(targetOffset) )
|
// m_targetOffset( addr64(targetOffset) )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
TypedVar( ULONG64 targetOffset );
|
// TypedVar( ULONG64 targetOffset );
|
||||||
|
//
|
||||||
TypedVar( const std::string &symbolName );
|
// TypedVar( const std::string &symbolName );
|
||||||
|
//
|
||||||
ULONG64
|
// ULONG64
|
||||||
getAddress() const {
|
// getAddress() const {
|
||||||
return m_targetOffset;
|
// return m_targetOffset;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG
|
// ULONG
|
||||||
getSize() const {
|
// getSize() const {
|
||||||
return m_typeInfo.fullSize();
|
// return m_typeInfo.fullSize();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
static
|
// static
|
||||||
boost::python::object
|
// boost::python::object
|
||||||
getFieldWrap( PyObject* self, const std::string &fieldName );
|
// getFieldWrap( PyObject* self, const std::string &fieldName );
|
||||||
|
//
|
||||||
boost::python::object
|
// boost::python::object
|
||||||
getField( boost::python::object &pyobj, const std::string &fieldName );
|
// getField( boost::python::object &pyobj, const std::string &fieldName );
|
||||||
|
//
|
||||||
ULONG64 getTargetOffset() const {
|
// ULONG64 getTargetOffset() const {
|
||||||
return m_targetOffset;
|
// return m_targetOffset;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::string data();
|
// std::string data();
|
||||||
|
//
|
||||||
std::string print();
|
// std::string print();
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
void reallocBuffer();
|
// void reallocBuffer();
|
||||||
|
//
|
||||||
TypedVar( const TypeInfo &typeInfo, ULONG64 targetOffset, char* buffer, size_t bufferLength );
|
// TypedVar( const TypeInfo &typeInfo, ULONG64 targetOffset, char* buffer, size_t bufferLength );
|
||||||
|
//
|
||||||
ULONG64 m_targetOffset;
|
// ULONG64 m_targetOffset;
|
||||||
|
//
|
||||||
TypeInfo m_typeInfo;
|
// TypeInfo m_typeInfo;
|
||||||
|
//
|
||||||
std::vector<char> m_buffer;
|
// std::vector<char> m_buffer;
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadTypedVarList( ULONG64 address, const std::string &moduleName, const std::string &typeName, const std::string &listEntryName );
|
//loadTypedVarList( ULONG64 address, const std::string &moduleName, const std::string &typeName, const std::string &listEntryName );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
loadTypedVarArray( ULONG64 address, const std::string &moduleName, const std::string &typeName, long number );
|
//loadTypedVarArray( ULONG64 address, const std::string &moduleName, const std::string &typeName, long number );
|
||||||
|
//
|
||||||
boost::python::object
|
//boost::python::object
|
||||||
containingRecord( ULONG64 address, const std::string &moduleName, const std::string &typeName, const std::string &fieldName );
|
//containingRecord( ULONG64 address, const std::string &moduleName, const std::string &typeName, const std::string &fieldName );
|
||||||
|
//
|
||||||
ULONG
|
//ULONG
|
||||||
sizeofType( const std::string &moduleName, const std::string &typeName );
|
//sizeofType( const std::string &moduleName, const std::string &typeName );
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
@ -1,49 +1,49 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "dbgext.h"
|
//#include "dbgext.h"
|
||||||
#include "disasm.h"
|
//#include "disasm.h"
|
||||||
#include "dbgexcept.h"
|
//#include "dbgexcept.h"
|
||||||
#include "dbgmem.h"
|
//#include "dbgmem.h"
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
void disasm::doDisasm()
|
//void disasm::doDisasm()
|
||||||
{
|
//{
|
||||||
HRESULT hres;
|
// HRESULT hres;
|
||||||
char buffer[0x100];
|
// char buffer[0x100];
|
||||||
ULONG disasmSize = 0;
|
// ULONG disasmSize = 0;
|
||||||
ULONG64 offset = addr64(m_currentOffset);
|
// ULONG64 offset = addr64(m_currentOffset);
|
||||||
ULONG64 endOffset = 0;
|
// ULONG64 endOffset = 0;
|
||||||
|
//
|
||||||
if ( m_beginOffset == 0 )
|
// if ( m_beginOffset == 0 )
|
||||||
{
|
// {
|
||||||
ULONG64 currentOffset = 0;
|
// ULONG64 currentOffset = 0;
|
||||||
|
//
|
||||||
hres = dbgExt->registers->GetInstructionOffset( ¤tOffset );
|
// hres = dbgExt->registers->GetInstructionOffset( ¤tOffset );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugRegisters::GetInstructionOffset failed" );
|
// throw DbgException( "IDebugRegisters::GetInstructionOffset failed" );
|
||||||
|
//
|
||||||
offset += currentOffset;
|
// offset += currentOffset;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
hres =
|
// hres =
|
||||||
dbgExt->control->Disassemble(
|
// dbgExt->control->Disassemble(
|
||||||
offset,
|
// offset,
|
||||||
DEBUG_DISASM_EFFECTIVE_ADDRESS,
|
// DEBUG_DISASM_EFFECTIVE_ADDRESS,
|
||||||
buffer,
|
// buffer,
|
||||||
sizeof(buffer),
|
// sizeof(buffer),
|
||||||
&disasmSize,
|
// &disasmSize,
|
||||||
&endOffset );
|
// &endOffset );
|
||||||
|
//
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
throw DbgException( "IDebugControl::Disassemble failed" );
|
// throw DbgException( "IDebugControl::Disassemble failed" );
|
||||||
|
//
|
||||||
hres = dbgExt->control->GetDisassembleEffectiveOffset( &m_ea );
|
// hres = dbgExt->control->GetDisassembleEffectiveOffset( &m_ea );
|
||||||
if ( FAILED( hres ) )
|
// if ( FAILED( hres ) )
|
||||||
m_ea = 0;
|
// m_ea = 0;
|
||||||
|
//
|
||||||
m_length = (ULONG)(endOffset - offset);
|
// m_length = (ULONG)(endOffset - offset);
|
||||||
|
//
|
||||||
m_disasm = std::string( buffer, disasmSize - 2);
|
// m_disasm = std::string( buffer, disasmSize - 2);
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
104
pykd/disasm.h
104
pykd/disasm.h
@ -1,54 +1,54 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class disasm {
|
//class disasm {
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
disasm( ULONG64 offset = 0) :
|
// disasm( ULONG64 offset = 0) :
|
||||||
m_beginOffset( offset ),
|
// m_beginOffset( offset ),
|
||||||
m_currentOffset( offset ) {
|
// m_currentOffset( offset ) {
|
||||||
doDisasm();
|
// doDisasm();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::string next() {
|
// std::string next() {
|
||||||
m_currentOffset += m_length;
|
// m_currentOffset += m_length;
|
||||||
doDisasm();
|
// doDisasm();
|
||||||
return m_disasm;
|
// return m_disasm;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
std::string instruction() const {
|
// std::string instruction() const {
|
||||||
return m_disasm;
|
// return m_disasm;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG64 begin() const {
|
// ULONG64 begin() const {
|
||||||
return m_beginOffset;
|
// return m_beginOffset;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG64 current() const {
|
// ULONG64 current() const {
|
||||||
return m_currentOffset;
|
// return m_currentOffset;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG length() const {
|
// ULONG length() const {
|
||||||
return m_length;
|
// return m_length;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
ULONG64 ea() const {
|
// ULONG64 ea() const {
|
||||||
return m_ea;
|
// return m_ea;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
void doDisasm();
|
// void doDisasm();
|
||||||
|
//
|
||||||
ULONG64 m_beginOffset;
|
// ULONG64 m_beginOffset;
|
||||||
ULONG64 m_currentOffset;
|
// ULONG64 m_currentOffset;
|
||||||
ULONG64 m_ea;
|
// ULONG64 m_ea;
|
||||||
ULONG m_length;
|
// ULONG m_length;
|
||||||
|
//
|
||||||
std::string m_disasm;
|
// std::string m_disasm;
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
/////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
170
pykd/intbase.h
170
pykd/intbase.h
@ -1,88 +1,88 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
class intBase : boost::integer_arithmetic<intBase>
|
//class intBase : boost::integer_arithmetic<intBase>
|
||||||
{
|
//{
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
explicit intBase( ULONG64 val = 0 ) : m_value( val) {}
|
// explicit intBase( ULONG64 val = 0 ) : m_value( val) {}
|
||||||
|
//
|
||||||
virtual ~intBase() {}
|
// virtual ~intBase() {}
|
||||||
|
//
|
||||||
operator ULONG64() const {
|
// operator ULONG64() const {
|
||||||
return value();
|
// return value();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
intBase& operator= ( ULONG64 val ) {
|
// intBase& operator= ( ULONG64 val ) {
|
||||||
setValue( val );
|
// setValue( val );
|
||||||
return *this;
|
// return *this;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
virtual ULONG64 value() const {
|
// virtual ULONG64 value() const {
|
||||||
return m_value;
|
// return m_value;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
virtual void setValue( ULONG64 value) {
|
// virtual void setValue( ULONG64 value) {
|
||||||
m_value = value;
|
// m_value = value;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
str() const {
|
// str() const {
|
||||||
std::stringstream ss;
|
// std::stringstream ss;
|
||||||
ss << value();
|
// ss << value();
|
||||||
return ss.str();
|
// return ss.str();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
std::string
|
// std::string
|
||||||
hex() const {
|
// hex() const {
|
||||||
std::stringstream ss;
|
// std::stringstream ss;
|
||||||
ss << std::hex << value();
|
// ss << std::hex << value();
|
||||||
return ss.str();
|
// return ss.str();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator+=(T const& rhs)
|
// intBase& operator+=(T const& rhs)
|
||||||
{ m_value += rhs; return *this; }
|
// { m_value += rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator-=(T const& rhs)
|
// intBase& operator-=(T const& rhs)
|
||||||
{ m_value -= rhs; return *this; }
|
// { m_value -= rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator*=(T const& rhs)
|
// intBase& operator*=(T const& rhs)
|
||||||
{ m_value *= rhs; return *this; }
|
// { m_value *= rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator/=(T const& rhs)
|
// intBase& operator/=(T const& rhs)
|
||||||
{ m_value /= rhs; return *this; }
|
// { m_value /= rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator%=(T const& rhs)
|
// intBase& operator%=(T const& rhs)
|
||||||
{ m_value %= rhs; return *this; }
|
// { m_value %= rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator&=(T const& rhs)
|
// intBase& operator&=(T const& rhs)
|
||||||
{ m_value &= rhs; return *this; }
|
// { m_value &= rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator|=(T const& rhs)
|
// intBase& operator|=(T const& rhs)
|
||||||
{ m_value |= rhs; return *this; }
|
// { m_value |= rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator^=(T const& rhs)
|
// intBase& operator^=(T const& rhs)
|
||||||
{ m_value ^= rhs; return *this; }
|
// { m_value ^= rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator<<=(T const& rhs)
|
// intBase& operator<<=(T const& rhs)
|
||||||
{ m_value <<= rhs; return *this; }
|
// { m_value <<= rhs; return *this; }
|
||||||
|
//
|
||||||
template <class T>
|
// template <class T>
|
||||||
intBase& operator>>=(T const& rhs)
|
// intBase& operator>>=(T const& rhs)
|
||||||
{ m_value >>= rhs; return *this; }
|
// { m_value >>= rhs; return *this; }
|
||||||
|
//
|
||||||
protected:
|
//protected:
|
||||||
|
//
|
||||||
mutable ULONG64 m_value;
|
// mutable ULONG64 m_value;
|
||||||
|
//
|
||||||
};
|
//};
|
104
pykd/pyaux.h
104
pykd/pyaux.h
@ -1,57 +1,57 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
typedef PyThreadState *PyThreadStatePtr;
|
//typedef PyThreadState *PyThreadStatePtr;
|
||||||
extern __declspec( thread ) PyThreadStatePtr ptrPyThreadState;
|
//extern __declspec( thread ) PyThreadStatePtr ptrPyThreadState;
|
||||||
|
//
|
||||||
// --> call back
|
//// --> call back
|
||||||
// { PyThread_StateSave state( winext->getThreadState() );
|
//// { PyThread_StateSave state( winext->getThreadState() );
|
||||||
// do_callback();
|
//// do_callback();
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// Ĺńëč ęîëáĺę áűë âűçâŕí č ďđč ýňîě ó ňĺęůĺăî ďîňîęŕ ńîőđŕíĺí ęîíňĺęńň ( áűë âűçîâ setExecutionStatus )
|
||||||
|
//// ňî ďĺđĺä âűďîëíĺíčĺě ďčňîíîâńęîăî ęîäŕ íóćíî âîńńňŕíîâčňü ęîíňĺęńň, ŕ ďîńëĺ âîçâđŕňŕ óďđŕâëĺíč˙,
|
||||||
|
//// ńíîâŕ ńîőđŕíčňü ĺăî
|
||||||
|
//
|
||||||
|
//class PyThread_StateSave {
|
||||||
|
//
|
||||||
|
//public:
|
||||||
|
//
|
||||||
|
// PyThread_StateSave()
|
||||||
|
// : m_bRestored(false)
|
||||||
|
// {
|
||||||
|
// if (ptrPyThreadState)
|
||||||
|
// {
|
||||||
|
// PyEval_RestoreThread( ptrPyThreadState );
|
||||||
|
// m_bRestored = true;
|
||||||
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Ĺńëč ęîëáĺę áűë âűçâŕí č ďđč ýňîě ó ňĺęůĺăî ďîňîęŕ ńîőđŕíĺí ęîíňĺęńň ( áűë âűçîâ setExecutionStatus )
|
// ~PyThread_StateSave() {
|
||||||
// ňî ďĺđĺä âűďîëíĺíčĺě ďčňîíîâńęîăî ęîäŕ íóćíî âîńńňŕíîâčňü ęîíňĺęńň, ŕ ďîńëĺ âîçâđŕňŕ óďđŕâëĺíč˙,
|
// if ( m_bRestored )
|
||||||
// ńíîâŕ ńîőđŕíčňü ĺăî
|
// ptrPyThreadState = PyEval_SaveThread();
|
||||||
|
|
||||||
class PyThread_StateSave {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
PyThread_StateSave()
|
|
||||||
: m_bRestored(false)
|
|
||||||
{
|
|
||||||
if (ptrPyThreadState)
|
|
||||||
{
|
|
||||||
PyEval_RestoreThread( ptrPyThreadState );
|
|
||||||
m_bRestored = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
~PyThread_StateSave() {
|
|
||||||
if ( m_bRestored )
|
|
||||||
ptrPyThreadState = PyEval_SaveThread();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool m_bRestored;
|
|
||||||
};
|
|
||||||
|
|
||||||
// { PyThread_StateRestore state;
|
|
||||||
// long_or_block_opreration();
|
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
class PyThread_StateRestore
|
//private:
|
||||||
{
|
// bool m_bRestored;
|
||||||
public:
|
//};
|
||||||
|
//
|
||||||
PyThread_StateRestore() {
|
//// { PyThread_StateRestore state;
|
||||||
ptrPyThreadState = PyEval_SaveThread();
|
//// long_or_block_opreration();
|
||||||
}
|
//// }
|
||||||
|
//
|
||||||
~PyThread_StateRestore() {
|
//class PyThread_StateRestore
|
||||||
PyEval_RestoreThread( ptrPyThreadState );
|
//{
|
||||||
}
|
//public:
|
||||||
};
|
//
|
||||||
|
// PyThread_StateRestore() {
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
// ptrPyThreadState = PyEval_SaveThread();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ~PyThread_StateRestore() {
|
||||||
|
// PyEval_RestoreThread( ptrPyThreadState );
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
//
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////
|
@ -5,4 +5,3 @@ EXPORTS
|
|||||||
info
|
info
|
||||||
py
|
py
|
||||||
pycmd
|
pycmd
|
||||||
pythonpath
|
|
||||||
|
@ -53,8 +53,8 @@ END
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 0,0,19,0
|
FILEVERSION 0,1,0,0
|
||||||
PRODUCTVERSION 0,0,19,0
|
PRODUCTVERSION 0,1,0,0
|
||||||
FILEFLAGSMASK 0x17L
|
FILEFLAGSMASK 0x17L
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@ -70,11 +70,11 @@ BEGIN
|
|||||||
BLOCK "041904b0"
|
BLOCK "041904b0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "pykd - python extension for windbg"
|
VALUE "FileDescription", "pykd - python extension for windbg"
|
||||||
VALUE "FileVersion", "0, 0, 19, 0"
|
VALUE "FileVersion", "0, 1, 0, 0"
|
||||||
VALUE "InternalName", "pykd"
|
VALUE "InternalName", "pykd"
|
||||||
VALUE "OriginalFilename", "pykd.dll"
|
VALUE "OriginalFilename", "pykd.dll"
|
||||||
VALUE "ProductName", "pykd - python extension for windbg"
|
VALUE "ProductName", "pykd - python extension for windbg"
|
||||||
VALUE "ProductVersion", "0, 0, 19, 0"
|
VALUE "ProductVersion", "0, 1, 0, 0"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
@ -349,82 +349,10 @@
|
|||||||
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=".\dbgbreak.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgcmd.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgdump.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgevent.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgeventcb.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgexcept.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\dbgext.cpp"
|
RelativePath=".\dbgext.cpp"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\dbgio.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgmem.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgmodule.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgpath.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgprocess.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgreg.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgsym.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgsynsym.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgsystem.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgtype.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\disasm.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\pykd.cpp"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\pykd.def"
|
RelativePath=".\pykd.def"
|
||||||
>
|
>
|
||||||
@ -471,90 +399,6 @@
|
|||||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
>
|
>
|
||||||
<File
|
|
||||||
RelativePath=".\dbgbreak.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgclient.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgcmd.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgdump.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgevent.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgeventcb.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgexcept.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgext.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgio.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgmem.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgmodule.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgpath.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgprocess.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgreg.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgsym.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgsynsym.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgsystem.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\dbgtype.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\disasm.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\intbase.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
|
||||||
RelativePath=".\pyaux.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\resource.h"
|
RelativePath=".\resource.h"
|
||||||
>
|
>
|
||||||
|
@ -30,32 +30,32 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <atlbase.h>
|
#include <atlbase.h>
|
||||||
|
|
||||||
|
//
|
||||||
#ifndef __field_ecount_opt
|
//#ifndef __field_ecount_opt
|
||||||
#define __field_ecount_opt(x)
|
//#define __field_ecount_opt(x)
|
||||||
#endif // __field_ecount_opt
|
//#endif // __field_ecount_opt
|
||||||
|
//
|
||||||
|
//
|
||||||
#define BOOST_PYTHON_STATIC_LIB
|
//#define BOOST_PYTHON_STATIC_LIB
|
||||||
|
//
|
||||||
#pragma warning(push)
|
//#pragma warning(push)
|
||||||
// 'return' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data
|
//// 'return' : conversion from 'Py_ssize_t' to 'unsigned int', possible loss of data
|
||||||
#pragma warning(disable:4244)
|
//#pragma warning(disable:4244)
|
||||||
#include <boost/python.hpp>
|
//#include <boost/python.hpp>
|
||||||
#include <boost/python/object.hpp>
|
//#include <boost/python/object.hpp>
|
||||||
#pragma warning(pop)
|
//#pragma warning(pop)
|
||||||
|
//
|
||||||
#include <vector>
|
//#include <vector>
|
||||||
|
//
|
||||||
template <typename TElem>
|
//template <typename TElem>
|
||||||
TElem *getVectorBuffer(std::vector<TElem> &vec)
|
//TElem *getVectorBuffer(std::vector<TElem> &vec)
|
||||||
{
|
//{
|
||||||
return vec.size() ? &vec[0] : NULL;
|
// return vec.size() ? &vec[0] : NULL;
|
||||||
}
|
//}
|
||||||
template <typename TElem>
|
//template <typename TElem>
|
||||||
const TElem *getVectorBuffer(const std::vector<TElem> &vec)
|
//const TElem *getVectorBuffer(const std::vector<TElem> &vec)
|
||||||
{
|
//{
|
||||||
return vec.size() ? &vec[0] : NULL;
|
// return vec.size() ? &vec[0] : NULL;
|
||||||
}
|
//}
|
||||||
|
//
|
||||||
// TODO: reference additional headers your program requires here
|
//// TODO: reference additional headers your program requires here
|
||||||
|
@ -20,8 +20,8 @@ def getTestSuite( singleName = "" ):
|
|||||||
if singleName == "":
|
if singleName == "":
|
||||||
return unittest.TestSuite(
|
return unittest.TestSuite(
|
||||||
[ unittest.TestLoader().loadTestsFromTestCase( basetest.BaseTest ),
|
[ unittest.TestLoader().loadTestsFromTestCase( basetest.BaseTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( typeinfo.TypeInfoTest ),
|
# unittest.TestLoader().loadTestsFromTestCase( typeinfo.TypeInfoTest ),
|
||||||
unittest.TestLoader().loadTestsFromTestCase( regtest.CpuRegTest )
|
# unittest.TestLoader().loadTestsFromTestCase( regtest.CpuRegTest )
|
||||||
] )
|
] )
|
||||||
else:
|
else:
|
||||||
return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
return unittest.TestSuite( unittest.TestLoader().loadTestsFromName( singleName ) )
|
||||||
|
@ -1,34 +1,34 @@
|
|||||||
|
|
||||||
import unittest
|
#import unittest
|
||||||
import pykd
|
#import pykd
|
||||||
import target
|
#import target
|
||||||
|
|
||||||
class CpuRegTest( unittest.TestCase ):
|
#class CpuRegTest( unittest.TestCase ):
|
||||||
|
|
||||||
def testBasic(self):
|
# def testBasic(self):
|
||||||
try:
|
# try:
|
||||||
reg = pykd.cpuReg(0)
|
# reg = pykd.cpuReg(0)
|
||||||
self.assertTrue(True)
|
# self.assertTrue(True)
|
||||||
except pykd.BaseException:
|
# except pykd.BaseException:
|
||||||
pass
|
# pass
|
||||||
|
|
||||||
|
|
||||||
def testGPR(self):
|
# def testGPR(self):
|
||||||
|
|
||||||
if pykd.is64bitSystem():
|
# if pykd.is64bitSystem():
|
||||||
|
|
||||||
rax = pykd.cpuReg("rax")
|
# rax = pykd.cpuReg("rax")
|
||||||
self.assertEqual( rax, pykd.reg("rax") )
|
# self.assertEqual( rax, pykd.reg("rax") )
|
||||||
|
|
||||||
rip = pykd.cpuReg("rip")
|
# rip = pykd.cpuReg("rip")
|
||||||
self.assertEqual( rip, pykd.reg("rip") )
|
# self.assertEqual( rip, pykd.reg("rip") )
|
||||||
|
|
||||||
else:
|
# else:
|
||||||
|
|
||||||
eax = pykd.cpuReg("eax")
|
# eax = pykd.cpuReg("eax")
|
||||||
self.assertEqual( eax, pykd.reg("eax") )
|
# self.assertEqual( eax, pykd.reg("eax") )
|
||||||
|
|
||||||
eip = pykd.cpuReg("eip")
|
# eip = pykd.cpuReg("eip")
|
||||||
self.assertEqual( eip, pykd.reg("eip") )
|
# self.assertEqual( eip, pykd.reg("eip") )
|
||||||
|
|
||||||
|
|
@ -2,78 +2,78 @@
|
|||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
import unittest
|
#import unittest
|
||||||
import pykd
|
#import pykd
|
||||||
import target
|
#import target
|
||||||
|
|
||||||
|
|
||||||
class TypeInfoTest( unittest.TestCase ):
|
#class TypeInfoTest( unittest.TestCase ):
|
||||||
|
|
||||||
def testBasicTypes(self):
|
# def testBasicTypes(self):
|
||||||
self.assertEqual( pykd.char_t.name(), "char" )
|
# self.assertEqual( pykd.char_t.name(), "char" )
|
||||||
self.assertEqual( pykd.char_t.size(), 1 )
|
# self.assertEqual( pykd.char_t.size(), 1 )
|
||||||
self.assertEqual( pykd.uchar_t.name(), "unsigned char" )
|
# self.assertEqual( pykd.uchar_t.name(), "unsigned char" )
|
||||||
self.assertEqual( pykd.uchar_t.size(), 1 )
|
# self.assertEqual( pykd.uchar_t.size(), 1 )
|
||||||
|
|
||||||
def testSimpleStruct(self):
|
# def testSimpleStruct(self):
|
||||||
ti = pykd.typeInfo( target.moduleName, "Type1" )
|
# ti = pykd.typeInfo( target.moduleName, "Type1" )
|
||||||
self.assertTrue( hasattr( ti, "field1" ) )
|
# self.assertTrue( hasattr( ti, "field1" ) )
|
||||||
self.assertTrue( hasattr( ti, "field2" ) )
|
# self.assertTrue( hasattr( ti, "field2" ) )
|
||||||
self.assertTrue( hasattr( ti, "field3" ) )
|
# self.assertTrue( hasattr( ti, "field3" ) )
|
||||||
|
|
||||||
tv = pykd.typedVar( ti, target.module.var1 )
|
# tv = pykd.typedVar( ti, target.module.var1 )
|
||||||
self.assertEqual( tv.field1, -121 )
|
# self.assertEqual( tv.field1, -121 )
|
||||||
self.assertEqual( tv.field2, 220 )
|
# self.assertEqual( tv.field2, 220 )
|
||||||
# self.assertLess( tv.field3 - 1.0095, 0.0001 )
|
# self.assertLess( tv.field3 - 1.0095, 0.0001 )
|
||||||
|
|
||||||
def testEnumField(self):
|
# def testEnumField(self):
|
||||||
ti = pykd.typeInfo( target.moduleName, "Type2" )
|
# ti = pykd.typeInfo( target.moduleName, "Type2" )
|
||||||
self.assertEqual( hasattr( ti, "field1" ), True )
|
# self.assertEqual( hasattr( ti, "field1" ), True )
|
||||||
|
|
||||||
tv = pykd.typedVar( ti, target.module.var2 )
|
# tv = pykd.typedVar( ti, target.module.var2 )
|
||||||
self.assertEqual( tv.field1, 100 )
|
# self.assertEqual( tv.field1, 100 )
|
||||||
|
|
||||||
def testNamespace(self):
|
# def testNamespace(self):
|
||||||
ti1 = pykd.typeInfo( target.moduleName, "Namespace1::Class1" )
|
# ti1 = pykd.typeInfo( target.moduleName, "Namespace1::Class1" )
|
||||||
ti2 = pykd.typeInfo( target.moduleName, "Namespace1::Namespace2::Class2" )
|
# ti2 = pykd.typeInfo( target.moduleName, "Namespace1::Namespace2::Class2" )
|
||||||
var3 = pykd.typedVar( ti1, pykd.getOffset( target.moduleName, "Namespace1::var3" ) )
|
# var3 = pykd.typedVar( ti1, pykd.getOffset( target.moduleName, "Namespace1::var3" ) )
|
||||||
var4 = pykd.typedVar( ti1, pykd.getOffset( target.moduleName, "Namespace1::Namespace2::var4" ) )
|
# var4 = pykd.typedVar( ti1, pykd.getOffset( target.moduleName, "Namespace1::Namespace2::var4" ) )
|
||||||
self.assertEqual( var3.m_field1, 50 )
|
# self.assertEqual( var3.m_field1, 50 )
|
||||||
|
|
||||||
def testTemplates(self):
|
# def testTemplates(self):
|
||||||
ti3 = pykd.typeInfo( target.moduleName, "Namespace3::Class3<int>" )
|
# ti3 = pykd.typeInfo( target.moduleName, "Namespace3::Class3<int>" )
|
||||||
var5 = pykd.typedVar( ti3, pykd.getOffset( target.moduleName, "Namespace3::var5" ) )
|
# var5 = pykd.typedVar( ti3, pykd.getOffset( target.moduleName, "Namespace3::var5" ) )
|
||||||
self.assertEqual( var5.m_field1, 5 )
|
# self.assertEqual( var5.m_field1, 5 )
|
||||||
|
|
||||||
def testNestedStruct(self):
|
# def testNestedStruct(self):
|
||||||
ti4 = pykd.typeInfo( target.moduleName, "Type4" )
|
# ti4 = pykd.typeInfo( target.moduleName, "Type4" )
|
||||||
self.assertTrue( hasattr( ti4, "field1" ) )
|
# self.assertTrue( hasattr( ti4, "field1" ) )
|
||||||
self.assertTrue( hasattr( ti4, "field2" ) )
|
# self.assertTrue( hasattr( ti4, "field2" ) )
|
||||||
self.assertTrue( hasattr( ti4, "field3" ) )
|
# self.assertTrue( hasattr( ti4, "field3" ) )
|
||||||
self.assertTrue( hasattr( ti4, "field4" ) )
|
# self.assertTrue( hasattr( ti4, "field4" ) )
|
||||||
self.assertTrue( hasattr( ti4, "field4" ) )
|
# self.assertTrue( hasattr( ti4, "field4" ) )
|
||||||
self.assertTrue( hasattr( ti4.field4, "field41" ) )
|
# self.assertTrue( hasattr( ti4.field4, "field41" ) )
|
||||||
|
|
||||||
def testPtrField(self):
|
# def testPtrField(self):
|
||||||
v6 = pykd.typedVar( target.moduleName, "Type6", pykd.getOffset( target.moduleName, "var6" ) )
|
# v6 = pykd.typedVar( target.moduleName, "Type6", pykd.getOffset( target.moduleName, "var6" ) )
|
||||||
self.assertEqual( v6.field1, 10 )
|
# self.assertEqual( v6.field1, 10 )
|
||||||
self.assertEqual( v6.field2.field1, 10 )
|
# self.assertEqual( v6.field2.field1, 10 )
|
||||||
self.assertEqual( v6.field2.field2, 20 )
|
# self.assertEqual( v6.field2.field2, 20 )
|
||||||
self.assertNotEqual( v6.field2, 0 )
|
# self.assertNotEqual( v6.field2, 0 )
|
||||||
self.assertEqual( v6.field3[0].field1, 10 )
|
# self.assertEqual( v6.field3[0].field1, 10 )
|
||||||
self.assertEqual( v6.field3[1].field2, 20 )
|
# self.assertEqual( v6.field3[1].field2, 20 )
|
||||||
|
|
||||||
def testArrayField(self):
|
# def testArrayField(self):
|
||||||
v7 = pykd.typedVar( target.moduleName, "Type7", pykd.getOffset( target.moduleName, "var7" ) )
|
# v7 = pykd.typedVar( target.moduleName, "Type7", pykd.getOffset( target.moduleName, "var7" ) )
|
||||||
self.assertEqual( v7.field1[1].field1, 10 )
|
# self.assertEqual( v7.field1[1].field1, 10 )
|
||||||
self.assertEqual( v7.field1[5].field2, 20 )
|
# self.assertEqual( v7.field1[5].field2, 20 )
|
||||||
self.assertEqual( v7.field2[1][0].field1, 10 )
|
# self.assertEqual( v7.field2[1][0].field1, 10 )
|
||||||
self.assertEqual( v7.field2[0][1].field2, 20 )
|
# self.assertEqual( v7.field2[0][1].field2, 20 )
|
||||||
|
|
||||||
def testTypedVarByAddress(self):
|
# def testTypedVarByAddress(self):
|
||||||
var5 = pykd.typedVar( pykd.getOffset( target.moduleName, "Namespace3::var5" ) )
|
# var5 = pykd.typedVar( pykd.getOffset( target.moduleName, "Namespace3::var5" ) )
|
||||||
self.assertEqual( var5.m_field1, 5 )
|
# self.assertEqual( var5.m_field1, 5 )
|
||||||
|
|
||||||
def testTypedVarBySymbolName(self):
|
# def testTypedVarBySymbolName(self):
|
||||||
var5 = pykd.typedVar( "Namespace3::var5" )
|
# var5 = pykd.typedVar( "Namespace3::var5" )
|
||||||
self.assertEqual( var5.m_field1, 5 )
|
# self.assertEqual( var5.m_field1, 5 )
|
||||||
|
@ -1,190 +1,190 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
|
||||||
#include <string>
|
//#include <string>
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
// áàçîâûé òèïû
|
//// áàçîâûé òèïû
|
||||||
|
//
|
||||||
char charVar = -100;
|
//char charVar = -100;
|
||||||
unsigned char ucharVar = 200;
|
//unsigned char ucharVar = 200;
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
struct Type1 {
|
//struct Type1 {
|
||||||
|
//
|
||||||
char field1;
|
// char field1;
|
||||||
|
//
|
||||||
unsigned char field2;
|
// unsigned char field2;
|
||||||
|
//
|
||||||
double field3;
|
// double field3;
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
Type1 var1 = { -121, 220, 1.0095f };
|
//Type1 var1 = { -121, 220, 1.0095f };
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
enum Enum1 {
|
//enum Enum1 {
|
||||||
|
//
|
||||||
Enum1Val1 = 100,
|
// Enum1Val1 = 100,
|
||||||
Enum1Val2 = 200,
|
// Enum1Val2 = 200,
|
||||||
Enum1Val3 = 300
|
// Enum1Val3 = 300
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
struct Type2 {
|
//struct Type2 {
|
||||||
|
//
|
||||||
Enum1 field1;
|
// Enum1 field1;
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
|
//
|
||||||
Type2 var2 = { Enum1Val1 };
|
//Type2 var2 = { Enum1Val1 };
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
//
|
||||||
namespace Namespace1 {
|
//namespace Namespace1 {
|
||||||
|
//
|
||||||
|
//
|
||||||
class Class1 {
|
// class Class1 {
|
||||||
|
//
|
||||||
public:
|
// public:
|
||||||
|
//
|
||||||
Class1( unsigned long v1 ) :
|
// Class1( unsigned long v1 ) :
|
||||||
m_field1( v1 )
|
// m_field1( v1 )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
private:
|
// private:
|
||||||
|
//
|
||||||
unsigned long m_field1;
|
// unsigned long m_field1;
|
||||||
|
//
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
Class1 var3( 50 );
|
// Class1 var3( 50 );
|
||||||
|
//
|
||||||
namespace Namespace2 {
|
// namespace Namespace2 {
|
||||||
|
//
|
||||||
class Class2 {
|
// class Class2 {
|
||||||
|
//
|
||||||
public:
|
// public:
|
||||||
|
//
|
||||||
Class2( const std::string &str ) :
|
// Class2( const std::string &str ) :
|
||||||
m_field1 ( str )
|
// m_field1 ( str )
|
||||||
{}
|
// {}
|
||||||
|
//
|
||||||
private:
|
// private:
|
||||||
|
//
|
||||||
std::string m_field1;
|
// std::string m_field1;
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
Class2 var4( "hello" );
|
// Class2 var4( "hello" );
|
||||||
|
//
|
||||||
};
|
// };
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
namespace Namespace3
|
//namespace Namespace3
|
||||||
{
|
//{
|
||||||
|
//
|
||||||
template<typename T>
|
// template<typename T>
|
||||||
class Class3
|
// class Class3
|
||||||
{
|
// {
|
||||||
public:
|
// public:
|
||||||
Class3(T val): m_field1 (val)
|
// Class3(T val): m_field1 (val)
|
||||||
{
|
// {
|
||||||
}
|
// }
|
||||||
private:
|
// private:
|
||||||
T m_field1;
|
// T m_field1;
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
Class3<int> var5(5);
|
// Class3<int> var5(5);
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
#pragma pack( push, 4 )
|
//#pragma pack( push, 4 )
|
||||||
|
//
|
||||||
struct Type4
|
//struct Type4
|
||||||
{
|
//{
|
||||||
int field1;
|
// int field1;
|
||||||
|
//
|
||||||
struct {
|
// struct {
|
||||||
|
//
|
||||||
int field2;
|
// int field2;
|
||||||
|
//
|
||||||
int field3;
|
// int field3;
|
||||||
};
|
// };
|
||||||
|
//
|
||||||
struct {
|
// struct {
|
||||||
|
//
|
||||||
int field41;
|
// int field41;
|
||||||
|
//
|
||||||
} field4;
|
// } field4;
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
Type4 var4 = {};
|
//Type4 var4 = {};
|
||||||
|
//
|
||||||
#pragma pack( pop )
|
//#pragma pack( pop )
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class Type5 {
|
//class Type5 {
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
int field1;
|
// int field1;
|
||||||
int field2;
|
// int field2;
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
Type5() : field1(10), field2(20) {}
|
// Type5() : field1(10), field2(20) {}
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
class Type6 {
|
//class Type6 {
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
int field1;
|
// int field1;
|
||||||
Type5 *field2;
|
// Type5 *field2;
|
||||||
Type5 *field3[2];
|
// Type5 *field3[2];
|
||||||
Type5 **field4;
|
// Type5 **field4;
|
||||||
|
//
|
||||||
public:
|
//public:
|
||||||
|
//
|
||||||
Type6() {
|
// Type6() {
|
||||||
field1 = 10;
|
// field1 = 10;
|
||||||
field2 = new Type5;
|
// field2 = new Type5;
|
||||||
field3[0] = new Type5;
|
// field3[0] = new Type5;
|
||||||
field3[1] = new Type5;
|
// field3[1] = new Type5;
|
||||||
|
//
|
||||||
field4 = &field2;
|
// field4 = &field2;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
~Type6() {
|
// ~Type6() {
|
||||||
delete field2;
|
// delete field2;
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
Type6 var6;
|
//Type6 var6;
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
class Type7 {
|
//class Type7 {
|
||||||
|
//
|
||||||
private:
|
//private:
|
||||||
|
//
|
||||||
Type5 field1[10];
|
// Type5 field1[10];
|
||||||
|
//
|
||||||
Type5 field2[2][2];
|
// Type5 field2[2][2];
|
||||||
|
//
|
||||||
int field3[2][2][2];
|
// int field3[2][2][2];
|
||||||
|
//
|
||||||
};
|
//};
|
||||||
|
//
|
||||||
Type7 var7;
|
//Type7 var7;
|
||||||
|
//
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////
|
Loading…
Reference in New Issue
Block a user