[0.1.x] added : is64bitSystem routine

git-svn-id: https://pykd.svn.codeplex.com/svn@71845 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\kernelnet_cp 2011-11-28 06:37:23 +00:00 committed by Mikhail I. Izmestev
parent 427f5e290d
commit 5ee21bec08
5 changed files with 117 additions and 4 deletions

68
pykd/cpureg.cpp Normal file
View File

@ -0,0 +1,68 @@
#include "stdafx.h"
#include "cpureg.h"
#include "dbgclient.h"
namespace pykd {
///////////////////////////////////////////////////////////////////////////////////
python::object DebugClient::getRegByIndex( ULONG index )
{
HRESULT hres;
DEBUG_VALUE debugValue;
hres = m_registers->GetValue( index, &debugValue );
if ( FAILED( hres ) )
throw DbgException( "IDebugRegister::GetValue failed" );
switch( debugValue.Type )
{
case DEBUG_VALUE_INT8:
return boost::python::long_( debugValue.I8 );
break;
case DEBUG_VALUE_INT16:
return boost::python::long_( debugValue.I16 );
break;
case DEBUG_VALUE_INT32:
return boost::python::long_( debugValue.I32 );
break;
case DEBUG_VALUE_INT64:
return boost::python::long_(debugValue.I64 );
break;
}
throw DbgException( "Invalid register value" );
}
python::object getRegByIndex( ULONG index )
{
return g_dbgClient->getRegByIndex( index );
}
///////////////////////////////////////////////////////////////////////////////////
python::object DebugClient::getRegByName( const std::wstring &regName )
{
ULONG registerIndex = 0;
HRESULT hres;
hres = m_registers->GetIndexByNameWide( regName.c_str(), &registerIndex );
if ( FAILED( hres ) )
throw DbgException( "IDebugRegister2::GetIndexByNameWide failed" );
return getRegByIndex( registerIndex );
}
python::object getRegByName( const std::wstring &regName )
{
return g_dbgClient->getRegByName( regName );
}
///////////////////////////////////////////////////////////////////////////////////
} // end namespace pykd

17
pykd/cpureg.h Normal file
View File

@ -0,0 +1,17 @@
#pragma once
#include "intbase.h"
#include "dbgobj.h"
namespace pykd {
///////////////////////////////////////////////////////////////////////////////////
python::object getRegByName( const std::wstring &regName );
python::object getRegByIndex( ULONG index );
///////////////////////////////////////////////////////////////////////////////////
}; // end pykd namespace

View File

@ -88,6 +88,26 @@ ULONG getExecutionStatus()
return g_dbgClient->getExecutionStatus(); return g_dbgClient->getExecutionStatus();
} }
///////////////////////////////////////////////////////////////////////////////////
bool DebugClient::is64bitSystem()
{
HRESULT hres;
hres = m_control->IsPointer64Bit();
if ( FAILED( hres ) )
throw DbgException( "IDebugControl::IsPointer64Bit failed" );
return hres == S_OK;
}
bool
is64bitSystem()
{
return g_dbgClient->is64bitSystem();
}
/////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////
bool DebugClient::isDumpAnalyzing() bool DebugClient::isDumpAnalyzing()

View File

@ -86,6 +86,8 @@ public:
template<ULONG status> template<ULONG status>
void changeDebuggerStatus(); void changeDebuggerStatus();
bool is64bitSystem();
bool isKernelDebugging(); bool isKernelDebugging();
bool isDumpAnalyzing(); bool isDumpAnalyzing();
@ -213,6 +215,8 @@ python::tuple getDebuggeeType();
ULONG getExecutionStatus(); ULONG getExecutionStatus();
bool is64bitSystem();
bool isKernelDebugging(); bool isKernelDebugging();
bool isDumpAnalyzing(); bool isDumpAnalyzing();

View File

@ -145,14 +145,16 @@ BOOST_PYTHON_MODULE( pykd )
"Attach debugger to a exsisting process" ) "Attach debugger to a exsisting process" )
.def( "attachKernel", &DebugClient::attachKernel, .def( "attachKernel", &DebugClient::attachKernel,
"Attach debugger to a target's kernel" ) "Attach debugger to a target's kernel" )
.def( "expr", &pykd::DebugClient::evaluate, .def( "expr", &DebugClient::evaluate,
"Evaluate windbg expression" ) "Evaluate windbg expression" )
.def( "getDebuggeeType", &pykd::DebugClient::getDebuggeeType, .def( "getDebuggeeType", &DebugClient::getDebuggeeType,
"Return type of the debuggee" ) "Return type of the debuggee" )
.def( "getExecutionStatus", &pykd::DebugClient::getExecutionStatus, .def( "getExecutionStatus", &DebugClient::getExecutionStatus,
"Return information about the execution status of the debugger" ) "Return information about the execution status of the debugger" )
.def( "go", &pykd::DebugClient::changeDebuggerStatus<DEBUG_STATUS_GO>, .def( "go", &DebugClient::changeDebuggerStatus<DEBUG_STATUS_GO>,
"Change debugger status to DEBUG_STATUS_GO" ) "Change debugger status to DEBUG_STATUS_GO" )
.def( "is64bitSystem", &DebugClient::is64bitSystem,
"Check if target system has 64 address space" )
.def( "isDumpAnalyzing", &pykd::DebugClient::isDumpAnalyzing, .def( "isDumpAnalyzing", &pykd::DebugClient::isDumpAnalyzing,
"Check if it is a dump analyzing ( not living debuggee )" ) "Check if it is a dump analyzing ( not living debuggee )" )
.def( "isKernelDebugging", &pykd::DebugClient::isKernelDebugging, .def( "isKernelDebugging", &pykd::DebugClient::isKernelDebugging,
@ -252,6 +254,8 @@ BOOST_PYTHON_MODULE( pykd )
"Return information about the execution status of the debugger" ); "Return information about the execution status of the debugger" );
python::def( "go", &changeDebuggerStatus<DEBUG_STATUS_GO>, python::def( "go", &changeDebuggerStatus<DEBUG_STATUS_GO>,
"Change debugger status to DEBUG_STATUS_GO" ); "Change debugger status to DEBUG_STATUS_GO" );
python::def( "is64bitSystem", &is64bitSystem,
"Check if target system has 64 address space" );
python::def( "isDumpAnalyzing", &isDumpAnalyzing, python::def( "isDumpAnalyzing", &isDumpAnalyzing,
"Check if it is a dump analyzing ( not living debuggee )" ); "Check if it is a dump analyzing ( not living debuggee )" );
python::def( "isKernelDebugging", &isKernelDebugging, python::def( "isKernelDebugging", &isKernelDebugging,